:root {
  color-scheme: dark;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #f9fafb;
  --background: #0b0f19;
  --background-end: #0b0f19;
  --panel: #111827;
  --surface: #0e1422;
  --input: #1f2937;
  --line: #374151;
  --muted: #9ca3af;
  --accent: #60a5fa;
  --positive: #34d399;
  --negative: #f87171;
  --active: #1b2638;
  --gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --shadow: 0 10px 25px -8px #00000080;
  --header: 65px;
  --sidebar: 240px;
}

:root[data-theme=light] {
  color-scheme: light;
  color: #111827;
  --background: #f3f4f6;
  --background-end: #f3f4f6;
  --panel: #ffffff;
  --surface: #ffffff;
  --input: #f3f4f6;
  --line: #d1d5db;
  --muted: #4b5563;
  --accent: #2563eb;
  --positive: #047857;
  --negative: #b91c1c;
  --active: #e5edff;
  --shadow: 0 6px 18px -8px #11182733;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--background); }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(145deg, var(--background), var(--background-end));
}
a { color: var(--accent); text-underline-offset: .2em; }
button, input, select, textarea { font: inherit; }
button, .button, input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 9px;
  color: inherit;
  background: var(--input);
  padding: .52rem .72rem;
}
button, .button { cursor: pointer; line-height: 1.35; font-weight: 580; }
.button { display: inline-flex; align-items: center; text-decoration: none; }
button:hover:not(:disabled), .button:hover, button[aria-pressed=true] { border-color: var(--accent); }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.primary {
  background: var(--gradient);
  color: #ffffff;
  font-weight: 750;
  border-color: transparent;
}
.primary:hover:not(:disabled) { filter: brightness(1.1); }
.danger { color: var(--negative); justify-self: start; }
.icon { inline-size: 1.24rem; block-size: 1.24rem; flex: 0 0 auto; vertical-align: middle; }
.skip-link { position: fixed; z-index: 10; inset: .5rem auto auto .75rem; padding: .5rem; background: var(--panel); }
.skip-link:not(:focus) { transform: translateY(-160%); }
.workspace { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); grid-template-rows: auto 1fr; }
.topbar {
  grid-column: 1/-1;
  position: sticky;
  z-index: 4;
  top: 0;
  min-height: var(--header);
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .6rem clamp(.8rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { color: inherit; display: flex; align-items: center; gap: .7rem; font-size: 1.22rem; font-weight: 780; text-decoration: none; }
.mark { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--gradient); color: #fff; font-weight: 800; font-size: 1.2rem; }
.logo { height: 38px; width: 38px; object-fit: cover; display: block; border-radius: 9px; }
.topbar-actions { margin-left: auto; display: flex; gap: .5rem; }
.topbar-actions button { display: flex; align-items: center; gap: .4rem; min-height: 40px; }
#menu { display: none; }
.sidebar {
  position: sticky;
  align-self: start;
  top: var(--header);
  height: calc(100dvh - var(--header));
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: .85rem .65rem;
}
nav, .nav-group { display: grid; gap: .25rem; }
nav a {
  display: flex;
  gap: .65rem;
  align-items: center;
  color: var(--muted);
  font-size: .91rem;
  font-weight: 620;
  text-decoration: none;
  padding: .65rem .6rem;
  border-radius: 9px;
}
nav a:hover, nav a[aria-current=page] { color: inherit; background: var(--active); }
nav a[aria-current=page] .icon { color: var(--accent); }
.nav-group { padding: .35rem 0 .55rem; margin: .35rem 0; border-block: 1px solid var(--line); }
.nav-group h2 { margin: .35rem .6rem 0; color: var(--muted); font-size: .82rem; font-weight: 690; }
.nav-group a { padding-left: .95rem; }
main { width: 100%; max-width: 1590px; margin: 0 auto; padding: clamp(.85rem, 3vw, 2rem) clamp(.85rem, 3vw, 2rem) 4rem; min-width: 0; }
h1, h2, h3 { margin: 0; line-height: 1.2; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.65rem, 3vw, 2.6rem); font-weight: 760; letter-spacing: -.035em; }
h2 { font-size: 1.16rem; }
h3 { font-size: 1rem; }
p { margin: .35rem 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 15px; padding: clamp(.75rem, 1.5vw, 1.15rem); min-width: 0; box-shadow: var(--shadow); }
.stack { display: grid; gap: .9rem; align-content: start; min-width: 0; }
.grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.bar { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; min-width: 0; }
.spread { justify-content: space-between; }
.metrics { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr)); }
.metric { display: grid; gap: .25rem; min-height: 105px; text-decoration: none; color: inherit; }
.metric span { color: var(--muted); font-size: .91rem; }
.metric strong { font-size: 1.9rem; font-variant-numeric: tabular-nums; }
.metric:hover { border-color: var(--accent); }
form { display: grid; gap: .8rem; }
label { display: grid; gap: .25rem; min-width: 0; overflow-wrap: anywhere; }
label:has(input[type=checkbox]) { display: flex; align-items: center; gap: .55rem; }
input, select, textarea { min-width: 0; width: 100%; }
input[type=checkbox] { inline-size: 1.05rem; block-size: 1.05rem; accent-color: var(--accent); }
textarea { min-height: 5rem; resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0; min-width: 0; padding: .85rem; }
select[multiple] { min-height: 8rem; }
output, code, pre { overflow-wrap: anywhere; }
pre { margin: 0; white-space: pre-wrap; }
.muted, .empty { color: var(--muted); }
.empty { padding: .65rem 0; }
.bad, [data-error=true] { color: var(--negative); }
.good { color: var(--positive); }
.badge { display: inline-block; background: var(--input); border: 1px solid var(--line); border-radius: 999px; padding: .22rem .58rem; font-size: .79rem; font-weight: 690; }
.badge.success { color: var(--positive); }
.badge.alert { color: var(--negative); }
.notice { position: fixed; bottom: 1rem; left: 1rem; right: 1rem; max-width: 640px; margin: auto;
  padding: .75rem 1rem; border: 1px solid var(--accent); border-radius: 10px; background: var(--surface); z-index: 6; box-shadow: var(--shadow); }
