:root {
  --bg: #0e1116;
  --bg-2: #171c24;
  --ink: #f4f7fb;
  --muted: #9aa3b2;
  --line: #2c3442;
  --accent: #3ddc97;
  --accent-ink: #06281c;
  --danger: #ff6b6b;
  --warn: #f5c16c;
  --shadow: 0 16px 40px rgba(0, 0, 0, .28);
  --radius: 16px;
  --font: "Segoe UI", sans-serif;
  --display: "Segoe UI", sans-serif;
  --title: 1.55rem;
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f4f6f8;
  --bg-2: #ffffff;
  --ink: #17202a;
  --muted: #5c6b7a;
  --line: #d9e0e7;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --shadow: 0 10px 30px rgba(23, 32, 42, .08);
  color-scheme: light;
}
html[data-theme="metal"] {
  --bg: #1b170f;
  --bg-2: #242017;
  --ink: #f4efe6;
  --muted: #b7b1a6;
  --line: #3a342c;
  --accent: #0056a7;
  --accent-ink: #ffffff;
  --shadow: none;
  --radius: 999px;
  --display: Georgia, "Times New Roman", serif;
  --title: 1.8rem;
  color-scheme: dark;
}
html[data-theme="humanist"] {
  --bg: #f6efe6;
  --bg-2: #fffaf3;
  --ink: #1c1a17;
  --muted: #6d645b;
  --line: #eadfce;
  --accent: #1c1a17;
  --accent-ink: #fef9ed;
  --shadow: none;
  --radius: 28px;
  --display: Georgia, "Times New Roman", serif;
  --title: 1.8rem;
  color-scheme: light;
}
html[data-theme="retro"] {
  --bg: #f3d7b0;
  --bg-2: #fff1d6;
  --ink: #3b2414;
  --muted: #7a4b28;
  --line: #5c3317;
  --accent: #e07a2f;
  --accent-ink: #3b2414;
  --danger: #9b2335;
  --shadow: 6px 6px 0 #5c3317;
  --radius: 22px;
  --font: "Trebuchet MS", "Arial Rounded MT Bold", sans-serif;
  --display: Georgia, serif;
  --title: 1.7rem;
  color-scheme: light;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
}
html[data-theme="humanist"] body {
  background: radial-gradient(1200px 500px at 20% -10%, #f3c7b0, transparent 50%), var(--bg);
}
html[data-theme="retro"] body {
  background-image: repeating-linear-gradient(90deg, transparent, transparent 18px, rgba(92, 51, 23, .05) 18px, rgba(92, 51, 23, .05) 19px);
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: var(--bg);
  color: var(--ink);
  color-scheme: light;
}
select option,
select optgroup {
  background-color: #ffffff;
  color: #17202a;
}
.topbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: .8rem 1.2rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  backdrop-filter: blur(10px);
  z-index: 5;
}
html[data-theme="retro"] .topbar { border-bottom-width: 3px; background: var(--bg-2); }
.brand { display: flex; gap: .55rem; align-items: center; text-decoration: none; font-size: 1.05rem; }
.brand strong { font-weight: 750; }
.tabs { display: flex; gap: .35rem; flex-wrap: wrap; flex: 1; }
.tabs a, .button, button {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  text-decoration: none;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: var(--radius);
  padding: .45rem .75rem;
  cursor: pointer;
}
.tabs a.is-on, button, .button {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
button.ghost, .tabs a { background: transparent; color: var(--ink); }
.who { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.version { color: var(--muted); font-variant-numeric: tabular-nums; }
.icon { width: 1.05rem; height: 1.05rem; }
main { padding: 1.4rem; max-width: 1280px; margin: 0 auto; }
h1 { font-family: var(--display); font-size: var(--title); line-height: .95; margin: 0; font-weight: 500; letter-spacing: -.03em; }
.basis { margin: .35rem 0 0; max-width: 46rem; color: var(--muted); font-size: .72rem; line-height: 1.35; }
h2 { margin: 0 0 .6rem; font-size: 1rem; }
.eyebrow { display: flex; gap: .4rem; align-items: center; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; margin: 0 0 .35rem; }
.page-head, .toolbar, .row, .filters { display: flex; gap: .8rem; align-items: end; justify-content: space-between; flex-wrap: wrap; }
.filters { margin-bottom: 1rem; }
.filters > * { min-width: 0; }
.detail-card { margin-top: 1rem; }
.page-head { margin-bottom: 1rem; }
.card, .auth-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) / 2);
  padding: 1rem;
  box-shadow: var(--shadow);
}
html[data-theme="metal"] .card { border-radius: 8px; }
.auth-card { max-width: 460px; margin: 8vh auto; }
.stack { display: grid; gap: .75rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.split { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.split > *, .stack, .grid-2, .grid-2 > * { min-width: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.settings { display: grid; gap: .7rem; align-items: start; }
.settings .card { padding: .7rem .8rem; }
.settings h2 { margin: 0 0 .35rem; font-size: .92rem; }
.settings .hint { margin: .15rem 0 .45rem; }
.settings-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; align-items: start; }
.settings-2 { display: grid; grid-template-columns: 1.15fr .85fr; gap: .7rem; align-items: start; }
.settings .row input, .settings .row select { width: auto; flex: 1; min-width: 0; }
label { display: grid; gap: .3rem; font-size: .92rem; min-width: 0; }
input, select {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .55rem .7rem;
  max-width: 100%;
}
input:not([type="checkbox"]):not([type="radio"]),
textarea { cursor: text; }
select:disabled,
input:disabled,
textarea:disabled,
.filters select:disabled { opacity: .45; cursor: not-allowed; }
.stack input,
.stack select,
.filters input,
.filters select,
.grid-2 input,
.grid-2 select {
  width: 100%;
  min-width: 0;
}
.gate {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 400px);
  gap: 3rem;
  align-items: center;
  max-width: 880px;
  margin: 7vh auto 0;
}
.gate-solo { grid-template-columns: minmax(0, 36rem); }
.gate-intro h1 { line-height: 1.05; font-size: clamp(2.2rem, 4vw, 3.1rem); margin-bottom: .55rem; }
.gate-lead { margin: 0; max-width: 28rem; color: var(--ink); font-size: 1.02rem; line-height: 1.5; }
.gate-panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.35rem 1.25rem 1.15rem;
  box-shadow: var(--shadow);
}
html[data-theme="metal"] .gate-panel { border-top: 3px solid var(--accent); }
.gate-panel label { color: var(--ink); font-size: .98rem; }
.gate-panel input {
  background: var(--bg);
  border-radius: 8px;
  padding: .72rem .8rem;
  opacity: 1;
}
.gate-panel button {
  width: 100%;
  justify-content: center;
  margin-top: .2rem;
  border-radius: 8px;
  padding: .72rem .9rem;
}
@media (max-width: 760px) {
  .gate { grid-template-columns: 1fr; gap: 1.2rem; margin-top: 1.2rem; }
}
.row input { flex: 1; width: auto; min-width: 0; }
html[data-theme="retro"] input, html[data-theme="retro"] select, html[data-theme="retro"] button { border-width: 2px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .4rem .35rem; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .82rem; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
.actions, .inline { display: flex; gap: .25rem; align-items: center; }
.actions form, .inline { margin: 0; }
.pill { border-radius: 999px; padding: .1rem .5rem; border: 1px solid var(--line); font-size: .8rem; }
.pill.ok { color: var(--accent); }
.pill.off { color: var(--danger); }
.flash { padding: .7rem 1rem; border-radius: 12px; }
.flash-ok { background: color-mix(in srgb, var(--accent) 18%, var(--bg-2)); }
.flash-error { background: color-mix(in srgb, var(--danger) 18%, var(--bg-2)); }
.hint, small { color: var(--muted); }
.danger { color: var(--danger); }
.check { grid-template-columns: auto 1fr; align-items: center; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .55rem; margin-bottom: .8rem; }
.kpi { padding: .45rem .55rem; }
.kpi strong { display: block; font-size: 1.05rem; line-height: 1.1; }
.kpi span { display: block; margin-top: .2rem; color: var(--muted); font-size: .68rem; line-height: 1.2; }
.pie-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .7rem; margin-bottom: .8rem; }
.blocks { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.block-wide { grid-column: 1 / -1; }
.block { font-size: .78rem; padding: .55rem .65rem; }
.block h2 { font-size: .82rem; margin: 0 0 .35rem; }
.chart-box { position: relative; width: 100%; max-height: 600px; }
.chart-box-pie { height: 168px; }
.chart-box-dist { height: 190px; }
.chart-box-wide { height: 220px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }
.block footer { display: flex; gap: .3rem; margin-top: .25rem; }
.block footer button { padding: .2rem .45rem; font-size: .7rem; }
.mini { margin-top: .15rem; font-size: .68rem; line-height: 1.1; max-height: 108px; overflow: auto; }
.mini td { padding: .05rem .2rem; border-bottom-width: 0; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; align-items: start; }
.group-fold { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 .7rem; background: var(--bg-2); }
.group-fold > summary { cursor: pointer; display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; padding: .85rem 1rem; font-weight: 600; list-style: none; }
.group-fold > summary::-webkit-details-marker { display: none; }
.group-fold > summary::before { content: "▸"; color: var(--muted); margin-right: .45rem; }
.group-fold[open] > summary::before { content: "▾"; }
.group-fold > summary span { flex: 1; }
.group-fold > summary small { color: var(--muted); font-weight: 500; font-size: .75rem; }
.group-fold .group-body { padding: 0 .85rem .85rem; }
.group-fold .group-body h2 { margin: 0 0 .45rem; font-size: .92rem; }
.cost-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; align-items: start; margin-bottom: .8rem; }
.cost-grid h2 { margin: 0 0 .35rem; font-size: 1rem; }
.cost-grid label { display: grid; gap: .2rem; margin: .4rem 0; font-size: .78rem; }
.cost-grid input, .cost-grid select { width: 100%; }
.cost-actions { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.section-head h2 { margin: 0; font-size: .92rem; }
.section-head button { padding: .25rem .5rem; font-size: .75rem; }
.table-wrap { margin-bottom: .8rem; }
.compact { font-size: .78rem; }
.compact th, .compact td { padding: .28rem .25rem; }
.log-list { display: grid; gap: .6rem; }
.log-call summary { cursor: pointer; font-weight: 600; }
.log-call table { margin-top: .6rem; }
.log-call th { width: 16rem; text-align: left; white-space: nowrap; }
.log-depth { margin-top: 1.4rem; }
.log-depth h2 { margin: 0 0 .4rem; }
.log-depth h3 { margin: 1rem 0 .4rem; font-size: 1rem; }
.log-text { white-space: pre-wrap; overflow: auto; max-height: 24rem; font-size: .85rem; }
.progress { margin: 0 0 1rem; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); }
ul.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
dialog { border: 1px solid var(--line); background: var(--bg-2); color: var(--ink); border-radius: 16px; max-width: 640px; }
code { word-break: break-all; }
@media (max-width: 900px) {
  .split, .grid-2, .stat-grid, .blocks, .pie-row, .cost-grid, .settings-3, .settings-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .block-wide { grid-column: auto; }
  .topbar { flex-wrap: wrap; }
  h1 { font-size: 1.4rem; }
}
