/* Plate-forme dashboard.
   One bold element: each country is a CFA banknote (engraved rosette, denomination-sized
   amount, flag edge). Everything around it is quiet: paper, ink, hairlines, tabular
   figures. Status colours carry meaning only. */

@font-face {
  font-family: "Bricolage";
  src: url("display.woff2") format("woff2");
  font-weight: 200 800; font-stretch: 75% 100%; font-display: swap;
}
@font-face {
  font-family: "Instrument";
  src: url("text.woff2") format("woff2");
  font-weight: 400 700; font-stretch: 75% 100%; font-display: swap;
}

:root {
  --paper: #f3f5f2;
  --surface: #ffffff;
  --sunk: #eaeee9;
  --ink: #172036;
  --ink-2: #39425a;
  --muted: #5c6478;
  --line: #dce1e3;
  --line-strong: #c3cad0;

  --td: #27358f;
  --td-tint: #e9ebf6;
  --cm: #1d6b45;
  --cm-tint: #e5f0ea;

  --ok: #12704f;
  --ok-tint: #e2f2ea;
  --hold: #a5650a;
  --hold-tint: #fbf0d9;
  --danger: #b42318;
  --danger-tint: #fcebe9;
  --shadow-mode: #475467;

  --focus: #2f6fed;
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 18px;
  --display: "Bricolage", ui-sans-serif, system-ui, sans-serif;
  --text: "Instrument", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.125rem;
  --step-2: 1.5rem;
  --step-3: 2rem;
  --tabbar: 0px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10142a;
    --surface: #161b35;
    --sunk: #1c2240;
    --ink: #eef0f6;
    --ink-2: #c9cede;
    --muted: #949bb3;
    --line: #2a3152;
    --line-strong: #3a4268;
    --td: #8d9cf2;
    --td-tint: #1e2550;
    --cm: #6fcf9c;
    --cm-tint: #163a2b;
    --ok: #5fd19f;
    --ok-tint: #143b2c;
    --hold: #f0b44c;
    --hold-tint: #3d2d10;
    --danger: #ff8a7e;
    --danger-tint: #431c1a;
    --shadow-mode: #aab3c8;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.5 var(--text);
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- buttons and inputs ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 2.5rem; padding: 0 1rem;
  border: 1px solid var(--line-strong); border-radius: var(--r-s);
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: var(--step--1); cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { border-color: var(--ink-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn--primary:hover { background: var(--ink-2); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn--danger:hover { background: var(--danger-tint); border-color: var(--danger); }
.btn--solid-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--sunk); border-color: transparent; }
.btn--small { min-height: 2rem; padding: 0 .7rem; }

.field { display: grid; gap: .35rem; }
.field > span { font-size: var(--step--1); font-weight: 600; color: var(--ink-2); }
.field small { color: var(--muted); font-size: var(--step--1); }
.input, .select {
  width: 100%; min-height: 2.75rem; padding: 0 .85rem;
  border: 1px solid var(--line-strong); border-radius: var(--r-s);
  background: var(--surface);
}
.input:focus, .select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.input--code {
  font: 600 1.75rem/1 var(--display); letter-spacing: .5em; text-align: center;
  font-stretch: 80%; padding-inline-start: .5em; min-height: 3.5rem;
}

/* ---------- login ---------- */

.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem;
  position: relative; overflow: hidden;
}
.login__rosette { position: absolute; inset: auto -18vmax -18vmax auto; width: 70vmax; opacity: .5; pointer-events: none; color: var(--td); }
.login__card {
  position: relative; width: min(24rem, 100%);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-l); padding: 2rem 1.75rem 1.75rem;
  display: grid; gap: 1.1rem;
  box-shadow: 0 30px 60px -30px color-mix(in srgb, var(--ink) 35%, transparent);
}
.login__card h1 { margin: 0; font: 700 var(--step-3)/1.05 var(--display); font-stretch: 85%; letter-spacing: -.01em; }
.login__card p { margin: -.6rem 0 .2rem; color: var(--muted); }
.login__error { color: var(--danger); font-size: var(--step--1); min-height: 1.2em; margin: 0; }

/* ---------- shell ---------- */

.shell { min-height: 100dvh; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__row {
  max-width: 78rem; margin: 0 auto; padding: .75rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; margin-inline-end: auto; }
.brand img { width: 1.9rem; height: 1.9rem; }
.brand b { font: 700 var(--step-1)/1 var(--display); font-stretch: 85%; }
.live { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); font-size: var(--step--1); }
.live::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-tint); }
.live--stale::before { background: var(--hold); box-shadow: 0 0 0 3px var(--hold-tint); }

