/* IPTV Session Control
   Single dark (OLED) theme. Status colours are reserved: they mean state and
   nothing else, and every one of them is paired with a text label so colour
   never carries meaning on its own. */

:root {
  color-scheme: dark;

  --page:        #000000;
  --surface-1:   #0e0e0d;
  --surface-2:   #161615;
  --surface-3:   #1f1f1d;
  --hairline:    rgba(255, 255, 255, 0.10);
  --hairline-2:  rgba(255, 255, 255, 0.06);

  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;

  --good:     #0ca30c;
  --warning:  #fab219;
  --critical: #d03b3b;
  --serious:  #ec835a;
  --info:     #3987e5;

  --good-wash:     rgba(12, 163, 12, 0.13);
  --warning-wash:  rgba(250, 178, 25, 0.13);
  --critical-wash: rgba(208, 59, 59, 0.15);
  --serious-wash:  rgba(236, 131, 90, 0.14);
  --info-wash:     rgba(57, 135, 229, 0.13);

  --radius:    14px;
  --radius-sm: 9px;
  --gutter:    16px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* A class with `display` beats the UA rule for [hidden]; make it explicit so
   toggling `hidden` from JS actually hides the element. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--gutter) 64px;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px var(--gutter);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand-name {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.topbar-spacer { flex: 1 1 auto; }

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.who { color: var(--text-secondary); }

/* ---------- buttons ---------- */

.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-primary);
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}
.btn:hover { background: #2a2a27; }
.btn:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn-danger {
  color: #ffdcdc;
  background: var(--critical-wash);
  border-color: rgba(208, 59, 59, 0.45);
}
.btn-danger:hover { background: rgba(208, 59, 59, 0.24); }

.btn-quiet { background: transparent; }
.btn-quiet:hover { background: var(--surface-2); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- stat tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin: 20px 0 22px;
}

.tile {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 14px 16px 15px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tile-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.tile-value {
  font-size: 32px;
  font-weight: 640;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.tile-note { font-size: 12px; color: var(--text-muted); }

.tile-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted); flex: none;
}
.tile.is-critical { border-color: rgba(208, 59, 59, 0.42); }
.tile.is-critical .tile-dot { background: var(--critical); }
.tile.is-critical .tile-value { color: var(--critical); }
.tile.is-warning .tile-dot { background: var(--warning); }
.tile.is-info .tile-dot { background: var(--info); }
.tile.is-serious .tile-dot { background: var(--serious); }

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.search {
  flex: 1 1 240px;
  min-width: 0;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
}
.search::placeholder { color: var(--text-muted); }
.search:focus { outline: none; border-color: var(--info); }

.segmented {
  display: flex;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  overflow-x: auto;
}

.seg {
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.seg:hover { color: var(--text-primary); }
.seg[aria-pressed="true"] {
  background: var(--surface-3);
  color: var(--text-primary);
}

.seg-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* ---------- banner ---------- */

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.banner-warn {
  background: var(--warning-wash);
  border-color: rgba(250, 178, 25, 0.35);
  color: #ffe8b5;
}
.banner-info {
  background: var(--info-wash);
  border-color: rgba(57, 135, 229, 0.35);
  color: #cfe2fb;
}
.banner-bad {
  background: var(--critical-wash);
  border-color: rgba(208, 59, 59, 0.4);
  color: #ffd9d9;
}

/* ---------- table ---------- */

.card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.card-title { font-size: 14px; font-weight: 620; }
.card-sub { font-size: 12px; color: var(--text-muted); }

.table-scroll { overflow-x: auto; }

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.grid th {
  text-align: left;
  font-size: 11px;
  font-weight: 620;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
  background: var(--surface-1);
}

table.grid th.sortable { cursor: pointer; user-select: none; }
table.grid th.sortable:hover { color: var(--text-secondary); }
table.grid th .arrow { opacity: 0.45; margin-left: 4px; }

table.grid td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--hairline-2);
  vertical-align: middle;
  white-space: nowrap;
}
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: rgba(255, 255, 255, 0.025); }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.sec { color: var(--text-secondary); }
.mono { font-family: var(--mono); font-size: 12.5px; }

.uname { font-weight: 600; }

.over-plus { color: var(--critical); font-weight: 620; }

/* ---------- status pill (icon + label, never colour alone) ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 640;
  letter-spacing: 0.04em;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill .glyph { font-size: 10px; line-height: 1; }

.pill-green    { background: var(--good-wash);     border-color: rgba(12,163,12,.4);   color: #9ae79a; }
.pill-yellow   { background: var(--warning-wash);  border-color: rgba(250,178,25,.4);  color: #ffdf9e; }
.pill-red      { background: var(--critical-wash); border-color: rgba(208,59,59,.45);  color: #ffb3b3; }
.pill-banned   { background: var(--serious-wash);  border-color: rgba(236,131,90,.45); color: #ffc9ad; }
.pill-info     { background: var(--info-wash);     border-color: rgba(57,135,229,.4);  color: #b9d6fa; }
.pill-neutral  { background: var(--surface-3);     border-color: var(--hairline);      color: var(--text-secondary); }

/* ---------- empty state ---------- */

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* ---------- login ---------- */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px var(--gutter);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  padding: 30px 26px 26px;
}

.login-brand { margin-bottom: 22px; }
.login-brand .n {
  font-size: 21px;
  font-weight: 680;
  letter-spacing: -0.02em;
}
.login-brand .s {
  font-size: 12.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 3px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  font: inherit;
  font-size: 14.5px;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
}
.field input:focus { outline: none; border-color: var(--info); }

.btn-primary {
  width: 100%;
  margin-top: 6px;
  padding: 11px;
  font-size: 14px;
  font-weight: 620;
  color: #ffffff;
  background: #1f6fc4;
  border: 1px solid #2a78d6;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn-primary:hover { background: #2a78d6; }

.login-error {
  background: var(--critical-wash);
  border: 1px solid rgba(208, 59, 59, 0.42);
  color: #ffc4c4;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- detail page ---------- */

.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin: 20px 0 18px;
}
.detail-title { font-size: 25px; font-weight: 660; letter-spacing: -0.02em; }
.detail-meta { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.detail-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.section { margin-top: 22px; }
.section-title {
  font-size: 12px;
  font-weight: 640;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.note-input {
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  min-width: 200px;
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i {
  width: 9px; height: 9px; border-radius: 50%;
  display: inline-block; font-style: normal;
}

.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.error-code { font-size: 54px; font-weight: 700; color: var(--text-muted); }

/* ---------- responsive ---------- */

.hide-lg { display: none; }

@media (max-width: 720px) {
  .tile-value { font-size: 27px; }
  table.grid th, table.grid td { padding: 9px 8px; font-size: 13px; }
  .hide-sm { display: none; }
  .hide-lg { display: inline; }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tile { padding: 12px 13px 13px; }
  .topbar-inner { padding: 10px var(--gutter); }
  .brand-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
