/* Heartstabbed Board v3 — monochrome financial dashboard.
   System: one neutral ramp (ink -> surface), hairline borders instead of shadows, Inter with tabular figures,
   colour only for performance (--pos / --neg). Chart series use the grey ramp --s1..--s6.
   Old token names (--card, --green, --pink...) are kept as aliases so app.js / board.js keep working. */
:root {
  /* neutrals */
  --bg: #f5f5f6; --surface: #ffffff; --surface-2: #f4f4f5; --surface-3: #e9e9ec;
  --ink: #09090b; --ink-2: #3f3f46; --muted: #71717a; --faint: #a1a1aa;
  --line: rgba(9, 9, 11, .08); --line-strong: rgba(9, 9, 11, .14);
  /* performance accents */
  --pos: #16803c; --pos-soft: rgba(22, 128, 60, .08); --neg: #c0362c; --neg-soft: rgba(192, 54, 44, .07);
  /* chart series ramp (darkest = biggest seller) */
  --s1: #09090b; --s2: #52525b; --s3: #85858e; --s4: #aeaeb6; --s5: #cdcdd3; --s6: #e2e2e6; --s-rest: rgba(9, 9, 11, .07);
  /* shape + type */
  --r: 16px; --r-sm: 12px; --r-xs: 8px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --shadow: 0 1px 0 rgba(9, 9, 11, .02);
  --pop: 0 24px 64px rgba(0, 0, 0, .18), 0 0 0 1px var(--line);
  --f: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --fd: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --surface: #0c0c0d; --surface-2: #141416; --surface-3: #1e1e21;
    --ink: #f4f4f5; --ink-2: #d4d4d8; --muted: #8b8b93; --faint: #5c5c64;
    --line: rgba(255, 255, 255, .07); --line-strong: rgba(255, 255, 255, .13);
    --pos: #5fcf8c; --pos-soft: rgba(95, 207, 140, .1); --neg: #f2766b; --neg-soft: rgba(242, 118, 107, .1);
    --s1: #f4f4f5; --s2: #b6b6bd; --s3: #85858d; --s4: #5d5d65; --s5: #424248; --s6: #2f2f34; --s-rest: rgba(255, 255, 255, .08);
    --shadow: none;
    --pop: 0 24px 80px rgba(0, 0, 0, .7), 0 0 0 1px var(--line-strong);
    color-scheme: dark;
  }
}
:root {
  /* legacy aliases (used by the scripts) — all map onto the monochrome system */
  --card: var(--surface); --card2: var(--surface-2);
  --green: var(--pos); --green-soft: var(--pos-soft); --red: var(--neg); --red-soft: var(--neg-soft);
  --blue: var(--ink); --blue-soft: var(--surface-3); --orange: var(--ink-2); --orange-soft: var(--surface-3);
  --pink: var(--s1); --pink-soft: var(--surface-3); --purple: var(--s2); --teal: var(--s4); --yellow: var(--s5);
  --gray-soft: var(--s-rest);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 14.5px/1.5 var(--f); -webkit-font-smoothing: antialiased; letter-spacing: -.006em; font-feature-settings: "cv11", "ss01"; }
h1, h2, h3 { font-family: var(--fd); margin: 0; font-weight: 600; letter-spacing: -.02em; text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.num, b { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: var(--ink); color: var(--bg); }

/* eyebrow label: the one small-caps label style used everywhere */
.label, .eyebrow { font-size: 11.5px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }

/* ---------- buttons ---------- */
.btn { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 10px; padding: 8px 14px; font-weight: 500; font-size: 13.5px; cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease); }
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { background: var(--ink-2); }
.btn.green { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 8px; }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.danger { color: var(--neg); border-color: var(--neg-soft); background: var(--neg-soft); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.icon-btn { border: 1px solid var(--line); background: var(--surface-2); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; color: var(--muted); font-size: 13px; transition: color .15s, background .15s; }
.icon-btn:hover { color: var(--ink); background: var(--surface-3); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left)); }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 36px 30px; display: grid; gap: 14px; }
.login-card form { display: grid; gap: 10px; }
.login-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.setpw { display: grid; gap: 8px; margin: 6px 0 14px; }
.setpw label { font-size: 13px; color: var(--muted); }
.login-card h1 { font-size: 28px; }
.login-msg { margin: 0; min-height: 1.4em; color: var(--muted); font-size: 13.5px; }
.logo { font: 600 15px var(--fd); display: flex; align-items: center; gap: 10px; letter-spacing: -.01em; }
.logo-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--ink); position: relative; flex: none; }
.logo-mark::after { content: ""; position: absolute; inset: 7px 6px 6px; background: var(--bg); clip-path: path("M7 13S1 9.3 1 5.2A3.3 3.3 0 0 1 7 3a3.3 3.3 0 0 1 6 2.2C13 9.3 7 13 7 13z"); transform: scale(.95); }

