/* QSpend for Qatar — one stylesheet for every page.
   Mobile first: almost everyone opens a link like this on a phone.
   Colours are defined as tokens on :root and only ever redefined as tokens, so
   both themes resolve as a complete set. */

:root {
  --ground:    #FBFAF9;
  --surface:   #FFFFFF;
  --surface-2: #F2F0EE;
  --line:      #E2DEDA;
  --line-soft: #EDEAE7;
  --ink:       #191617;
  --ink-2:     #57504F;
  --ink-3:     #857D7B;
  --accent:    #8A1538;          /* Qatar maroon */
  --accent-ink:#FFFFFF;
  --accent-bg: #F7E9ED;
  --good:      #1F6B4A;
  --good-bg:   #E6F1EB;
  --warn:      #8A5A12;
  --warn-bg:   #F8EFDD;
  --bad:       #A32B1C;
  --bad-bg:    #F8E7E4;
  --shadow:    0 1px 2px rgba(25,22,23,.04), 0 10px 28px -16px rgba(25,22,23,.18);

  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:  ui-monospace, SFMono-Regular, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:    #131113;
    --surface:   #1C1A1C;
    --surface-2: #252225;
    --line:      #332F32;
    --line-soft: #272428;
    --ink:       #EDE9EA;
    --ink-2:     #ADA5A8;
    --ink-3:     #837B7E;
    --accent:    #E88BA3;
    --accent-ink:#2A0C16;
    --accent-bg: #2E171F;
    --good:      #6FC29A;
    --good-bg:   #16281F;
    --warn:      #D9A94E;
    --warn-bg:   #2C2414;
    --bad:       #E58573;
    --bad-bg:    #2E1A16;
    --shadow:    0 1px 2px rgba(0,0,0,.35), 0 10px 30px -16px rgba(0,0,0,.7);
  }
}

:root[data-theme="dark"] {
  --ground:    #131113;
  --surface:   #1C1A1C;
  --surface-2: #252225;
  --line:      #332F32;
  --line-soft: #272428;
  --ink:       #EDE9EA;
  --ink-2:     #ADA5A8;
  --ink-3:     #837B7E;
  --accent:    #E88BA3;
  --accent-ink:#2A0C16;
  --accent-bg: #2E171F;
  --good:      #6FC29A;
  --good-bg:   #16281F;
  --warn:      #D9A94E;
  --warn-bg:   #2C2414;
  --bad:       #E58573;
  --bad-bg:    #2E1A16;
  --shadow:    0 1px 2px rgba(0,0,0,.35), 0 10px 30px -16px rgba(0,0,0,.7);
}

