:root {
  --bg: #070d16;
  --surface: #0e1726;
  --surface-2: #131f31;
  --surface-3: #18263c;
  --border: #1f3149;
  --border-soft: #17263a;
  --text: #e6edf6;
  --muted: #8798b0;
  --faint: #5d708c;
  --green: #3ddc97;
  --green-dim: rgba(61, 220, 151, .12);
  --red: #ff6b6b;
  --red-dim: rgba(255, 107, 107, .12);
  --amber: #ffc46b;
  --blue: #5aa9ff;
  --blue-dim: rgba(90, 169, 255, .12);
  --violet: #a78bfa;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --radius: 12px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app { display: flex; min-height: 100vh; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 248px; flex: 0 0 248px;
  background: linear-gradient(180deg, #0b1422 0%, #080f1a 100%);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 22px 20px 24px; border-bottom: 1px solid var(--border-soft); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--green), #1e9c78);
  color: #062015; font-weight: 800; font-size: 15px;
  display: grid; place-items: center; letter-spacing: -.5px;
  box-shadow: 0 4px 18px rgba(61, 220, 151, .25);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand-sub { color: var(--faint); font-size: 11px; letter-spacing: .6px; text-transform: uppercase; margin-top: 2px; }

.nav { padding: 16px 10px; display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 9px;
  color: var(--muted); font-weight: 500; font-size: 13.5px;
  transition: .15s ease;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--green-dim); color: var(--green); box-shadow: inset 2px 0 0 var(--green); }
.ico { width: 18px; text-align: center; font-size: 15px; opacity: .9; }

.zone-box { margin: auto 14px 14px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 11.5px; color: var(--muted); }
.zone-box h4 { margin: 0 0 10px; font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); }
.zone-row { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; }
.zone-row b { color: var(--text); font-weight: 600; }
.zone-tag { padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; }
.zone-tag.bt { background: var(--blue-dim); color: var(--blue); }
.zone-tag.fw { background: rgba(167, 139, 250, .14); color: var(--violet); }