/* ---------- inputs ---------- */
label { font-size: 12px; font-weight: 500; color: var(--muted); }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--surface-3); }
textarea { resize: vertical; }

/* ---------- shell ---------- */
.shell { max-width: 1200px; margin: 0 auto; padding: 0 max(20px, env(safe-area-inset-right)) 120px max(20px, env(safe-area-inset-left)); }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; align-items: center; gap: 16px; padding: 14px 0; margin-bottom: 8px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--line); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--bg); z-index: 10; }

/* segmented control (nav + chart toggles) */
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 2px; gap: 2px; margin: 0 auto; }
.seg button { border: 0; background: transparent; border-radius: 8px; padding: 6px 14px; font-weight: 500; font-size: 13px; color: var(--muted); cursor: pointer; transition: color .15s, background .15s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong); }
@media (prefers-color-scheme: dark) { .seg button[aria-selected="true"] { background: var(--surface-3); box-shadow: none; } }
/* the main nav reads as quiet text tabs */
.topbar .seg { background: transparent; border: 0; gap: 4px; }
.topbar .seg button { padding: 7px 12px; font-size: 13.5px; }
.top-right { display: flex; align-items: center; gap: 12px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); font-weight: 600; font-size: 12.5px; display: grid; place-items: center; cursor: pointer; }
.avatar:hover { background: var(--surface-3); }
.synced { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.synced::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--pos); margin-right: 7px; vertical-align: 1px; }
.synced:empty::before { display: none; }
.tabbar { display: none; }
@media (max-width: 760px) {
  .topbar .seg, .synced { display: none; }
  .topbar { justify-content: space-between; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0; z-index: 6; padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px); border-top: 1px solid var(--line); }
  .tabbar button { border: 0; background: transparent; display: grid; justify-items: center; gap: 3px; font-size: 10.5px; font-weight: 500; color: var(--faint); padding: 4px 0; cursor: pointer; letter-spacing: .01em; }
  .tabbar button svg { width: 22px; height: 22px; }
  .tabbar button[aria-selected="true"] { color: var(--ink); }
}

/* ---------- cards + grid ---------- */
.view { display: grid; gap: var(--sp-4); padding-top: var(--sp-3); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--sp-5); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--sp-4); min-height: 30px; }
.card-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); }
.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--sp-4); }
@media (max-width: 960px) { .grid3 { grid-template-columns: 1fr; } .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } .card { padding: 20px; } }