.dialog-notice { padding: .55rem; border: 1px solid var(--line); border-radius: 8px; }
dialog.card { color: inherit; max-width: min(820px, calc(100% - 1.5rem)); width: 100%; max-height: calc(100dvh - 1.5rem); overflow: auto; }
dialog::backdrop { background: #05080fc4; }
dialog header { padding-bottom: .8rem; margin-bottom: .8rem; border-bottom: 1px solid var(--line); }
.qr { display: block; width: min(320px, 100%); margin: auto; }
.skeleton { min-height: 9rem; position: relative; overflow: hidden; }
.skeleton::after { content: ""; position: absolute; inset: 1rem; border-radius: 8px;
  background: repeating-linear-gradient(var(--active) 0 14px, transparent 14px 30px);
  animation: pulse 1.35s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } }
.login { display: grid; min-height: 100dvh; place-items: center; padding: 1rem; }
.login-card { width: min(100%, 430px); margin: 0; padding: clamp(1rem, 4vw, 2.25rem); display: grid; gap: 1.15rem; }
.login-card .logo { width: 72px; height: 72px; border-radius: 14px; }
.scroll { overflow: auto; max-height: 64vh; border: 1px solid var(--line); border-radius: 10px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; font-size: .9rem; }
.table th, .table td { padding: .62rem .65rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td { overflow-wrap: anywhere; }
.table tr:last-child td { border-bottom: 0; }
.table th { position: sticky; top: 0; z-index: 1; background: var(--surface); color: var(--muted); white-space: nowrap; }
.table tr:hover td { background: var(--active); }
.table input[type=checkbox] { display: block; }
.schedule { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
summary { cursor: pointer; font-weight: 650; }
details[open] > summary { margin-bottom: .65rem; }
.queue { list-style: none; padding: 0; margin: 0; max-height: 62vh; overflow: auto; }
.queue li { display: grid; gap: .35rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.queue li[draggable=true] { cursor: grab; }
.queue li.over { border-top: 2px solid var(--accent); }
.player { display: grid; grid-template-columns: minmax(130px, .7fr) minmax(0, 2.2fr) minmax(190px, 1fr); gap: .8rem; align-items: start; }
.player video, .stream-preview video { display: block; width: 100%; aspect-ratio: 16/9; background: #05080f; border-radius: 9px; }
.programme { max-height: 64vh; overflow: auto; }
.programme article { padding: .45rem 0; border-bottom: 1px solid var(--line); }
@media (max-width: 1150px) {
  .player { grid-template-columns: minmax(135px, 1fr) minmax(0, 2.6fr); }
  .programme, .schedule > .scroll { grid-column: 1/-1; }
}
@media (max-width: 850px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  #menu { display: inline-flex; align-items: center; min-height: 40px; }
  .sidebar { display: none; position: fixed; z-index: 3; left: 0; width: min(280px, 85vw); box-shadow: var(--shadow); }
  .sidebar.is-open { display: block; }
}
@media (max-width: 650px) {
  .schedule, .player { grid-template-columns: minmax(0, 1fr); }
  .table { min-width: max(100%, 480px); }
  .table td { max-width: 220px; }
}


.meter { height: 12px; border-radius: 999px; background: var(--input); overflow: hidden; border: 1px solid var(--line); }
.meter span { display: block; height: 100%; background: var(--gradient); }
.meter span.full { background: var(--negative); }
.primary { box-shadow: 0 0 18px -4px #3b82f673; }
#lang { font-weight: 750; min-width: 52px; }
.login-card #lang { justify-self: end; }
