/* Theme "APA Nano · glass"
   Layout language from the owner's reference page: the app sits in a deep green frame, the navigation hangs
   from the top edge in a notch with inverted corners, a second notch at the bottom carries three stat pills,
   cards are frosted glass with a soft two-layer shadow, and one dark feature card with concentric rings.
   Colours are APA Nano's: brand green #006633 (apanano.com), a near-white surface with faint green, blue and
   amber light behind the glass, and the APA logo. Loaded after styles.css; it overrides tokens and looks only. */

:root {
  color-scheme: light;
  --font: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  --frame: 12px;
  --notch-r: 26px;
  --ground: #0b2016;
  --bg: #f4f9f6;
  --glow-1: rgba(0, 122, 61, .16);
  --glow-2: rgba(47, 98, 214, .10);
  --glow-3: rgba(237, 161, 0, .10);
  --panel: #ffffff;
  --panel-2: #f1f7f3;
  --glass: rgba(255, 255, 255, .66);
  --glass-strong: rgba(255, 255, 255, .82);
  --glass-line: rgba(255, 255, 255, .7);
  --ink: #10231c;
  --ink-2: #2b463b;
  --mute: #52675d;
  --faint: #73877e;
  --line: rgba(16, 35, 28, .09);
  --line-2: rgba(16, 35, 28, .17);
  --accent: #006633;
  --accent-hi: #00552a;
  --accent-wash: rgba(0, 102, 51, .10);
  --nav: #13432b;
  --nav-ink: #e3f3eb;
  --dark-card: #10251b;
  --dark-ink: #eaf5ef;
  --dark-muted: #a9c9b8;
  --shell: transparent;
  --shell-ink: var(--ink);
  --shell-mute: var(--mute);
  --s-apa: #00753a;
  --s-best: #eb6834;
  --s-avg: #2a78d6;
  --s-dom: #eda100;
  --s-imp: #e87ba4;
  --s-track: #6250d6;
  --s-dompo: #a0721c;
  --s-master: #8aa396;
  --s-other: #bccbc2;
  --good: #1a7033;
  --bad: #b5361f;
  --bad-fill: #d03b3b;
  --bad-wash: rgba(193, 61, 41, .10);
  --chart-surface: #ffffff;
  --grid: rgba(16, 35, 28, .07);
  --axis: rgba(16, 35, 28, .18);
  --radius: 22px;
  --shadow: 0 1px 2px rgba(14, 40, 30, .05), 0 12px 30px -18px rgba(14, 50, 36, .22);
  --shadow-lg: 0 2px 8px rgba(14, 40, 30, .08), 0 34px 70px -26px rgba(10, 40, 30, .34);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #040a08; --bg: #0c1714; --glow-1: rgba(31, 157, 92, .16); --glow-2: rgba(57, 135, 229, .10); --glow-3: rgba(201, 133, 0, .08);
    --panel: #14211d; --panel-2: #1a2b25; --glass: rgba(20, 33, 29, .66); --glass-strong: rgba(20, 33, 29, .84); --glass-line: rgba(226, 242, 234, .08);
    --ink: #e6f2ec; --ink-2: #c3d7ce; --mute: #93aba1; --faint: #7f978a; --line: rgba(226, 242, 234, .08); --line-2: rgba(226, 242, 234, .17);
    --accent: #3fbf7f; --accent-hi: #56cf91; --accent-wash: rgba(63, 191, 127, .14); --nav: #0e2a1d; --nav-ink: #cfe6d8; --dark-card: #0a1a12;
    --s-apa: #1f9d5c; --s-best: #d95926; --s-avg: #3987e5; --s-dom: #c98500; --s-imp: #d55181; --s-track: #9085e9; --s-dompo: #b8862a; --s-master: #6f877b; --s-other: #2f4a3e;
    --good: #3fbf7f; --bad: #e66767; --bad-wash: rgba(230, 103, 103, .14); --chart-surface: #14211d; --grid: rgba(226, 242, 234, .07); --axis: rgba(226, 242, 234, .16);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 34px -18px rgba(0, 0, 0, .8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #040a08; --bg: #0c1714; --glow-1: rgba(31, 157, 92, .16); --glow-2: rgba(57, 135, 229, .10); --glow-3: rgba(201, 133, 0, .08);
  --panel: #14211d; --panel-2: #1a2b25; --glass: rgba(20, 33, 29, .66); --glass-strong: rgba(20, 33, 29, .84); --glass-line: rgba(226, 242, 234, .08);
  --ink: #e6f2ec; --ink-2: #c3d7ce; --mute: #93aba1; --faint: #7f978a; --line: rgba(226, 242, 234, .08); --line-2: rgba(226, 242, 234, .17);
  --accent: #3fbf7f; --accent-hi: #56cf91; --accent-wash: rgba(63, 191, 127, .14); --nav: #0e2a1d; --nav-ink: #cfe6d8; --dark-card: #0a1a12;
  --s-apa: #1f9d5c; --s-best: #d95926; --s-avg: #3987e5; --s-dom: #c98500; --s-imp: #d55181; --s-track: #9085e9; --s-dompo: #b8862a; --s-master: #6f877b; --s-other: #2f4a3e;
  --good: #3fbf7f; --bad: #e66767; --bad-wash: rgba(230, 103, 103, .14); --chart-surface: #14211d; --grid: rgba(226, 242, 234, .07); --axis: rgba(226, 242, 234, .16);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 34px -18px rgba(0, 0, 0, .8);
}

