/* Memo Admin — "field notebook": warm paper, ink, one burnt-orange accent.
   Display: Fraunces (serif) · Text: Instrument Sans. Both are self-hosted (the CSP forbids other origins). */

@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("/fonts/fraunces-latin-wght-normal.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; }
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("/fonts/fraunces-latin-ext-wght-normal.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: "Fraunces"; font-style: italic; font-weight: 100 900; font-display: swap; src: url("/fonts/fraunces-latin-wght-italic.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; }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/fonts/instrument-sans-latin-wght-normal.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; }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/fonts/instrument-sans-latin-ext-wght-normal.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; }

/* ---------------------------------------------------------------- themes */
:root {
  color-scheme: light;
  --bg: #f2ecdf; --bg2: #ebe3d1; --surface: #fbf7ee; --surface2: #f5efe2;
  --ink: #1e1b14; --mute: #6b655a; --line: #dad1bd; --line2: #c8bda5;
  --accent: #c2410c; --on-accent: #fff7ef; --accent-soft: #f6dccb;
  --s1: #1f6b52; --s2: #c2410c; --s3: #8f6411;
  --good: #1f6b52; --warn: #b45309; --bad: #b42318;
  --grain: .05; --shadow: 0 1px 0 rgba(30,27,20,.04), 0 10px 30px -18px rgba(60,40,10,.35);
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --text: "Instrument Sans", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14120d; --bg2: #1a1711; --surface: #1e1b14; --surface2: #26221a;
    --ink: #ede5d3; --mute: #a39a85; --line: #35301f; --line2: #4a4430;
    --accent: #f08a4b; --on-accent: #1a0e05; --accent-soft: #3a2616;
    --s1: #5cc49a; --s2: #f08a4b; --s3: #e5b84a;
    --good: #5cc49a; --warn: #f0a050; --bad: #ff8a7a;
    --grain: .07; --shadow: 0 1px 0 rgba(0,0,0,.3), 0 12px 32px -18px rgba(0,0,0,.8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14120d; --bg2: #1a1711; --surface: #1e1b14; --surface2: #26221a;
  --ink: #ede5d3; --mute: #a39a85; --line: #35301f; --line2: #4a4430;
  --accent: #f08a4b; --on-accent: #1a0e05; --accent-soft: #3a2616;
  --s1: #5cc49a; --s2: #f08a4b; --s3: #e5b84a;
  --good: #5cc49a; --warn: #f0a050; --bad: #ff8a7a;
  --grain: .07; --shadow: 0 1px 0 rgba(0,0,0,.3), 0 12px 32px -18px rgba(0,0,0,.8);
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15.5px/1.55 var(--text); font-feature-settings: "tnum" 1, "lnum" 1; }
body::before { content: ""; position: fixed; inset: 0; z-index: 100; pointer-events: none; opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.015em; margin: 0; }
p { margin: 0; }
code { font: .86em var(--mono); background: var(--surface2); padding: .08em .35em; border-radius: 5px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.help { color: var(--mute); font-size: .88rem; }
.empty-line { color: var(--mute); padding: .4rem 0; }
.hl { font-weight: 650; background: linear-gradient(transparent 64%, color-mix(in srgb, var(--accent) 30%, transparent) 64%); padding: 0 .12em; border-radius: 2px; }

/* ---------------------------------------------------------------- controls */
.btn { background: var(--surface); border: 1px solid var(--line2); border-radius: 10px; padding: .45rem .85rem; transition: background .15s, transform .15s; }
.btn:hover { background: var(--surface2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 650; }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn:disabled { opacity: .6; cursor: progress; }
.link-btn { background: none; border: 0; color: var(--accent); padding: .2rem 0; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--line2); border-radius: 999px; }
.seg button { border: 0; background: none; padding: .32rem .8rem; border-radius: 999px; color: var(--mute); font-size: .86rem; white-space: nowrap; transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); font-weight: 600; }
label { display: grid; gap: .3rem; font-size: .84rem; color: var(--mute); }
input { background: var(--surface); border: 1px solid var(--line2); border-radius: 10px; padding: .6rem .75rem; color: var(--ink); }
.err { color: var(--bad); min-height: 1.3em; font-size: .9rem; }

/* ---------------------------------------------------------------- brand + auth */
.brand { display: flex; align-items: center; gap: .7rem; }
.brand b { display: block; font: 600 1.25rem/1 var(--display); letter-spacing: -.02em; }
.brand small { display: block; color: var(--mute); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; margin-top: .2rem; }
.mark { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 12px; background: var(--accent); color: var(--on-accent); font: italic 700 1.55rem/1 var(--display); box-shadow: var(--shadow); }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 4.5rem 16px 2rem;
  background: radial-gradient(60rem 30rem at 15% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%), radial-gradient(50rem 30rem at 100% 110%, color-mix(in srgb, var(--s1) 14%, transparent), transparent 60%); }
