/* Dashboard styles, part 1 of 8: colours (light and dark), page elements, sign-in, controls, the sidebar.
 * The parts load in this order, and a later rule wins over an earlier one. */

/* Unda Control (the dashboard): sidebar layout, table-first.
 * Colours come only from the variables below. Light is the default; the dark
 * palette applies when <html data-theme="dark"> (set before first paint by the
 * page head from the viewer’s saved choice: light, dark or match the system). */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e6e8f0;
  --border-strong: #d3d8e3;
  --text: #0f172a;
  --muted: #5d6a80;
  --faint: #9aa4b6;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef0ff;
  --ok: #15803d;
  --ok-soft: #e6f5ea;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --info: #0369a1;
  --info-soft: #e0f2fe;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px -12px rgba(16, 24, 40, 0.18), 0 2px 6px rgba(16, 24, 40, 0.05);
  --ring: rgba(79, 70, 229, 0.2);
  --sidebar: 232px;
  --ok-border: #b7e3c3;
  --info-border: #b9e0f6;
  --warn-border: #f5dc8a;
  --warn-border-strong: #fcd34d;
  --danger-border: #f2b8b8;
  --accent-border: #cdd0fb;
  --ok-tint: #f7fdf9;
  --info-tint: #f7fcff;
  --warn-tint: #fffdf5;
  --danger-tint: #fffafa;
  --push: #6d28d9;
  --push-soft: #f1eafe;
  --push-border: #ddd0fb;
  --accent-area: rgba(79, 70, 229, 0.1);
  --ok-area: rgba(21, 128, 61, 0.12);
  --on-accent: #ffffff;
  --toast: #1e293b;
  color-scheme: light;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  --bg: #0a0e1a;
  --surface: #111727;
  --surface-2: #161d30;
  --border: #232c42;
  --border-strong: #323d58;
  --text: #e2e8f0;
  --muted: #9aa8bf;
  --faint: #6b7a93;
  --accent: #818cf8;
  --accent-strong: #a5b4fc;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --ok: #4ade80;
  --ok-soft: rgba(34, 197, 94, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --info: #38bdf8;
  --info-soft: rgba(14, 165, 233, 0.14);
  --ok-border: rgba(74, 222, 128, 0.32);
  --info-border: rgba(56, 189, 248, 0.32);
  --warn-border: rgba(251, 191, 36, 0.32);
  --warn-border-strong: rgba(251, 191, 36, 0.45);
  --danger-border: rgba(248, 113, 113, 0.35);
  --accent-border: rgba(129, 140, 248, 0.35);
  --ok-tint: rgba(34, 197, 94, 0.07);
  --info-tint: rgba(14, 165, 233, 0.07);
  --warn-tint: rgba(245, 158, 11, 0.07);
  --danger-tint: rgba(239, 68, 68, 0.07);
  --push: #c4b5fd;
  --push-soft: rgba(139, 92, 246, 0.16);
  --push-border: rgba(167, 139, 250, 0.35);
  --accent-area: rgba(129, 140, 248, 0.16);
  --ok-area: rgba(74, 222, 128, 0.14);
  --on-accent: #0a0e1a;
  --toast: #334155;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, 0.6);
  --ring: rgba(129, 140, 248, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
a { color: var(--accent-strong); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--on-accent); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { width: 16px; height: 16px; flex: none; }

/* ---------- sign-in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 14px; padding: 24px 16px; }
.signin-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); }
.signin-card h1 { margin-bottom: 6px; }
.signin-card label { display: block; font-weight: 600; margin: 14px 0 6px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-lg { font-size: 20px; margin-bottom: 18px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; display: inline-block;
  background: linear-gradient(135deg, #818cf8, #4f46e5 55%, #7c3aed);
  box-shadow: inset 0 0 0 5px var(--surface), 0 0 0 1px var(--accent);
}

/* ---------- controls ---------- */
input[type=text], input[type=password], input[type=search], input[type=email], input[type=number], input[type=time], input[type=date], input[type=datetime-local], select {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 10px; min-width: 0; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 600;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 7px 12px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-sm { padding: 4px 9px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-danger { color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
.btn-danger-solid:hover { background: #991b1b; border-color: #991b1b; }
.btn.recording { color: var(--danger); border-color: var(--danger-border); background: var(--danger-soft); }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); display: inline-block; }
.recording .rec-dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
.form-error { color: var(--danger); min-height: 1.3em; margin: 6px 0 0; font-size: 13px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 0 12px 12px;
}
.sidebar-top { height: 60px; display: flex; align-items: center; padding: 0 8px; flex: none; }
/* The menu scrolls inside the sidebar on short screens (a 1366×768 laptop, Windows at
 * 125-150 % scaling), so it can never push the footer (status, Sign out) off screen. */
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; margin: 0 -12px; padding: 0 12px 8px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 600; position: relative;
}
/* Section headings (Live / Content / Settings), shown only when the menu is long. */
.nav-group { padding: 14px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.nav-group:first-child { padding-top: 4px; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav .count { margin-left: auto; font-size: 12px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav a[aria-current="page"] .count { background: var(--surface); border-color: var(--accent-border); color: var(--accent-strong); }
.sidebar-foot { flex: none; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.health { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); display: inline-block; flex: none; }
.health.ok .dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }
.health.bad .dot { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18); }
.health.bad { color: var(--danger); }

/* Stale data (GS-08): the live channel lost its heartbeat. Figures stay visible
 * but greyed, so nobody reads old numbers as current; the banner says how old. */
.conn-banner { position: sticky; top: 0; z-index: 40; padding: 10px 28px; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--warn-border-strong); font-weight: 600; font-size: 14px; }
body.stale #view { filter: grayscale(1); opacity: 0.55; transition: opacity 0.2s, filter 0.2s; }
.content { min-width: 0; }
.page { padding: 22px 28px 64px; max-width: 1440px; }
.page:focus { outline: none; }

.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead .sub { color: var(--muted); margin: 4px 0 0; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent-strong); text-decoration: underline; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
