/* Farm Analyzer design system. Plain CSS, served from 'self' (CSP: no inline styles, no external fonts). */
:root {
  --bg: #f2f4f3;
  --bg-glow-1: rgba(16, 185, 129, .10);
  --bg-glow-2: rgba(234, 179, 8, .07);
  --panel: #ffffff;
  --panel-2: #f8faf9;
  --ink: #0f1a15;
  --ink-2: #33413a;
  --muted: #66746d;
  --line: #e3e8e5;
  --line-strong: #d3dbd6;
  --accent: #059669;
  --accent-2: #10b981;
  --accent-deep: #047857;
  --accent-ink: #ffffff;
  --accent-soft: rgba(16, 185, 129, .12);
  --gold: #ca8a04;
  --warn: #a16207;
  --warn-bg: #fef6dc;
  --warn-line: #f6e1a1;
  --bad: #c0262d;
  --bad-bg: #fdeceb;
  --bad-line: #f6c9c6;
  --good: #047857;
  --good-bg: #e2f6ec;
  --good-line: #bce8d2;
  --info: #1d5fbf;
  --info-bg: #e9f1fd;
  --info-line: #c9dcf8;
  --chip: #eef2f0;
  --row-hover: #eef5f1;
  --zebra: #f7f9f8;
  --shadow-sm: 0 1px 2px rgba(16, 24, 20, .05);
  --shadow: 0 1px 2px rgba(16, 24, 20, .04), 0 4px 16px -4px rgba(16, 24, 20, .08);
  --shadow-lg: 0 2px 4px rgba(16, 24, 20, .04), 0 16px 40px -12px rgba(16, 24, 20, .18);
  --gloss: linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 55%);
  --side-bg: linear-gradient(180deg, #0f2a20 0%, #0b1f18 55%, #08160f 100%);
  --side-ink: #d5e5dc;
  --side-muted: #7f9a8b;
  --side-line: rgba(255, 255, 255, .08);
  --side-hover: rgba(255, 255, 255, .06);
  --radius: 14px;
  --radius-sm: 9px;
  --sans: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a100d; --bg-glow-1: rgba(16, 185, 129, .10); --bg-glow-2: rgba(234, 179, 8, .05);
    --panel: #121a16; --panel-2: #0f1613; --ink: #e8efeb; --ink-2: #c3cfc8; --muted: #8b9a92;
    --line: #1f2a25; --line-strong: #2a3832;
    --accent: #10b981; --accent-2: #34d399; --accent-deep: #059669; --accent-ink: #04140d; --accent-soft: rgba(52, 211, 153, .14);
    --gold: #facc15;
    --warn: #f5c150; --warn-bg: rgba(245, 193, 80, .10); --warn-line: rgba(245, 193, 80, .25);
    --bad: #ff8f87; --bad-bg: rgba(255, 110, 100, .10); --bad-line: rgba(255, 110, 100, .25);
    --good: #5ee0a6; --good-bg: rgba(52, 211, 153, .10); --good-line: rgba(52, 211, 153, .25);
    --info: #8cb8ff; --info-bg: rgba(110, 160, 255, .10); --info-line: rgba(110, 160, 255, .25);
    --chip: #1b2520; --row-hover: #18241e; --zebra: #141d18;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px -8px rgba(0, 0, 0, .5);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .4), 0 20px 48px -12px rgba(0, 0, 0, .7);
    --gloss: linear-gradient(180deg, rgba(255, 255, 255, .25), rgba(255, 255, 255, 0) 55%);
    --side-bg: linear-gradient(180deg, #0d1a14 0%, #09130f 100%);
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); min-height: 100vh;
  background:
    radial-gradient(900px 500px at 100% -10%, var(--bg-glow-1), transparent 70%),
    radial-gradient(700px 420px at 20% -20%, var(--bg-glow-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  font: 14.5px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-deep); }
h1 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -.025em; font-weight: 700; margin: 0 0 .35rem; }
h1 small { font-size: .55em; font-weight: 500; letter-spacing: 0; }
h2 { font-size: 1.08rem; letter-spacing: -.01em; font-weight: 650; margin: 1.75rem 0 .7rem; }
h3 { font-size: .95rem; font-weight: 650; margin: 1.1rem 0 .45rem; color: var(--ink-2); }
p { margin: .4rem 0 .85rem; }
small, .muted { color: var(--muted); }
.main > p.muted:first-of-type, h1 + p.muted { max-width: 75ch; }
code, .mono { font-family: var(--mono); font-size: .86em; }
code { background: var(--chip); border: 1px solid var(--line); padding: .05em .35em; border-radius: 6px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
ol, ul { padding-left: 1.3rem; }
li { margin: .2rem 0; }
::selection { background: var(--accent-soft); }

/* ---------- shell ---------- */
.layout { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side-bg); color: var(--side-ink);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 1.1rem .85rem 1rem; display: flex; flex-direction: column;
  border-right: 1px solid rgba(0, 0, 0, .2);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .04);
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.brand { display: flex; align-items: center; gap: .7rem; padding: .2rem .45rem .9rem; color: inherit; text-decoration: none; font-weight: 700; letter-spacing: -.01em; font-size: 1.02rem; }
.brand:hover { color: inherit; }
.brand small { display: block; font-weight: 500; font-size: .74rem; color: var(--side-muted); letter-spacing: 0; }
.logo { width: 34px; height: 34px; flex: none; border-radius: 9px; box-shadow: 0 4px 14px -2px rgba(16, 185, 129, .55), inset 0 1px 0 rgba(255, 255, 255, .3); }
.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav-group { font-size: .68rem; font-weight: 650; text-transform: uppercase; letter-spacing: .09em; color: var(--side-muted); padding: 1rem .7rem .35rem; }
.nav-group:first-child { padding-top: .35rem; }
.nav a {
  display: flex; align-items: center; gap: .7rem; padding: .5rem .7rem; border-radius: 10px;
  color: var(--side-ink); text-decoration: none; font-weight: 500; font-size: .92rem;
  transition: background .15s, color .15s;
}
.nav a svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a.on {
  color: #fff; position: relative;
  background: linear-gradient(90deg, rgba(16, 185, 129, .28), rgba(16, 185, 129, .08));
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, .22);
}
.nav a.on::before { content: ""; position: absolute; left: -.85rem; top: 22%; bottom: 22%; width: 3px; border-radius: 0 3px 3px 0; background: #34d399; box-shadow: 0 0 12px #34d399; }
.nav a.on svg { opacity: 1; color: #6ee7b7; }
.userbox { margin-top: auto; padding: .7rem .55rem .2rem; border-top: 1px solid var(--side-line); display: flex; align-items: center; gap: .6rem; }
.nav-group + .userbox, .nav a + .userbox { margin-top: 1.25rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: #062417; background: linear-gradient(135deg, #6ee7b7, #10b981); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4); }
.who { flex: 1; min-width: 0; font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { display: block; color: var(--side-muted); font-weight: 500; font-size: .72rem; text-transform: capitalize; }
.side button.ghost { background: transparent; color: var(--side-muted); border-color: var(--side-line); box-shadow: none; }
.side button.ghost:hover { color: #fff; background: var(--side-hover); }
.menu-toggle { display: none; }
.main { padding: 2rem 2.25rem 4rem; min-width: 0; max-width: 1480px; width: 100%; }
.main > h1:first-child, .main > .spread:first-child, .main > .flash + h1, .main > .flash + .spread { margin-top: 0; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; z-index: 20; height: auto; max-height: 100vh; padding: .6rem .9rem; border-right: 0; box-shadow: 0 6px 24px -10px rgba(0, 0, 0, .5); }
  .brand { padding: .15rem 0; }
  .logo { width: 30px; height: 30px; }
  .menu-toggle {
    display: inline-flex; align-items: center; gap: .4rem; background: rgba(255, 255, 255, .06); color: var(--side-ink);
    border: 1px solid var(--side-line); box-shadow: none; padding: .4rem .7rem;
  }
  .menu-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .menu-toggle:hover { background: var(--side-hover); }
  .nav { display: none; padding: .4rem 0 .6rem; }
  .nav.open { display: flex; }
  .nav a.on::before { left: -.9rem; }
  .main { padding: 1.25rem 1rem 3rem; }
  h1 { font-size: 1.45rem; }
}

/* public pages (login, no access) */
.public { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.public .main.narrow { margin: 0; max-width: 460px; padding: 0; }
.public-brand { color: var(--ink); justify-content: center; padding-bottom: 1.25rem; font-size: 1.15rem; }
.public-brand small { color: var(--muted); }
.public-brand .logo { width: 44px; height: 44px; border-radius: 12px; }
.public .panel { padding: 1.75rem; box-shadow: var(--shadow-lg); }
.public .panel h1 { font-size: 1.4rem; }
.public .panel .btn.primary, .public .panel button { width: 100%; text-align: center; justify-content: center; padding: .7rem 1rem; }
.public .panel form { margin-top: .6rem; }
.narrow { max-width: 640px; margin: 3rem auto; }

/* ---------- surfaces ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel table { margin: 0 -.25rem; width: calc(100% + .5rem); }
.grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); margin-bottom: 1rem; }
.tile {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem 1.05rem; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.tile::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), transparent);
  opacity: .85;
}
.tile::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 140px; height: 140px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 65%); opacity: .7; pointer-events: none;
}
.tile:has(a):hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
.tile .v { font-size: 1.85rem; line-height: 1.15; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tile .k { color: var(--muted); font-size: .82rem; font-weight: 500; margin-top: .2rem; }
.tile a { text-decoration: none; color: inherit; display: block; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; margin-bottom: .35rem; }
.spread > h1 { margin-bottom: 0; }
.spread > p { margin: .4rem 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.cols > .panel { margin-bottom: 0; }
.cols + * { margin-top: 1rem; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; } .tile .v { font-size: 1.45rem; } .tile { padding: .85rem .9rem; } }

/* ---------- tables ---------- */
.tablewrap {
  overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); box-shadow: var(--shadow); margin-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
}
table { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: .62rem .8rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th {
  font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  background: var(--panel-2); position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
th a { color: inherit; text-decoration: none; }
th a:hover { color: var(--ink); }
td.n, th.n { text-align: right; white-space: nowrap; }
tbody tr { transition: background .12s; }
tr:last-child td { border-bottom: 0; }
tr.sub td { background: var(--panel-2); font-size: .88rem; }
td a { font-weight: 550; text-decoration: none; }
td a:hover { text-decoration: underline; }
td.empty { padding: 1.75rem; }

/* readability for long lists */
.tablewrap td { font-size: .9rem; line-height: 1.4; padding-top: .55rem; padding-bottom: .55rem; }
.tablewrap td.n, .tablewrap th.n { padding-left: .5rem; padding-right: .7rem; }
.tablewrap tbody tr:nth-child(even) > td { background: var(--zebra); }
.tablewrap tbody tr:hover > td { background: var(--row-hover); }
.tablewrap td:first-child > a:first-child { font-weight: 650; font-size: .95rem; }
.tablewrap td > br + small, .tablewrap td > div > small { display: inline-block; margin-top: .15rem; line-height: 1.4; }
.tablewrap td > small:only-child, .tablewrap td > div:only-of-type > small { color: var(--ink-2); }
.tablewrap td:has(> small:only-child) { min-width: 9.5rem; }
/* long explanations: two lines in the table, full text under "Evidence" / on the detail page */
.tablewrap td > div > small { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; font-size: .8rem; }
.tablewrap td.mw16 { min-width: 15rem; max-width: 22rem; }
.tablewrap td details.evidence:not([open]) { margin-top: .1rem; }
.tablewrap td details.evidence > summary { font-size: .74rem; }
.tablewrap td.n { font-weight: 550; color: var(--ink); }
.tablewrap td .chip + small { white-space: nowrap; margin-left: .2rem; }
.tablewrap td details.evidence[open] { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; margin-top: .45rem; }
.tablewrap th { border-bottom: 1px solid var(--line-strong); }
/* Tables only scroll sideways inside their card; up and down is always the page itself, so the
   mouse wheel never gets trapped in a table and nothing is cut off. */
@media (max-width: 860px) {
  /* keep the name column pinned while scrolling sideways */
  .tablewrap td:first-child, .tablewrap th:first-child { position: sticky; left: 0; z-index: 1; box-shadow: inset -1px 0 0 var(--line); }
  .tablewrap td:first-child { background: var(--panel); }
  .tablewrap th:first-child { z-index: 2; }
  .tablewrap td:first-child { min-width: 9.5rem; max-width: 12rem; }
  .tablewrap table:has(> thead th:first-child input[type=checkbox]) :is(td, th):first-child { min-width: 0; box-shadow: none; }
  .tablewrap table:has(> thead th:first-child input[type=checkbox]) :is(td, th):nth-child(2) { position: sticky; left: 2.45rem; z-index: 1; min-width: 9.5rem; box-shadow: inset -1px 0 0 var(--line); }
  .tablewrap table:has(> thead th:first-child input[type=checkbox]) td:nth-child(2) { background: var(--panel); }
  .tablewrap table:has(> thead th:first-child input[type=checkbox]) th:nth-child(2) { z-index: 2; }
  th, td { padding: .55rem .6rem; }
}

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .6rem; border-radius: 999px;
  background: var(--chip); color: var(--ink-2); border: 1px solid var(--line);
  font-size: .76rem; font-weight: 600; line-height: 1.5; white-space: nowrap; vertical-align: middle;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.chip.good { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.chip.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.chip.info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.a-increase { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.a-maintain { background: var(--chip); }
.a-reduce, .a-monitor { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.a-investigate { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.a-consider_removing { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.a-insufficient_evidence { background: var(--chip); color: var(--muted); }
a:has(> .chip) { text-decoration: none; color: var(--ink); font-weight: 650; display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .45rem .2rem .2rem; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); transition: border-color .15s, box-shadow .15s; }
a:has(> .chip):hover { border-color: var(--line-strong); box-shadow: var(--shadow); color: var(--ink); }
a:has(> .chip) > .chip { border-color: transparent; }

/* ---------- callouts ---------- */
.flash, .note, .warnbox {
  position: relative; padding: .75rem 1rem .75rem 2.1rem; border-radius: var(--radius-sm); margin: .7rem 0 1rem;
  border: 1px solid transparent; font-size: .92rem;
}
.flash::before, .note::before, .warnbox::before {
  content: ""; position: absolute; left: .95rem; top: 1.18rem; width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 18%, transparent);
}
.flash.ok { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.flash.err { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.note { background: var(--info-bg); color: var(--ink-2); border-color: var(--info-line); }
.note::before { color: var(--info); }
.warnbox { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.flash a, .warnbox a { color: inherit; font-weight: 650; }
.empty { padding: 2.25rem 1.5rem; text-align: center; color: var(--muted); }
.panel.empty { border-style: dashed; box-shadow: none; background: var(--panel-2); }

/* ---------- forms ---------- */
form.inline { display: inline; }
label { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; letter-spacing: .01em; }
label.check { display: inline-flex; gap: .45rem; align-items: center; color: var(--ink-2); font-size: .88rem; font-weight: 500; margin: 0; cursor: pointer; }
input, select, textarea, button {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: .48rem .7rem; max-width: 100%;
  transition: border-color .15s, box-shadow .15s, background .15s, transform .08s;
}
input, select, textarea { box-shadow: inset 0 1px 2px rgba(16, 24, 20, .04); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input:disabled, select:disabled { opacity: .55; cursor: not-allowed; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366746d' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .6rem center; background-size: 14px;
}
textarea { width: 100%; font-family: var(--mono); font-size: .84rem; line-height: 1.5; padding: .75rem .85rem; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 1.05rem; height: 1.05rem; padding: 0; accent-color: var(--accent); box-shadow: none; cursor: pointer; vertical-align: middle; }
input[type=file] { padding: .35rem; }
input[type=file]::file-selector-button { font: inherit; font-size: .85rem; font-weight: 600; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--chip); color: var(--ink); padding: .3rem .7rem; margin-right: .6rem; cursor: pointer; }

button, .btn {
  cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap;
  display: inline-flex; align-items: center; gap: .4rem; vertical-align: middle;
  padding: .5rem .95rem; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  font-size: .88rem; font-weight: 600; line-height: 1.3;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .5);
}
button:hover, .btn:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--line-strong)); color: var(--ink); box-shadow: var(--shadow); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .6; cursor: progress; transform: none; }
button.primary, .btn.primary {
  color: #fff; border-color: var(--accent-deep);
  background: var(--gloss), linear-gradient(180deg, var(--accent-2), var(--accent) 60%, var(--accent-deep));
  box-shadow: 0 1px 2px rgba(4, 120, 87, .3), 0 6px 16px -6px rgba(5, 150, 105, .6), inset 0 1px 0 rgba(255, 255, 255, .28);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .12);
}
button.primary:hover, .btn.primary:hover { color: #fff; filter: brightness(1.06) saturate(1.05); box-shadow: 0 1px 2px rgba(4, 120, 87, .3), 0 10px 22px -6px rgba(5, 150, 105, .65), inset 0 1px 0 rgba(255, 255, 255, .3); }
button.danger, .btn.danger {
  color: #fff; border-color: #a11d23;
  background: var(--gloss), linear-gradient(180deg, #ef4444, #c0262d);
  box-shadow: 0 6px 16px -8px rgba(192, 38, 45, .7), inset 0 1px 0 rgba(255, 255, 255, .25);
}
button.danger:hover { color: #fff; filter: brightness(1.06); }
button.small, .btn.small { padding: .3rem .65rem; font-size: .8rem; border-radius: 8px; }
@media (prefers-color-scheme: dark) {
  button, .btn { box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .04); }
  button.primary, .btn.primary { color: #03150d; text-shadow: none; }
  button.primary:hover, .btn.primary:hover { color: #03150d; }
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.filters { display: flex; flex-wrap: wrap; gap: .85rem 1rem; align-items: flex-end; }
.filters > div { min-width: 120px; }
.filters > div > select + select { margin-left: .25rem; }
.filters input[type=number] { width: 7.5rem; }
.filters .row { gap: 1rem; padding-bottom: .45rem; }
form.panel.filters { padding: 1.1rem 1.25rem; }
@media (max-width: 860px) {
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .filters > div { min-width: 0; }
  .filters > div > input:not([type=checkbox]), .filters > div > select:only-of-type, .filters input[type=number] { width: 100%; }
  .filters > .row { grid-column: 1 / -1; padding-bottom: 0; }
  .filters > div:last-child:not(.row) { grid-column: 1 / -1; }
  .filters > div:last-child > button { width: 100%; justify-content: center; }
}
.panel td { white-space: normal; }
.panel td:has(> small), .panel td:has(> .chip) { white-space: nowrap; }

details summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details summary:hover { color: var(--accent-deep); }
details.panel > summary { list-style: none; display: flex; align-items: center; gap: .5rem; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin-right: .2rem; }
details.panel[open] > summary::before { transform: rotate(45deg); }
details.panel[open] > summary { margin-bottom: .85rem; }
details.evidence { font-size: .84rem; margin-top: .3rem; }
details.evidence > summary { font-size: .78rem; display: inline-block; }
details.evidence ul { margin: .35rem 0; }
details.evidence pre { white-space: pre-wrap; background: var(--panel-2); border: 1px solid var(--line); padding: .6rem .7rem; border-radius: 8px; overflow-x: auto; }
details.inline { display: inline-block; vertical-align: top; }
details.inline > summary { list-style: none; color: var(--ink); }
details.inline > summary::-webkit-details-marker { display: none; }
details.inline > .panel { box-shadow: var(--shadow-lg); min-width: 260px; }

/* ---------- data bits ---------- */
.bar { height: 8px; background: var(--chip); border-radius: 999px; overflow: hidden; min-width: 60px; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .08); }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: .5rem 0 1rem; }
.kv dt { color: var(--muted); font-size: .85rem; font-weight: 500; }
.kv dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.pager { margin-top: 1rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; color: var(--muted); font-size: .88rem; }
.mapbox { width: 100%; max-width: 680px; aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: var(--radius); display: block;
  background: radial-gradient(circle at 50% 50%, var(--panel), var(--panel-2)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .02), var(--shadow-sm); }
.legend { display: flex; flex-wrap: wrap; gap: .35rem 1rem; align-items: center; color: var(--muted); font-size: .84rem; }
.legend span { display: inline-flex; align-items: center; }
.legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .35rem; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, var(--chip)); }
svg.chart { overflow: visible; }
svg.chart text { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
svg.chart .axis { stroke: var(--line-strong); }
svg.chart .series { fill: var(--accent); }
svg.chart .line { stroke: var(--accent); fill: none; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.doc { white-space: pre-wrap; font-family: var(--mono); font-size: .84rem; line-height: 1.6; margin: 0; overflow-wrap: anywhere; }


/* ---------- settings ---------- */
.toc { gap: .35rem .5rem; margin: .4rem 0 1.2rem; }
.toc a { font-size: .84rem; font-weight: 600; text-decoration: none; padding: .25rem .65rem; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); }
.toc a:hover { border-color: var(--line-strong); color: var(--ink); }
.panel > h2 { margin-top: 0; }
.panel[id], .sub[id] { scroll-margin-top: 1rem; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem 1.5rem; align-items: start; }
.field.wide { grid-column: 1 / -1; max-width: 40rem; }
.field:has(fieldset) { grid-column: span 2; }
@media (max-width: 860px) { .field:has(fieldset) { grid-column: auto; } }
.field fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: .45rem; }
.field legend { font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: .35rem; padding: 0; }
.field fieldset label.check { align-items: flex-start; }
.field fieldset label.check input { margin-top: .2rem; }
.with-unit { display: flex; align-items: center; gap: .5rem; }
.with-unit input[type=number] { width: 8rem; }
.with-unit select { min-width: 13rem; }
.unit { color: var(--muted); font-size: .85rem; }
.help { display: block; margin-top: .3rem; font-size: .8rem; line-height: 1.4; }
details.panel > summary { font-size: 1.02rem; font-weight: 650; color: var(--ink); }
.sub { border-top: 1px solid var(--line); padding-top: .4rem; margin-top: 1rem; }
.sub > h3 { margin-top: .6rem; }
@media (max-width: 860px) { .with-unit input[type=number], .with-unit select { width: 100%; min-width: 0; } }

/* ---------- "your setup" bar ---------- */
details.setup { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .55rem .9rem; margin: .4rem 0 1rem; box-shadow: var(--shadow-sm); }
details.setup > summary { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1.1rem; color: var(--ink-2); font-weight: 500; font-size: .86rem; }
details.setup > summary::-webkit-details-marker { display: none; }
details.setup > summary strong { color: var(--ink); font-weight: 650; }
.setup-k { font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.setup-edit { margin-left: auto; color: var(--accent); font-weight: 650; }
details.setup[open] .setup-edit { visibility: hidden; }

/* ---------- raid fill bar ---------- */
.fill { display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; white-space: nowrap; }
.fill-bar { display: inline-block; width: 54px; height: 7px; border-radius: 999px; background: var(--chip); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.fill-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.fill-too_few .fill-bar i { background: var(--warn); }
.fill-too_many .fill-bar i { background: var(--info); }
.fill-empty .fill-bar i { background: var(--bad); }
.fill-bar i.w0 { width: 0%; }
.fill-bar i.w5 { width: 5%; }
.fill-bar i.w10 { width: 10%; }
.fill-bar i.w15 { width: 15%; }
.fill-bar i.w20 { width: 20%; }
.fill-bar i.w25 { width: 25%; }
.fill-bar i.w30 { width: 30%; }
.fill-bar i.w35 { width: 35%; }
.fill-bar i.w40 { width: 40%; }
.fill-bar i.w45 { width: 45%; }
.fill-bar i.w50 { width: 50%; }
.fill-bar i.w55 { width: 55%; }
.fill-bar i.w60 { width: 60%; }
.fill-bar i.w65 { width: 65%; }
.fill-bar i.w70 { width: 70%; }
.fill-bar i.w75 { width: 75%; }
.fill-bar i.w80 { width: 80%; }
.fill-bar i.w85 { width: 85%; }
.fill-bar i.w90 { width: 90%; }
.fill-bar i.w95 { width: 95%; }
.fill-bar i.w100 { width: 100%; }

/* ---------- view switcher and summary pills ---------- */
.views { display: grid; gap: .45rem; margin: .6rem 0 .3rem; }
.views .row { gap: .35rem; }
.views-k { font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); min-width: 5.5rem; }
.pills { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 1rem; }
.pill { display: inline-flex; flex-direction: column; padding: .45rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); text-decoration: none; color: var(--ink); box-shadow: var(--shadow-sm); min-width: 7.5rem; }
a.pill:hover { border-color: var(--line-strong); box-shadow: var(--shadow); color: var(--ink); }
.pill b { font-size: 1.2rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.pill small { font-size: .76rem; }
.pill.warn b { color: var(--warn); } .pill.bad b { color: var(--bad); } .pill.info b { color: var(--info); } .pill.good b { color: var(--good); }
details.more-filters { flex-basis: 100%; }
details.more-filters > summary { font-size: .84rem; }
details.more-filters[open] > .filters { margin-top: .8rem; }
.sub-line { display: block; color: var(--muted); font-size: .8rem; line-height: 1.4; margin-top: .1rem; }
tr.group td { background: var(--panel-2) !important; font-weight: 650; font-size: .82rem; color: var(--ink-2); padding-top: .45rem; padding-bottom: .45rem; }
tr.total td { font-weight: 700; border-top: 1px solid var(--line-strong); }
.steps { display: grid; gap: .5rem; padding-left: 1.2rem; margin: .3rem 0; }
.next { display: grid; gap: .55rem; margin: 0; padding: 0; list-style: none; }
.next li { display: flex; gap: .6rem; align-items: baseline; margin: 0; }
.next li::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); transform: translateY(-1px); }
.next li.ok::before { background: var(--good); }
.kv.compact { grid-template-columns: max-content 1fr; gap: .25rem 1rem; font-size: .84rem; margin: .4rem 0; }
.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin: .5rem 0 1rem; }

/* ---------- utilities ---------- */
.mt0 { margin-top: 0; } .mt1 { margin-top: .6rem; } .mt2 { margin-top: 1rem; }
.wfull { width: 100%; } .nowrap { white-space: nowrap; } .w5 { width: 5rem; } .w22 { width: 22rem; } .grow { flex: 1; }
.mw10 { min-width: 10rem; } .mw14 { min-width: 220px; } .mw16 { min-width: 260px; } .mw22 { min-width: 22rem; } .mw30 { min-width: 30rem; }
@media (max-width: 860px) { .mw22, .mw30, .w22 { min-width: 0; width: 100%; } }
.faded { opacity: .55; }
.dot-new { background: var(--accent); } .dot-queue { background: #3b82f6; } .dot-farm { background: #8a8f98; }
.dot-warn { background: var(--warn); } .dot-bad { background: var(--bad); }
.cols > *, .grid > * { min-width: 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