.sidebar-foot { padding: 14px 20px 18px; border-top: 1px solid var(--border-soft); font-size: 11.5px; color: var(--faint); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.dot.bad { background: var(--red); box-shadow: 0 0 10px var(--red); }
.version { width: 100%; padding-left: 15px; opacity: .7; }

/* ---------- topbar ---------- */
.main { flex: 1; min-width: 0; }
.topbar {
  height: 74px; padding: 0 30px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(9, 16, 27, .85); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.topbar p { margin: 2px 0 0; color: var(--faint); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.pill { padding: 6px 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.content { padding: 26px 30px 60px; max-width: 1600px; }

/* ---------- generic ---------- */
.btn {
  padding: 9px 15px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer;
  font-weight: 600; font-size: 12.5px; transition: .15s ease; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: #2b4463; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #2fbf82, #229c70); border-color: transparent; color: #04231a; }
.btn-primary:hover { filter: brightness(1.1); background: linear-gradient(135deg, #3ddc97, #27ab7c); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); }
.btn-sm { padding: 6px 10px; font-size: 11.5px; }

.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 700; }
.card .hint { color: var(--faint); font-size: 12px; margin: 0 0 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

.stat { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; font-weight: 600; }
.stat .value { font-size: 25px; font-weight: 700; margin-top: 8px; letter-spacing: -.7px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.pos { color: var(--green); } .neg { color: var(--red); } .warn { color: var(--amber); } .info { color: var(--blue); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge.ok { background: var(--green-dim); color: var(--green); }
.badge.no { background: var(--red-dim); color: var(--red); }
.badge.lock { background: rgba(167, 139, 250, .14); color: var(--violet); }
.badge.neutral { background: var(--surface-3); color: var(--muted); }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
input, select, textarea {
  background: #0a1421; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 11px; outline: none; width: 100%;
  font-variant-numeric: tabular-nums;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-dim); }
textarea { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; line-height: 1.6; resize: vertical; min-height: 150px; }
input[type=number] { -moz-appearance: textfield; }

/* ---------- table ---------- */
.table-wrap { overflow: auto; border-radius: 10px; border: 1px solid var(--border-soft); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th {
  background: var(--surface-2); color: var(--faint); text-align: left;
  padding: 10px 12px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px;
  font-weight: 700; position: sticky; top: 0; white-space: nowrap; cursor: pointer; user-select: none;
}
thead th:hover { color: var(--text); }
tbody td { padding: 9px 12px; border-top: 1px solid var(--border-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-2); }
td.right, th.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11.5px; }
.empty { padding: 40px; text-align: center; color: var(--faint); }

/* ---------- coverage matrix ---------- */
.matrix { display: grid; gap: 3px; font-size: 10.5px; }
.matrix .cell { height: 15px; border-radius: 3px; background: #111c2c; border: 1px solid rgba(255,255,255,.03); }
.matrix .cell.full { background: #1f8f68; }
.matrix .cell.partial { background: #6b6a2a; }
.matrix .cell.none { background: #2a1520; }
.legend { display: flex; gap: 14px; font-size: 11px; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- charts ---------- */
canvas { width: 100%; display: block; }
.chart-box { position: relative; }
.chart-legend { display: flex; gap: 16px; font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.chart-legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: 3px; margin-right: 5px; }

/* ---------- heatmap ---------- */
.heatmap { display: grid; grid-template-columns: 62px repeat(12, minmax(0, 1fr)); gap: 4px; font-size: 10.5px; }
.heatmap .hl { color: var(--faint); font-size: 10px; text-align: center; padding-top: 5px; }
.heatmap .hy { color: var(--muted); font-weight: 700; display: grid; align-items: center; cursor: pointer; }
.heatmap .hy:hover { color: var(--green); }
.heatmap .hm {
  padding: 9px 2px; text-align: center; border-radius: 5px; font-weight: 700;
  font-variant-numeric: tabular-nums; cursor: default; border: 1px solid rgba(255,255,255,.04);
}
.heatmap .hm.selected { outline: 2px solid var(--green); outline-offset: 1px; }

/* ---------- gate / lock ---------- */
.lock-panel { border: 1px dashed rgba(167,139,250,.5); background: rgba(167,139,250,.06); border-radius: var(--radius); padding: 24px; text-align: center; }
.lock-panel .big { font-size: 30px; margin-bottom: 8px; }
.gate-steps { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.gate-step { flex: 1; min-width: 150px; padding: 12px 14px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; }
.gate-step.done { border-color: rgba(61,220,151,.45); background: var(--green-dim); }
.gate-arrow { color: var(--faint); font-size: 18px; }

/* ---------- misc ---------- */
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; padding: 12px 18px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 13px; opacity: 0; transform: translateY(12px); transition: .25s ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { border-color: rgba(255,107,107,.5); color: #ffc9c9; }
.progress { height: 7px; background: var(--surface-3); border-radius: 20px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--green), #1e9c78); transition: width .3s ease; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); margin-bottom: 16px; }
.tabs button { background: none; border: none; color: var(--muted); padding: 9px 14px; cursor: pointer; font-size: 12.5px; font-weight: 600; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--green); border-bottom-color: var(--green); }
.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; }
.kv:last-child { border-bottom: none; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.strategy-item { padding: 13px 15px; border: 1px solid var(--border-soft); border-radius: 9px; background: var(--surface-2); cursor: pointer; margin-bottom: 8px; }
.strategy-item:hover { border-color: #2b4463; }
.strategy-item.active { border-color: var(--green); background: var(--green-dim); }
.strategy-item .nm { font-weight: 600; font-size: 13px; }
.strategy-item .ds { color: var(--faint); font-size: 11.5px; margin-top: 3px; }
.watch-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 11px; border-radius: 8px; background: var(--surface-2); margin-bottom: 6px; cursor: pointer; font-size: 12.5px; }
.watch-item:hover { background: var(--surface-3); }
.watch-item.active { outline: 1px solid var(--green); }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .sidebar { width: 62px; flex-basis: 62px; }
  .brand > div:last-child, .nav a span:not(.ico), .zone-box, .sidebar-foot span:not(.dot), .version { display: none; }
  .nav a { justify-content: center; }
  .content { padding: 18px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
}
