:root {
  --bg: #F4F6F3; --card: #FFFFFF; --ink: #14201A; --ink2: #3D4A42; --mute: #4B5A51; --line: #E3E8E2; --soft: #EEF1ED;
  --brand: #0F6B46; --brand-ink: #FFFFFF; --hero: #0F3D2A; --hero2: #164D36; --hero-mute: #CFE3D7; --up: #8FE0B5;
  --bad: #B23A0E; --bad2: #D9622B; --bad3: #E8925F; --bad4: #F0B48E; --bad-bg: #FDEDE4; --bad-ink: #8F2E0B;
  --warn-bg: #FFF4D6; --warn-ink: #6B4A00; --info-bg: #E3EDF9; --info-ink: #1D4E89; --good-bg: #E2F2E9;
  --radius: 16px; --nav-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1411; --card: #18211C; --ink: #E9EFEA; --ink2: #C3CEC6; --mute: #9DABA2; --line: #2A3530; --soft: #222C27;
    --brand: #3FB984; --brand-ink: #06120C; --hero: #123D2A; --hero2: #1A5238; --hero-mute: #BFD9CA; --up: #8FE0B5;
    --bad: #FF8A5C; --bad2: #F0915F; --bad3: #E7A47B; --bad4: #D9B79F; --bad-bg: #3A1F14; --bad-ink: #FFB394;
    --warn-bg: #3A3014; --warn-ink: #F5D27A; --info-bg: #172A40; --info-ink: #9CC3F2; --good-bg: #173326;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0E1411; --card: #18211C; --ink: #E9EFEA; --ink2: #C3CEC6; --mute: #9DABA2; --line: #2A3530; --soft: #222C27;
    --brand: #3FB984; --brand-ink: #06120C; --hero: #123D2A; --hero2: #1A5238; --hero-mute: #BFD9CA; --up: #8FE0B5;
    --bad: #FF8A5C; --bad2: #F0915F; --bad3: #E7A47B; --bad4: #D9B79F; --bad-bg: #3A1F14; --bad-ink: #FFB394;
    --warn-bg: #3A3014; --warn-ink: #F5D27A; --info-bg: #172A40; --info-ink: #9CC3F2; --good-bg: #173326;
    color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 15px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); }
