/* Shared base styles for the Sanyu app (design: 2026-07 "navy refined"). */
* { box-sizing: border-box; }

:root {
  --navy-1: #0b1626;
  --navy-2: #16233c;
  --bg: #eef2f7;
  --panel: #ffffff;
  --border: #dfe5ee;
  --border-strong: #c3ccd9;
  --text: #101828;
  --muted: #667085;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-weak: #eff4ff;
  --danger: #dc2626;
  --ok: #12805c;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.10), 0 1px 2px rgba(16, 24, 40, 0.06);
}

html, body {
  margin: 0;
  padding: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button { font-family: inherit; }
input, select, textarea { font-family: inherit; }
svg { display: block; }

/* App layout: fixed sidebar + content */
.app-layout {
  display: flex;
  min-height: 100vh;
}

#app-nav {
  width: 236px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-1) 0%, var(--navy-2) 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 12px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.45);
}

.brand-name { font-size: 16px; font-weight: 800; color: #fff; line-height: 1.2; }
.brand-sub { font-size: 10.5px; color: #7d8aa0; }

.nav-links {
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 3px;
  flex-grow: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #aab4c4;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  position: relative;
}

.nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #e2e8f0; }
.nav-link.is-active { background: rgba(59, 130, 246, 0.16); color: #fff; font-weight: 700; }

.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 3px;
  background: #3b82f6;
}

.nav-link svg { color: #64748b; flex-shrink: 0; }
.nav-link.is-active svg { color: #60a5fa; }

.nav-footer {
  padding: 12px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.nav-user {
  color: #8b98ab;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 8px;
}

.nav-logout {
  width: 100%;
  padding: 7px;
  background: rgba(255, 255, 255, 0.04);
  color: #aab4c4;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
}

.nav-logout:hover { background: rgba(255, 255, 255, 0.10); color: #fff; }

.app-main {
  flex-grow: 1;
  padding: 24px 30px;
  min-width: 0;
}

/* Page header */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-title {
  font-size: 20px;
  font-weight: 800;
  margin: 0;
}

.page-sub { font-size: 12.5px; color: var(--muted); margin: 3px 0 0; }
.page-actions { text-align: right; flex-shrink: 0; }
.page-actions .note { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(29, 78, 216, 0.35);
}

.button:hover { background: var(--accent-strong); }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button:disabled:hover { background: var(--accent); }

.button--secondary {
  background: var(--panel);
  color: #344054;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}
.button--secondary:hover { background: #f8fafc; }
.button--secondary:disabled:hover { background: var(--panel); }

.button--ghost { background: transparent; color: var(--muted); border: none; box-shadow: none; }
.button--ghost:hover { background: var(--bg); color: var(--text); }
.button--ghost:disabled:hover { background: transparent; }

.button--danger { background: transparent; color: var(--danger); border: none; box-shadow: none; }
.button--danger:hover { background: #fef2f2; }
.button--danger:disabled:hover { background: transparent; }

.button--sm { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }

/* Status badges (doc list + editor header) */
.doc-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: #667085;
}

.doc-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}

.doc-badge--processing { background: #dbeafe; color: #1d4ed8; }
.doc-badge--processing::before { animation: badge-pulse 1.2s infinite; }
.doc-badge--extracted { background: #d1fadf; color: #12805c; }
.doc-badge--approved { background: var(--navy-2); color: #93c5fd; }
.doc-badge--approved::before { background: #60a5fa; }
.doc-badge--error { background: #fee4e2; color: #b42318; }
.doc-badge--empty { background: #fef0c7; color: #93540a; }

@keyframes badge-pulse { 50% { opacity: 0.3; } }

/* Document list (left pane of OCR screens) */
.doc-panel { padding: 14px; }

#doc-list { display: flex; flex-direction: column; gap: 3px; }

.doc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
}

.doc-row:hover { background: #f4f7fb; }

.doc-row.is-selected {
  background: var(--accent-weak);
  border-color: #b9cdf7;
  box-shadow: inset 3px 0 0 var(--accent);
}

.doc-row__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.doc-row.is-selected .doc-row__name { color: var(--accent-strong); font-weight: 700; }

.doc-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.chip {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: #475467;
}

/* Upload dropzone */
.dropzone {
  display: block;
  border: 1.5px dashed var(--border-strong);
  border-radius: 8px;
  padding: 16px 10px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: #fafbfd;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-weak);
  color: var(--accent-strong);
}

.dropzone svg { margin: 0 auto 6px; color: #98a2b3; }
.dropzone:hover svg, .dropzone.is-dragover svg { color: var(--accent); }
.dropzone b { display: block; font-size: 12.5px; color: var(--text); margin-bottom: 2px; }
.dropzone:hover b, .dropzone.is-dragover b { color: var(--accent-strong); }
.dropzone span { font-size: 11px; }

.extract-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 12px;
}

.extract-row .button { flex-grow: 1; }
.extract-row .count { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* PDF preview pane */
.pdf-panel { overflow: hidden; padding: 8px; background: #e4e9f1; }
.pdf-panel embed { width: 100%; height: 100%; border: none; border-radius: 6px; }

/* Result editor frame */
.editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafbfd;
  border-radius: 10px 10px 0 0;
}

/* title takes line 1 and shrinks; when the panel is narrow the actions wrap
   to their own line (right-aligned) instead of colliding with the status. */
.editor-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }

.editor-title .editor-fname {
  font-size: 13.5px;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; margin-left: auto; }

.editor-body { padding: 16px; position: relative; min-height: 200px; }

.editor-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.is-busy::after {
  content: "処理中...";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  color: var(--muted);
  border-radius: 10px;
  z-index: 2;
}

/* Header form (label above input) */
.header-form {
  display: flex;
  gap: 12px 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.field label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 700;
}

.field .control { position: relative; display: flex; align-items: center; }

.field input, .field select {
  width: 150px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 13px;
  background: #fff;
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.field input:disabled { background: var(--bg); color: var(--muted); }
.field--wide input { width: 220px; }

.field .suffix-btn {
  position: absolute;
  right: 5px;
  border: none;
  background: transparent;
  color: #98a2b3;
  padding: 3px;
  border-radius: 6px;
  cursor: pointer;
}

.field .suffix-btn:hover { color: var(--accent); background: var(--accent-weak); }
.field input.has-suffix { padding-right: 30px; }

.field-hint { font-size: 11px; color: var(--muted); margin-top: 3px; }

.assist-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--ok);
  margin-top: 4px;
  min-height: 15px;
  white-space: nowrap;
}

/* Items table */
.table-scroll {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.items-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 12.5px;
}

.items-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f5f9;
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border-strong);
  color: #475467;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.items-table th.num, .items-table td.num { text-align: right; }

.items-table td {
  padding: 2px 4px;
  border-bottom: 1px solid #eef2f7;
  white-space: nowrap;
  vertical-align: top;
}

.items-table tbody tr:hover td { background: #f8fafd; }

.items-table input, .items-table select {
  width: 100%;
  min-width: 36px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12.5px;
  background: transparent;
}

.items-table td.num input { text-align: right; font-variant-numeric: tabular-nums; }

.items-table input:not(:disabled):hover,
.items-table select:not(:disabled):hover { border-color: var(--border-strong); background: #fff; }

.items-table input:focus, .items-table select:focus {
  border-color: var(--accent);
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.items-table td.warn { background: #fffaeb; }
.items-table td.warn input::placeholder { color: #b54708; }

.cell-editor { display: flex; align-items: center; gap: 2px; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #b2bccb;
  font-size: 13px;
  padding: 3px;
  border-radius: 6px;
}

.icon-button:hover { color: var(--accent); background: var(--accent-weak); }

.row-actions { white-space: nowrap; }
.items-table tr .row-actions .icon-button { opacity: 0; }
.items-table tr:hover .row-actions .icon-button { opacity: 1; }
.row-actions .icon-button:hover { color: var(--text); background: var(--bg); }
.row-actions .icon-button.icon-button--danger:hover { color: var(--danger); background: #fef2f2; }

.add-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
}

.add-row:hover { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-weak); }

/* Search dialogs */
.search-dialog {
  width: 480px;
  max-width: 90vw;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 16px 48px rgba(16, 24, 40, 0.24);
}

.search-dialog::backdrop { background: rgba(11, 22, 38, 0.45); }

.search-dialog__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  margin-bottom: 12px;
}

.search-dialog__close {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  padding: 4px;
  border-radius: 6px;
}

.search-dialog__close:hover { background: var(--bg); color: var(--text); }

.search-dialog__input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 13px;
  margin-bottom: 10px;
}

.search-dialog__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.search-dialog__results {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.search-dialog__row {
  display: flex;
  gap: 12px;
  padding: 7px 8px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  border-radius: 6px;
}

.search-dialog__row:hover { background: var(--accent-weak); }
.search-dialog__code { color: var(--accent); font-family: monospace; flex-shrink: 0; }

/* Toast notifications */
#toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  background: var(--navy-2);
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.35);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 380px;
  animation: toast-in 0.18s ease-out;
}

.toast svg { margin-top: 1px; flex-shrink: 0; }
.toast--ok svg { color: #34d399; }
.toast--error svg { color: #f87171; }
.toast__title { display: block; font-size: 13px; font-weight: 700; }
.toast__sub { font-size: 11.5px; color: #aab4c4; word-break: break-all; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Misc text helpers */
.error-text { color: var(--danger); font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }

/* Compact density for the work screens (OCR / renamer).
   Scoped to body.app-compact so the dashboard and login keep the base sizes. */
.app-compact .app-main { padding: 14px 18px; }
.app-compact .page-head { margin-bottom: 12px; }
.app-compact .page-title { font-size: 17px; }
.app-compact .page-sub { margin-top: 2px; font-size: 12px; }
.app-compact .page-actions .note { margin-top: 4px; }
.app-compact .button { padding: 8px 14px; font-size: 13px; }
.app-compact .button--sm { padding: 5px 10px; font-size: 12px; }
.app-compact .doc-panel { padding: 10px; }
.app-compact .dropzone { padding: 10px 8px; }
.app-compact .extract-row { margin: 8px 0 10px; }
.app-compact .doc-row { padding: 6px 8px; font-size: 12.5px; }
.app-compact .doc-summary { margin-bottom: 8px; padding-bottom: 8px; }
.app-compact .editor-head { padding: 8px 12px; }
.app-compact .editor-body { padding: 12px; }
.app-compact .header-form { padding: 10px 12px; margin-bottom: 10px; gap: 8px 12px; }
.app-compact .field input, .app-compact .field select { padding: 6px 9px; }
.app-compact .items-table { font-size: 12px; }
.app-compact .items-table th { padding: 6px; font-size: 10.5px; }
.app-compact .items-table input, .app-compact .items-table select { padding: 5px; font-size: 12px; }
.app-compact .add-row { margin-top: 8px; padding: 6px; font-size: 12px; }

/* Split handle between the PDF pane and the editor (drag to resize) */
.split-handle {
  align-self: stretch;
  width: 6px;
  border-radius: 3px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.12s;
}

.split-handle:hover, .is-resizing .split-handle { background: rgba(37, 99, 235, 0.35); }

.is-resizing { user-select: none; cursor: col-resize; }
.is-resizing .pdf-panel embed { pointer-events: none; }

/* Focus mode: hide nav + page head; the document list collapses to a narrow
   rail (filename + status dot) so other files stay one click away. */
.is-zen #app-nav, .is-zen .page-head { display: none; }
.is-zen .app-main { padding: 10px 12px; }
.is-zen .dropzone, .is-zen .extract-row, .is-zen .doc-summary { display: none; }
.is-zen .doc-panel {
  padding: 6px;
  max-height: calc(100vh - 26px);
  overflow-y: auto;
}
.is-zen .doc-row { padding: 5px 6px; font-size: 11.5px; gap: 5px; }
.is-zen .doc-row .doc-badge { font-size: 0; gap: 0; padding: 3px; }

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy-1) 0%, var(--navy-2) 55%, #1c3252 100%);
}

.login-card {
  width: 380px;
  background: var(--panel);
  border-radius: 14px;
  padding: 36px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.login-card .brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  font-size: 21px;
  margin: 0 auto 14px;
}

.login-card h1 { font-size: 19px; font-weight: 800; margin: 0 0 4px; }
.login-sub { font-size: 12.5px; color: var(--muted); margin: 0 0 24px; }

.login-card .field { text-align: left; margin-bottom: 14px; }
.login-card .field input { width: 100%; }
.login-card .button { width: 100%; margin-top: 6px; }
.login-card .error-text { text-align: left; margin: 0 0 10px; }
.login-foot { font-size: 11.5px; color: var(--muted); margin-top: 18px; }
