/* XStream design system — sober, high-contrast, light & dark themes. No external dependencies. */
:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --gap: 16px;
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --ease: cubic-bezier(.2,.7,.2,1);

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e6e9ee;
  --border: #dde1e7;
  --border-strong: #c7cdd6;
  --text: #141820;
  --text-2: #4a5363;
  --text-3: #6b7484;
  --brand: #1f6feb;
  --brand-hover: #1958c4;
  --brand-soft: #e7f0fe;
  --brand-text: #ffffff;
  --ok: #138a52;
  --ok-soft: #e3f6ec;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --danger: #c9302c;
  --danger-soft: #fdeceb;
  --info: #0e7490;
  --info-soft: #e2f4f8;
  --live: #e0245e;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 4px 12px rgba(16,24,40,.05);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.16);
  --focus: 0 0 0 3px rgba(31,111,235,.35);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f1218;
  --surface: #161a22;
  --surface-2: #1c212b;
  --surface-3: #252b37;
  --border: #2a313d;
  --border-strong: #3a4352;
  --text: #e8ebf1;
  --text-2: #b3bac7;
  --text-3: #8b94a5;
  --brand: #4c8dff;
  --brand-hover: #6aa0ff;
  --brand-soft: #1a2840;
  --brand-text: #0b1220;
  --ok: #3ccb80;
  --ok-soft: #12291e;
  --warn: #f0a83a;
  --warn-soft: #2e2312;
  --danger: #ff6b66;
  --danger-soft: #331816;
  --info: #45c1db;
  --info-soft: #102a31;
  --live: #ff4f86;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 1px 3px rgba(0,0,0,.45), 0 4px 12px rgba(0,0,0,.25);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
  --focus: 0 0 0 3px rgba(76,141,255,.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5;
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { vertical-align: middle; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; } h4 { font-size: 14px; }
p { margin: 0 0 .75em; }
code, kbd, pre { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; overflow: auto; max-height: 520px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.skip-link:focus { left: 8px; }

.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 14px; height: 14px; flex: none; }
.icon-lg { width: 24px; height: 24px; flex: none; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 18px; font-weight: 700; font-size: 16px; color: var(--text); border-bottom: 1px solid var(--border); }
.brand:hover { text-decoration: none; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: var(--brand-text); display: grid; place-items: center; }
.brand .logo svg { width: 20px; height: 20px; }
.brand img.logo-img { max-height: 30px; max-width: 160px; }
.nav { padding: 10px 10px 24px; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 14px 10px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; transition: background .15s var(--ease), color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav a .badge { margin-left: auto; }
.station-switch { margin: 10px 10px 0; }
.station-switch select { width: 100%; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-3); min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.topbar .crumbs a { color: var(--text-2); }
.topbar .spacer { flex: 1; }
.content { padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }
.menu-toggle { display: none; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { margin: 0; }
.page-header .subtitle { color: var(--text-3); margin-top: 4px; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { margin: 0; font-size: 15px; }
.card-body { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.card + .card { margin-top: var(--gap); }
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.span-2 { grid-column: span 2; }
.stack > * + * { margin-top: var(--gap); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }

.stat { padding: 16px 18px; }
.stat .label { color: var(--text-3); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.stat.ok .value { color: var(--ok); } .stat.warn .value { color: var(--warn); } .stat.danger .value { color: var(--danger); }

.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: 3px; transition: width .4s var(--ease); }
.meter.warn > span { background: var(--warn); } .meter.danger > span { background: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-text); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); background: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor; border-color: var(--text-3) transparent var(--text-3) transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.btn-primary.loading::after, .btn-danger.loading::after { border-color: #fff transparent #fff transparent; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn.active { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); z-index: 1; }

/* ---------- Badges & status ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-live { background: var(--live); color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.dot.pulse { animation: pulse 1.6s infinite; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: 13px; color: var(--text); }
.field .help, .help { font-size: 12.5px; color: var(--text-3); margin: 0; }
.field-error { color: var(--danger); font-size: 12.5px; margin: 0; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search],
input[type=date], input[type=time], input[type=datetime-local], input[type=tel], select, textarea {
  width: 100%; height: 36px; padding: 0 10px; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; }
select { padding-right: 28px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input[readonly] { background: var(--surface-2); }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
input[type=range] { width: 100%; accent-color: var(--brand); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 36px; height: 20px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s var(--ease); }
.switch input:checked + .track { background: var(--brand); border-color: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
.input-group { display: flex; }
.input-group input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); min-width: 0; }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; }
.days { display: flex; gap: 4px; flex-wrap: wrap; }
.days label { position: relative; }
.days input { position: absolute; opacity: 0; }
.days span { display: inline-grid; place-items: center; min-width: 42px; height: 32px; padding: 0 6px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--text-2); user-select: none; }
.days input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-text); }
.days input:focus-visible + span { box-shadow: var(--focus); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0; }
legend { font-weight: 650; padding: 0 6px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.segmented { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 8px; gap: 2px; border: 1px solid var(--border); }
.segmented a, .segmented button { border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; font: inherit; font-weight: 550; color: var(--text-2); cursor: pointer; }
.segmented .active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); text-decoration: none; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 600; background: var(--surface); position: sticky; top: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.selected { background: var(--brand-soft); }
.table-toolbar { display: flex; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.table-toolbar .search { position: relative; flex: 1; min-width: 180px; max-width: 360px; }
.table-toolbar .search input { padding-left: 32px; }
.table-toolbar .search .icon { position: absolute; left: 10px; top: 9px; color: var(--text-3); }
.pagination { display: flex; gap: 4px; align-items: center; justify-content: flex-end; padding: 12px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 32px; height: 30px; display: inline-grid; place-items: center; padding: 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--border); color: var(--text-2); }
.pagination .current { background: var(--brand); border-color: var(--brand); color: var(--brand-text); }

/* ---------- Alerts / flash / empty ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 16px; }
.alert .icon { margin-top: 1px; }
.alert-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.alert-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.alert-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert-info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.alert p { color: var(--text); margin: 0; } .alert strong { color: inherit; }
.empty { text-align: center; padding: 48px 24px; color: var(--text-3); }
.empty .icon-lg { width: 40px; height: 40px; color: var(--text-3); margin-bottom: 12px; }
.empty h3 { color: var(--text); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); animation: toast-in .2s var(--ease); }
.toast.ok { border-left-color: var(--ok); } .toast.warn { border-left-color: var(--warn); } .toast.danger { border-left-color: var(--danger); }
.toast .msg { flex: 1; }
.toast button { border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 0; }

/* ---------- Dialog ---------- */
dialog.modal { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog.modal.wide { width: min(880px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(10,14,20,.5); }
dialog.modal .modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
dialog.modal .modal-header h2 { margin: 0; font-size: 16px; }
dialog.modal .modal-body { padding: 18px; overflow: auto; max-height: calc(100vh - 200px); }
dialog.modal .modal-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 14px; border: 0; background: none; font: inherit; font-weight: 550; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs .active { color: var(--brand); border-bottom-color: var(--brand); }
[role="tabpanel"][hidden] { display: none; }

/* ---------- Key/value, copy fields ---------- */
.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 8px 16px; }
.kv dt { color: var(--text-3); font-weight: 500; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.copy-field { display: flex; align-items: center; gap: 6px; }
.copy-field input { font-family: var(--mono); font-size: 13px; }

/* ---------- Now playing / player ---------- */
.now-playing { display: flex; gap: 14px; align-items: center; min-width: 0; }
.now-playing .cover { width: 56px; height: 56px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; overflow: hidden; flex: none; color: var(--text-3); }
.now-playing .cover img { width: 100%; height: 100%; object-fit: cover; }
.now-playing .title { font-weight: 650; font-size: 15px; }
.now-playing .artist { color: var(--text-2); }
.progress { height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; background: var(--brand); width: 0; transition: width 1s linear; }

/* ---------- Upload ---------- */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--text-3); transition: background .15s, border-color .15s; cursor: pointer; }
.dropzone.dragover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.upload-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.upload-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.upload-item .name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item .meter { grid-column: 1 / -1; }

/* ---------- Calendar ---------- */
.cal { --hour-h: 44px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-toolbar { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.cal-toolbar .title { font-weight: 650; margin: 0 8px; }
.cal-grid { display: grid; grid-template-columns: 56px repeat(var(--cols, 7), minmax(90px, 1fr)); overflow: auto; max-height: 70vh; position: relative; }
.cal-head { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 6px; font-weight: 600; font-size: 12.5px; text-align: center; }
.cal-head.today { color: var(--brand); }
.cal-times { border-right: 1px solid var(--border); }
.cal-time { height: var(--hour-h); font-size: 11px; color: var(--text-3); text-align: right; padding: 2px 6px 0 0; border-bottom: 1px solid var(--border); }
.cal-col { position: relative; border-right: 1px solid var(--border); background-image: linear-gradient(to bottom, var(--border) 1px, transparent 1px); background-size: 100% var(--hour-h); min-height: calc(var(--hour-h) * 24); }
.cal-col.today { background-color: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
.cal-event { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 4px 6px; font-size: 12px; color: #fff; overflow: hidden; cursor: grab; box-shadow: var(--shadow-sm); border: 1px solid rgba(0,0,0,.12); user-select: none; touch-action: none; }
.cal-event:focus-visible { box-shadow: var(--focus); }
.cal-event.dragging { opacity: .85; cursor: grabbing; z-index: 5; }
.cal-event .t { font-weight: 650; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event .h { opacity: .9; font-size: 11px; }
.cal-event .resize { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.cal-event.exception { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px); }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 4; pointer-events: none; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); }
.cal-month .cell { min-height: 108px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; font-size: 12px; }
.cal-month .cell.other { background: var(--surface-2); color: var(--text-3); }
.cal-month .cell .d { font-weight: 650; margin-bottom: 4px; }
.cal-month .pill { display: block; border-radius: 4px; padding: 1px 6px; color: #fff; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: 240px; position: relative; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .axis text { fill: var(--text-3); font-size: 11px; }
.chart .grid line { stroke: var(--border); }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2; }
.chart .area { fill: var(--brand); opacity: .12; }
.chart .bar { fill: var(--brand); }
.chart .bar.alt { fill: var(--ok); }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 6px 8px; border-radius: 6px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, var(--brand-soft), transparent), var(--bg); }
.auth-card { width: min(400px, 100%); }
.auth-card .brand { border: 0; justify-content: center; height: auto; padding: 0 0 20px; font-size: 20px; }
.auth-card .card-body { padding: 26px; }

/* ---------- Public player ---------- */
.public-body { background: var(--bg); }
.public-wrap { max-width: 760px; margin: 0 auto; padding: 32px 16px 48px; }
.station-hero { display: flex; gap: 20px; align-items: center; }
.station-hero .logo { width: 104px; height: 104px; border-radius: 16px; background: var(--surface-3); overflow: hidden; flex: none; display: grid; place-items: center; color: var(--text-3); }
.station-hero .logo img { width: 100%; height: 100%; object-fit: cover; }
.player { display: flex; align-items: center; gap: 16px; padding: 18px; }
.player .play-btn { width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-text); display: grid; place-items: center; cursor: pointer; flex: none; box-shadow: var(--shadow); }
.player .play-btn:hover { background: var(--brand-hover); }
.player .play-btn .icon { width: 26px; height: 26px; }
.player .volume { display: flex; align-items: center; gap: 8px; width: 160px; }
.embed-body { margin: 0; background: transparent; }
.embed-player { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; font-family: var(--font); min-height: 84px; }
.embed-player.widget { min-height: 56px; padding: 8px 10px; border-radius: 28px; }
.embed-player .info { min-width: 0; flex: 1; }

/* ---------- Misc ---------- */
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 4px; min-height: 1em; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
.log-view { font-family: var(--mono); font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-all; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; max-height: 560px; overflow: auto; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain > li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-plain > li:last-child { border-bottom: 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); align-items: start; }
.timeline li:last-child { border-bottom: 0; }
.sortable-ghost { opacity: .4; }
.drag-handle { cursor: grab; color: var(--text-3); }
.help-tip { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font-size: 11px; font-weight: 700; cursor: help; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.danger-zone .card-header h2 { color: var(--danger); }
.notice-restart { border-left: 4px solid var(--warn); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: min(300px, 86vw); transform: translateX(-100%); transition: transform .2s var(--ease); box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 0 12px; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .table th, .table td { padding: 8px 10px; }
  .hide-mobile { display: none !important; }
  .station-hero { flex-direction: column; text-align: center; }
  .player { flex-wrap: wrap; justify-content: center; }
}
@media print {
  .sidebar, .topbar, .page-header .actions, .no-print { display: none !important; }
  .app { display: block; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; }
}