.nav { max-width: 78rem; margin: 0 auto; padding: 0 1.25rem; display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
.nav a {
  display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap;
  padding: .55rem .75rem .7rem; text-decoration: none; color: var(--muted);
  font-weight: 600; font-size: var(--step--1); border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.nav svg { width: 1.05rem; height: 1.05rem; }
.nav .badge-dot { min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem; border-radius: 999px; background: var(--hold); color: #fff; font-size: .7rem; display: inline-grid; place-items: center; }

.main { max-width: 78rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; display: grid; gap: 1.5rem; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; font: 700 var(--step-3)/1.1 var(--display); font-stretch: 85%; letter-spacing: -.01em; }
.page-head p { margin: .25rem 0 0; color: var(--muted); max-width: 60ch; }

.notice {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .85rem 1rem; border-radius: var(--r-m);
  background: var(--hold-tint); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--hold) 30%, transparent);
}
.notice svg { flex: none; width: 1.25rem; height: 1.25rem; color: var(--hold); margin-top: .1rem; }
.notice p { margin: 0; max-width: 75ch; }

/* ---------- demo ---------- */

.demo-tag { font-size: var(--step--1); font-weight: 600; color: var(--td); background: var(--td-tint); padding: .2rem .6rem; border-radius: 999px; white-space: nowrap; }
.demo-box { display: grid; gap: .6rem; padding: .8rem .9rem; border-radius: var(--r-m); background: var(--td-tint); font-size: var(--step--1); color: var(--ink-2); justify-items: start; }
.demo-hint { margin: -.35rem 0 0; font-size: var(--step--1); color: var(--muted); }
.linklike { border: 0; background: none; padding: 0; color: var(--td); font-weight: 600; text-decoration: underline; cursor: pointer; }
.notice--demo { background: var(--td-tint); border-color: color-mix(in srgb, var(--td) 25%, transparent); }
.notice--demo svg { color: var(--td); }
.tg { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.tg li { display: grid; grid-template-columns: 3.2rem 1fr; gap: .75rem; align-items: start; }
.tg time { color: var(--muted); font-size: var(--step--1); padding-top: .55rem; }
.tg p { margin: 0; padding: .55rem .8rem; border-radius: 4px 14px 14px 14px; background: var(--sunk); white-space: pre-wrap; word-break: break-word; font-size: var(--step--1); max-width: 70ch; }

/* ---------- banknotes (the signature) ---------- */

.notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 30rem), 1fr)); gap: 1.25rem; }
.note {
  --c: var(--td); --c-tint: var(--td-tint);
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: var(--r-l);
  background:
    radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--c) 14%, transparent), transparent 60%),
    linear-gradient(var(--surface), var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 28%, var(--line));
  padding: 1.35rem 1.5rem 1.25rem 1.85rem;
  display: grid; gap: 1.1rem;
}
.note--cm { --c: var(--cm); --c-tint: var(--cm-tint); }
.note::after {  /* engraved inner frame, like the border of a banknote */
  content: ""; position: absolute; inset: 6px 6px 6px 12px; pointer-events: none;
  border: 1px solid color-mix(in srgb, var(--c) 18%, transparent); border-radius: calc(var(--r-l) - 5px);
}
.note__flag { position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 6px; display: grid; }
.note__rosette {
  position: absolute; inset-inline-end: -5.5rem; top: -5.5rem; width: 20rem; color: var(--c); opacity: .5; z-index: -1; pointer-events: none;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 18%, transparent 62%);
          mask-image: radial-gradient(circle at 50% 50%, #000 18%, transparent 62%);
}
.note__head { display: flex; align-items: center; gap: .5rem .75rem; flex-wrap: wrap; }
.note__country { font: 700 var(--step-2)/1 var(--display); font-stretch: 80%; color: var(--c); }
.note__serial { color: var(--muted); font-size: var(--step--1); letter-spacing: .04em; margin-inline-start: auto; }
.note__value { display: grid; gap: .15rem; }
.note__alarm { margin: 0; padding: .6rem .75rem; border-radius: var(--r-s); background: var(--danger-tint); color: var(--danger); font-size: var(--step--1); font-weight: 600; }
.note__amount {
  font: 700 clamp(2.6rem, 7vw, 4.25rem)/.9 var(--display);
  font-stretch: 75%; font-variation-settings: "opsz" 96; letter-spacing: -.02em;
  color: var(--ink);
}
.note__amount small { font: 600 var(--step-1)/1 var(--display); font-stretch: 85%; color: var(--muted); margin-inline-start: .35rem; letter-spacing: 0; }
.note__caption { color: var(--muted); font-size: var(--step--1); }
.note__stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid color-mix(in srgb, var(--c) 16%, var(--line)); }
.stat { padding: .75rem .5rem 0 0; display: grid; gap: .1rem; text-decoration: none; }
.stat + .stat { padding-inline-start: .9rem; border-inline-start: 1px solid color-mix(in srgb, var(--c) 16%, var(--line)); }
.stat b { font: 700 var(--step-2)/1 var(--display); font-stretch: 85%; }
.stat span { color: var(--muted); font-size: var(--step--1); }
a.stat:hover b { text-decoration: underline; text-underline-offset: 3px; }
.stat--hold b { color: var(--hold); }