/* ---------- hero: month earned + goal ring ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-6); align-items: center; padding: 28px 28px 26px; }
.hero-top { display: flex; align-items: center; gap: 8px; }
.hero-num { font: 600 clamp(44px, 7.2vw, 68px)/1 var(--fd); letter-spacing: -.045em; font-variant-numeric: tabular-nums; margin: 14px 0 14px; }
.hero-num .unit { font-size: .42em; color: var(--muted); font-weight: 500; margin-right: 8px; letter-spacing: -.01em; vertical-align: .55em; }
.hero-figs { display: flex; align-items: baseline; gap: 0 28px; flex-wrap: wrap; margin: 14px 0; }
.hero-figs .hero-num { margin: 0; }
.hero-num.usd { color: var(--pos); padding-left: 28px; border-left: 1px solid var(--line-strong); }
.hero-num.usd .unit { color: var(--pos); opacity: .7; }
.hero-num .unit.tail { margin: 0 0 0 8px; font-size: .28em; letter-spacing: .08em; vertical-align: .9em; }
@media (max-width: 600px) { .hero-num.usd { border-left: 0; padding-left: 0; } }
.usd-sub { font: 600 17px/1.1 var(--fd); color: var(--pos); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.hero-sub { font-size: 13.5px; color: var(--muted); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.goal-bar { position: relative; height: 4px; border-radius: 4px; background: var(--surface-3); margin-top: 22px; max-width: 520px; }
.goal-bar i { position: absolute; inset: 0 auto 0 0; background: var(--ink); border-radius: 4px; transition: width 1s var(--ease); }
.goal-bar em { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 1px; background: var(--muted); }
.goal-scale { display: flex; justify-content: space-between; max-width: 520px; margin-top: 8px; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.ring { width: 156px; height: 156px; }
.ring .track { stroke: var(--surface-3); }
.ring .fill { stroke: var(--ink); transition: stroke-dashoffset 1.1s var(--ease); }
.ring-text { font: 600 26px var(--fd); fill: var(--ink); letter-spacing: -.03em; }
.ring-small { font: 500 9.5px var(--f); fill: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
@media (max-width: 600px) { .hero { grid-template-columns: 1fr; padding: 22px 20px; gap: 12px; } .ring { display: none; } }

/* ---------- KPI strip: one panel, hairline dividers ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.kpis .tile { border-radius: 0; border: 0; border-left: 1px solid var(--line); background: transparent; box-shadow: none; padding: 20px 22px; }
.kpis .tile:first-child { border-left: 0; }
@media (max-width: 860px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis .tile:nth-child(3) { border-left: 0; } .kpis .tile:nth-child(n+3) { border-top: 1px solid var(--line); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 16px 18px; display: grid; gap: 6px; min-width: 0; align-content: start; }
.tile b { font: 600 26px/1.1 var(--fd); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.delta { font-size: 12.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--pos); } .delta.down { color: var(--neg); } .delta.flat { color: var(--muted); }

/* status pills: neutral by default, colour only for good / bad */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 6px; white-space: nowrap; border: 1px solid var(--line-strong); color: var(--ink-2); background: transparent; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill.green { color: var(--pos); border-color: transparent; background: var(--pos-soft); }
.pill.red { color: var(--neg); border-color: transparent; background: var(--neg-soft); }
.pill.gray, .pill.faint { color: var(--muted); }
.pill.orange, .pill.blue, .pill.pink, .pill.neutral, .pill.outline { color: var(--ink-2); }

/* ---------- charts ---------- */
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.chart-box.short { height: 190px; }
.stack { display: grid; gap: var(--sp-4); }
.insights .card { padding: 28px 32px; }
.insights .card-head h2 { font-size: 20px; }
.insights .chart-box.big { height: 400px; }
.insights .muted { font-size: 16px !important; }
@media (max-width: 760px) { .insights .card { padding: 20px; } .insights .chart-box.big { height: 300px; } }
.legend { display: flex; gap: 6px 18px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 7px; vertical-align: 0; }
.legend b { color: var(--ink); font-weight: 600; margin-left: 4px; }
.chart-foot { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--line); flex-wrap: wrap; }
.note { margin: 0; font-size: 12px; color: var(--faint); }

