:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #11161d;
  --ink-2: #4b5563;
  --muted: #8b93a1;
  --line: #e4e7ec;
  --accent: #0f7a5a;
  --accent-soft: #e7f5ef;
  --danger: #c8342b;
  --danger-soft: #fdecea;
  --warn: #b06d00;
  --warn-soft: #fff5e0;
  --gt: #6b7280;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 17px; font-weight: 650; }
h2 { font-size: 14px; font-weight: 620; }
code { font-size: 12px; background: #f1f3f6; padding: 1px 4px; border-radius: 4px; }
.muted { color: var(--muted); font-weight: 450; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  padding: 14px 24px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand .dot {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(145deg, #17a173, #0b5f47);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35);
  position: relative;
}
.brand .dot::after {
  content: ""; position: absolute; inset: 9px 8px; border-radius: 3px;
  border: 2px solid rgba(255, 255, 255, .85); border-bottom-width: 5px;
}
.brand p { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); }

.controls { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
select, input[type="number"] {
  font: inherit; font-size: 13.5px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 10px; min-width: 150px;
}
input[type="number"] { min-width: 0; width: 52px; text-align: center; -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button {
  width: 30px; height: 32px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); font-size: 16px; line-height: 1; cursor: pointer;
}
.stepper button:hover { background: #f7f8fa; }

.seg { display: inline-flex; background: #eef0f3; border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  font: inherit; font-size: 13px; padding: 5px 11px; border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-2); cursor: pointer;
}
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); font-weight: 550; }

/* ---------- layout ---------- */
main { padding: 20px 24px 40px; max-width: 1380px; margin: 0 auto; display: grid; gap: 18px; }
.grid { display: grid; gap: 18px; }
.two-one { grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); }
@media (max-width: 1040px) { .two-one { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { display: flex; gap: 8px; align-items: baseline; }

/* ---------- kpis ---------- */
.kpis { display: grid; gap: 18px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1040px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.kpi .k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.kpi .v { font-size: 30px; font-weight: 640; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi .s { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.kpi.danger { background: var(--danger-soft); border-color: #f4c9c5; }
.kpi.danger .v { color: var(--danger); }

/* ---------- viewer ---------- */
.shot { position: relative; border-radius: 12px; overflow: hidden; background: #0b0e13; aspect-ratio: 4 / 3; display: grid; place-items: center; }
.shot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.shot-note {
  position: absolute; left: 12px; bottom: 12px; display: flex; gap: 8px; flex-wrap: wrap;
}
.shot-note span {
  font-size: 12px; padding: 5px 9px; border-radius: 999px;
  background: rgba(12, 16, 24, .78); color: #fff; backdrop-filter: blur(6px);
}
.shot-note span.warn { background: rgba(176, 109, 0, .92); }
.shot-note span.bad { background: rgba(200, 52, 43, .92); }
.shot-note span.ok { background: rgba(15, 122, 90, .92); }

.transport { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
input[type="range"] { flex: 1; accent-color: var(--accent); height: 22px; }
.ticker { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink-2); min-width: 118px; text-align: right; }

button.primary, button.ghost {
  font: inherit; font-size: 13.5px; font-weight: 550; padding: 8px 14px; border-radius: 9px;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
}
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: #0c6a4e; }
button.primary:disabled { background: #9db8ae; cursor: progress; }
button.ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
button.ghost:hover { background: #f7f8fa; }
button.ghost:disabled { color: var(--muted); cursor: progress; }

.pill {
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em; padding: 3px 9px; border-radius: 999px;
  background: #eef1f4; color: var(--ink-2);
}
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--accent-soft); color: var(--accent); }

/* ---------- alerts ---------- */
.alert-list { display: grid; gap: 8px; max-height: 430px; overflow: auto; margin-right: -4px; padding-right: 4px; }
.alert-row {
  display: grid; grid-template-columns: 62px 1fr auto; gap: 10px; align-items: center;
  padding: 6px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  background: #fbfcfd;
}
.alert-row:hover { background: #f4f7f9; border-color: var(--line); }
.alert-row.current { border-color: var(--accent); background: var(--accent-soft); }
.alert-row img { width: 62px; height: 46px; object-fit: cover; border-radius: 6px; background: #0b0e13; }
.alert-row .t { font-size: 13px; font-weight: 550; font-variant-numeric: tabular-nums; }
.alert-row .n { font-size: 12px; color: var(--ink-2); }
.alert-row .c { font-size: 11.5px; color: var(--danger); font-weight: 600; }
.hint { margin: 12px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }

/* ---------- chart ---------- */
.chart { width: 100%; height: 230px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.legend .sw { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.sw.correct { background: var(--accent); }
.sw.gt { background: var(--gt); }
.sw.alert { background: var(--danger); }
.sw.blurry { background: var(--warn); }

/* ---------- table ---------- */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: right; padding: 7px 6px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
th:first-child, td:first-child { text-align: left; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7f9fb; }
tbody tr.on { background: var(--accent-soft); font-weight: 600; }
td .tier { display: block; font-size: 10.5px; color: var(--muted); font-weight: 450; }

/* ---------- live ---------- */
.live-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 20px; }
@media (max-width: 1040px) { .live-body { grid-template-columns: 1fr; } }
.live-copy p { margin: 0 0 12px; color: var(--ink-2); font-size: 13.5px; }
.live-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.live-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 16px 0 0; }
.live-stats div { background: #f8fafb; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.live-stats dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.live-stats dd { margin: 3px 0 0; font-size: 15px; font-weight: 620; font-variant-numeric: tabular-nums; }
.json {
  margin: 0; background: #0f141b; color: #d6e2ee; border-radius: 10px; padding: 12px;
  font: 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}

footer { color: var(--muted); font-size: 12px; padding: 4px 2px 0; }