.auth-tools { position: fixed; top: 14px; right: 14px; display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; z-index: 5; }
.auth-card { width: min(26rem, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 1.7rem; display: grid; gap: 1rem; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.7rem; margin-top: .4rem; }
.auth-card form { display: grid; gap: .85rem; }
.qr { width: 11rem; height: 11rem; background: #fff; padding: .5rem; border-radius: 12px; justify-self: center; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 17.5rem minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--bg2); border-right: 1px solid var(--line); padding: 1.4rem 1.1rem; display: flex; flex-direction: column; gap: 1.6rem; }
.nav { display: grid; gap: 1.1rem; }
.nav-group { display: grid; gap: .1rem; }
.nav-title { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); padding: 0 .7rem .35rem; }
.nav-item { display: flex; align-items: center; gap: .7rem; padding: .5rem .7rem; border-radius: 10px; color: var(--ink); text-decoration: none; transition: background .15s; }
.nav-item:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.nav-item[aria-current="page"] { background: var(--surface); box-shadow: inset 3px 0 0 var(--accent), var(--shadow); font-weight: 650; }
.nav-ico { width: 1.3rem; text-align: center; color: var(--accent); }
.side-foot { margin-top: auto; display: grid; gap: .6rem; }
.side-foot .seg { width: 100%; } .side-foot .seg button { flex: 1; padding-inline: .3rem; }
.who { color: var(--mute); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; gap: .5rem; } .row .btn { flex: 1; }
.content { padding: 2.4rem clamp(16px, 3.5vw, 3.2rem) 4rem; max-width: 82rem; width: 100%; }
.page-head { display: grid; gap: .7rem; margin-bottom: 1.8rem; }
.page-head h1 { font-size: clamp(2rem, 4.4vw, 3rem); font-weight: 600; line-height: 1.05; }
.intro { color: var(--mute); font-size: 1.04rem; max-width: 62ch; }
.controls { display: flex; flex-wrap: wrap; gap: .7rem 1.1rem; align-items: center; margin-top: .5rem; }
.ctl-note { flex-basis: 100%; color: var(--mute); font-size: .8rem; max-width: 80ch; }

main { display: grid; gap: 1rem; outline: none; }
.hero { font: 500 clamp(1.45rem, 3vw, 2.15rem)/1.28 var(--display); letter-spacing: -.012em; max-width: 34em; padding: .2rem 0 .6rem; }
.kpis { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1rem 1.1rem; display: grid; gap: .25rem; align-content: start; box-shadow: var(--shadow); }
.kpi-label { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--mute); }
.kpi-value { font: 600 2.35rem/1.1 var(--display); letter-spacing: -.02em; }
.kpi-note { font-size: .8rem; color: var(--mute); line-height: 1.35; }
.delta { font-size: .8rem; color: var(--mute); margin-top: .2rem; } .delta b { margin-right: .15rem; }
.delta.up b { color: var(--good); } .delta.down b { color: var(--bad); } .delta.flat b, .delta.none { color: var(--mute); }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1.2rem 1.3rem 1.3rem; min-width: 0; box-shadow: var(--shadow); display: grid; gap: .7rem; align-content: start; }
.card h2 { font-size: 1.2rem; }
.sub { font: 650 .82rem var(--text); letter-spacing: .02em; color: var(--mute); margin: .5rem 0 .3rem; }

