:root {
  --bg: #0a0f1a;
  --bg-2: #0f172a;
  --panel: #0b1224;
  --card: #111827;
  --line: rgba(148, 163, 184, 0.18);
  --text: #f8fafc;
  --muted: #94a3b8;
  --orange: #fb923c;
  --cyan: #22d3ee;
  --violet: #a855f7;
  --indigo: #6366f1;
  --ok: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --r: 12px;
  --fast: 120ms cubic-bezier(.2, .8, .2, 1);
  --sat: 1.15;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { min-height: 100dvh; }
img, svg { max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.app { max-width: 1180px; margin: 0 auto; padding: 0 16px 48px; }

.top {
  position: sticky; top: 0; z-index: 40;
  width: 100%;
  margin: 0 0 14px;
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background-color: #4c1d95;
  background-image: linear-gradient(90deg, #4338ca 0%, #6d28d9 45%, #7e22ce 100%);
  box-shadow: 0 10px 30px rgba(76, 29, 149, .35);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, #22d3ee, #a855f7);
  display: grid; place-items: center;
  box-shadow: 0 0 16px rgba(34, 211, 238, .45);
}
.logo svg { width: 18px; height: 18px; }
.brand h1 {
  margin: 0; font-size: 1.15rem; letter-spacing: -.02em; white-space: nowrap;
}
.brand h1 span { color: var(--orange); }
.live {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 800; letter-spacing: .08em;
  background: rgba(15, 23, 42, .35); border: 1px solid rgba(255,255,255,.18);
  padding: 6px 10px; border-radius: 999px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 8px #4ade80; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.guide {
  border: 1px solid rgba(255,255,255,.35);
  background: #3730a3; color: #fff;
  border-radius: 8px; padding: 8px 12px; font-weight: 700;
  transition: transform var(--fast), background var(--fast);
}
.guide:hover { transform: translateY(-1px); background: #4f46e5; }

.tabs {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px;
}
.tab {
  border: 1px solid rgba(168, 85, 247, .55);
  background: #1e293b; color: #fde047;
  border-radius: 12px; padding: 9px 14px; font-weight: 800;
  display: inline-flex; align-items: center; gap: 7px;
  transition: transform var(--fast), background var(--fast), color var(--fast);
}
.tab[aria-selected="true"] {
  background: linear-gradient(90deg, #22d3ee, #818cf8 55%, #a855f7);
  color: #fff; border-color: transparent;
  box-shadow: 0 8px 22px rgba(129, 140, 248, .35);
}
.tab:hover { transform: translateY(-1px); }

.tip {
  display: flex; gap: 8px; align-items: flex-start;
  background: linear-gradient(90deg, rgba(146, 64, 14, .28), rgba(124, 45, 18, .18));
  border: 1px solid rgba(251, 191, 36, .4);
  color: #fde68a; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px;
  font-size: 13px;
}
.tip strong { color: #fdba74; }

.panel {
  background: linear-gradient(180deg, #0f172a, #0b1220);
  border: 2px solid rgba(100, 116, 139, .35);
  border-radius: 16px; margin-bottom: 12px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0,0,0,.28);
}
.panel > summary,
.panel-head {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase;
}
.panel > summary::-webkit-details-marker { display: none; }
.chip-ico {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; margin-right: 8px;
}
.head-l { display: flex; align-items: center; }
.panel-body { padding: 0 14px 14px; }

.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.grid-ions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 900px) {
  .grid-4, .grid-ions { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grid-ions { grid-template-columns: 1fr; }
  .brand h1 { font-size: .95rem; }
  .live { display: none; }
  .top { padding: 10px 12px; }
}

label.k {
  display: block; font-size: 10px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: #a5b4fc; margin-bottom: 6px;
}
select, .num {
  width: 100%; background: #0b1220; border: 2px solid rgba(99, 102, 241, .45);
  border-radius: 10px; padding: 8px 10px; font-weight: 700;
}
.range-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.pill {
  font-size: 11px; font-weight: 800; background: rgba(79, 70, 229, .35);
  padding: 3px 8px; border-radius: 6px;
}
input[type=range] {
  width: 100%; accent-color: #818cf8; height: 18px; cursor: pointer;
}
.seg { display: flex; background: #0b1220; border: 1px solid rgba(99,102,241,.4); border-radius: 8px; padding: 3px; }
.seg button {
  flex: 1; border: 0; background: transparent; color: #94a3b8;
  font-weight: 800; font-size: 12px; padding: 8px; border-radius: 6px;
}
.seg button.on { background: linear-gradient(90deg, #4f46e5, #6366f1); color: #fff; }
.ctx {
  margin-top: 12px; border: 1px solid rgba(34, 211, 238, .28);
  border-radius: 10px; padding: 10px;
}
.ctx-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.ctx-btns button {
  border: 1px solid #22d3ee; background: rgba(15, 23, 42, .6); color: #67e8f9;
  border-radius: 4px; padding: 7px 10px; font-size: 11px; font-weight: 800; letter-spacing: .12em;
}
.ctx-btns button.on { background: linear-gradient(90deg, #0891b2, #4f46e5); color: #fff; border-color: transparent; }

.ion {
  background: #0b1220; border: 1px solid rgba(51, 65, 85, .8);
  border-radius: 12px; padding: 10px; position: relative;
  contain: layout style;
}
.ion.out { box-shadow: 0 0 0 1px rgba(248, 113, 113, .55), 0 0 18px rgba(248, 113, 113, .18); }
.ion-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.ion-name { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; }
.ion-ico { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; }
.ion-val { display: flex; align-items: center; gap: 4px; }
.ion-val input {
  width: 64px; text-align: right; background: #020617; border-radius: 8px;
  border: 1px solid currentColor; padding: 5px 6px; font-weight: 800; font-size: 13px;
}
.unit { font-size: 10px; font-weight: 700; opacity: .85; }
.track { position: relative; height: 18px; display: flex; align-items: center; }
.track-bg { position: absolute; inset: 7px 0; border-radius: 99px; overflow: hidden; }
.track-fill { height: 100%; width: 0; border-radius: 99px; }
.track input[type=range] {
  position: relative; z-index: 2; opacity: 0; margin: 0; height: 18px;
}
.knob {
  position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid currentColor; transform: translateX(-7px); pointer-events: none; z-index: 1;
}
.bounds { display: flex; justify-content: space-between; font-size: 10px; color: #64748b; margin-top: 4px; }
.norm {
  font-weight: 800; padding: 1px 6px; border-radius: 6px;
  background: rgba(6, 95, 70, .45); color: #6ee7b7;
}
.norm.bad { background: rgba(127, 29, 29, .5); color: #fca5a5; }

.c-cyan { color: #67e8f9; --ion: #22d3ee; --g: linear-gradient(90deg, #22d3ee, #0891b2); --trk: rgba(8, 47, 73, .75); }
.c-teal { color: #5eead4; --ion: #14b8a6; --g: linear-gradient(90deg, #2dd4bf, #0f766e); --trk: rgba(4, 47, 46, .75); }
.c-emerald { color: #6ee7b7; --ion: #34d399; --g: linear-gradient(90deg, #34d399, #059669); --trk: rgba(6, 78, 59, .75); }
.c-rose { color: #fda4af; --ion: #fb7185; --g: linear-gradient(90deg, #fb7185, #e11d48); --trk: rgba(76, 5, 25, .75); }
.c-amber { color: #fcd34d; --ion: #f59e0b; --g: linear-gradient(90deg, #fbbf24, #d97706); --trk: rgba(69, 26, 3, .75); }
.c-blue { color: #93c5fd; --ion: #60a5fa; --g: linear-gradient(90deg, #60a5fa, #2563eb); --trk: rgba(23, 37, 84, .75); }
.c-purple { color: #d8b4fe; --ion: #c084fc; --g: linear-gradient(90deg, #c084fc, #7c3aed); --trk: rgba(46, 16, 101, .75); }
.c-indigo { color: #a5b4fc; --ion: #818cf8; --g: linear-gradient(90deg, #818cf8, #4f46e5); --trk: rgba(30, 27, 75, .75); }
.ion-ico, .chip-ico { background: var(--g); box-shadow: 0 0 12px color-mix(in srgb, var(--ion) 50%, transparent); }
.track-bg { background: var(--trk); }
.track-fill { background: var(--g); }

.metrics {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0;
}
@media (max-width: 700px) { .metrics { grid-template-columns: 1fr 1fr; } }
.metric {
  background: rgba(15, 23, 42, .7); border-radius: 10px; padding: 10px;
  border: 1px solid rgba(45, 212, 191, .35);
  transition: transform var(--fast), background var(--fast);
}
.metric:hover { transform: translateY(-1px); background: rgba(30, 41, 59, .75); }
.metric b { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.metric .v { font-size: 22px; font-weight: 900; line-height: 1.15; }
.metric small { color: #64748b; font-size: 10px; }
.metric.hot .v { color: #f87171; }
.metric.ok .v { color: #2dd4bf; }

.flags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.flag {
  font-size: 11px; font-weight: 800; padding: 5px 8px; border-radius: 999px;
  background: rgba(127, 29, 29, .45); color: #fecaca; border: 1px solid rgba(248, 113, 113, .35);
}
.flag.ok { background: rgba(6, 78, 59, .4); color: #a7f3d0; border-color: rgba(52, 211, 153, .3); }

.note {
  background: rgba(19, 78, 74, .35); border: 1px solid rgba(45, 212, 191, .35);
  border-radius: 10px; padding: 10px; margin-top: 8px;
}
.note h4 { margin: 0 0 4px; color: #5eead4; font-size: 12px; }
.note p { margin: 0 0 6px; font-size: 12px; color: #ccfbf1; }
.alert {
  display: flex; gap: 6px; background: rgba(127, 29, 29, .35);
  border: 1px solid rgba(248, 113, 113, .3); border-radius: 8px; padding: 6px 8px;
  color: #fca5a5; font-size: 11px; font-weight: 700;
}

.water {
  background: linear-gradient(135deg, rgba(124, 45, 18, .35), rgba(15, 23, 42, .5));
  border: 1px solid rgba(249, 115, 22, .5); border-radius: 12px; padding: 12px; margin-top: 10px;
}
.water h4 { margin: 0 0 8px; color: #fdba74; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kv div { background: rgba(0,0,0,.25); border-radius: 8px; padding: 8px; }
.kv b { display: block; font-size: 10px; color: #fdba74; letter-spacing: .06em; text-transform: uppercase; }
.kv span { font-weight: 900; }

.vent {
  background: linear-gradient(180deg, #111827, #0b1220);
  border: 1px solid rgba(52, 211, 153, .25); border-radius: 16px; padding: 14px; margin: 14px 0;
}
.vent h3 { margin: 0 0 4px; }
.muted { color: var(--muted); font-size: 13px; }
.vent-meta { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; font-size: 13px; }
.vent-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 800px) { .vent-grid, .kv { grid-template-columns: 1fr 1fr; } }
.vent-item span { display: block; font-size: 10px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: #64748b; }
.sed { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.sed div { background: #0b1220; border-radius: 10px; padding: 10px; border: 1px solid var(--line); }
.sed b { color: #c4b5fd; }

.disorders h2 { font-size: 1.15rem; margin: 18px 0 8px; }
.d-item { margin-bottom: 8px; border: 1px solid rgba(99, 102, 241, .28); border-radius: 12px; background: #0f172a; overflow: hidden; }
.d-item.hit { border-color: rgba(251, 146, 60, .7); box-shadow: 0 0 0 1px rgba(251, 146, 60, .25); }
.d-item > summary {
  cursor: pointer; padding: 12px 14px; font-weight: 900; letter-spacing: .02em;
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.d-item > summary::-webkit-details-marker { display: none; }
.d-body { padding: 0 14px 14px; font-size: 13.5px; line-height: 1.55; color: #e2e8f0; }
.d-body h5 { margin: 12px 0 6px; color: #67e8f9; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.d-body ul { margin: 0; padding-left: 18px; }
.d-body li { margin: 3px 0; }
.block { background: rgba(15, 23, 42, .6); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 8px 0; }
.crit { color: #fdba74; font-weight: 800; }

.foot {
  margin-top: 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 700px) { .foot, .sed { grid-template-columns: 1fr; } }
.card {
  background: #0f172a; border: 1px solid var(--line); border-radius: 14px; padding: 14px;
}
.card h4 { margin: 0 0 8px; }
.refs { display: flex; flex-wrap: wrap; gap: 8px; }
.refs a {
  color: #93c5fd; text-decoration: none; font-size: 12px; font-weight: 700;
  border: 1px solid rgba(147, 197, 253, .25); padding: 6px 8px; border-radius: 8px;
}
.refs a:hover { background: rgba(37, 99, 235, .2); }
.hidden { display: none !important; }

.modal {
  position: fixed; inset: 0; background: rgba(2, 6, 23, .72);
  display: grid; place-items: center; z-index: 80; padding: 16px;
}
.modal .box {
  width: min(520px, 100%); background: #0f172a; border: 1px solid rgba(168, 85, 247, .4);
  border-radius: 16px; padding: 16px;
}
.modal h3 { margin: 0 0 8px; }
kbd { background: #1e293b; border: 1px solid #334155; border-radius: 4px; padding: 1px 5px; font-size: 12px; }

.jump {
  width: 100%; margin: 8px 0 0; border: 0; border-radius: 12px; padding: 12px;
  font-weight: 900; letter-spacing: .04em; text-transform: uppercase;
  color: #fff; background: linear-gradient(90deg, #2563eb, #7c3aed);
  box-shadow: 0 10px 24px rgba(124, 58, 237, .35);
  transition: transform var(--fast);
}
.jump:hover { transform: translateY(-1px); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 0; }
.ghost {
  background: #1e293b; border: 1px solid rgba(168, 85, 247, .4); color: #e2e8f0;
  border-radius: 10px; padding: 8px 10px; font-weight: 700; font-size: 12px;
}
