/* Takya Financials. Every colour, size and radius here is quoted from the design
   handoff, whose values come from the brand document (takya games/documents/
   Brand Identity & Design System.md — the source of truth; v1.33 added Muted
   Text, Sunken Ivory and Red Tint for internal product UI). */

@font-face {
  font-family: 'Young Serif';
  src: url('assets/fonts/young-serif-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: block; /* the wordmark is live text in this face — never flash a fallback */
}
@font-face {
  font-family: 'Work Sans';
  src: url('assets/fonts/work-sans-400-600.woff2') format('woff2');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --red: #C82A19;          /* Cushion Red */
  --gold: #C97A3D;         /* Woven Gold */
  --ivory: #F5EAE6;        /* Ivory */
  --ink: #2A1C1D;          /* Charcoal */
  --white: #FFFFFF;
  --muted: #6B5654;        /* Muted Text — internal product UI, brand doc v1.33 */
  --border: #E4D4CE;       /* Border */
  --sunken: #EFE1DC;       /* Sunken Ivory, brand doc §2.3 */
  --red-tint: #FCE6E4;     /* Red Tint, brand doc §2.3 */
  --green: #2E6B45;        /* Profit Green — internal product UI, brand doc v1.34 §2.3 */
  --green-tint: #E6EEE9;   /* Green Tint — Profit Green at Red Tint's lightness, brand doc v1.35 §2.3 */

  --display: 'Young Serif', Georgia, serif;
  --body: 'Work Sans', -apple-system, 'Helvetica Neue', sans-serif;

  --shadow-rest: 0 1px 3px rgba(42, 28, 29, .08);
  --shadow-tabs: 0 -1px 3px rgba(42, 28, 29, .06);
  --focus: rgba(200, 42, 25, .35);
  --ease-settle: cubic-bezier(.22, 1, .36, 1);

  --hdr-h: 77px; /* kept current by app.js from the header's real height */
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--red); }
body { font-family: var(--body); color: var(--ink); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
h1, h2 { margin: 0; font-family: var(--display); font-weight: 400; line-height: 1.08; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; }

@keyframes tk-settle { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes tk-drift { from { background-position-x: 0; } to { background-position-x: 30px; } }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.settle { animation: tk-settle 900ms var(--ease-settle) both; animation-delay: calc(var(--i, 0) * 100ms); }
main.static .settle { animation: none; } /* a data refresh repaints in place; only entering a view animates */

/* ── shell ─────────────────────────────────────────── */
.app { min-height: 100vh; min-height: 100dvh; background: var(--ivory); max-width: 520px; margin: 0 auto; position: relative; }

.hdr { position: sticky; top: 0; z-index: 20; background: var(--red); }
.hdr-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: calc(env(safe-area-inset-top) + 14px) 20px 12px;
}
.wordmark { width: 150px; line-height: 0; } /* 150px is the brand's documented minimum */
.wordmark svg { display: block; width: 150px; height: auto; }
.hdr-meta {
  text-align: right; font-size: 11px; line-height: 1.3; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: rgba(255, 255, 255, .82);
}
.hdr-meta .year { color: var(--white); }

.weave { height: 8px; background: url('assets/takya-weave-tile.png') repeat; background-size: auto 100%; }
.weave.drift { animation: tk-drift 22s linear infinite; }
.weave.edge { height: 6px; }

.notice {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  background: var(--sunken); border-bottom: 1px solid var(--border); font-size: 12px; line-height: 1.45;
}
.notice .msg { min-width: 0; flex: 1 1 auto; }
.notice .act {
  flex: 0 0 auto; background: none; border: 0; padding: 6px 0; cursor: pointer;
  font-weight: 600; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--red);
}
.pill {
  flex: 0 0 auto; display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--gold); color: var(--ink);
  font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; line-height: 1.6;
}