/* live indicator */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.live { display: inline-flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--mute); padding: .3rem .75rem; border: 1px solid var(--line2); border-radius: 999px; background: var(--surface); }
.live-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 55%, transparent); animation: beat 2s infinite; }
.live[data-state="paused"] .live-dot { background: var(--mute); animation: none; }
.live[data-state="error"] .live-dot { background: var(--bad); animation: none; }
.live[data-state="new"] { color: var(--ink); border-color: var(--good); }
@keyframes beat { 70% { box-shadow: 0 0 0 .45rem transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* bars */
.bars { display: grid; gap: .55rem; }
.bar { display: grid; grid-template-columns: minmax(5.5rem, 10.5rem) minmax(0, 1fr) auto; gap: .7rem; align-items: center; font-size: .9rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { display: block; height: .62rem; background: var(--surface2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--s1), color-mix(in srgb, var(--s1) 70%, var(--s3))); border-radius: 999px; transition: width .7s cubic-bezier(.2,.7,.2,1); }
.bar-value { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; font-weight: 600; }
.bar-value small { color: var(--mute); font-weight: 400; margin-left: .45rem; }
.bar.is-hidden .bar-track { background: repeating-linear-gradient(135deg, var(--surface2) 0 6px, var(--line) 6px 7px); }
.hidden-cell { display: inline-block; padding: 0 .45rem; border: 1px dashed var(--line2); border-radius: 999px; color: var(--mute); font-weight: 500; cursor: help; }

/* tables */
.scroll { overflow-x: auto; margin: 0 -.3rem; padding: 0 .3rem; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th { text-align: left; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--mute); font-weight: 600; padding: .45rem .7rem; border-bottom: 1px solid var(--line2); white-space: nowrap; }
td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
.wrap td { white-space: normal; } .wrap td:first-child { white-space: nowrap; }
code.ex { word-break: break-all; color: var(--mute); }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details pre { margin: .5rem 0 0; font: .78rem/1.45 var(--mono); white-space: pre-wrap; word-break: break-all; color: var(--mute); }

/* chart */
.chart-box { display: grid; gap: .5rem; }
.chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .axis { fill: var(--mute); font: 11px var(--text); }
.chart .guide { stroke: var(--line2); stroke-width: 1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.readout { min-height: 1.5rem; font-size: .88rem; color: var(--mute); }
.readout b { color: var(--ink); } .sw, .legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin: 0 .3rem 0 .4rem; vertical-align: -1px; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; font-size: .85rem; } .legend i { margin-left: 0; }

/* lists + boxes */
.steps { margin: 0; padding-left: 1.3rem; display: grid; gap: .5rem; }
.insights, .never, .how { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.insights li, .never li, .how li { display: flex; gap: .7rem; align-items: baseline; }
.ico { color: var(--accent); width: 1rem; flex: none; text-align: center; } .ico.bad { color: var(--bad); }
.insights .good .ico { color: var(--good); } .insights .warn .ico { color: var(--warn); }
.state { border: 1.5px dashed var(--line2); border-radius: 18px; padding: 2.2rem 1.4rem; text-align: center; display: grid; gap: .5rem; justify-items: center; }
.state h3 { font-size: 1.25rem; } .state p { color: var(--mute); max-width: 52ch; }
.glossary { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr; gap: .55rem 1.2rem; margin: 0; }
.glossary dt { font-weight: 650; } .glossary dd { margin: 0; color: var(--mute); }
.code-box { position: relative; } .code-box .btn { position: absolute; top: .5rem; right: .5rem; padding: .25rem .6rem; }
.code-box pre { margin: 0; padding: 1rem; background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; font: .8rem/1.55 var(--mono); }

/* loading + entrance */
.skeleton-wrap { display: grid; gap: 1rem; } .skeleton-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }
.skeleton { height: 7.5rem; border-radius: 16px; background: linear-gradient(100deg, var(--surface) 30%, var(--surface2) 50%, var(--surface) 70%) 0 0 / 220% 100%; animation: shimmer 1.3s linear infinite; border: 1px solid var(--line); }
.skeleton.wide { height: 5rem; }
@keyframes shimmer { to { background-position: -220% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.reveal { animation: rise .55s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i, 0) * 70ms); }
@media (prefers-reduced-motion: reduce) { .reveal, .skeleton { animation: none; } .bar-fill { transition: none; } }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 62rem) {
  .shell { display: flex; flex-direction: column; }
  .side { display: contents; }                                   /* brand + menu stay on top, the controls drop to the bottom */
  .brand { order: 0; padding: 1rem 16px .5rem; }
  .nav { order: 1; display: flex; overflow-x: auto; gap: .3rem; padding: .35rem 16px .7rem; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
  .nav-group { display: flex; gap: .2rem; } .nav-title { display: none; }
  .nav-item { white-space: nowrap; border: 1px solid var(--line); background: var(--surface); }
  .nav-item[aria-current="page"] { box-shadow: none; background: var(--ink); color: var(--bg); border-color: var(--ink); } .nav-item[aria-current="page"] .nav-ico { color: var(--bg); }
  .content { order: 2; padding-top: 1.3rem; }
  .side-foot { order: 3; margin: 0; padding: 1.2rem 16px 2.5rem; border-top: 1px solid var(--line); background: var(--bg2); grid-template-columns: 1fr 1fr; align-items: center; }
  .side-foot .who { grid-column: 1 / -1; order: -1; }
}
@media (max-width: 34rem) {
  .bar { grid-template-columns: minmax(4.5rem, 7rem) minmax(0, 1fr) auto; gap: .5rem; }
  .glossary { grid-template-columns: 1fr; gap: .1rem; } .glossary dd { margin-bottom: .6rem; }
  .side-foot { grid-template-columns: 1fr; }
}