/* ---------- frame ---------- */
html, body { background: var(--ground); }
body { padding: var(--frame); font-size: 14px; }
.app {
  position: relative; border-radius: 34px; min-height: calc(100vh - 2 * var(--frame)); overflow: clip; isolation: isolate;
  background:
    radial-gradient(900px 520px at 6% -6%, var(--glow-1), transparent 62%),
    radial-gradient(760px 520px at 100% 8%, var(--glow-2), transparent 60%),
    radial-gradient(900px 640px at 55% 108%, var(--glow-3), transparent 62%),
    var(--bg);
}

/* notch: a piece of the dark frame that reaches into the app, with inverted rounded corners */
.notch { position: relative; z-index: 2; background: var(--ground); }
.notch::before, .notch::after { content: ""; position: absolute; width: var(--notch-r); height: var(--notch-r); pointer-events: none; }
.notch--top { width: fit-content; max-width: calc(100% - 2 * var(--notch-r) - 24px); margin: 0 auto; padding: 0 12px 12px; border-radius: 0 0 var(--notch-r) var(--notch-r); }
.notch--top::before { top: 0; right: 100%; background: radial-gradient(circle at 0 100%, transparent calc(var(--notch-r) - .5px), var(--ground) var(--notch-r)); }
.notch--top::after { top: 0; left: 100%; background: radial-gradient(circle at 100% 100%, transparent calc(var(--notch-r) - .5px), var(--ground) var(--notch-r)); }
.notch--bot { width: fit-content; max-width: calc(100% - 2 * var(--notch-r) - 24px); margin: 0 auto; padding: 10px 10px 0; border-radius: var(--notch-r) var(--notch-r) 0 0; }
.notch--bot::before { bottom: 0; right: 100%; background: radial-gradient(circle at 0 0, transparent calc(var(--notch-r) - .5px), var(--ground) var(--notch-r)); }
.notch--bot::after { bottom: 0; left: 100%; background: radial-gradient(circle at 100% 0, transparent calc(var(--notch-r) - .5px), var(--ground) var(--notch-r)); }