/* ---------- lists ---------- */
.list { display: grid; counter-reset: rank; }
.row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; padding-top: 2px; }
.row-thumb { width: 64px; height: 36px; border-radius: 6px; object-fit: cover; background: var(--surface-2); display: block; border: 1px solid var(--line); }
.row-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-right { text-align: right; display: grid; justify-items: end; gap: 3px; }
.row-right b { font: 600 16px var(--fd); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
#o-top .row { grid-template-columns: 18px auto minmax(0, 1fr) auto; }
#o-top .row::before { counter-increment: rank; content: counter(rank); font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.spark { width: 84px; height: 26px; display: block; }
.spark path.l { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.spark path.a { fill: var(--surface-3); opacity: .6; }
.clickable { cursor: pointer; transition: background .15s; }
.clickable:hover .row-title { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }

/* ---------- AI briefing ---------- */
.ai-head { display: flex; align-items: center; gap: 10px; }
.ai-badge { height: 22px; padding: 0 7px; border-radius: 6px; border: 1px solid var(--line-strong); display: inline-grid; place-items: center; color: var(--ink-2); font-weight: 600; font-size: 10.5px; letter-spacing: .08em; flex: none; }
.ai-headline { font: 600 20px/1.3 var(--fd); letter-spacing: -.02em; margin: 2px 0 10px; }
.ai-text p, #o-ai > p { margin: 0 0 12px; color: var(--ink-2); max-width: 70ch; line-height: 1.6; }
#o-ai > p.muted { color: var(--muted); }
.sugg { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.sugg-title { font-weight: 500; }
.sugg-why { font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.alert { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.alert:first-child { border-top: 0; }
.alert-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 7px; }
.empty-note { color: var(--muted); font-size: 13.5px; padding: 8px 0; }

/* items toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar input { max-width: 260px; }
.toolbar select { width: auto; }

/* ---------- board ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; scroll-snap-type: x proximity; align-items: flex-start; margin: 0 calc(-1 * max(20px, env(safe-area-inset-left))); padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
.column { flex: 0 0 290px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 150px); scroll-snap-align: start; }
@media (prefers-color-scheme: dark) { .column { background: #08080a; } }
@media (max-width: 600px) { .column { flex-basis: 84vw; max-height: none; } }
.col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px; }
.col-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; filter: grayscale(1); background: var(--muted) !important; }
.column:has(.col-name) .col-head .col-dot { opacity: .8; }
.col-name { font: 600 14px var(--fd); }
.col-count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.col-hint { font-size: 12px; color: var(--muted); margin: -6px 4px 0; }
.col-add { margin-left: auto; }
.cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; overflow-y: auto; padding: 2px; }
.empty { font-size: 12.5px; color: var(--muted); text-align: center; padding: 16px 8px; border: 1px dashed var(--line-strong); border-radius: var(--r-sm); }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px 12px; cursor: grab; display: grid; gap: 8px; transition: border-color .15s, transform .15s var(--ease); }
.kcard:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.kcard.sortable-ghost { opacity: .35; }
.kcard-thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r-xs); background: var(--surface-2); display: block; }
.kcard-title { font-weight: 500; line-height: 1.35; word-break: break-word; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 11.5px; font-weight: 500; border-radius: 6px; padding: 2px 8px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.hot { background: var(--pos-soft); color: var(--pos); border-color: transparent; }
.chip.dead { color: var(--faint); }
.chip.watch, .chip.new { color: var(--ink-2); border-color: var(--line-strong); }
.chip.steady { color: var(--ink-2); }
.kcard-sales { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.kcard-sales b { color: var(--ink); font-variant-numeric: tabular-nums; }
.ref-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.ref-strip img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 5px; display: block; background: var(--surface-2); }

/* ---------- sheets (dialogs) ---------- */
.sheet { border: 0; border-radius: 20px; padding: 0; width: min(560px, calc(100vw - 20px)); max-height: calc(100vh - 40px); background: var(--surface); color: var(--ink); box-shadow: var(--pop); }
.sheet::backdrop { background: rgba(0, 0, 0, .45); backdrop-filter: blur(6px); }
.sheet-body { padding: 24px; display: grid; gap: 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sheet-head h2 { font-size: 19px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two > div { display: grid; gap: 6px; min-width: 0; }
.count { font-size: 12px; color: var(--muted); text-align: right; margin-top: -4px; }
.sheet-foot { display: flex; gap: 8px; margin-top: 10px; }
.spacer { flex: 1; }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.kv div { padding: 12px 14px; border-left: 1px solid var(--line); }
.kv div:first-child { border-left: 0; }
.kv span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.kv b { font: 600 18px var(--fd); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.sec-label { font-size: 11.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.sec-msg { margin: 0; font-size: 12px; color: var(--muted); }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.thumb-grid:empty { display: none; }
.thumb { position: relative; border-radius: var(--r-xs); overflow: hidden; background: var(--surface-2); aspect-ratio: 1 / 1; display: block; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.refs .thumb { aspect-ratio: 3 / 4; }
.thumb .x { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .65); color: #fff; font-size: 11px; cursor: pointer; padding: 0; }

/* week strip */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 760px) { .week { grid-template-columns: repeat(7, 120px); overflow-x: auto; padding-bottom: 4px; } }
.day { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; display: grid; gap: 6px; align-content: start; min-height: 132px; cursor: pointer; min-width: 0; transition: border-color .15s; }
.day:hover { border-color: var(--line-strong); }
.day.gap { background: transparent; border-style: dashed; border-color: var(--line-strong); }
.day.today { border-color: var(--ink); }
.day-name { font-size: 10.5px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.day-num { font: 600 19px var(--fd); letter-spacing: -.02em; }
.day img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 5px; display: block; background: var(--surface); }
.day-title { font-size: 12px; font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.day-empty { font-size: 12px; color: var(--faint); }

/* checklist */
.checks { display: grid; gap: 6px; }
.check { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-weight: 500; cursor: pointer; color: var(--ink); font-size: 13.5px; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); flex: none; padding: 0; }
.check.done { color: var(--muted); text-decoration: line-through; }
textarea[readonly] { color: var(--muted); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 500; font-size: 13.5px; z-index: 20; box-shadow: var(--pop); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* record-day popup */
.sheet.record { width: min(460px, calc(100vw - 20px)); }
.record-title { font-size: 30px; letter-spacing: -.035em; line-height: 1.1; }
.record .kv b { color: var(--ink); } .record .kv div:last-child b { color: var(--pos); }
.record-player { margin-top: 8px; aspect-ratio: 16 / 9; border-radius: var(--r-sm); overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; }
.record-player iframe { width: 100%; height: 100%; border: 0; display: block; }
.record-player { position: relative; }
.record-player > div:first-child, .record-player iframe { width: 100%; height: 100%; }
.record-hint { color: var(--muted); font-size: 13px; }
.record-hint.over { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 6px 12px; border-radius: 8px; font-weight: 500; pointer-events: none; }

/* ===================== v4 Intel ===================== */
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes cellIn { from { opacity: 0; transform: scale(.6); } to { opacity: var(--a); transform: none; } }
@keyframes grow { from { width: 0; } to { width: var(--w); } }
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }
.view:not([hidden]) { animation: viewIn .38s var(--ease, cubic-bezier(.2,.8,.2,1)); }
.rise { animation: rise .55s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 55ms); }
.intel-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--sp-4); }
.intel-seg { margin: 0; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.intel-seg::-webkit-scrollbar { display: none; }
.intel-seg button { white-space: nowrap; }
#intel-fresh.late { color: var(--neg); }
.intel-body { display: grid; gap: var(--sp-4); }
.intel-body .chart-box.big { height: 360px; }
.skel { height: 160px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; color: var(--muted); }
.takeaway { margin: 12px 0 0; font-size: 14.5px; color: var(--ink-2); line-height: 1.5; }
.ihero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--sp-5); align-items: center; }
.ibig { display: flex; align-items: baseline; gap: 6px; margin: 6px 0 4px; }
.ibig .num { font-size: clamp(44px, 7vw, 68px); font-weight: 700; letter-spacing: -.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.ibig .unit { color: var(--muted); font-size: 16px; }
.ihero .muted { margin: 4px 0 10px; }
.istats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.istat { background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.istat .num { font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.istat .sub { font-size: 12.5px; color: var(--muted); }
.actions { display: grid; gap: 10px; }
.action { display: flex; justify-content: space-between; gap: 16px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-sm); transition: border-color .2s, transform .2s; }
.action:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.action p { margin: 4px 0 0; font-size: 13.5px; }
.action-r { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; text-align: right; }
.action-r .ev { font-size: 20px; font-weight: 650; color: var(--pos); font-variant-numeric: tabular-nums; }
.action-r .sub { font-size: 12px; color: var(--muted); }
.btn-mini { border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink); border-radius: 8px; padding: 5px 10px; font: 500 12.5px var(--f); cursor: pointer; transition: background .15s, transform .1s; white-space: nowrap; }
.btn-mini:hover { background: var(--surface-3); } .btn-mini:active { transform: scale(.97); } .btn-mini:disabled { opacity: .6; cursor: default; }
.alert-row { padding: 10px 12px; border-left: 2px solid var(--ink); background: var(--surface-2); border-radius: 0 8px 8px 0; font-size: 14px; }
.list { display: grid; gap: 8px; }
.arow { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.arow:last-child { border-bottom: 0; } .arow .muted { font-size: 13px; }
.itable { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 calc(-1 * var(--sp-2)); }
.itable table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.itable th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.itable td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.itable tr:last-child td { border-bottom: 0; }
.itable tr { transition: background .15s; } .itable tr:hover td { background: var(--surface-2); }
.itable .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line-strong); border-radius: 999px; padding: 5px 12px; font-size: 13px; transition: background .15s; }
.chip:hover { background: var(--surface-2); }
.heat { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 3px; align-items: center; }
.heat i { aspect-ratio: 1; border-radius: 4px; background: var(--ink); opacity: var(--a); min-height: 10px; }
.heat-in i { animation: cellIn .4s cubic-bezier(.2,.8,.2,1) both; animation-delay: var(--d); }
.heat-in i { opacity: var(--a); }
.heat .hlab { font-size: 10px; color: var(--muted); text-align: left; white-space: nowrap; overflow: visible; }
.heat .dlab { font-size: 11.5px; color: var(--muted); }
.isel, .iinput { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; font: 500 13px var(--f); max-width: 100%; }
.simform { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 10px; }
.iinput { width: 100%; font-size: 14px; }
.simout { margin-top: 16px; }
.simtop .num { font-size: 34px; font-weight: 700; letter-spacing: -.03em; }
.factors { display: grid; gap: 8px; margin-top: 12px; }
.factor, .hbar { display: grid; grid-template-columns: 150px minmax(0, 1fr) 80px; gap: 10px; align-items: center; font-size: 13.5px; }
.factor i, .hbar i { height: 8px; border-radius: 99px; background: var(--ink); width: var(--w); animation: grow .8s cubic-bezier(.2,.8,.2,1) both; }
.factor b, .hbar b { text-align: right; font-variant-numeric: tabular-nums; }
.bars { display: grid; gap: 8px; }
@media (max-width: 760px) {
  .intel-top { flex-direction: column; align-items: stretch; }
  .intel-body .chart-box.big { height: 260px; }
  .ihero { grid-template-columns: 1fr; }
  .action { flex-direction: column; } .action-r { align-items: flex-start; text-align: left; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .simform { grid-template-columns: 1fr; }
  .factor, .hbar { grid-template-columns: 110px minmax(0, 1fr) 64px; }
  .heat { grid-template-columns: 28px repeat(24, minmax(0, 1fr)); gap: 2px; }
  .heat i { border-radius: 2px; min-height: 8px; }
  .heat .hlab { font-size: 8.5px; }
}
@media (prefers-reduced-motion: reduce) { .rise, .heat-in i, .factor i, .hbar i, .view:not([hidden]), .skel { animation: none !important; } }
@media (max-width: 760px) {
  .intel-body .card-head { flex-wrap: wrap; row-gap: 4px; height: auto; }
  .intel-body .card-head .label { white-space: normal; }
  .intel-body .card { padding: 18px; }
  .itable table { font-size: 13px; }
}
.intel-body { grid-template-columns: minmax(0, 1fr); }
.intel-body > *, .intel-top { min-width: 0; }
@media (max-width: 760px) { .ihero { grid-template-columns: minmax(0, 1fr); } .istat .num { font-size: 22px; } }
.card-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.info { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 1px solid var(--line-strong); background: transparent; color: var(--muted); font: 600 11px/1 var(--f); font-style: italic; cursor: pointer; display: grid; place-items: center; padding: 0; transition: color .15s, border-color .15s, background .15s; }
.info:hover, .info[aria-expanded="true"] { color: var(--ink); border-color: var(--ink); }
.explain { margin: -6px 0 14px; padding: 10px 12px; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); background: var(--surface-2); border-radius: var(--r-xs); animation: viewIn .25s ease; }
@media (prefers-reduced-motion: reduce) { .explain { animation: none; } }

/* stale-data alarm + upload plan */
.stale { background: var(--neg); color: #fff; font: 600 13.5px var(--f); padding: 10px 14px; border-radius: 12px; margin: 10px 0 4px; text-align: center; animation: rise .4s ease both; }
.plan-chips { margin: 4px 0 12px; }
.plan-chips .btn-mini[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