/* ── base ──────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 620; letter-spacing: -.01em; text-wrap: balance; line-height: 1.2; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: .98rem; }
p { margin: 0; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}
.wrap { max-width: 44rem; margin: 0 auto; padding: 1.1rem 1rem 4rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-s { display: flex; flex-direction: column; gap: .5rem; }
.muted { color: var(--ink-2); }
.small { font-size: .87rem; }
.tiny  { font-size: .78rem; color: var(--ink-3); }
.num   { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.center { text-align: center; }

/* ── header ────────────────────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--ground);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 44rem; margin: 0 auto; padding: .7rem 1rem;
  display: flex; align-items: center; gap: .75rem;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 650; letter-spacing: -.02em; text-decoration: none; color: var(--ink); }
.dot { width: .62rem; height: .62rem; border-radius: 50%; background: var(--accent); flex: none; }
.spacer { flex: 1; }
.nav { display: flex; gap: .15rem; }
.nav a {
  padding: .35rem .6rem; border-radius: 7px; text-decoration: none;
  color: var(--ink-2); font-size: .88rem;
}
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }

/* ── cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 1rem; box-shadow: var(--shadow);
}
.card-flat { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: .85rem 1rem; }

/* ── buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .72rem 1.05rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: .95rem;
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-block { width: 100%; }
.btn-sm { padding: .42rem .7rem; font-size: .84rem; border-radius: 8px; }
.btn-danger { color: var(--bad); }

/* ── forms ─────────────────────────────────────────────────────────────── */
label { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
input, textarea, select {
  width: 100%; font: inherit; font-size: .95rem;
  padding: .6rem .7rem; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
textarea { min-height: 6.5rem; resize: vertical; font-family: var(--mono); font-size: .85rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; }
.row > * { flex: 1 1 8rem; }

/* ── chips ─────────────────────────────────────────────────────────────── */
.chip {
  display: inline-block; padding: .16rem .5rem; border-radius: 999px;
  font-size: .74rem; font-weight: 650; letter-spacing: .01em; white-space: nowrap;
}
.chip-good { background: var(--good-bg); color: var(--good); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-bad  { background: var(--bad-bg);  color: var(--bad); }
.chip-mute { background: var(--surface-2); color: var(--ink-2); }

/* ── notices ───────────────────────────────────────────────────────────── */
.notice { border-radius: 10px; padding: .7rem .9rem; font-size: .9rem; }
.notice-good { background: var(--good-bg); color: var(--good); }
.notice-warn { background: var(--warn-bg); color: var(--warn); }
.notice-bad  { background: var(--bad-bg);  color: var(--bad); }
.notice-info { background: var(--surface-2); color: var(--ink-2); }

/* ── landing ───────────────────────────────────────────────────────────── */
.hero { padding: 2.6rem 0 1.4rem; display: flex; flex-direction: column; gap: 1rem; }
.hero h1 { font-family: var(--serif); font-size: clamp(2rem, 8vw, 2.7rem); font-weight: 600; letter-spacing: -.02em; }
.hero .sub { font-size: 1.05rem; color: var(--ink-2); max-width: 30rem; }
.promises { display: flex; flex-direction: column; gap: .55rem; margin: 0; padding: 0; list-style: none; }
.promises li { display: grid; grid-template-columns: 1.1rem 1fr; gap: .6rem; font-size: .92rem; color: var(--ink-2); align-items: start; }
.tick { color: var(--good); font-weight: 700; }

/* ── setup steps ───────────────────────────────────────────────────────── */
.step { display: grid; grid-template-columns: 1.9rem 1fr; gap: .85rem; }
.step-n {
  width: 1.9rem; height: 1.9rem; border-radius: 50%;
  background: var(--surface-2); color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: .85rem; font-weight: 700; flex: none;
}
.step-done .step-n { background: var(--good); color: var(--surface); }
.step-now  .step-n { background: var(--accent); color: var(--accent-ink); }
.step-body { display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.taps { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--ink-2); }
.taps b { color: var(--ink); }
.keybox {
  font-family: var(--mono); font-size: .82rem; word-break: break-all;
  background: var(--surface-2); border: 1px dashed var(--line);
  border-radius: 9px; padding: .6rem .7rem; color: var(--ink);
}

/* ── bank picker ───────────────────────────────────────────────────────── */
.banks { display: flex; flex-wrap: wrap; gap: .45rem; }
.bank {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-size: .88rem; font-weight: 500; cursor: pointer;
  color: var(--ink);
}
.bank input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent); }
.bank:has(input:checked) { border-color: var(--accent); background: var(--accent-bg); }

.copyrow { display: flex; gap: .4rem; align-items: stretch; }
.copyrow input { flex: 1; font-family: var(--mono); font-size: .85rem; }
.copyrow .btn { flex: none; white-space: nowrap; }

details > summary { cursor: pointer; font-size: .92rem; padding: .2rem 0; }
details[open] > summary { margin-bottom: .6rem; }

/* ── stats ─────────────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: .6rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: .8rem .9rem; }
.stat .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 650; }
.stat .v { font-family: var(--serif); font-size: 1.55rem; font-variant-numeric: tabular-nums; margin-top: .15rem; }
.stat .d { font-size: .78rem; color: var(--ink-3); }

canvas { display: block; width: 100%; height: auto; }

/* ── lists ─────────────────────────────────────────────────────────────── */
.tx { display: flex; flex-direction: column; }
.tx-row {
  display: grid; grid-template-columns: 1fr auto; gap: .5rem 1rem;
  padding: .68rem 0; border-bottom: 1px solid var(--line-soft); align-items: baseline;
}
.tx-row:last-child { border-bottom: 0; }
.tx-m { font-weight: 600; overflow-wrap: anywhere; }
.tx-s { font-size: .78rem; color: var(--ink-3); }
.tx-a { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.tx-a.credit { color: var(--good); }

.bars { display: flex; flex-direction: column; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; }
.bar-track { grid-column: 1 / -1; height: .42rem; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }

.scroller { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line-soft); }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 650; }
td.n, th.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── review queue ──────────────────────────────────────────────────────── */
.raw {
  font-family: var(--mono); font-size: .8rem; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--surface-2); border-radius: 9px; padding: .6rem .7rem; color: var(--ink-2);
}
.consent { display: grid; grid-template-columns: 1.1rem 1fr; gap: .5rem; align-items: start; font-size: .82rem; color: var(--ink-2); font-weight: 400; }
.consent input { width: 1.05rem; height: 1.05rem; margin: .2rem 0 0; }

footer { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .78rem; color: var(--ink-3); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