.gauge { display: grid; gap: .4rem; }
.gauge__bar { height: .45rem; border-radius: 999px; background: color-mix(in srgb, var(--c) 12%, var(--sunk)); overflow: hidden; }
.gauge__fill { height: 100%; background: var(--c); border-radius: inherit; transition: width .6s cubic-bezier(.2,.7,.2,1); }
.gauge__fill--high { background: var(--hold); }
.gauge__label { display: flex; justify-content: space-between; font-size: var(--step--1); color: var(--muted); }

.note__controls { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.note__controls .spacer { flex: 1; }
.note--off .note__amount, .note--off .note__stats { opacity: .45; }
.offline { font-size: var(--step--1); color: var(--muted); padding: .2rem .55rem; border: 1px dashed var(--line-strong); border-radius: 999px; }

.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--sunk); border: 1px solid var(--line); }
.segmented button {
  border: 0; background: transparent; padding: .35rem .85rem; border-radius: 999px;
  font-size: var(--step--1); font-weight: 600; color: var(--muted); cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 20%, transparent); }
.segmented button:disabled { cursor: default; }
.note .segmented button[aria-pressed="true"] { color: var(--c); }

/* ---------- panels, chart, lists ---------- */

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.25rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 1.1rem 1.25rem; min-width: 0; }
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .85rem; }
.panel__head h2 { margin: 0; font: 700 var(--step-1)/1.2 var(--display); font-stretch: 90%; }
.panel__head span { color: var(--muted); font-size: var(--step--1); }

.chart { width: 100%; height: 13rem; display: block; }
.chart text { fill: var(--muted); font: 500 11px var(--text); }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 4; }
.legend { display: flex; gap: 1rem; font-size: var(--step--1); color: var(--muted); margin-top: .35rem; }
.legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-inline-end: .35rem; vertical-align: -1px; }

.attention { list-style: none; margin: 0; padding: 0; display: grid; }
.attention li + li { border-top: 1px solid var(--line); }
.attention a { display: flex; align-items: center; gap: .75rem; padding: .7rem 0; text-decoration: none; }
.attention a:hover .attention__text { text-decoration: underline; text-underline-offset: 3px; }
.attention__count { min-width: 2.2rem; height: 2.2rem; padding: 0 .4rem; border-radius: var(--r-s); display: grid; place-items: center; font: 700 var(--step-1)/1 var(--display); background: var(--hold-tint); color: var(--hold); }
.attention__count--danger { background: var(--danger-tint); color: var(--danger); }
.attention__text { display: grid; }
.attention__text small { color: var(--muted); }
.calm { color: var(--muted); padding: .5rem 0; margin: 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 7.5rem 1fr auto; gap: .25rem 1rem; padding: .75rem 0; border-top: 1px solid var(--line); align-items: baseline; }
.timeline li:first-child { border-top: 0; }
.timeline time { color: var(--muted); font-size: var(--step--1); }
.timeline .who { display: flex; gap: .5rem; flex-wrap: wrap; align-items: baseline; }
.timeline .why { grid-column: 2 / 4; color: var(--muted); font-size: var(--step--1); }
.amount { font-weight: 600; white-space: nowrap; }

/* ---------- chips and badges ---------- */