/* ---------- top bar: brand left, nav in the notch, tools right ---------- */
.shell { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 14px; background: transparent; color: var(--ink); padding: 0 22px 0 24px; min-height: 76px; }
.shell .notch--top { position: absolute; top: 0; left: 0; right: 0; }
.shell__brand { gap: 12px; min-width: 0; flex: 0 1 auto; }
.brand-logo { display: block; height: 40px; width: auto; background: #fff; border-radius: 13px; padding: 4px 10px; box-shadow: var(--shadow); }
.shell__mark { border-radius: 13px; background: var(--accent); width: 40px; height: 40px; }
.shell__title { font-size: 15px; font-weight: 700; color: var(--ink); }
.shell__sub { color: var(--mute); max-width: 300px; }
.tabs { background: var(--nav); border: 0; border-radius: 99px; padding: 5px; gap: 2px; display: flex; overflow-x: auto; scrollbar-width: none; }
.tabs a { color: var(--nav-ink); border: 0; border-radius: 99px; padding: 9px 16px; font-weight: 600; font-size: 13.5px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tabs a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.tabs a[aria-current="page"] { background: #f2faf6; color: #0d2a1c; box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.shell__tools { gap: 8px; flex: 0 0 auto; position: relative; z-index: 3; }
.proto-badge { border: 1px solid var(--line-2); color: var(--mute); background: var(--glass); border-radius: 99px; padding: 4px 10px; white-space: nowrap; }
.tool-btn { border: 1px solid var(--line); background: var(--glass-strong); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); color: var(--ink); border-radius: 99px; padding: 9px 15px; box-shadow: var(--shadow); font-weight: 600; }
.tool-btn:hover { background: var(--panel); }
.tool-btn--ghost { box-shadow: none; background: var(--glass); }

/* ---------- filters as glass pills ---------- */
.filterbar { background: transparent; border: 0; padding: 4px 24px 2px; gap: 10px 14px; }
.flabel { color: var(--mute); text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 600; }
select, input[type="search"] { border-radius: 99px; border: 1px solid var(--line); background: var(--glass-strong); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); padding: 7px 12px; box-shadow: var(--shadow); }
.preset { border-radius: 99px; border: 1px solid var(--line); background: var(--glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); padding: 6px 13px; font-weight: 500; }
.preset:hover { border-color: var(--accent); }
.preset.is-on { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 16px -8px rgba(0, 102, 51, .7); }
:root[data-theme="dark"] .preset.is-on { color: #06140f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .preset.is-on { color: #06140f; } }
.seg { border: 1px solid var(--line); background: var(--glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-radius: 99px; padding: 3px; gap: 2px; }
.seg__btn { border: 0 !important; background: transparent; border-radius: 99px; padding: 6px 12px; color: var(--mute); font-weight: 600; }
.seg__btn.is-on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(16, 35, 28, .14); }
.filterbar__note { color: var(--mute); }

/* ---------- page ---------- */
main { padding: 16px 24px 12px; }
.page__title { font-size: 32px; font-weight: 600; letter-spacing: -.025em; margin: 2px 0 4px; }
.page__sub { margin: 0 0 18px; color: var(--mute); font-size: 14px; }
.page__sub b { color: var(--ink); font-weight: 700; }
.card, .tile {
  border: 1px solid var(--glass-line); border-radius: var(--radius); box-shadow: var(--shadow);
  background: var(--glass); -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
}
.card { padding: 18px 20px 16px; }
.tile { padding: 16px 18px; }
.tile__label, .hero__label { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600; color: var(--mute); }
.tile__value { font-weight: 700; letter-spacing: -.02em; }
.card h2 { font-size: 15.5px; font-weight: 600; }
.chart { background: transparent; }

/* the dark feature card with concentric rings, as in the reference */
.hero {
  position: relative; overflow: hidden; border: 0; border-radius: var(--radius); box-shadow: var(--shadow-lg); color: var(--dark-ink);
  background:
    repeating-radial-gradient(circle at 92% 8%, rgba(255, 255, 255, .055) 0 1px, transparent 1px 16px),
    radial-gradient(130% 100% at 100% 0%, rgba(0, 153, 76, .35), transparent 55%),
    linear-gradient(165deg, #0e2a1c, var(--dark-card) 60%, #0b3a22);
}
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .10); box-shadow: 0 0 0 28px rgba(255, 255, 255, .025), 0 0 0 56px rgba(255, 255, 255, .02); pointer-events: none; }
.hero .hero__label { color: var(--dark-muted); }
.hero__num { color: #fff; }
.hero__num small { color: var(--dark-muted); }
.hero__line, .hero__line b { color: var(--dark-ink); }
.hero__foot { color: var(--dark-muted); }
.hero a { color: #a7e3c6; }

.pill { border-radius: 99px; padding: 2px 9px; }
.chip { border-radius: 99px; background: var(--glass-strong); border-color: var(--line); }
.callout { border-radius: 16px; border: 1px solid rgba(193, 61, 41, .18); background: var(--bad-wash); border-left: 4px solid var(--bad-fill); }
.op__why { border-radius: 12px; border-left-color: var(--accent); background: var(--panel-2); }
.oplist, .table-wrap { border-top-color: var(--line); }
.tbl th { background: var(--glass-strong); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); color: var(--mute); text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 600; }
.tbl td { border-bottom-color: var(--line); }
.tbl tbody tr:hover td { background: var(--accent-wash); }
.tbl tr.is-apa td { background: var(--accent-wash); }
.tbl tr.is-apa td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
.bar { border-radius: 99px; }
.drawer { -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.drawer__panel { border-radius: 24px 0 0 24px; background: var(--glass-strong); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.drawer__head { background: transparent; }
.tip { border-radius: 12px; }
.cta { color: var(--accent); }
.foot { padding: 6px 24px 14px; }

/* ---------- bottom notch: three stat pills ---------- */
.dock { position: sticky; bottom: 0; z-index: 10; margin-top: 8px; }
.dock .notch--bot { display: flex; gap: 10px; }
.stat {
  display: flex; align-items: center; gap: 12px; min-width: 0; padding: 9px 10px 9px 16px; border-radius: 22px 22px 0 0;
  background: color-mix(in oklab, var(--accent) 78%, #071a10); color: #fff; border: 0; cursor: pointer; text-align: left; font: inherit;
}
.stat:hover { background: color-mix(in oklab, var(--accent) 88%, #071a10); }
.stat__icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .14); flex: 0 0 auto; }
.stat__icon svg { width: 17px; height: 17px; }
.stat__text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.stat__value { font-weight: 700; font-size: 15px; white-space: nowrap; }
.stat__label { font-size: 12px; opacity: .8; white-space: nowrap; }
.stat__go { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, .35); margin-left: 6px; flex: 0 0 auto; }
.stat:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }

/* ---------- narrow screens ---------- */
@media (max-width: 1180px) {
  .shell { flex-wrap: wrap; padding-top: 70px; }
  .shell__sub { display: none; }
}
@media (max-width: 900px) {
  .stat__go { display: none; }
  .stat { padding: 8px 12px; }
}
@media (max-width: 720px) {
  :root { --frame: 6px; --notch-r: 18px; }
  .app { border-radius: 22px; }
  .shell { padding: 60px 12px 6px; min-height: 0; }
  .notch--top { padding: 0 8px 8px; max-width: calc(100% - 2 * var(--notch-r) - 8px); }
  .tabs a { padding: 9px 11px; font-size: 13px; min-height: 40px; }
  .brand-logo { height: 32px; padding: 3px 8px; }
  .shell__title { display: none; }
  .filterbar { padding: 0 12px 4px; }
  main { padding: 10px 12px 8px; }
  .page__title { font-size: 22px; }
  .page__sub { font-size: 13px; margin-bottom: 12px; }
  .dock .notch--bot { gap: 6px; padding: 6px 6px 0; max-width: calc(100% - 2 * var(--notch-r) - 8px); }
  .stat { padding: 7px 10px; gap: 8px; border-radius: 16px 16px 0 0; }
  .stat__icon { display: none; }
  .stat__value { font-size: 13px; }
  .stat__label { font-size: 11px; }
}
@media (max-height: 480px) {
  :root { --frame: 4px; }
  .app { border-radius: 16px; }
  .shell { padding: 52px 12px 4px; min-height: 0; }
  .tabs a { padding: 6px 12px; min-height: 34px; }
  .brand-logo { height: 30px; }
  .shell__title { display: none; }
  .dock { display: none; }
}
@media (prefers-contrast: more) {
  .card, .tile, .tool-btn, .seg, .preset, select, input[type="search"] { background: var(--panel) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
}
@media print {
  html, body { background: #fff; padding: 0; }
  .app { border-radius: 0; background: #fff; }
  .notch, .dock { display: none !important; }
  .shell { padding-top: 0; }
  .card, .tile { box-shadow: none; background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; border: 1px solid #ddd; }
  .hero { background: #fff; color: #111; border: 1px solid #ccc; box-shadow: none; }
  .hero::after { display: none; }
  .hero__num, .hero__line, .hero__line b, .hero__foot, .hero .hero__label, .hero__num small { color: #111; }
}

/* fit fixes after the first glass shots */
@media (min-width: 1181px) { .shell__brand { max-width: calc(50% - 330px); } }
@media (max-width: 1599px) { .proto-badge { display: none; } }
.stat { flex: 1 1 0; }
.stat__text { overflow: hidden; }
.stat__value, .stat__label { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 720px) {
  .dock .notch--bot { width: calc(100% - 2 * var(--notch-r) - 8px); }
  .stat { justify-content: center; text-align: center; }
  .stat__label { display: none; }
}
@media (max-width: 720px) {
  .dock .notch--bot { gap: 4px; padding: 5px 5px 0; }
  .stat { padding: 7px 4px; border-radius: 14px 14px 0 0; min-height: 44px; }
  .stat__value { font-size: 12px; letter-spacing: -.01em; overflow: visible; }
}

/* ---------- material picker ---------- */
.matbtn {
  display: grid; text-align: left; gap: 1px; min-width: 0; max-width: 340px; padding: 6px 14px 7px; border-radius: 16px; cursor: pointer;
  border: 1px solid var(--line); background: var(--glass-strong); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: var(--shadow); color: var(--ink); font: inherit;
}
.matbtn:hover { border-color: var(--accent); }
.matbtn[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash), var(--shadow); }
.matbtn__label { font-size: 11.5px; color: var(--mute); font-weight: 600; }
.matbtn__name { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; min-width: 0; }
.matbtn__name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matbtn__sub { font-size: 11.5px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.matpop {
  position: absolute; z-index: 40; top: 74px; left: 20px; width: min(520px, calc(100% - 40px)); max-height: min(70vh, 620px);
  display: flex; flex-direction: column; border-radius: 22px; border: 1px solid var(--glass-line); box-shadow: var(--shadow-lg);
  background: var(--glass-strong); -webkit-backdrop-filter: blur(22px) saturate(1.3); backdrop-filter: blur(22px) saturate(1.3); overflow: hidden;
}
.matpop__head { display: flex; gap: 8px; padding: 14px 14px 6px; align-items: center; }
.matpop__head input { flex: 1 1 auto; min-width: 0; }
.matpop__meta { margin: 0; padding: 0 16px 8px; font-size: 12px; color: var(--mute); }
.matpop__list { list-style: none; margin: 0; padding: 0 8px 8px; overflow: auto; flex: 1 1 auto; }
.mopt { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 8px 10px; border-radius: 12px; cursor: pointer; }
.mopt:hover, .mopt.is-active { background: var(--accent-wash); }
.mopt[aria-selected="true"] .mopt__name { color: var(--accent); }
.mopt__name { font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.mopt__meta { grid-column: 1; font-size: 12px; color: var(--mute); }
.mopt__tag { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 11.5px; font-weight: 700; border-radius: 99px; padding: 3px 9px; white-space: nowrap; }
.mopt__tag--full { background: var(--accent); color: #fff; }
.mopt__tag--cmp { background: rgba(47, 98, 214, .12); color: #2a58c2; }
.mopt__tag--none { background: var(--panel-2); color: var(--mute); }
.mopt--empty { color: var(--mute); cursor: default; }
.matpop__foot { margin: 0; padding: 10px 16px 12px; font-size: 12px; color: var(--mute); border-top: 1px solid var(--line); }
.page--nodata .nodata { max-width: 760px; margin: 24px auto; padding: 28px 30px; }
.nodata__kicker { margin: 0 0 4px; font-size: 12.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.nodata__text { color: var(--ink-2); font-size: 15px; line-height: 1.6; margin: 8px 0 18px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hi); }
@media (max-width: 1180px) { .matpop { top: 128px; } }
@media (max-width: 720px) {
  .matbtn { max-width: 52vw; padding: 5px 10px; }
  .matbtn__sub, .matbtn__label { display: none; }
  .matbtn__name { font-size: 12.5px; }
  .matpop { top: 112px; left: 8px; width: calc(100% - 16px); max-height: 72vh; }
  .mopt { min-height: 44px; }
}
@media (max-width: 1000px) { .stat__label { display: none; } }
/* picker button shows the whole name (wraps to two lines when needed); stat pills keep their natural width */
.matbtn__name > span { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; line-height: 1.25; }
.matbtn__name { font-size: 13.5px; }
.matbtn__sub { white-space: normal; overflow: visible; }
.stat { flex: 0 1 auto; }
.stat__value, .stat__label { overflow: visible; text-overflow: clip; }
@media (max-width: 720px) { .stat { flex: 1 1 0; } }

@media (max-width: 420px) { .stat__unit { display: none; } .stat__value { font-size: 11.5px; } }

/* ===== owner: "nền trắng, không dùng nền màu đậm" — the light theme has no dark surfaces at all.
   Component colours below come from tokens, so the dark theme keeps its look when chosen. ===== */
:root {
  --ground: #ffffff;
  --nav: #eef5f0; --nav-ink: #2b463b; --nav-on: #006633; --nav-on-ink: #ffffff;
  --hero-bg: linear-gradient(160deg, #f3faf6 0%, #e4f3ea 100%);
  --hero-ring: rgba(0, 102, 51, .07); --hero-ink: #0d2a1c; --hero-mute: #4f6b5e; --hero-num: #006633; --hero-link: #006633;
  --stat-bg: #ffffff; --stat-hover: #f2f8f4; --stat-ink: #10231c; --stat-icon: rgba(0, 102, 51, .10); --stat-icon-ink: #006633; --stat-go: rgba(16, 35, 28, .18);
  --frame-line: rgba(16, 35, 28, .08);
}
:root[data-theme="dark"] {
  --ground: #040a08;
  --nav: #0e2a1d; --nav-ink: #cfe6d8; --nav-on: #f2faf6; --nav-on-ink: #0d2a1c;
  --hero-bg: linear-gradient(165deg, #0e2a1c, #0a1a12 60%, #0b3a22);
  --hero-ring: rgba(255, 255, 255, .055); --hero-ink: #eaf5ef; --hero-mute: #a9c9b8; --hero-num: #ffffff; --hero-link: #a7e3c6;
  --stat-bg: #1f6b45; --stat-hover: #237a4f; --stat-ink: #ffffff; --stat-icon: rgba(255, 255, 255, .14); --stat-icon-ink: #ffffff; --stat-go: rgba(255, 255, 255, .35);
  --frame-line: transparent;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #040a08;
    --nav: #0e2a1d; --nav-ink: #cfe6d8; --nav-on: #f2faf6; --nav-on-ink: #0d2a1c;
    --hero-bg: linear-gradient(165deg, #0e2a1c, #0a1a12 60%, #0b3a22);
    --hero-ring: rgba(255, 255, 255, .055); --hero-ink: #eaf5ef; --hero-mute: #a9c9b8; --hero-num: #ffffff; --hero-link: #a7e3c6;
    --stat-bg: #1f6b45; --stat-hover: #237a4f; --stat-ink: #ffffff; --stat-icon: rgba(255, 255, 255, .14); --stat-icon-ink: #ffffff; --stat-go: rgba(255, 255, 255, .35);
    --frame-line: transparent;
  }
}
.app { box-shadow: inset 0 0 0 1px var(--frame-line); }
.notch::before, .notch::after { filter: none; }
.notch--top { box-shadow: 0 1px 0 var(--frame-line); }
.tabs { background: var(--nav); box-shadow: inset 0 0 0 1px var(--frame-line); }
.tabs a { color: var(--nav-ink); }
.tabs a:hover { color: var(--nav-on); background: rgba(0, 102, 51, .08); }
.tabs a[aria-current="page"] { background: var(--nav-on); color: var(--nav-on-ink); box-shadow: 0 4px 12px -6px rgba(0, 102, 51, .6); }
.hero {
  color: var(--hero-ink); border: 1px solid var(--frame-line);
  background: repeating-radial-gradient(circle at 92% 8%, var(--hero-ring) 0 1px, transparent 1px 16px), var(--hero-bg);
}
.hero::after { border-color: var(--hero-ring); box-shadow: 0 0 0 28px var(--hero-ring), 0 0 0 56px var(--hero-ring); opacity: .6; }
.hero .hero__label, .hero__num small, .hero__foot { color: var(--hero-mute); }
.hero__num { color: var(--hero-num); }
.hero__line, .hero__line b { color: var(--hero-ink); }
.hero a { color: var(--hero-link); }
.stat { background: var(--stat-bg); color: var(--stat-ink); box-shadow: inset 0 0 0 1px var(--frame-line); }
.stat:hover { background: var(--stat-hover); }
.stat__icon { background: var(--stat-icon); color: var(--stat-icon-ink); }
.stat__go { border-color: var(--stat-go); }
.stat:focus-visible { outline: 2px solid var(--accent); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --bg: #fdfefd; --glow-1: rgba(0, 122, 61, .06); --glow-2: rgba(47, 98, 214, .04); --glow-3: rgba(237, 161, 0, .04); } }
:root[data-theme="light"] { --bg: #fdfefd; --glow-1: rgba(0, 122, 61, .06); --glow-2: rgba(47, 98, 214, .04); --glow-3: rgba(237, 161, 0, .04); }
#mat-sap-wrap { display: none; }

/* owner: pure white background, no green tint anywhere behind the content (light theme) */
:root[data-theme="light"] {
  --ground: #ffffff; --bg: #ffffff;
  --glow-1: transparent; --glow-2: transparent; --glow-3: transparent;
  --glass: rgba(255, 255, 255, .92); --glass-strong: #ffffff;
  --hero-bg: #ffffff; --hero-ring: rgba(0, 102, 51, .06);
  --nav: #f3f6f4;
}
:root[data-theme="light"] .app { box-shadow: none; }
:root[data-theme="light"] .hero { border: 1px solid var(--line); box-shadow: var(--shadow); }

/* ===== v3: less text, details on hover, logo without its white box, light only, price board ===== */
#btn-theme { display: none !important; }
.brand-logo { background: transparent; box-shadow: none; padding: 0; border-radius: 0; mix-blend-mode: multiply; height: 42px; }

/* notes and guides leave the page; the same text shows when the pointer is on the card title */
.page__sub, #trend-empty, .foot-note, .more-hint, #t-note, .filterbar__note, .sr-list, .callout__text { display: none !important; }
.card__head { position: relative; }
.card__hint {
  display: none; position: absolute; z-index: 30; left: 0; top: calc(100% + 4px); max-width: 420px; padding: 10px 12px;
  background: #fff; color: var(--ink-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 12.5px; line-height: 1.5;
}
.card__head:hover .card__hint, .card__head:focus-within .card__hint { display: block; }
.card__head:has(.card__hint) h2::after {
  content: "i"; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 8px; border-radius: 50%;
  font: 700 11px/1 var(--font); color: var(--mute); border: 1px solid var(--line-2); vertical-align: 2px; cursor: help;
}

/* tiles: number first, the explanation on hover or tap */
.tile { position: relative; cursor: default; }
.tile__sub {
  display: none; position: absolute; z-index: 25; left: 12px; right: 12px; top: calc(100% - 6px); padding: 10px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 12.5px;
}
.tile:hover .tile__sub, .tile:focus-within .tile__sub, .tile:focus .tile__sub { display: block; }
.hero .hero__foot { display: none; }
.hero:hover .hero__foot { display: block; }

/* trend callout becomes just the month chips */
.callout { background: transparent; border: 0; padding: 0; margin: 2px 0 6px; }

/* ---------- price board ---------- */
.board-head { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 10px; }
.board-head .page__title { margin: 0; }
.board-sum { display: flex; gap: 8px 18px; flex-wrap: wrap; margin: 0 0 12px; font-size: 13px; color: var(--ink-2); }
.board-sum .up b { color: var(--bad); } .board-sum .down b { color: var(--good); }
.board-card { padding: 6px 8px 8px; }
.tbl--board { font-size: 13.5px; }
.tbl--board th { font-size: 12px; }
.tbl--board td { padding: 9px 10px; vertical-align: middle; }
.brow { cursor: pointer; transition: background 120ms ease-out; }
.brow:hover td, .brow:focus td { background: var(--accent-wash); }
.brow:focus { outline: none; }
.brow:focus-visible td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.brow.is-sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.bname { min-width: 220px; max-width: 420px; }
.bname__n { display: block; font-weight: 700; color: var(--ink); }
.bname__m { display: block; font-size: 11.5px; color: var(--mute); }
.bprice { font-weight: 700; font-size: 14.5px; }
.bprice.up { color: var(--bad); } .bprice.down { color: #0b7a3b; }
.bchg { display: inline-block; min-width: 72px; text-align: center; font-weight: 700; padding: 3px 8px; border-radius: 8px; font-size: 12.5px; }
.bchg.up { background: rgba(208, 59, 59, .12); color: var(--bad); }
.bchg.down { background: rgba(12, 163, 12, .12); color: #0b7a3b; }
.spark { display: block; margin-left: auto; }
@media (max-width: 720px) { .bname { min-width: 0; } .tbl--board td { padding: 8px 6px; } .bchg { min-width: 0; } }
.chips { flex-wrap: nowrap !important; overflow-x: auto !important; -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent) !important; mask-image: linear-gradient(90deg, #000 92%, transparent) !important; scrollbar-width: none; }

@media (max-width: 560px) {
  .hide-xs { display: none; }
  .board-head .row-gap { width: 100%; }
  .board-head .seg { flex: 1 1 auto; }
  .bname__n { font-size: 13px; }
}

.brank { font-weight: 800; }
.brank.is-1 { color: #fff; background: var(--accent); border-radius: 8px; padding: 2px 7px; }
.brank.is-top { color: var(--accent); }

/* hover bubbles sit above neighbouring cards (each glass card is its own stacking layer) */
.tile:hover, .tile:focus-within, .tile:focus, .hero:hover { z-index: 45; }
.card:hover, .card:focus-within { z-index: 40; position: relative; }
.overview, .tiles, .strip, .grid2 { isolation: auto; }

/* ---------- upload ---------- */
.drop {
  display: grid; justify-items: center; gap: 6px; padding: 30px 20px; margin-bottom: 16px; cursor: pointer; text-align: center;
  border: 2px dashed var(--line-2); border-radius: 22px; background: #fff; transition: border-color 150ms ease-out, background 150ms ease-out;
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: var(--accent-wash); }
.drop.is-busy { opacity: .6; pointer-events: none; }
.drop__icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent); }
.drop__title { font-weight: 700; font-size: 15px; }
.drop__sub { font-size: 12.5px; color: var(--mute); }
.ok-text { color: #0b7a3b; }

/* the menu grew to 6 tabs: it hangs in its own row at the top, brand + picker + tools sit under it at every width */
.shell { flex-wrap: wrap; padding-top: 68px; padding-bottom: 6px; min-height: 0; }
.shell__brand { max-width: none !important; flex: 1 1 auto; }
.matbtn { max-width: 420px; }
@media (max-width: 720px) { .shell { padding-top: 60px; } }
@media (max-height: 480px) { .shell { padding-top: 52px; } }

/* ---------- AI assistant ---------- */
.drawer--ai .drawer__panel { width: min(720px, 100%); display: flex; flex-direction: column; }
.ai__body { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; min-height: 0; }
#ai-chat { overflow: hidden; }
#ai-cfg { overflow: auto; }
.ai__warn { margin: 0; padding: 10px 12px; border-radius: 12px; background: #fff7e6; color: #7a5200; font-size: 13px; }
.ai__ctx { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: var(--panel-2); }
.ai__ctx-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.ai__checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; }
.ai__checks .check { font-size: 12.5px; min-height: 0; }
.ai__preview summary { cursor: pointer; font-size: 12.5px; color: var(--accent); margin-top: 6px; }
.ai__preview pre { max-height: 200px; overflow: auto; white-space: pre-wrap; font-size: 11.5px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.ai__quick { display: flex; gap: 6px; flex-wrap: wrap; }
.ai__chip { color: var(--ink-2) !important; font-weight: 500 !important; font-size: 12.5px; white-space: normal; text-align: left; }
.ai__log { flex: 1 1 auto; min-height: 160px; overflow: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; }
.ai__msg { padding: 10px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.55; max-width: 92%; }
.ai__msg p { margin: 0 0 6px; } .ai__msg ul { margin: 0 0 6px; padding-left: 18px; }
.ai__msg--user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.ai__msg--assistant { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.ai__typing { color: var(--mute); font-style: italic; }
.ai__copy { font-size: 12px; margin-top: 4px; }
.ai__form textarea { width: 100%; resize: vertical; border: 1px solid var(--line-2); border-radius: 14px; padding: 10px 12px; font: inherit; }
.ai__field { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 10px; }
.ai__field input, .ai__field textarea { border: 1px solid var(--line-2); border-radius: 12px; padding: 8px 10px; font: inherit; font-weight: 400; background: #fff; }
.ai__field input[type="range"] { padding: 0; border: 0; }
.ai__keyrow { display: flex; gap: 6px; } .ai__keyrow input { flex: 1 1 auto; }
.ai__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ai__hint { margin: -4px 0 10px; font-size: 12px; color: var(--mute); }
#btn-ai { font-weight: 700; }
@media (max-width: 720px) { .ai__checks, .ai__grid { grid-template-columns: 1fr; } #btn-ai { padding: 8px 12px; } }

.ai__h { display: block; font-size: 14.5px; margin: 6px 0 4px; color: var(--accent); }

/* ---------- Auth gate, left-corner user management & iframe link manager ---------- */
.auth-gate {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 520px at 8% 0%, rgba(0, 122, 61, .28), transparent 60%),
    radial-gradient(760px 520px at 96% 12%, rgba(47, 98, 214, .18), transparent 58%),
    var(--ground);
}
.auth-card {
  width: min(440px, 100%); padding: 28px 26px 24px; border-radius: 26px;
  background: rgba(255, 255, 255, .94); box-shadow: var(--shadow-lg);
}
.auth-card__brand { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.auth-card__title { margin: 0 0 2px; font-size: 20px; font-weight: 700; color: var(--ink); }
.auth-card__sub { margin: 0; font-size: 13px; color: var(--mute); }
.auth-form { display: grid; gap: 6px; margin-top: 10px; }
.auth-submit { width: 100%; justify-content: center; padding: 11px 16px; margin-top: 6px; font-size: 14px; font-weight: 700; }

.auth-corner {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px;
  border-radius: 99px; background: var(--glass); border: 1px solid var(--line);
  box-shadow: var(--shadow); flex-shrink: 0;
}
.auth-corner__btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  background: var(--accent); color: #fff; border-color: var(--accent); font-size: 12.5px;
}
.auth-corner__btn:hover { background: var(--accent-hi); }
.auth-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 99px; background: rgba(255, 255, 255, .24); font-size: 11px; font-weight: 700;
}
.auth-corner__user {
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 0 6px;
  max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.auth-corner__logout { padding: 6px 10px; font-size: 12.5px; }

.drawer--users { justify-content: flex-end; }
.drawer--users .drawer__panel { width: min(820px, 100%); display: flex; flex-direction: column; border-left: 1px solid var(--line); border-right: 0; }
.users-add { background: var(--panel); margin-bottom: 14px; }
.users-add h3, .users-panel h3 { margin: 0 0 10px; font-size: 14.5px; font-weight: 700; }
.users-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; }
.users-form-grid .ai__field { margin-bottom: 6px; }
.users-form-grid select { border-radius: 12px; }
.users-msg { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; font-size: 13px; font-weight: 600; }
.users-msg--ok { background: rgba(0, 102, 51, .11); color: #0b5d31; }
.users-msg--err { background: var(--bad-wash); color: var(--bad); }
.pill-btn {
  border: 1px solid transparent; border-radius: 99px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.pill-btn--on { background: rgba(0, 102, 51, .12); color: #006633; border-color: rgba(0, 102, 51, .25); }
.pill-btn--off { background: var(--bad-wash); color: var(--bad); border-color: rgba(181, 54, 31, .25); }
.users-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-xs { padding: 4px 10px !important; font-size: 12px !important; min-height: 0 !important; }
.btn-danger { color: var(--bad) !important; border-color: rgba(181, 54, 31, .3) !important; }
.pw-row td { background: var(--panel-2); }
.pw-input { flex: 1; min-width: 180px; border: 1px solid var(--line-2); border-radius: 10px; padding: 5px 10px; background: #fff; }

.embed-list { display: grid; gap: 12px; }
.embed-item { background: var(--panel); padding: 14px 16px; margin-bottom: 0; }
.embed-item__top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.embed-url-box { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.embed-url-input {
  flex: 1; min-width: 0; border: 1px solid var(--line-2); border-radius: 10px; padding: 6px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--panel-2);
}
.embed-code-preview {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; resize: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--mute); background: var(--panel-2);
}

@media (max-width: 720px) {
  .users-form-grid { grid-template-columns: 1fr; }
  .auth-corner { width: auto; justify-content: flex-end; }
}

/* ---------- Menu sits below the logo row; tools & user admin stay on the right ---------- */
.shell { padding: 12px 24px 6px !important; row-gap: 10px; align-items: center; }
.shell .notch--top {
  position: static; order: 3; flex: 1 1 100%;
  display: flex; justify-content: center;
  width: 100%; max-width: 100%; margin: 2px auto 0; padding: 0;
  background: transparent; box-shadow: none;
}
.shell .notch--top::before, .shell .notch--top::after { display: none; }
.shell__tools { flex-wrap: wrap; justify-content: flex-end; }
.matpop { top: 68px; }
@media (max-width: 1180px) { .matpop { top: 68px; } }
@media (max-width: 720px) {
  .shell { padding: 10px 12px 6px !important; }
  .shell__tools { justify-content: flex-start; }
  .matpop { top: 118px; }
}
@media (max-height: 480px) {
  .shell { padding: 8px 12px 4px !important; }
}
