/* Purpose Expenses — black & white first; secondary colours only for status. */
:root {
  --black: #000;
  --white: #fff;
  --ink: #0a0a0a;
  --ink-2: #4a4a4a;
  --ink-3: #8a8a8a;
  --line: #e6e6e6;
  --line-2: #d0d0d0;
  --wash: #f5f5f5;
  --orange: #F99D3E;
  --red: #F1667C;
  --teal: #88D1D1;
  --green: #BBD976;
  --lavender: #B6B6DB;
  --radius: 3px;
  --head: 'Raleway', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow: 0 12px 40px rgba(0, 0, 0, .16);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--body); color: var(--ink); background: var(--white); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

h1, h2, h3, .head { font-variant-numeric: lining-nums; font-family: var(--head); font-weight: 900; text-transform: uppercase; letter-spacing: .01em; line-height: 1; margin: 0; }
h1 { font-size: clamp(34px, 6vw, 56px); }
h2 { font-size: 22px; }
h3 { font-size: 14px; letter-spacing: .06em; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px; border-radius: var(--radius);
  border: 1.5px solid var(--black); background: var(--black); color: var(--white); font-family: var(--head); font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform .08s, opacity .15s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--black); }
.btn.invert { background: var(--white); color: var(--black); border-color: var(--white); }
.btn.invert-ghost { background: transparent; color: var(--white); border-color: var(--white); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 11px; }
.btn.danger { background: transparent; color: #b4233a; border-color: transparent; }
.btn svg { width: 18px; height: 18px; }
.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- Sign in ---------- */
.signin { min-height: 100dvh; background: var(--black); color: var(--white); display: grid; grid-template-rows: 1fr auto; padding: 32px 24px; }
.signin-inner { align-self: center; justify-self: center; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 28px; }
.signin-logo { width: 72px; height: 72px; }
.signin h1 { font-size: clamp(44px, 12vw, 72px); }
.signin p { color: #bdbdbd; margin: 0; font-size: 17px; }
.signin .err { color: var(--red); font-size: 14px; }
.signin footer { text-align: center; color: #6d6d6d; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
#gsi-button { min-height: 44px; }

/* ---------- App shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--white); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1120px; margin: 0 auto; height: 76px; padding: 0 24px; display: flex; align-items: center; gap: 24px; }
.topbar .logo { height: 44px; width: 44px; display: block; }
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab { height: 76px; display: flex; align-items: center; padding: 0 12px; font-family: var(--head); font-weight: 800; font-size: 13px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3); text-decoration: none; border-bottom: 3px solid transparent; }
.tab.active { color: var(--black); border-bottom-color: var(--black); }
.user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--black); color: var(--white); display: grid; place-items: center;
  font-family: var(--head); font-weight: 900; font-size: 13px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
main { max-width: 1120px; margin: 0 auto; padding: 56px 24px 120px; }

/* ---------- Capture ---------- */
.capture { background: var(--white); color: var(--black); padding: 8px 0 0; display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: end; position: relative; }
.capture p { margin: 16px 0 0; color: var(--ink-2); }
.capture-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.capture .manual { color: var(--ink-2); font-size: 13px; }
.capture.drag { outline: 3px dashed var(--black); outline-offset: 8px; border-radius: var(--radius); }
.dropnote { font-size: 12px; color: #8a8a8a; margin-top: 6px; }

/* ---------- Upload queue ---------- */
.queue { margin-top: 28px; display: grid; gap: 8px; }
.qitem { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.qthumb { width: 44px; height: 44px; border-radius: var(--radius); background: var(--wash); object-fit: cover; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--ink-3); }
.qstatus { font-size: 13px; color: var(--ink-2); }
.qitem > div:last-child { display: flex; align-items: center; gap: 4px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line-2); border-top-color: var(--black); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toolbar & list ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 80px 0 20px; }
.toolbar h2 { margin-right: auto; }
.field, select.field, input.field { height: 40px; border: 1.5px solid var(--line-2); border-radius: var(--radius); padding: 0 12px; background: var(--white); min-width: 0; }
.field:focus { outline: none; border-color: var(--black); }
.search { width: 200px; }
.summary { display: flex; flex-wrap: wrap; gap: 6px 24px; padding: 16px 0; border-top: 2px solid var(--black); font-size: 13px; color: var(--ink-2); }
.summary b { color: var(--black); font-weight: 600; }

.list { border-top: 1px solid var(--line); }
.month { font-family: var(--head); font-weight: 800; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding: 36px 0 12px; display: flex; justify-content: space-between; }
.row { display: grid; grid-template-columns: 56px 1fr 170px 140px 20px; gap: 16px; align-items: center; padding: 20px 8px; border-bottom: 1px solid var(--line);
  cursor: pointer; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; }
.row:hover { background: var(--wash); }
.date { font-variant-numeric: lining-nums tabular-nums; font-family: var(--head); font-weight: 900; line-height: 1; text-align: center; }
.date .d { font-size: 22px; display: block; }
.date .m { font-size: 10px; letter-spacing: .1em; color: var(--ink-3); }
.merchant { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desc { font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: var(--radius); background: var(--wash); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.amount { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.amount .ccy { font-size: 11px; color: var(--ink-3); font-weight: 600; margin-right: 4px; }
.flag { width: 10px; height: 10px; border-radius: 50%; background: var(--orange); justify-self: center; }
.empty { padding: 56px 0; text-align: center; color: var(--ink-3); }
.empty h3 { color: var(--ink); margin-bottom: 8px; }

/* ---------- Drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(980px, 100%); background: var(--white); z-index: 41; display: grid; grid-template-columns: 1fr 420px; box-shadow: var(--shadow); }
.drawer-preview { background: #141414; display: grid; place-items: center; overflow: auto; padding: 20px; position: relative; }
.drawer-preview img { max-height: calc(100dvh - 40px); object-fit: contain; }
.drawer-preview iframe { width: 100%; height: 100%; border: 0; background: var(--white); }
.drawer-preview .none { color: #777; text-align: center; font-size: 14px; }
.drawer-form { display: flex; flex-direction: column; overflow: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--white); z-index: 1; }
.drawer-body { padding: 28px 28px; display: grid; gap: 22px; }
.drawer-foot { margin-top: auto; padding: 16px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; position: sticky; bottom: 0; background: var(--white); }
label.lbl { display: grid; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
label.lbl .field { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--ink); font-weight: 400; width: 100%; }
textarea.field { height: 72px; padding: 10px 12px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-amt { display: grid; grid-template-columns: 1fr 110px; gap: 16px; }
.note { font-size: 13px; color: var(--ink-2); background: var(--wash); border-radius: var(--radius); padding: 10px 12px; }
.note.warn { background: #fff3e6; border-left: 3px solid var(--orange); }
.override { border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; }
.override .t { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.icon-btn { width: 36px; height: 36px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; border-radius: 50%; }
.icon-btn:hover { background: var(--wash); }
.icon-btn svg { width: 20px; height: 20px; }
.ai-tag { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: var(--radius); background: var(--wash); }
.ai-tag.ok { background: #eef6dd; }
.ai-tag.check { background: #fff3e6; }

/* ---------- Report ---------- */
.panel { border: 1.5px solid var(--black); border-radius: var(--radius); padding: 32px; display: grid; gap: 28px; margin-top: 28px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { height: 32px; padding: 0 14px; border-radius: var(--radius); border: 1.5px solid var(--line-2); background: var(--white); cursor: pointer; font-size: 13px; font-weight: 500; }
.pill.active { background: var(--black); border-color: var(--black); color: var(--white); }
.report-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 20px; }
.report-grid .wide { grid-column: span 2; }
table.lines { width: 100%; border-collapse: collapse; margin-top: 56px; font-size: 14px; }
table.lines { border-collapse: separate; border-spacing: 0; }
table.lines th:first-child { border-top-left-radius: var(--radius); border-bottom-left-radius: var(--radius); }
table.lines th:last-child { border-top-right-radius: var(--radius); border-bottom-right-radius: var(--radius); }
table.lines th { font-family: var(--head); font-weight: 800; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; text-align: left; padding: 12px 10px; background: var(--black); color: var(--white); }
table.lines td { padding: 16px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.lines .r { text-align: right; font-variant-numeric: tabular-nums; }
table.lines tfoot td { border-bottom: 0; font-weight: 700; padding-top: 14px; }
.amt-input { width: 110px; height: 32px; text-align: right; border: 1.5px solid var(--line-2); border-radius: var(--radius); padding: 0 8px; font-variant-numeric: tabular-nums; }
.amt-input:focus { outline: none; border-color: var(--black); }
.amt-input.overridden { border-color: var(--black); background: #fafafa; font-weight: 600; }
.rate { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.totals { display: grid; grid-template-columns: 1fr 340px; gap: 48px; margin-top: 56px; align-items: start; }
.cat-totals { display: grid; gap: 0; }
.cat-totals div { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.grand { background: #ebebeb; color: var(--black); border-radius: var(--radius); padding: 28px; display: grid; gap: 10px; }
.grand .label { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--ink-2); }
.grand .sub { font-size: 13px; color: var(--ink-2); }
.grand .v { font-family: var(--head); font-weight: 900; font-size: 34px; line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; }
.grand .v .ccy { font-weight: 400; margin-left: .25em; }
.generate { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 64px; padding-top: 32px; border-top: 2px solid var(--black); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--black); }
.progress { font-size: 14px; color: var(--ink-2); }
.done-card { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--black); color: var(--white); padding: 12px 18px; border-radius: var(--radius);
  font-size: 14px; z-index: 60; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.toast.err { background: #b4233a; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .panel { padding: 22px; gap: 22px; }
  .totals { gap: 32px; }
  body { font-size: 16px; }
  .topbar-inner { gap: 10px; padding: 0 16px; height: 64px; }
  .topbar .logo { height: 36px; width: 36px; }
  .tab { height: 64px; padding: 0 8px; font-size: 12px; }
  .user .name, #signout { display: none; }
  .avatar { cursor: pointer; }
  main { padding: 32px 16px 120px; }
  .capture { grid-template-columns: 1fr; padding: 4px 0 0; }
  .capture-actions { justify-content: stretch; }
  .capture-actions .btn { flex: 1; }
  .dropnote { display: none; }
  .toolbar { margin-top: 56px; }
  .toolbar h2 { width: 100%; }
  .toolbar .field { flex: 1 1 calc(50% - 5px); }
  .search { width: auto; }
  .row { grid-template-columns: 44px 1fr auto; gap: 12px; padding: 16px 4px; }
  .row .cat { display: none; }
  .row .flag { display: none; }
  .drawer { grid-template-columns: 1fr; grid-template-rows: 38dvh 1fr; }
  .drawer-preview img { max-height: 36dvh; }
  .report-grid { grid-template-columns: 1fr 1fr; }
  .report-grid .wide { grid-column: span 2; }
  table.lines .hide-m { display: none; }
  table.lines { font-size: 13px; }
  .totals { grid-template-columns: 1fr; }
}