.chip { display: inline-flex; align-items: center; padding: .05rem .45rem; border-radius: 4px; font-size: .75rem; font-weight: 700; letter-spacing: .03em; }
.chip--TD { background: var(--td-tint); color: var(--td); }
.chip--CM { background: var(--cm-tint); color: var(--cm); }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; }
.badge--ok { background: var(--ok-tint); color: var(--ok); }
.badge--hold { background: var(--hold-tint); color: var(--hold); }
.badge--danger { background: var(--danger-tint); color: var(--danger); }
.badge--neutral { background: var(--sunk); color: var(--ink-2); }
.badge--done { background: transparent; color: var(--muted); border-color: var(--line); }
.badge--shadow { background: transparent; color: var(--shadow-mode); border: 1px dashed var(--line-strong); }

/* ---------- profit ---------- */

.figures { display: grid; grid-template-columns: repeat(4, 1fr); padding: 0; }
.figure { display: grid; gap: .2rem; padding: 1.1rem 1.25rem; align-content: start; }
.figure + .figure { border-inline-start: 1px solid var(--line); }
.figure__label { font-size: var(--step--1); color: var(--muted); font-weight: 600; }
.figure__value { font: 700 clamp(1.7rem, 3.4vw, 2.4rem)/1 var(--display); font-stretch: 78%; letter-spacing: -.01em; color: var(--ok); }
.figure--loss .figure__value { color: var(--danger); }
.figure:nth-child(3) .figure__value { color: var(--ink); }
.figure__sub { font-size: var(--step--1); color: var(--muted); }

