/* Palette from the dataviz reference instance. Single-hue (blue) for the
   hours magnitude chart, so no categorical CVD concerns. Dark mode is a
   selected step set, driven by Telegram's theme via [data-theme]. */
:root {
  color-scheme: light;
  --page:           #f9f9f7;
  --surface:        #fcfcfb;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --muted:          #898781;
  --grid:           #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);
  --accent:         #2a78d6;
  --accent-soft:    #cde2fb;
  --good:           #0ca30c;
  --critical:       #d03b3b;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:           #0d0d0d;
  --surface:        #1a1a19;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --muted:          #898781;
  --grid:           #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255,255,255,0.10);
  --accent:         #3987e5;
  --accent-soft:    #184f95;
  --good:           #0ca30c;
  --critical:       #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
.app-root { max-width: 720px; margin: 0 auto; padding: 12px 14px 40px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 12px;
}
.app-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.app-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.ghost-btn {
  background: var(--surface); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 10px;
  width: 38px; height: 38px; font-size: 18px; cursor: pointer;
}
.ghost-btn:active { transform: scale(0.96); }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-secondary); border-radius: 999px;
  padding: 8px 14px; font-size: 14px; cursor: pointer;
}
.tab.active { background: var(--accent); color: #fff; border-color: transparent; }

.view { display: flex; flex-direction: column; gap: 14px; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.card .hint { color: var(--muted); font-size: 13px; }

/* hero: the "who's working now" card — the first thing an admin sees */
.card.hero {
  border: 1px solid var(--good);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 14%, transparent);
}
.card.hero h2 { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.card.hero .row .name { font-size: 16px; font-weight: 600; }
.dot.live { background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: pulse 1.8s infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* stat tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.tile .label { font-size: 12px; color: var(--text-secondary); }
.tile .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.tile .value small { font-size: 14px; font-weight: 600; color: var(--text-secondary); }

/* lists */
.row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 2px; border-top: 1px solid var(--grid);
}
.row:first-of-type { border-top: 0; }
.row .name { font-size: 15px; }
.row .meta { font-size: 13px; color: var(--text-secondary); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.dot.on { background: var(--good); }
.dot.off { background: var(--baseline); }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-secondary); }
.badge.inactive { color: var(--critical); border-color: var(--critical); }

/* bar chart (single-series magnitude) */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 10px; }
.bar-name { font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--grid); border-radius: 5px; height: 18px; position: relative; }
.bar-fill {
  height: 18px; background: var(--accent);
  border-radius: 0 4px 4px 0; min-width: 3px; transition: width .3s ease;
}
.bar-val { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text-primary); }

/* forms + buttons */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.field label { font-size: 12px; color: var(--text-secondary); }
.field input {
  background: var(--page); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 12px; font-size: 15px; color: var(--text-primary);
}
.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: 11px 14px; font-size: 15px; font-weight: 600; cursor: pointer; width: 100%;
}
.btn:active { transform: scale(0.99); }
.btn.small { width: auto; padding: 7px 12px; font-size: 13px; }
.btn.subtle { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); }

.seg { display: flex; gap: 6px; margin-bottom: 12px; }
.seg button {
  flex: 1; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-secondary); border-radius: 10px; padding: 9px; font-size: 14px; cursor: pointer;
}
.seg button.active { background: var(--accent); color: #fff; border-color: transparent; }

.empty { color: var(--muted); font-size: 14px; padding: 16px 0; text-align: center; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--text-primary); color: var(--page); padding: 10px 16px;
  border-radius: 10px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

table.data { width: 100%; border-collapse: collapse; }
.clickable { cursor: pointer; }
.vbtns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* video overlay */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.overlay-box {
  background: var(--surface); border-radius: 14px; padding: 12px; width: 100%; max-width: 420px;
}
.overlay-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 14px; }
.overlay-box video { width: 100%; border-radius: 10px; background: #000; max-height: 70vh; }

table.data th, table.data td {
  text-align: left; padding: 8px 4px; font-size: 13px; border-top: 1px solid var(--grid);
}
table.data th { color: var(--muted); font-weight: 500; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