main { padding: 20px 16px 112px; display: flex; flex-direction: column; gap: 16px; }
main.months { padding: 0 0 112px; display: block; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; max-width: 520px; margin: 0 auto;
  background: var(--white); border-top: 1px solid var(--border); box-shadow: var(--shadow-tabs);
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
}
.tabs[hidden] { display: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 7px; min-height: 56px; padding: 12px 6px 11px;
  background: none; border: 0; border-top: 2px solid transparent; margin-top: -1px; cursor: pointer; color: var(--ink);
}
.tab .label { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; line-height: 1.3; }
.tab .hint { font-size: 10px; font-variant-numeric: tabular-nums; color: var(--muted); line-height: 1.3; }
.tab[aria-current="page"] { border-top-color: var(--red); color: var(--red); }

/* ── shared pieces ─────────────────────────────────── */
.card { background: var(--white); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-rest); }
.card.hero { border-radius: 28px; position: relative; overflow: hidden; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); line-height: 1.3; }
.eyebrow.sm { font-size: 10px; }
.h2 { font-size: 20px; }
.num { font-variant-numeric: tabular-nums; }
/* Every money figure is coloured by its sign: loss red, profit green, zero ink. */
.neg { color: var(--red); }
.pos { color: var(--green); }
.none { color: var(--muted); }
.tab .hint.neg { color: var(--red); }
.tab .hint.pos { color: var(--green); }
.pressable { transition: transform 160ms ease; cursor: pointer; }
.pressable:active { transform: scale(.985); }

.row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.row > .v { flex: 0 0 auto; font-variant-numeric: tabular-nums; }