.ledger { font-size: var(--step-0); }
.ledger th { position: static; text-align: start; font-weight: 400; color: var(--ink-2); padding: .5rem 0; border-bottom: 1px solid var(--line); background: none; }
.ledger td { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.ledger tr:last-child th, .ledger tr:last-child td { border-bottom: 0; }
.ledger--sub th, .ledger--sub td { font-weight: 600; color: var(--ink); }
.ledger--total th, .ledger--total td { font: 700 var(--step-1)/1.2 var(--display); color: var(--ink); border-top: 2px solid var(--ink); padding-top: .7rem; }
.neg { color: var(--danger); }

.stock { display: grid; gap: 1rem; }
.stock__item { padding-inline-start: .9rem; border-inline-start: 3px solid var(--td); display: grid; gap: .5rem; }
.stock--CM { border-inline-start-color: var(--cm); }
.stock__head { display: flex; align-items: center; justify-content: space-between; }
.stock__head b { font: 700 var(--step-1)/1 var(--display); font-stretch: 85%; }
.warn { margin: 0; font-size: var(--step--1); color: var(--hold); }

.entries { list-style: none; margin: 0; padding: 0; }
.entries li { display: grid; grid-template-columns: 7.5rem auto 1fr auto; gap: .75rem; align-items: center; padding: .6rem 0; border-top: 1px solid var(--line); font-size: var(--step--1); }
.entries li:first-child { border-top: 0; }
.entries time { color: var(--muted); }
.entries .is-void .entries__text, .entries li.is-void .entries__text { text-decoration: line-through; color: var(--muted); }
.chip--ALL { background: var(--sunk); color: var(--ink-2); }

/* ---------- market ---------- */

.market-country { display: grid; gap: .75rem; }
.market-country__title { margin: 0; font: 700 var(--step-2)/1 var(--display); font-stretch: 80%; padding-inline-start: .7rem; border-inline-start: 4px solid var(--td); color: var(--td); }
.market-country__title--CM { border-inline-start-color: var(--cm); color: var(--cm); }
.grid-even { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: 1.25rem; }
.market { display: grid; align-content: start; gap: .9rem; }
.market .panel__head { margin-bottom: 0; }
.rank { display: flex; align-items: center; gap: .9rem; }
.rank__n { font: 700 3.25rem/1 var(--display); font-stretch: 75%; color: var(--hold); }
.rank__n--top { color: var(--ok); }
.rank__n--none { color: var(--muted); }
.rank span { color: var(--ink-2); font-size: var(--step--1); }
.advice { padding: .75rem .9rem; background: var(--sunk); border-radius: var(--r-s); }
.pricefig { margin: 0; }
.chart--small { height: 7.5rem; }
.row--mine { background: color-mix(in srgb, var(--ok-tint) 70%, transparent); }
.chip--me { margin-inline-start: .4rem; background: var(--ok); color: #fff; }

.review { padding: .9rem 1rem; border-radius: var(--r-m); background: var(--hold-tint); border: 1px solid color-mix(in srgb, var(--hold) 30%, transparent); }

/* ---------- records ---------- */

.records-form { display: grid; gap: .6rem; }
.records-form > .input { max-width: none; min-height: 2.9rem; }
.records-form .check .input { min-height: 2.4rem; width: auto; }
.record-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); }
.record-list li { display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; padding: .8rem 1rem; border-top: 1px solid var(--line); }
.record-list li:first-child { border-top: 0; }
.record-list li.is-flag { box-shadow: inset 3px 0 0 var(--danger); }
.record-list time { color: var(--muted); font-size: var(--step--1); padding-top: .15rem; }
.record-head { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.record-text { margin: .3rem 0 0; color: var(--ink-2); font-size: var(--step--1); }
.record-list .sms { margin-top: .4rem; }
.record-flag { margin: .3rem 0 0; color: var(--danger); font-weight: 600; font-size: var(--step--1); }
a.btn { text-decoration: none; }

/* ---------- tables ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.toolbar .input { max-width: 16rem; min-height: 2.4rem; }
.toolbar .select { width: auto; min-height: 2.4rem; }
.toolbar .grow { flex: 1; }
.check { display: inline-flex; gap: .45rem; align-items: center; font-size: var(--step--1); font-weight: 600; color: var(--ink-2); cursor: pointer; }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
th { text-align: start; font-weight: 600; color: var(--muted); padding: .7rem .9rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
td { padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--sunk); }
tbody tr.row--flag { box-shadow: inset 3px 0 0 var(--danger); background: color-mix(in srgb, var(--danger-tint) 45%, transparent); }
.num { text-align: end; white-space: nowrap; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .8rem; letter-spacing: -.01em; }
.dim { color: var(--muted); }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font: 700 var(--step-1)/1.3 var(--display); margin-bottom: .25rem; }
.pager { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: var(--step--1); }

.sms { margin: 0; padding: .6rem .75rem; border-inline-start: 3px solid var(--line-strong); background: var(--sunk); border-start-start-radius: 0; border-end-start-radius: 0; border-start-end-radius: var(--r-s); border-end-end-radius: var(--r-s); white-space: pre-wrap; word-break: break-word; max-width: 70ch; }

/* ---------- drawer, modal, toasts ---------- */

.scrim { position: fixed; inset: 0; z-index: 40; background: color-mix(in srgb, #0a0e1f 45%, transparent); animation: fade .15s ease-out; }
.drawer {
  position: fixed; z-index: 41; top: 0; inset-inline-end: 0; bottom: 0; width: min(34rem, 100%);
  background: var(--surface); border-inline-start: 1px solid var(--line); overflow-y: auto;
  padding: 1.25rem 1.5rem 2rem; display: grid; align-content: start; gap: 1.25rem;
  animation: slide .22s cubic-bezier(.2,.7,.2,1);
}
.drawer__head { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.drawer h2 { margin: 0; font: 700 var(--step-2)/1.1 var(--display); font-stretch: 85%; word-break: break-all; }
.drawer h3 { margin: 0 0 .5rem; font: 700 var(--step-0)/1.2 var(--display); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0; font-size: var(--step--1); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.steps li { padding: .6rem .8rem; border: 1px solid var(--line); border-radius: var(--r-s); font-size: var(--step--1); display: grid; gap: .25rem; }

.modal-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1rem; }
.modal {
  position: relative; width: min(26rem, 100%); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-l); padding: 1.5rem;
  display: grid; gap: 1rem; animation: pop .18s cubic-bezier(.2,.7,.2,1);
  box-shadow: 0 30px 70px -30px rgba(10, 14, 31, .55);
}
.modal h2 { margin: 0; font: 700 var(--step-2)/1.1 var(--display); font-stretch: 85%; }
.modal p { margin: 0; color: var(--ink-2); }
.modal__actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .25rem; }

#toasts { position: fixed; z-index: 60; inset-inline-end: 1rem; bottom: calc(1rem + var(--tabbar) + env(safe-area-inset-bottom)); display: grid; gap: .5rem; width: min(24rem, calc(100% - 2rem)); }
.toast { padding: .75rem 1rem; border-radius: var(--r-m); background: var(--ink); color: var(--paper); font-size: var(--step--1); box-shadow: 0 12px 30px -12px rgba(0,0,0,.5); animation: pop .18s ease-out; }
.toast--error { background: var(--danger); color: #fff; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes pop { from { transform: translateY(6px) scale(.98); opacity: 0; } }

/* the one orchestrated moment: notes settle in on first load */
.notes--intro .note { animation: settle .5s cubic-bezier(.2,.7,.2,1) both; }
.notes--intro .note + .note { animation-delay: .08s; }
@keyframes settle { from { transform: translateY(8px); opacity: 0; } }

/* ---------- phone ---------- */

@media (max-width: 760px) {
  :root { --tabbar: 4.1rem; }
  .topbar__row { padding: .6rem 1rem; }
  /* backdrop-filter would make the fixed tab bar position itself inside the header */
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--paper); }
  .note__serial { display: none; }
  .brand b { display: none; }
  .demo-tag { font-size: .7rem; }
  .topbar .live { display: none; }
  .nav {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); justify-content: space-between; gap: 0;
  }
  .nav a { flex: 1 0 auto; flex-direction: column; gap: .15rem; padding: .35rem .4rem; font-size: .68rem; border-bottom: 0; border-radius: var(--r-s); position: relative; }
  .nav a[aria-current="page"] { background: var(--sunk); }
  .nav svg { width: 1.3rem; height: 1.3rem; }
  .nav .badge-dot { position: absolute; top: .1rem; inset-inline-end: 22%; }
  .main { padding: 1rem 1rem 2rem; gap: 1.1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .note { padding: 1.15rem 1.1rem 1.1rem 1.5rem; }
  .note__rosette { width: 14rem; inset-inline-end: -4rem; top: -3.5rem; }
  .stat b { font-size: var(--step-1); }
  .timeline li { grid-template-columns: 1fr auto; }
  .timeline time { grid-column: 1 / 3; }
  .timeline .why { grid-column: 1 / 3; }
  .hide-sm { display: none; }
  .figures { grid-template-columns: 1fr 1fr; }
  .figure:nth-child(3) { border-inline-start: 0; }
  .figure:nth-child(n+3) { border-top: 1px solid var(--line); }
  .entries li { grid-template-columns: auto 1fr auto; }
  .entries time { grid-column: 1 / -1; }
  .record-list li { grid-template-columns: 1fr; gap: .3rem; }
  .advice { grid-template-columns: 1fr; gap: .1rem; }
  .advice dd { margin-bottom: .45rem; font-weight: 600; }
  .toolbar .input { max-width: none; flex: 1 1 100%; }
  .drawer { top: auto; height: 88dvh; width: 100%; border-inline-start: 0; border-top: 1px solid var(--line); border-radius: var(--r-l) var(--r-l) 0 0; animation-name: rise; }
  @keyframes rise { from { transform: translateY(30px); opacity: 0; } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Language switch and right-to-left (Arabic) */
.lang__select {
  font: inherit; font-size: var(--step--1); color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-s); padding: .3rem .5rem; cursor: pointer;
}
.lang__select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.lang--login { justify-self: end; }
[dir="rtl"] body {
  font-family: "Instrument", "Geeza Pro", "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif;
}
/* Arabic letters must join: no tracking, no condensed widths. */
[dir="rtl"] * { letter-spacing: 0 !important; }
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] .brand b { font-family: "Geeza Pro", "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif; }
/* Numbers, IDs, phone numbers and charts stay left to right. */
[dir="rtl"] .mono, [dir="rtl"] .num, [dir="rtl"] .amount, [dir="rtl"] .note__amount, [dir="rtl"] svg { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .num { text-align: end; }
[dir="rtl"] .tg p[dir="auto"], [dir="rtl"] .sms { text-align: start; }

/* Wording page */
.wording td { vertical-align: middle; }
.wording__en { color: var(--muted); font-size: var(--step--1); max-width: 22rem; }
.wording__def { font-size: var(--step--1); max-width: 22rem; }
.wording__mine { min-width: 14rem; }
.wording__mine .input { min-height: 2.3rem; }
.wording__actions { white-space: nowrap; }
.wording__actions .btn + .btn { margin-inline-start: .4rem; }
@media (max-width: 760px) {
  .wording__def { display: none; }
}

/* Eleven sections: on wide screens the tabs wrap instead of hiding off the edge. */
@media (min-width: 761px) {
  .nav { flex-wrap: wrap; overflow-x: visible; }
  .nav a { padding-inline: .6rem; }
}
