/* «الخزنة», The Vault Ledger. Tokens from docs/design/2026-08-12-baddal-identity.md.
   Metal discipline: gold = profit only; copper = money out; mint = money in, liveness, CTA. */
@font-face { font-family: 'Cairo'; font-style: normal; font-weight: 300 700; font-display: swap; src: url('/static/fonts/cairo-arabic.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Cairo'; font-style: normal; font-weight: 300 700; font-display: swap; src: url('/static/fonts/cairo-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Cairo'; font-style: normal; font-weight: 300 700; font-display: swap; src: url('/static/fonts/cairo-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --obsidian: #0C1210; --slate: #16201C; --slate-hi: #1D2A24; --hairline: #223029;
  --mist: #EDF2EE; --sage: #8FA096; --faded: #7C8D83; --disabled: #5E6E65;
  --mint: #3DF2A6; --mint-ink: #05130C; --gold: #C9A227; --copper: #D07B3F; --buy: #9CE8C6; --danger: #E5735C;
  --r-panel: 20px; --r-field: 18px; --pad: 16px;
  color-scheme: dark;
}
/* «الخزنة» by day (D11, amends the LOCKED dark-only spec on the CEO's word):
   the vault's metals on cool paper. Same roles; each metal darkened until it
   reads at AA as text on white (mint 5.4:1, gold 4.9:1, copper 5.5:1,
   danger 5.5:1, faded 5.2:1). Chosen in Settings; "system" follows the device. */
:root[data-theme=light] {
  --obsidian: #F4F6F4; --slate: #FFFFFF; --slate-hi: #EEF2EF; --hairline: #D9E0DB;
  --mist: #0E1A15; --sage: #4C5E55; --faded: #5F7067; --disabled: #9AA79F;
  --mint: #0B7A50; --mint-ink: #FFFFFF; --gold: #8A6D0B; --copper: #A4521C; --buy: #0B7A50; --danger: #B8402B;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme=system] {
    --obsidian: #F4F6F4; --slate: #FFFFFF; --slate-hi: #EEF2EF; --hairline: #D9E0DB;
    --mist: #0E1A15; --sage: #4C5E55; --faded: #5F7067; --disabled: #9AA79F;
    --mint: #0B7A50; --mint-ink: #FFFFFF; --gold: #8A6D0B; --copper: #A4521C; --buy: #0B7A50; --danger: #B8402B;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html { background: var(--obsidian); }
body { margin: 0; font: 400 14.5px/1.5 'Cairo', system-ui, sans-serif; color: var(--mist); background: var(--obsidian); padding-bottom: calc(84px + env(safe-area-inset-bottom)); -webkit-text-size-adjust: 100%; }
a { color: inherit; text-decoration: none; }
a.link { color: var(--mint); font-weight: 600; }
b { font-weight: 700; }
small, .small { font-size: 12px; }
.faded { color: var(--faded); }
.faint { opacity: .75; }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.in { color: var(--mint); }
.out { color: var(--copper); }
.profit { color: var(--gold); }
.danger { color: var(--danger); }
[hidden] { display: none !important; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px var(--pad); background: color-mix(in srgb, var(--obsidian) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--hairline); }
.brand { font-weight: 700; color: var(--mint); font-size: 17px; letter-spacing: .3px; }
.topbar-title { flex: 1; text-align: center; font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.langswitch { margin: 0; }
.pill-mini { border: 1px solid var(--hairline); background: var(--slate); color: var(--sage); border-radius: 999px; padding: 2px 10px; font: 600 12px 'Cairo', sans-serif; cursor: pointer; }

.page { max-width: 980px; margin: 0 auto; padding: 12px var(--pad); display: flex; flex-direction: column; gap: 14px; }
section { display: flex; flex-direction: column; gap: 10px; }

/* bottom tabs: a floating pill */
.tabs { position: fixed; left: 16px; right: 16px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 6; display: flex; justify-content: space-around; background: var(--slate); border: 1px solid var(--hairline); border-radius: 999px; padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.35); max-width: 560px; margin: 0 auto; }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 1px; flex: 1; padding: 6px 4px; border-radius: 999px; color: var(--faded); font-size: 11px; font-weight: 600; }
.tabs a .ico { font-size: 17px; line-height: 1; }
.tabs a.active { color: var(--mint); background: color-mix(in srgb, var(--mint) 10%, transparent); }
/* Desktop keeps the floating bottom pill (WP-05): the old top placement
   relied on `order` without a flex parent and fell under the content. */
@media (min-width: 900px) {
  .tabs a { flex-direction: row; gap: 6px; font-size: 13px; padding: 6px 14px; }
}
a.hero { display: flex; flex-direction: column; }
a.hero .link { color: var(--mint); font-weight: 600; }
.wallet-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; margin: 0; }
.wallet-row:hover { background: transparent; }
.wallet-row input, .wallet-row select { min-height: 40px; padding: 6px 12px; font-size: 14px; }
.auth { max-width: 420px; margin-top: 8vh; }
.pcur { align-self: flex-end; align-items: center; }
.pcur span { padding-inline: 8px; font-size: 12px; }
.slip .bought { margin-top: 8px; }

/* panels, rows, lists */
.panel { background: var(--slate); border: 1px solid var(--hairline); border-radius: var(--r-panel); padding: 14px var(--pad); }
.label { font-size: 11.5px; font-weight: 600; letter-spacing: 1.4px; color: var(--faded); text-transform: uppercase; }
.hint { color: var(--faded); font-size: 13px; margin: 0; }
.list { padding: 0; overflow: hidden; }
.list.panel > .row { padding-inline: var(--pad); }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--hairline); min-height: 56px; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--slate-hi); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--faded); font-size: 12.5px; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.amt { font-size: 17px; font-weight: 700; }
.row.void .row-title { text-decoration: line-through; color: var(--faded); }
.mark { width: 30px; height: 30px; border-radius: 999px; display: grid; place-items: center; font-weight: 700; flex: none; border: 1px solid var(--hairline); }
.mark.in { color: var(--mint); background: color-mix(in srgb, var(--mint) 10%, transparent); }
.mark.out { color: var(--copper); background: color-mix(in srgb, var(--copper) 12%, transparent); }
.mark.neutral { color: var(--sage); }
.chev { color: var(--faded); font-size: 22px; }
.code { width: 44px; flex: none; font-size: 12px; }
.group-head { padding: 10px var(--pad) 4px; font-size: 11.5px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--faded); background: var(--obsidian); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--hairline); color: var(--sage); vertical-align: middle; }
.tag.ok { color: var(--mint); border-color: color-mix(in srgb, var(--mint) 40%, transparent); }
.tag.warn { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 50%, transparent); }
.tag.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.empty { text-align: center; color: var(--sage); padding: 28px var(--pad); align-items: center; }
.empty p { margin: 4px 0; }
.flash { background: color-mix(in srgb, var(--mint) 12%, transparent); border: 1px solid color-mix(in srgb, var(--mint) 35%, transparent); color: var(--mint); border-radius: var(--r-field); padding: 10px 14px; font-weight: 600; }
.error { background: color-mix(in srgb, var(--danger) 12%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); border-radius: var(--r-field); padding: 10px 14px; font-weight: 600; }