/* ── cash view ─────────────────────────────────────── */
.bank-body { padding: 22px 22px 24px; }
.amount { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; }
.amount .cur { font-family: var(--display); font-size: 14px; color: var(--muted); }
.amount .fig { font-family: var(--display); font-size: 44px; line-height: 1.08; font-variant-numeric: tabular-nums; }
.asat { margin-top: 8px; font-size: 12px; color: var(--muted); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.hero-foot { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.stat-fig { margin-top: 5px; font-family: var(--display); font-size: 19px; line-height: 1.2; font-variant-numeric: tabular-nums; }

.stat { padding: 16px; text-align: left; }
.stat .fig { margin-top: 8px; font-family: var(--display); font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .foot { margin-top: 8px; font-size: 11px; color: var(--muted); }
.stat .link { margin-top: 8px; font-size: 11px; font-weight: 600; color: var(--red); }
button.stat { border: 1px solid var(--border); width: 100%; }

.chart { padding: 18px 18px 14px; }
.chart-head { align-items: flex-start; }
.readout { text-align: right; line-height: 1.3; }
.rd-date { display: block; font-size: 11px; color: var(--muted); }
.rd-val { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
/* pan-y: vertical drags still scroll the page; sideways drags scrub the line. */
.plot { position: relative; height: 120px; margin-top: 14px; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.plot svg { display: block; width: 100%; height: 120px; overflow: visible; }
.guide { position: absolute; top: 0; bottom: 0; width: 1px; margin-left: -.5px; background: rgba(42, 28, 29, .35); pointer-events: none; }
.guide[hidden] { display: none; }
.pin { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; box-shadow: 0 0 0 2px var(--white); pointer-events: none; }
.ticks { position: relative; height: 14px; margin-top: 8px; font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ticks span { position: absolute; top: 0; transform: translateX(-50%); }

.bars-card { padding: 18px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 104px; margin-top: 16px; }
.bar { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; background: none; border: 0; padding: 0; cursor: pointer; }
.bar .b { display: block; border-radius: 4px; min-height: 3px; position: relative; }
.bar .sp { display: block; }
/* Each bar's amount, reading upward: inside in white if the bar can hold it,
   otherwise just past the bar's end in its colour. */
.bl {
  position: absolute; left: 50%; font-style: normal; font-size: 9px; font-weight: 600; letter-spacing: .02em;
  font-variant-numeric: tabular-nums; line-height: 1; white-space: nowrap; pointer-events: none;
  writing-mode: vertical-rl; transform: translateX(-50%) rotate(180deg);
}
.bl.in { top: 50%; color: var(--white); transform: translate(-50%, -50%) rotate(180deg); }
.bl.out.down { top: calc(100% + 4px); }
.bl.out.up { bottom: calc(100% + 4px); }
.bar-labels { display: flex; gap: 6px; margin-top: 8px; }
.bar-labels span { flex: 1 1 0; min-width: 0; text-align: center; font-size: 9px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.legend { display: flex; gap: 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend b { width: 10px; height: 10px; border-radius: 2px; }

.table-card { padding: 18px 0 6px; }
.table-card .h2 { margin: 0 18px; }
.cash-grid { display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); align-items: baseline; }
.cash-head { gap: 4px 8px; margin-top: 14px; padding: 0 18px 12px; border-bottom: 1px solid var(--border); font-size: 9px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); line-height: 1.3; }
.cash-row { gap: 8px; padding: 11px 18px; border-bottom: 1px solid var(--sunken); font-size: 13px; }
.cash-head > :not(:first-child), .cash-row > :not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.cash-row > :last-child { font-weight: 600; }
.mo { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

.list-card { padding: 18px; }
.list { display: flex; flex-direction: column; margin-top: 8px; }
.entry { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--sunken); }
.entry .who { min-width: 0; }
.entry .name { font-size: 14px; font-weight: 500; line-height: 1.4; }
.entry .meta { margin-top: 3px; font-size: 11px; color: var(--muted); line-height: 1.4; }
.entry .v { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 600; }
.total { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 14px; }
.total .v { font-family: var(--display); font-size: 22px; font-variant-numeric: tabular-nums; }

/* ── summary view ──────────────────────────────────── */
.pl { padding: 22px; }
.pl h1 { margin-top: 8px; font-size: 31px; }
.pl .lines { display: flex; flex-direction: column; margin-top: 18px; }
.pl .line { padding: 12px 0; border-bottom: 1px solid var(--sunken); font-size: 14px; }
.pl .line.strong { font-weight: 600; }
.pl .line.strong .v { font-size: 15px; }
.pl .line.subtotal { border-bottom-color: var(--red); }
.pl .line.final { border-bottom: 0; font-weight: 600; }
.pl .line.final .v { font-size: 18px; }

.mbm { padding: 18px 0; }
.mbm .h2 { margin: 0 18px 4px; }
.mbm .hint { margin: 0 18px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.hscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { height: 0; width: 0; }
.mbm .hscroll { margin-top: 14px; }
.mbm .inner { min-width: 660px; }
.mbm-grid { display: grid; grid-template-columns: 52px repeat(6, minmax(0, 1fr)); gap: 8px; align-items: baseline; }
.mbm-head { padding: 0 18px 10px; font-size: 9px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); line-height: 1.3; }
.mbm-head > :not(:first-child), .mbm-row > :not(:first-child), .mbm-ytd > :not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.mbm-row { width: 100%; padding: 11px 18px; background: var(--white); border: 0; border-bottom: 1px solid var(--sunken); cursor: pointer; text-align: left; font-size: 12px; }
.mbm-row.sel { background: var(--red-tint); }
.mbm-row > :last-child { font-weight: 600; }
/* The YTD total is a band coloured by the year's operating result (Saleh,
   16 Sep 2026): Cushion Red for a loss, green for a profit, Charcoal at zero.
   Its figures all go white — a red or green figure would vanish on its own
   colour — and the minus sign still marks a loss. */
.mbm { padding-bottom: 0; overflow: hidden; }
.mbm-ytd { padding: 13px 18px 14px; font-size: 12px; font-weight: 600; background: var(--ink); color: var(--white); }
.mbm-ytd.ytd-neg { background: var(--red); }
.mbm-ytd.ytd-pos { background: var(--green); }
.mbm-ytd > *, .mbm-ytd .neg, .mbm-ytd .pos { color: var(--white); }
.mbm-ytd > :first-child { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }

/* ── months view ───────────────────────────────────── */
.chips { position: sticky; top: var(--hdr-h); z-index: 15; background: var(--ivory); border-bottom: 1px solid var(--border); }
.chips .strip { display: flex; gap: 8px; padding: 12px 16px; width: max-content; }
.chip {
  flex: 0 0 auto; padding: 7px 15px; border-radius: 999px; border: 1px solid var(--border); background: var(--white); color: var(--ink);
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; line-height: 1.4;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.chip.dim { opacity: .5; }
.chip[aria-current="true"] { background: var(--red); border-color: var(--red); color: var(--white); opacity: 1; }

.rail {
  position: relative; /* so each card's offsetLeft is measured from the rail itself */
  display: flex; align-items: flex-start; /* required: stretch would pad short months to the tallest */
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.rail::-webkit-scrollbar { height: 0; width: 0; }
.mcard { flex: 0 0 100%; width: 100%; scroll-snap-align: center; scroll-snap-stop: always; padding: 20px 16px 8px; }
.mcard > .stack { display: flex; flex-direction: column; gap: 14px; }
.mhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.mhead h1 { font-size: 31px; }
.mhead .pill { padding: 4px 11px; letter-spacing: .12em; }

.empty-card { padding: 28px 22px; text-align: center; }
.empty-card .t { font-family: var(--display); font-size: 20px; line-height: 1.08; }
.empty-card p { margin-top: 10px; font-size: 13px; line-height: 1.6; color: var(--muted); }

.op-body { padding: 20px 22px 22px; }
.op-body .amount { margin-top: 8px; }
.op-body .amount .fig { font-size: 36px; }
.op-body .hero-foot { margin-top: 18px; padding-top: 16px; }

.sec { padding: 18px; }
.sec .lines { display: flex; flex-direction: column; margin-top: 10px; }
.sec .line { padding: 11px 0; border-bottom: 1px solid var(--sunken); font-size: 13px; }
.sec .line .v { font-size: 14px; }
.sec .line.last { border-bottom: 0; font-weight: 600; }
.sec .line.big .v { font-size: 16px; }

.oh { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.oh .row { font-size: 13px; }
.oh .row .v { font-size: 14px; }
.track { height: 4px; margin-top: 7px; border-radius: 2px; background: var(--sunken); overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 2px; background: var(--red); }
.oh-total { margin-top: 18px; padding-top: 14px; border-top: 2px solid var(--red); font-size: 13px; font-weight: 600; }
.oh-total .v { font-size: 16px; }
.oh-tap { margin-top: 12px; font-size: 13px; }
.oh-tap .v { font-size: 14px; }

.opsec { padding: 18px 18px 20px; }
.opsec .top { padding-bottom: 14px; border-bottom: 2px solid var(--red); }
.opsec .top .t { font-family: var(--display); font-size: 20px; line-height: 1.08; }
.opsec .top .v { font-family: var(--display); font-size: 24px; }
.opsec .ref { margin-top: 12px; font-size: 11px; color: var(--muted); }
.opsec .ref + .ref { margin-top: 6px; }

.disc { overflow: hidden; }
.disc-btn { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 16px 18px; background: none; border: 0; cursor: pointer; text-align: left; }
.disc-btn .t { font-family: var(--display); font-size: 17px; }
.disc-btn .c { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--red); }
.disc-btn .c b { font-size: 15px; line-height: 1; font-weight: 600; }
.disc-panel { padding: 0 18px 8px; }
.disc-panel[hidden] { display: none; }
.log { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--sunken); }
.log .who { min-width: 0; }
.log .d { font-size: 13px; line-height: 1.4; }
.log .meta { margin-top: 3px; font-size: 11px; color: var(--muted); line-height: 1.4; }
.log .v { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 500; }
.log-none { padding: 11px 0 6px; border-top: 1px solid var(--sunken); font-size: 12px; color: var(--muted); }

/* ── states: connect, loading, problems ────────────── */
.gate-body { padding: 22px; }
.gate-body h1 { margin-top: 8px; font-size: 31px; }
.gate-body p { margin-top: 12px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.gate-body p.err { color: var(--ink); }
.btn {
  display: block; width: 100%; margin-top: 20px; min-height: 48px; padding: 13px 18px; border: 0; border-radius: 16px;
  background: var(--red); color: var(--white); font-weight: 600; font-size: 14px; cursor: pointer;
}