.wrap { padding-block: 16px 8px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 14px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.top h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.sub { font-size: 13px; color: var(--mute); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; padding: 5px 9px; border-radius: 999px; background: var(--soft); color: var(--mute); white-space: nowrap; }
.chip.sample { background: var(--warn-bg); color: var(--warn-ink); }
.scope { width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 0 12px; font-weight: 600; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card.tight { padding: 0; gap: 0; overflow: hidden; }
.hero { background: var(--hero); color: #fff; border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.hero .lbl { font-size: 13px; color: var(--hero-mute); }
.hero .big { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; }
.hero .chg { font-size: 13px; font-weight: 700; color: var(--up); }
.hero .chg.neg { color: #FFB394; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--hero2); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile span:first-child { font-size: 11px; color: var(--hero-mute); }
.tile span:last-child { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.row.center { align-items: center; }
.h2 { font-size: 15px; font-weight: 700; margin: 0; }
.bad { color: var(--bad); } .good { color: var(--brand); } .mute { color: var(--mute); }
.big-bad { font-size: 18px; font-weight: 800; color: var(--bad); }
.bar { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 6px; border-radius: 3px; }
.stack { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--soft); }
.stack > i { display: block; height: 10px; }
.leak { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.leak .row b { font-weight: 700; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--soft); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.list-item .t { font-size: 14px; font-weight: 600; }
.list-item .s { font-size: 12px; color: var(--mute); }
.col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 6px; white-space: nowrap; align-self: flex-start; }
.tag.green { background: var(--good-bg); color: var(--brand); }
.tag.red { background: var(--bad-bg); color: var(--bad-ink); }
.tag.yellow { background: var(--warn-bg); color: var(--warn-ink); }
.tag.blue { background: var(--info-bg); color: var(--info-ink); }
.tag.gray { background: var(--soft); color: var(--mute); }
.alerts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.alert { border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; border: 0; text-align: left; cursor: pointer; }
.alert b { font-size: 18px; font-weight: 800; }
.alert span { font-size: 12px; }
.alert.red { background: var(--bad-bg); color: var(--bad-ink); }
.alert.yellow { background: var(--warn-bg); color: var(--warn-ink); }
.alert.blue { background: var(--info-bg); color: var(--info-ink); }
.btn { height: 48px; border: 0; border-radius: 14px; background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 15px; padding: 0 16px; cursor: pointer; }
.btn.sm { height: 40px; border-radius: 12px; font-size: 14px; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); font-weight: 600; }
.btn.outline { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn.danger { background: var(--card); color: var(--bad-ink); border: 1px solid var(--line); font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.btns.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.pill { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 13px; white-space: nowrap; cursor: pointer; }
.pill.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--soft); border-radius: 12px; padding: 4px; gap: 4px; }
.tabs button { height: 36px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; font-size: 13px; cursor: pointer; }
.tabs button.on { background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.rec h3 { margin: 0; font-size: 17px; line-height: 1.3; }
.rec p { margin: 0; font-size: 13px; color: var(--ink2); line-height: 1.45; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.kv > div { background: var(--bg); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv small { font-size: 11px; color: var(--mute); }
.kv b { font-size: 15px; font-weight: 800; }
.mini-rec { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border-radius: 14px; border: 0; width: 100%; text-align: left; cursor: pointer; }
.mini-rec .col span:first-child { font-size: 11px; font-weight: 700; color: var(--brand); text-transform: uppercase; }
.mini-rec .col span:last-child { font-size: 14px; font-weight: 600; }
.mini-rec b { font-size: 13px; font-weight: 800; color: var(--brand); white-space: nowrap; }
.lines { display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.lines .row span:first-child { color: var(--ink2); }
.hr { height: 1px; background: var(--line); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select { height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 0 12px; width: 100%; }
.field.inline { flex-direction: row; justify-content: space-between; align-items: center; gap: 12px; }
.field.inline label { font-weight: 500; flex: 1; }
.field.inline input { width: 96px; text-align: right; }
.grid-form { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(4, minmax(0, 1fr)); gap: 6px; align-items: center; font-size: 12px; }
.grid-form input { height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); padding: 0 6px; width: 100%; font-size: 13px; }
.grid-form .hd { font-weight: 700; color: var(--mute); }
.map-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 8px; align-items: center; font-size: 13px; }
.map-row select { height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); padding: 0 8px; width: 100%; }
.map-row.missing label { color: var(--bad); }
.scroll-x { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table.pv { border-collapse: collapse; font-size: 12px; min-width: 100%; }
table.pv td, table.pv th { padding: 6px 8px; border-bottom: 1px solid var(--soft); white-space: nowrap; text-align: left; }
table.pv th { background: var(--soft); font-weight: 700; }
nav.bottom { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; z-index: 10; }
nav.bottom .in { width: 100%; max-width: 560px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
nav.bottom button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--mute); cursor: pointer; position: relative; }
nav.bottom button.on { color: var(--brand); font-weight: 700; }
nav.bottom svg { width: 22px; height: 22px; }
.badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.modal h2 { margin: 0; font-size: 18px; }
.opt { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; font-size: 14px; }
.opt input { width: 18px; height: 18px; accent-color: var(--brand); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; font-size: 14px; z-index: 30; display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px); }
.toast button { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 8px; height: 32px; padding: 0 12px; font-weight: 700; cursor: pointer; }
.empty { text-align: center; padding: 28px 16px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.empty h2 { margin: 0; font-size: 18px; }
.empty p { margin: 0; color: var(--mute); font-size: 14px; }
.manual h3 { margin: 4px 0 0; font-size: 16px; }
.manual p, .manual li { font-size: 14px; line-height: 1.5; color: var(--ink2); }
.manual ul, .manual ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.manual p { margin: 0; }
details.sec { background: var(--card); border-radius: 14px; padding: 12px 14px; }
details.sec summary { font-weight: 700; cursor: pointer; font-size: 15px; }
details.sec[open] summary { margin-bottom: 10px; }
details.sec > div { display: flex; flex-direction: column; gap: 8px; }
.note { font-size: 12px; color: var(--mute); }
.warnbox { background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.infobox { background: var(--info-bg); color: var(--info-ink); border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.45; }
.range { width: 100%; accent-color: var(--brand); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
