:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e4e6eb;
  --text: #121418;
  --muted: #6b7180;
  --accent: #1fbf6f;
  --accent-ink: #0b7a43;
  --accent-soft: #e3f8ec;
  --danger: #e0413a;
  --danger-soft: #fde8e7;
  --warn-bg: #fff4d6;
  --warn-ink: #7a5600;
  --info: #6d4aff;
  --info-soft: #efeaff;
  --shadow: 0 1px 2px rgba(16, 20, 28, .06), 0 4px 16px rgba(16, 20, 28, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --surface: #16191e;
    --surface-2: #1e2229;
    --border: #2a2f37;
    --text: #eef0f3;
    --muted: #949bab;
    --accent: #2bdc82;
    --accent-ink: #2bdc82;
    --accent-soft: #123222;
    --danger: #ff6b63;
    --danger-soft: #3a1714;
    --warn-bg: #3a2f10;
    --warn-ink: #ffd36b;
    --info: #a28bff;
    --info-soft: #241d45;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.logo {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 800;
}
.demo-pill {
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--warn-bg); color: var(--warn-ink);
}
.acting { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.acting select { padding: 7px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); max-width: 260px; }

/* layout */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 57px); }
.sidenav { display: flex; flex-direction: column; gap: 2px; padding: 20px 12px; border-right: 1px solid var(--border); background: var(--surface); }
.sidenav a { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: 10px; color: var(--muted); font-weight: 550; }
.sidenav a:hover { background: var(--surface-2); color: var(--text); }
.sidenav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav-foot { margin-top: auto; padding: 12px; display: flex; gap: 14px; }
.badge { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; text-align: center; }
main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }

/* cards & tiles */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.tile { padding: 16px 18px; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 13px; color: var(--muted); }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--muted); font-size: 13px; text-decoration: underline; }

/* tabs */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; width: fit-content; margin-bottom: 16px; }
.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* table */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.merchant { font-weight: 600; }
.sub { font-size: 13px; color: var(--muted); }
.clip { display: inline-block; margin-left: 6px; font-size: 12px; color: var(--muted); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }

.status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.status.submitted { background: var(--warn-bg); color: var(--warn-ink); }
.status.approved { background: var(--accent-soft); color: var(--accent-ink); }
.status.rejected { background: var(--danger-soft); color: var(--danger); }

.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--info-soft); color: var(--info); flex: none; }
.person { display: flex; align-items: center; gap: 10px; }

/* new expense */
.new-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.dropzone {
  min-height: 460px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface); text-align: center; padding: 24px;
  transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-size: 24px; }
.preview { width: 100%; height: 520px; border: 0; border-radius: 10px; background: var(--surface-2); object-fit: contain; }
.preview-wrap { padding: 12px; }
.pdf-pages { overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px; }
.pdf-pages canvas { background: #fff; border-radius: 4px; box-shadow: var(--shadow); flex: none; }
.preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 4px 12px; font-size: 14px; }
.preview-bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.form { padding: 22px; display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field textarea { resize: vertical; min-height: 70px; }
.field.ai input, .field.ai select, .field.ai textarea { background: var(--info-soft); }
.scan-note { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--info-soft); color: var(--info); font-size: 13px; font-weight: 550; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.approver-line { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.error { color: var(--danger); font-size: 14px; }

/* drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 16, .4); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 21; width: min(980px, 100%);
  background: var(--bg); box-shadow: -8px 0 32px rgba(0, 0, 0, .18); display: flex; flex-direction: column;
}
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 22px; background: var(--surface); border-bottom: 1px solid var(--border); }
.drawer-head h2 { flex: 1; }
.close { border: 0; background: var(--surface-2); width: 34px; height: 34px; border-radius: 10px; font-size: 18px; }
.drawer-body { flex: 1; overflow: auto; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; padding: 20px 22px; align-items: start; }
.receipt-box { padding: 12px; }
.receipt-box .preview { height: 640px; }
.no-receipt { height: 240px; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; }
.facts { padding: 18px 20px; }
.amount-big { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; }
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 9px 12px; margin: 16px 0 0; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.decision { padding: 18px 20px; margin-top: 14px; display: grid; gap: 10px; }
.decision textarea { width: 100%; min-height: 76px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); resize: vertical; }
.decision .actions { display: flex; gap: 10px; }
.decision .actions .btn { flex: 1; justify-content: center; }
.note { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-top: 14px; }
.note.rejected { background: var(--danger-soft); color: var(--danger); }
.note.approved { background: var(--accent-soft); color: var(--accent-ink); }
.note.info { background: var(--surface-2); color: var(--muted); }
.timeline { padding: 18px 20px; margin-top: 14px; }
.timeline ol { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 14px; }
.timeline li { display: grid; grid-template-columns: 12px 1fr; gap: 12px; font-size: 14px; }
.timeline .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--border); }
.timeline .dot.submitted { background: var(--warn-ink); }
.timeline .dot.approved { background: var(--accent); }
.timeline .dot.rejected { background: var(--danger); }
.timeline blockquote { margin: 4px 0 0; padding-left: 10px; border-left: 2px solid var(--border); color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  padding: 11px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 600; box-shadow: var(--shadow);
}

/* PIN page */
.pin-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.pin-card { width: min(380px, 100%); padding: 32px 28px; display: grid; gap: 14px; justify-items: center; text-align: center; }
.pin-card h1 { font-size: 22px; }
.pin-card p { margin: 0; }
.pin-card input { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); text-align: center; font-size: 18px; letter-spacing: .2em; }
.pin-card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.pin-card .btn { width: 100%; justify-content: center; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidenav { flex-direction: row; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav-foot { display: none; }
  main { padding: 20px 16px 60px; }
  .new-grid, .drawer-body { grid-template-columns: 1fr; }
  .dropzone { min-height: 220px; }
  .preview, .receipt-box .preview { height: 420px; }
  .tiles { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .demo-pill { display: none; }
}