/* stats */
.hero { gap: 12px; }
.hero-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { font-size: 26px; font-weight: 700; line-height: 1.2; }
.hero .stat { font-size: 24px; }
.hero .stat.profit, .hero-grid > div:last-child .stat { font-size: 30px; }
.stat small { font-size: 13px; color: var(--faded); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2.tight .panel { padding: 10px 14px; }
.stat-card { display: flex; flex-direction: column; gap: 4px; }
.stat-card .stat { font-size: 22px; }
.stat-card .sub { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--faded); }
.stat-card .sub span { display: flex; justify-content: space-between; gap: 8px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 54px; padding-top: 6px; border-top: 1px solid var(--hairline); }
.bar { flex: 1; min-width: 3px; height: max(2px, var(--h)); background: linear-gradient(180deg, var(--mint), color-mix(in srgb, var(--mint) 35%, transparent)); border-radius: 3px 3px 0 0; }
@media (max-width: 520px) { .hero-grid { grid-template-columns: 1fr 1fr; } .hero-grid > div:last-child { grid-column: span 2; } .stat { font-size: 22px; } }

/* buttons & chips */
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions.wrap > * { flex: 1 1 auto; }
.actions.sticky { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, transparent, var(--obsidian) 30%); padding: 12px 0 4px; }
.actions form { display: contents; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 8px 20px; border-radius: 999px; font: 700 14.5px 'Cairo', sans-serif; cursor: pointer; border: 1px solid var(--hairline); background: var(--slate); color: var(--mist); text-align: center; }
.btn.filled { background: var(--mint); color: var(--mint-ink); border-color: var(--mint); }
.btn.outline { background: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.btn.small { min-height: 36px; padding: 4px 14px; font-size: 13px; }
.btn:active { transform: translateY(1px); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; background: var(--slate); border: 1px solid var(--hairline); border-radius: 999px; padding: 4px; width: max-content; max-width: 100%; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.chips a, .seg label, .seg button { padding: 6px 14px; border-radius: 999px; color: var(--sage); font-weight: 600; font-size: 13px; white-space: nowrap; cursor: pointer; border: 0; background: transparent; font-family: inherit; }
.chips a.on, .seg label:has(input:checked), .seg button.on { background: color-mix(in srgb, var(--mint) 14%, transparent); color: var(--mint); }
.seg { position: relative; display: inline-flex; gap: 4px; background: var(--obsidian); border: 1px solid var(--hairline); border-radius: 999px; padding: 4px; flex-wrap: wrap; }
.seg input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; min-height: 0; padding: 0; opacity: 0; pointer-events: none; }
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.toolbar .hint { flex: 1 1 240px; }
.search { flex: 1 1 200px; margin: 0; }
.search input { width: 100%; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 7; background: var(--slate); border: 1px solid var(--hairline); border-radius: var(--r-field); min-width: 220px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.menu-list a { display: block; padding: 10px 16px; border-bottom: 1px solid var(--hairline); font-weight: 600; }
.menu-list a:last-child { border-bottom: 0; }
.menu-list a:hover { background: var(--slate-hi); }

/* forms */
.fields { gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 11.5px; font-weight: 600; letter-spacing: 1.2px; color: var(--faded); text-transform: uppercase; }
input, select, textarea { width: 100%; font: 400 15px 'Cairo', sans-serif; color: var(--mist); background: var(--obsidian); border: 1px solid var(--hairline); border-radius: var(--r-field); padding: 10px 14px; min-height: 44px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--mint); box-shadow: 0 0 0 1px var(--mint); }
input.num { font-variant-numeric: tabular-nums; direction: ltr; text-align: start; }
input.big { font-size: 26px; font-weight: 700; min-height: 60px; }
input[type=date] { direction: ltr; }
input[type=file] { padding: 8px; }
input[readonly] { color: var(--sage); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--faded) 50%), linear-gradient(135deg, var(--faded) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-inline-end: 34px; }
[dir=rtl] select { background-position: 15px 50%, 20px 50%; padding-inline-end: 14px; padding-inline-start: 34px; }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--mint); }
.doc-number { font-size: 22px; font-weight: 700; }

