:root {
  --bg: #f3f7fc;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --text: #18233a;
  --muted: #6c7a93;
  --line: #dfe8f4;
  --brand: #c14418;
  --brand-2: #df5a2a;
  --blue: #3f7cff;
  --blue-soft: #eaf1ff;
  --green: #12b981;
  --green-soft: #e8fbf4;
  --yellow: #f4b740;
  --yellow-soft: #fff8e8;
  --red: #ef4444;
  --red-soft: #fff0f0;
  --shadow: 0 20px 45px rgba(22, 38, 69, 0.08);
  --radius: 18px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f6f9fd 0%, #eef5fd 100%);
}
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; }
#login-screen { align-items: center; justify-content: center; padding: 32px; }
.login-shell { width: min(1080px, 100%); display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 28px; }
.brand-lockup, .login-card, .sidebar, .topbar, .card, .doc-viewer, .panel, .admin-tabs, .admin-subview, .modal-card {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(223,232,244,0.9);
}
.brand-lockup {
  border-radius: 28px;
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 420px;
  background: radial-gradient(circle at top right, rgba(63,124,255,0.14), transparent 30%),
              radial-gradient(circle at bottom left, rgba(193,68,24,0.12), transparent 30%),
              rgba(255,255,255,0.92);
}
.brand-logo { width: 220px; max-width: 100%; object-fit: contain; margin-bottom: 18px; }
.brand-lockup h1 { margin: 0 0 10px; font-size: 2.1rem; }
.brand-lockup p { margin: 0; color: var(--muted); font-size: 1.05rem; line-height: 1.7; }
.login-card { border-radius: 28px; padding: 34px; display: flex; flex-direction: column; gap: 12px; }
.login-card label { font-size: 0.86rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px;
  font: inherit; color: var(--text); background: #fff;
}
textarea { min-height: 92px; resize: vertical; }
.btn {
  border: 0; border-radius: 14px; padding: 12px 16px; font: inherit; font-weight: 700; cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: white; }
