/* Clipper PWA — mobile-first, dark theme, no build step. */

:root {
  --bg: #0b0f17;
  --surface: #141b2b;
  --surface-2: #1b2438;
  --border: #2c3a55;
  --text: #e8edf7;
  --muted: #93a1bd;
  --accent: #4da3ff;
  --success: #4dd98a;
  --danger: #ff5d5d;
  --warning: #ffc94d;
  --radius: 14px;
  --tap: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

body {
  min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; font-size: 1.1rem; }

.view {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

.view h1 {
  font-size: 1.35rem;
  margin: 8px 0 16px;
}

.view h2 {
  font-size: 1.05rem;
  margin: 24px 0 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- bottom tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tap);
  padding: 8px 4px;
  font-size: 0.72rem;
  color: var(--muted);
  text-decoration: none;
}

.tabbar a.active { color: var(--accent); }
.tab-icon { font-size: 1.15rem; }

body.hide-tabs .tabbar { display: none; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.card-head .streamer { font-weight: 700; }
.card-head .score { color: var(--warning); font-weight: 700; }
.card-head .status { margin-left: auto; }

.muted { color: var(--muted); font-size: 0.88rem; }

.reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.reasons span {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---------- video ---------- */
.video-wrap {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
}

video {
  display: block;
  width: 100%;
  max-height: 62vh;
  background: #000;
}

/* ---------- forms ---------- */
label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 10px 0 4px;
}

input, select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
}

input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input[readonly] { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #041225; }
.btn-success { background: var(--success); border-color: var(--success); color: #04231a; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #2a0505; }

.actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.actions .btn { flex: 1; min-height: 56px; font-size: 1.1rem; }

/* ---------- login ---------- */
.login-box {
  max-width: 380px;
  margin: 8vh auto 0;
}

.login-box .btn { width: 100%; margin-top: 18px; }

.error {
  background: rgba(255, 93, 93, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 12px;
  font-size: 0.9rem;
}

.hint { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }

kbd {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.8rem;
}

/* ---------- empty / loading ---------- */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
}

.empty .big { font-size: 2.4rem; margin-bottom: 8px; }

/* ---------- KPI tiles ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.kpi .value { font-size: 1.6rem; font-weight: 700; }
.kpi .label { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
td.wrap { white-space: normal; word-break: break-word; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--surface-2); }

/* ---------- chart ---------- */
.chart {
  width: 100%;
  height: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.chart-legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
}

.dot-blue { background: #4da3ff; }
.dot-green { background: #4dd98a; }

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.badge.ok { color: var(--success); border-color: var(--success); }
.badge.warn { color: var(--warning); border-color: var(--warning); }
.badge.bad { color: var(--danger); border-color: var(--danger); }

/* ---------- switch ---------- */
.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
  flex-shrink: 0;
}

.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }

.switch .track {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.15s;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s, background 0.15s;
}

.switch input:checked + .track { background: rgba(77, 217, 138, 0.25); border-color: var(--success); }
.switch input:checked + .track::after { transform: translateX(22px); background: var(--success); }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

@media (min-width: 720px) {
  body { padding-bottom: 16px; }
  .tabbar { position: static; border-top: 0; border-bottom: 1px solid var(--border); }
  .actions .btn { min-height: var(--tap); font-size: 1rem; }
}