/* the counter slip: two amounts joined by the RateBeam (identity: the signature) */
.slipform { max-width: 560px; width: 100%; margin: 0 auto; }
.kinds { max-width: 560px; width: 100%; margin: 0 auto; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.kinds a { padding: 6px 14px; border-radius: 999px; color: var(--sage); font-weight: 600; font-size: 13px; white-space: nowrap; }
.kinds a.on { background: color-mix(in srgb, var(--mint) 14%, transparent); color: var(--mint); }
.pair { display: flex; gap: 10px; flex-wrap: wrap; }
.pair > .field { flex: 1 1 140px; }
.pair > .field.grow { flex: 3 1 200px; }
.slip { gap: 4px; padding-block: 18px; }
.slip-side { display: flex; flex-direction: column; gap: 6px; }
.slip-amt { display: flex; align-items: center; gap: 10px; }
/* The slip's amounts are real fields at rest, not blank space: a field
   ground, a hairline box, and a faint 0 until typed (FIX-06a). */
.slip input.big { font-size: 42px; min-height: 72px; padding: 4px 16px; background: var(--obsidian); border: 1px solid var(--hairline); border-radius: var(--r-field); }
.slip input.big:focus { box-shadow: 0 0 0 1px var(--mint); border-color: var(--mint); }
input.big::placeholder { color: var(--disabled); }
.slip input.big.in { color: var(--mint); }
.slip input.big.out { color: var(--copper); }
.slip select.cur { width: auto; min-height: 40px; }
.beam { position: relative; height: 34px; display: grid; place-items: center; }
.beam::before { content: ''; position: absolute; inset-inline: 0; top: 50%; height: 1px; background: linear-gradient(90deg, transparent, var(--mint), transparent); opacity: .8; animation: beam 2.4s ease-in-out infinite; }
.beam.pulse::before { animation: beamflash .5s ease-out; }
.beam .chip { position: relative; background: var(--obsidian); border: 1px solid var(--hairline); border-radius: 999px; padding: 2px 12px; font-size: 13px; font-weight: 700; color: var(--mint); }
.beam .chip:empty { display: none; }
@keyframes beam { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes beamflash { from { opacity: 1; filter: brightness(1.8); } to { opacity: .8; } }
.expect { margin: 8px 0 0; padding-top: 10px; border-top: 1px solid var(--hairline); color: var(--sage); }
.legs .leg { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.legs .leg:hover { background: transparent; }
.legs input, .legs select { min-height: 40px; padding: 6px 10px; font-size: 14px; }
.btn.wide { flex: 1 1 100%; }
.record { flex-wrap: wrap; }
.record .btn.outline { flex: 1 1 140px; }
.group-head.day { display: flex; justify-content: space-between; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--mist); border-top: 1px solid var(--hairline); }
.entry-head { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--hairline); }
.facts-panel.void { opacity: .7; }
.settle-panel { gap: 10px; }
.settle-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; margin: 0; }
.settle-row input, .settle-row select { min-height: 40px; padding: 6px 10px; font-size: 14px; }
@media (max-width: 520px) { .settle-row { grid-template-columns: 1fr 1fr; } .settle-row .btn { grid-column: 1 / 3; } }
@media (max-width: 420px) { .legs .leg { grid-template-columns: 1fr 1fr; } .legs .leg select { grid-column: 1 / 3; } }

/* document view */
.doc-head { gap: 8px; }
.doc-head.void { opacity: .7; }
.doc-type { color: var(--sage); font-weight: 600; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 6px 0; }
.facts dt { color: var(--faded); font-size: 12.5px; }
.facts dd { margin: 0; font-weight: 600; }
.facts a { color: var(--mint); }
.doc-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--hairline); padding-top: 10px; }
.settle { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; color: var(--sage); font-size: 13.5px; }
.share textarea { font-size: 13px; color: var(--sage); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--hairline); color: var(--sage); }
.kv:last-child { border-bottom: 0; }
.kv.total { color: var(--mist); font-size: 17px; }
.period { gap: 8px; display: flex; flex-direction: column; }
.period-range { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin: 0; }
.period-range label { display: flex; flex-direction: column; font-size: 12px; color: var(--faded); gap: 2px; }
.period-range input { min-height: 40px; }
ul.plain { margin: 0; padding: 0; list-style: none; color: var(--sage); font-size: 13px; }
.about p { margin: 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
