:root {
  --ink: #203c34;
  --ink-soft: #39564e;
  --muted: #72817d;
  --line: #dde7e3;
  --line-strong: #cbd8d3;
  --page: #f2f6f4;
  --white: #fff;
  --green: #16856b;
  --green-dark: #153f35;
  --green-soft: #e6f2ed;
  --gold: #d39b24;
  --orange: #cf6b3d;
  --blue: #3b718f;
  --rose: #bc6383;
  --olive: #687c52;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--page); }
button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.topbar { min-height: 70px; display: grid; grid-template-columns: 220px 1fr 260px; align-items: center; gap: 18px; padding: 9px clamp(14px, 3vw, 42px); position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; flex: none; border-radius: 14px; background: var(--green-soft); }
.brand-mark svg { width: 28px; fill: var(--green); }
.brand-mark .sun { fill: var(--gold); }
.brand b, .brand small { display: block; }
.brand b { font-size: 1.05rem; }
.brand small { margin-top: 1px; color: var(--muted); font-size: .67rem; font-weight: 680; letter-spacing: .09em; text-transform: uppercase; }
.main-nav { display: flex; justify-content: center; gap: 4px; }
.nav-button { display: inline-flex; align-items: center; gap: 7px; padding: 9px 13px; border: 0; border-radius: 10px; color: #60716c; background: transparent; font-size: .82rem; font-weight: 690; cursor: pointer; }
.nav-button span { font-size: 1rem; }
.nav-button:hover { color: var(--green-dark); background: #f0f5f3; }
.nav-button.active { color: #fff; background: var(--green-dark); }
.topbar-status { display: flex; justify-content: flex-end; align-items: center; gap: 8px; color: var(--muted); font-size: .75rem; }
.live-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(22,133,107,.12); }

.page-shell { width: min(1540px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 44px; }
.hero { min-height: 180px; display: flex; justify-content: space-between; align-items: center; gap: 28px; padding: clamp(25px, 4vw, 38px); color: #fff; border-radius: 26px; background: linear-gradient(125deg,#153d35 0%,#176c58 62%,#98701e 145%); box-shadow: 0 18px 42px rgba(20,70,58,.16); }
.eyebrow { margin: 0 0 8px; color: #bfe8da; font-size: .7rem; font-weight: 760; letter-spacing: .2em; }
.eyebrow.dark { color: var(--green); }
.hero h1, .page-intro h1 { margin: 0; font-size: clamp(2rem,4vw,3rem); line-height: 1.08; letter-spacing: -.04em; }
.hero > div > p:last-child, .page-intro > div > p:last-child { max-width: 760px; margin: 12px 0 0; line-height: 1.55; color: #e4f1ed; }
.hero-action { min-width: 270px; display: flex; align-items: center; gap: 12px; padding: 15px; border: 1px solid rgba(255,255,255,.18); border-radius: 16px; background: rgba(255,255,255,.08); }
.hero-action b, .hero-action small { display: block; }
.hero-action small { margin-top: 2px; color: #d7ebe4; font-size: .7rem; }
.hero-action-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 11px; color: #ffda87; background: rgba(255,255,255,.1); font-size: 1.25rem; }
.icon-button { width: 36px; height: 36px; margin-left: auto; border: 0; border-radius: 10px; cursor: pointer; }
.icon-button.light { color: #fff; background: rgba(255,255,255,.12); }
.icon-button:hover { transform: rotate(15deg); }
.page-intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; padding: 15px 3px 23px; }
.page-intro > div > p:last-child { color: var(--muted); }

.message { margin: 18px 0; padding: 14px 17px; border-radius: 13px; font-size: .84rem; line-height: 1.5; }
.message-warning { color: #6d4a0b; border: 1px solid #ead49b; background: #fff8e8; }
.message-error { color: #7b332b; border: 1px solid #ebc5bf; background: #fff2f0; }
.loading-state { min-height: 230px; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.spinner { width: 25px; height: 25px; border: 3px solid #d6e4de; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.kpi-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 14px; margin-top: 20px; }
.kpi-card { min-height: 126px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 7px 22px rgba(42,70,62,.05); }
.tone-green { background: linear-gradient(145deg,#fff 48%,#e7f4ef); }
.tone-gold { background: linear-gradient(145deg,#fff 48%,#fbf2df); }
.tone-blue { background: linear-gradient(145deg,#fff 48%,#e8f1f7); }
.tone-rose { background: linear-gradient(145deg,#fff 48%,#f7eaf0); }
.tone-sage { background: linear-gradient(145deg,#fff 48%,#edf1e7); }
.kpi-label { display: block; color: var(--muted); font-size: .66rem; font-weight: 780; letter-spacing: .1em; text-transform: uppercase; }
.kpi-card strong { display: block; margin: 10px 0 6px; font-size: clamp(1.45rem,2vw,1.9rem); line-height: 1; letter-spacing: -.04em; white-space: nowrap; }
.kpi-card small { display: block; color: var(--muted); font-size: .7rem; line-height: 1.35; }

.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 34px 2px 13px; }
.section-heading h2 { margin: 0 0 3px; font-size: 1.25rem; letter-spacing: -.02em; }
.section-heading p, .panel-heading p { margin: 0; color: var(--muted); font-size: .78rem; }
.source-chip { padding: 6px 10px; color: #3b655a; background: #e5f0ec; border-radius: 999px; font-size: .7rem; font-weight: 680; }
.chart-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 17px; }
.panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 7px 22px rgba(42,70,62,.05); }
.panel-wide { grid-column: span 2; }
.chart { width: 100%; min-height: 370px; }
.chart-lg { min-height: 420px; }
.chart-xl { min-height: 500px; }
.panel-heading { display: flex; justify-content: space-between; gap: 12px; padding: 19px 19px 10px; }
.panel-heading h3 { margin: 0 0 3px; font-size: 1.02rem; }
.diagnostics-grid { display: grid; grid-template-columns: minmax(0,2fr) minmax(290px,1fr); gap: 17px; }
.compact-panel { min-height: 330px; }

.table-scroll { overflow-x: auto; padding: 0 8px 10px; }
table { width: 100%; border-collapse: collapse; font-size: .77rem; }
th { padding: 10px; color: var(--muted); background: #f6f9f8; font-size: .63rem; text-align: left; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
th:first-child { border-radius: 9px 0 0 9px; }
th:last-child { border-radius: 0 9px 9px 0; }
td { padding: 11px 10px; border-bottom: 1px solid #edf2f0; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcfb; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; font-size: .66rem; font-weight: 740; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-online { color: #176e59; background: #e4f3ed; }
.status-offline { color: #946313; background: #fbf0d9; }
.status-error { color: #93453c; background: #f9e7e4; }
.list-stack { padding: 3px 18px 15px; }
.list-item { padding: 12px 0; border-bottom: 1px solid #edf2f0; }
.list-item:last-child { border: 0; }
.list-line { display: flex; justify-content: space-between; gap: 12px; }
.list-code { font-size: .85rem; font-weight: 760; }
.list-name, .list-meta { display: block; margin-top: 2px; color: var(--muted); font-size: .68rem; }
.count-badge { flex: none; align-self: flex-start; padding: 3px 7px; color: #80570d; border: 1px solid #d6a94e; border-radius: 999px; font-size: .68rem; font-weight: 750; }
.empty-state { padding: 42px 20px; color: var(--muted); text-align: center; }
.empty-state b { display: block; margin-bottom: 4px; color: var(--ink); }

.mode-switch { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.mode-button { padding: 9px 12px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: .78rem; font-weight: 700; cursor: pointer; }
.mode-button.active { color: #fff; background: var(--green-dark); }
.workbench { margin-bottom: 22px; padding: 18px; border: 1px solid var(--line); border-radius: 19px; background: #fff; box-shadow: 0 8px 24px rgba(42,70,62,.05); }
.preset-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding-bottom: 14px; border-bottom: 1px solid #edf2f0; }
.preset-row > span { margin-right: 6px; color: var(--muted); font-size: .68rem; font-weight: 760; letter-spacing: .07em; text-transform: uppercase; }
.preset-row button { padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fff; font-size: .72rem; font-weight: 670; cursor: pointer; }
.preset-row button:hover, .preset-row button.active { color: var(--green-dark); border-color: #a9cbc0; background: var(--green-soft); }
.control-grid { display: grid; grid-template-columns: repeat(6,minmax(130px,1fr)); gap: 12px; padding: 15px 0; }
.control-grid label, .option-row label { display: grid; gap: 6px; color: var(--muted); font-size: .66rem; font-weight: 760; letter-spacing: .07em; text-transform: uppercase; }
.control-grow { grid-column: span 2; }
input, select { width: 100%; min-height: 41px; padding: 0 11px; color: var(--ink); border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; outline: none; text-transform: none; letter-spacing: 0; font-size: .8rem; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22,133,107,.1); }
.option-row { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 18px; padding: 13px 0; border-top: 1px solid #edf2f0; }
.option-row label { min-width: 180px; }
.option-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: .66rem; font-weight: 760; letter-spacing: .07em; text-transform: uppercase; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line-strong); border-radius: 10px; background: #f7faf9; }
.segmented button { min-height: 33px; padding: 0 13px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: .75rem; font-weight: 690; cursor: pointer; }
.segmented button.active { color: #fff; background: var(--green); }
.option-help { flex: 1; min-width: 240px; margin: 0 0 5px; color: var(--muted); font-size: .72rem; }
.workbench-footer { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding-top: 13px; border-top: 1px solid #edf2f0; color: var(--muted); font-size: .75rem; }
.button { min-height: 41px; padding: 0 18px; color: #fff; border: 0; border-radius: 10px; background: var(--green); font-weight: 730; cursor: pointer; }
.button:hover { background: #116f59; }
.button:disabled { opacity: .55; cursor: wait; }
.mini-kpis { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin: 0 0 17px; }
.mini-kpis article { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.mini-kpis span { display: block; color: var(--muted); font-size: .62rem; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; }
.mini-kpis b { display: block; margin-top: 6px; font-size: 1.15rem; }
.analysis-grid { margin-bottom: 17px; }
.result-table { margin-top: 17px; }
.voltage-note { display: flex; gap: 10px; margin: 0 0 17px; padding: 13px 15px; color: #385d53; border: 1px solid #c9ddd6; border-radius: 13px; background: #edf6f2; font-size: .76rem; line-height: 1.45; }
.voltage-note b { flex: none; }
.table-action { padding: 5px 8px; border: 1px solid #b6cec6; border-radius: 8px; color: var(--green-dark); background: #f4f9f7; font-size: .67rem; font-weight: 700; cursor: pointer; }
.table-action:hover { background: var(--green-soft); }
.quality-ok { color: #176e59; font-weight: 720; }
.quality-warn { color: #9a5c13; font-weight: 720; }
.footer-note { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 24px 3px 0; color: var(--muted); font-size: .68rem; }

@media (max-width: 1250px) {
  .topbar { grid-template-columns: 200px 1fr auto; }
  .topbar-status span:last-child { display: none; }
  .kpi-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .control-grid { grid-template-columns: repeat(4,minmax(130px,1fr)); }
}
@media (max-width: 920px) {
  .topbar { grid-template-columns: auto 1fr; }
  .main-nav { justify-content: flex-end; }
  .topbar-status { display: none; }
  .hero, .page-intro { align-items: flex-start; flex-direction: column; }
  .hero-action { width: 100%; }
  .diagnostics-grid { grid-template-columns: 1fr; }
  .control-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .control-grow { grid-column: span 2; }
}
@media (max-width: 720px) {
  .page-shell { width: min(100% - 18px,1540px); padding-top: 12px; }
  .topbar { min-height: 60px; padding: 7px 10px; }
  .brand small { display: none; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-mark svg { width: 24px; }
  .main-nav { gap: 2px; }
  .nav-button { width: 39px; height: 39px; justify-content: center; padding: 0; font-size: 0; }
  .nav-button span { font-size: 1rem; }
  .hero { min-height: 0; padding: 22px; border-radius: 19px; }
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
  .panel-wide { grid-column: span 1; }
  .chart, .chart-lg { min-height: 350px; }
  .chart-xl { min-height: 440px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .mode-switch { width: 100%; }
  .mode-button { flex: 1; }
  .mini-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .workbench-footer { align-items: stretch; flex-direction: column; }
  .button { width: 100%; }
  .voltage-note { flex-direction: column; }
}
@media (max-width: 470px) {
  .brand b { font-size: .9rem; }
  .control-grid { grid-template-columns: 1fr; }
  .control-grow { grid-column: span 1; }
  .kpi-grid, .mini-kpis { grid-template-columns: 1fr; }
  .kpi-card { min-height: 112px; }
  .preset-row > span { width: 100%; }
}