.btn-secondary { background: linear-gradient(135deg, var(--blue), #6ca1ff); color: white; }
.btn-success { background: linear-gradient(135deg, var(--green), #32c994); color: white; }
.btn-warning { background: linear-gradient(135deg, #ffb138, #f8c252); color: white; }
.btn-ghost { background: #edf3fb; color: var(--text); }
.btn-outline { background: white; color: var(--text); border: 1px solid var(--line); }
.login-footnote { color: var(--muted); font-size: 0.9rem; margin-top: 8px; }

#app { display: none; }
#app.active { display: flex; }
.sidebar {
  width: 280px; min-height: 100vh; border-radius: 0 28px 28px 0; padding: 24px 18px;
  display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0;
}
.sidebar-logo { width: 170px; max-width: 100%; }
.sidebar-subtitle { color: var(--muted); font-size: 0.9rem; margin-top: 8px; }
.sidebar-brand { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.nav-button {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-radius: 16px; border: 1px solid transparent; background: transparent; padding: 13px 14px; cursor: pointer;
  color: var(--muted); font: inherit; font-weight: 700;
}
.nav-button.active { background: linear-gradient(135deg, rgba(63,124,255,0.14), rgba(193,68,24,0.1)); color: var(--text); border-color: rgba(63,124,255,0.14); }
.nav-dot { width: 9px; height: 9px; border-radius: 999px; background: var(--line); }
.nav-button.active .nav-dot { background: var(--brand); box-shadow: 0 0 0 6px rgba(193,68,24,0.12); }
.sidebar-user {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-top: 16px; border-top: 1px solid var(--line);
}
#user-name { font-weight: 800; }
#user-role { color: var(--muted); font-size: 0.92rem; }
.main { flex: 1; padding: 22px; }
.topbar {
  border-radius: 24px; padding: 22px 24px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
}
.topbar h2 { margin: 0 0 6px; }
.topbar p { margin: 0; color: var(--muted); }
.view { display: none; }
.view.active { display: block; }
.grid { display: grid; gap: 18px; }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.card {
  border-radius: 22px; padding: 20px;
}
.metric-label { color: var(--muted); text-transform: uppercase; font-size: 0.74rem; letter-spacing: 0.08em; font-weight: 800; }
.metric-value { font-size: 2rem; font-weight: 800; margin: 8px 0; }
.metric-sub { color: var(--muted); font-size: 0.94rem; }
.card h3 { margin: 0 0 14px; }
.table-wrap { overflow: auto; }
.table {
  width: 100%; border-collapse: collapse; min-width: 900px;
}
.table th, .table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.badge {
  display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 6px 11px; font-size: 0.82rem; font-weight: 800;
}
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.yellow { background: var(--yellow-soft); color: #a26d02; }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.purple { background: #f2ebff; color: #7147cc; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.toolbar .search { flex: 1; min-width: 220px; }
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.mini-kpi { border-radius: 18px; padding: 16px; background: var(--panel-soft); border: 1px solid var(--line); }
.mini-kpi .value { font-size: 1.5rem; font-weight: 800; margin-top: 6px; }

.intake-shell { display: grid; grid-template-columns: 1.05fr 1.25fr; gap: 18px; }
.doc-viewer, .panel { border-radius: 22px; padding: 18px; }
.doc-tabs, .sub-tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.tab-btn {
  padding: 10px 13px; border-radius: 12px; border: 1px solid var(--line); background: white; cursor: pointer; font-weight: 800; color: var(--muted);
}
.tab-btn.active { color: var(--text); background: linear-gradient(135deg, rgba(63,124,255,0.15), rgba(255,255,255,1)); border-color: rgba(63,124,255,0.25); }
.document-stage {
  border-radius: 18px; min-height: 420px; position: relative; overflow: hidden; background: linear-gradient(180deg, #fff, #f6faff); border: 1px solid var(--line);
}
.document-paper {
  position: absolute; inset: 16px; background: #fff; border-radius: 14px; border: 1px solid #e8edf6; padding: 18px; overflow: hidden;
}
.doc-header-line, .doc-line { height: 12px; border-radius: 999px; background: linear-gradient(90deg, #eef3fb, #f6f9fe); margin-bottom: 10px; }
.doc-header-line { height: 16px; width: 50%; }
.doc-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px 14px; margin: 14px 0; }
.doc-line.short { width: 55%; }
.doc-line.medium { width: 70%; }
.doc-line.long { width: 92%; }
.scan-line {
  position: absolute; left: 0; right: 0; top: -18%; height: 20%;
  background: linear-gradient(180deg, transparent, rgba(63,124,255,0.22), transparent);
  opacity: 0; pointer-events: none;
}
.scan-line.active { animation: scan 2.1s ease-in-out forwards; opacity: 1; }
@keyframes scan {
  0% { top: -18%; }
  100% { top: 110%; }
}
.highlight-box {
  position: absolute; border: 2px solid rgba(63,124,255,0.95); border-radius: 12px; background: rgba(63,124,255,0.08);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.8) inset, 0 0 16px rgba(63,124,255,0.32); opacity: 0; transform: scale(0.96);
}
.highlight-box.glow { animation: glowIn 0.5s ease forwards, pulseGlow 2s ease infinite 0.55s; }
@keyframes glowIn { to { opacity: 1; transform: scale(1); } }
@keyframes pulseGlow {
  0%,100% { box-shadow: 0 0 0 1px rgba(255,255,255,0.8) inset, 0 0 14px rgba(63,124,255,0.24); }
  50% { box-shadow: 0 0 0 1px rgba(255,255,255,0.9) inset, 0 0 24px rgba(63,124,255,0.48); }
}
.highlight-label {
  position: absolute; top: -12px; left: 10px; background: var(--blue); color: white; padding: 4px 8px; border-radius: 999px; font-size: 0.74rem; font-weight: 800;
}
.progress-card { display: grid; gap: 10px; margin-bottom: 14px; }
.progress-item { display: grid; grid-template-columns: 140px 1fr auto; align-items: center; gap: 10px; font-size: 0.92rem; }
.progress-bar { height: 11px; border-radius: 999px; background: #e8eef9; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--blue), #91b6ff); transition: width 0.4s ease; }
.extract-list { display: grid; gap: 10px; }
.extract-item, .form-field {
  border: 1px solid var(--line); border-radius: 16px; padding: 12px 13px; background: #fff;
}
.extract-item .top, .form-field .top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.extract-item .name, .form-field label { font-weight: 800; font-size: 0.93rem; }
.extract-item .value { font-weight: 700; }
.conf { font-size: 0.78rem; font-weight: 800; padding: 5px 8px; border-radius: 999px; }
.conf.high { background: var(--green-soft); color: var(--green); }
.conf.medium { background: var(--yellow-soft); color: #996500; }
.conf.low { background: var(--red-soft); color: var(--red); }
.form-section-title { margin: 16px 0 10px; font-size: 0.84rem; color: var(--muted); text-transform: uppercase; font-weight: 800; letter-spacing: 0.08em; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.form-field textarea { min-height: 88px; }
.form-field.full { grid-column: 1 / -1; }
.callout {
  border-radius: 18px; padding: 14px 16px; font-weight: 700; margin-bottom: 12px;
}
.callout.blue { background: var(--blue-soft); color: var(--blue); }
.callout.yellow { background: var(--yellow-soft); color: #996500; }
.callout.green { background: var(--green-soft); color: #087f58; }
.callout.red { background: var(--red-soft); color: var(--red); }
.action-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.admin-tabs { border-radius: 22px; padding: 12px; margin-bottom: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.admin-subview { border-radius: 22px; padding: 18px; display: none; }
.admin-subview.active { display: block; }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status-dot.green { background: var(--green); }
.status-dot.yellow { background: var(--yellow); }
.status-dot.red { background: var(--red); }
.modal {
  position: fixed; inset: 0; background: rgba(17, 25, 40, 0.4); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 40;
}
.modal.hidden { display: none; }
.modal-card { width: min(760px, 100%); border-radius: 24px; padding: 22px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; }
.modal-body { color: var(--muted); line-height: 1.7; }
.toast {
  position: fixed; right: 20px; bottom: 20px; background: #18233a; color: white; padding: 12px 16px; border-radius: 14px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: 0.25s ease; z-index: 60;
}
.toast.show { opacity: 1; transform: translateY(0); }
.legend { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.legend .pill { border-radius: 999px; padding: 6px 10px; font-size: 0.82rem; font-weight: 800; }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.yellow { background: var(--yellow-soft); color: #996500; }
.pill.red { background: var(--red-soft); color: var(--red); }

@media (max-width: 1180px) {
  .grid.stats, .kpi-row { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .intake-shell { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  #app.active { display: block; }
  .sidebar { width: auto; min-height: auto; border-radius: 0; position: static; }
  .main { padding: 14px; }
  .grid.stats, .kpi-row, .quick-grid, .form-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; }
}

.section-head{font-size:1rem;font-weight:900;color:var(--text);margin:4px 0 10px;padding-bottom:8px;border-bottom:2px solid var(--line);letter-spacing:.02em;}
.inline-note{margin-top:8px;padding:10px 12px;border-radius:12px;background:#f5f8fe;border:1px solid #d9e4f7;color:var(--muted);font-size:.9rem;font-weight:700;}
.inline-note.success{background:var(--green-soft);border-color:#bce8d8;color:var(--green);}
.inline-note.info{background:var(--blue-soft);border-color:#bfd4ff;color:var(--blue);}
.checklist{display:grid;gap:10px;padding:14px 16px;border:1px solid var(--line);background:#fff;border-radius:18px;}
.checklist label{display:flex;gap:10px;align-items:flex-start;font-weight:700;color:var(--text);}
.checklist input{margin-top:3px;}
