:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #66747a;
  --line: #d9e1df;
  --canvas: #eef2f1;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --teal: #167b70;
  --teal-dark: #0f6158;
  --teal-soft: #dcefeb;
  --blue: #376c91;
  --blue-soft: #e1edf4;
  --amber: #b97712;
  --amber-soft: #f6ead4;
  --red: #b13e43;
  --red-soft: #f5e0e1;
  --shadow: 0 12px 35px rgba(21, 34, 38, 0.12);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  font-weight: 450;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button, a, label, select { -webkit-tap-highlight-color: transparent; }
.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; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 14px; background: var(--ink); color: #f7faf9; display: flex; flex-direction: column; z-index: 10; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; color: inherit; text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 6px; display: grid; place-items: center; background: var(--teal); color: white; flex: 0 0 auto; }
.brand-mark svg { width: 20px; height: 20px; }
.brand strong, .login-brand strong { display: block; font-size: 15px; line-height: 1.1; }
.brand small, .login-brand small { display: block; margin-top: 3px; color: #9cadb1; font-size: 11px; text-transform: uppercase; font-weight: 700; letter-spacing: .08em; }
.primary-nav { display: grid; gap: 5px; }
.nav-item, .icon-text { width: 100%; border: 0; background: transparent; display: flex; align-items: center; gap: 11px; cursor: pointer; }
.nav-item { min-height: 42px; padding: 0 11px; border-radius: 6px; color: #aebbc0; font-weight: 650; text-align: left; }
.nav-item svg { width: 18px; height: 18px; }
.nav-item:hover { color: white; background: #253138; }
.nav-item.active { color: white; background: #2c3a40; box-shadow: inset 3px 0 var(--teal); }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; padding: 16px 8px 0; border-top: 1px solid #344148; }
.server-state { display: flex; align-items: center; gap: 8px; color: #c6d1d4; font-size: 12px; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: #3cc29f; box-shadow: 0 0 0 3px rgba(60, 194, 159, .14); flex: 0 0 auto; }
.icon-text.ghost { padding: 5px 0; color: #93a3a8; font-size: 12px; }
.icon-text.ghost:hover { color: white; }
.icon-text svg { width: 15px; height: 15px; }

.workspace { min-width: 0; padding: 0 30px 38px; }
.topbar { min-height: 90px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.eyebrow { margin: 0 0 4px; color: var(--teal); font-size: 10px; line-height: 1; text-transform: uppercase; font-weight: 800; letter-spacing: .1em; }
h1, h2, h3, p { letter-spacing: 0; }
h1 { margin: 0; font-size: 22px; line-height: 1.15; }
h2 { margin: 0; font-size: 15px; line-height: 1.25; }
h3 { margin: 0; font-size: 14px; }
.top-actions { display: flex; gap: 8px; }
.button { min-height: 38px; padding: 0 14px; border: 1px solid transparent; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 700; font-size: 13px; white-space: nowrap; }
.button svg { width: 16px; height: 16px; }
.button.primary { background: var(--teal); color: white; }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { background: var(--surface); border-color: var(--line); color: #334147; }
.button.secondary:hover { border-color: #b7c6c3; background: #fbfcfc; }
.button.danger { background: var(--red-soft); color: var(--red); }
.button.compact { min-height: 32px; padding: 0 11px; font-size: 12px; }
.button.full { width: 100%; }
.button[disabled] { opacity: .5; cursor: not-allowed; }
.icon-button { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); display: inline-grid; place-items: center; cursor: pointer; color: #526267; flex: 0 0 auto; }
.icon-button:hover { border-color: #aebebb; color: var(--ink); }
.icon-button svg { width: 16px; height: 16px; }
.icon-button.inverse { background: #26353b; border-color: #46575d; color: white; }

.view { display: none; }
.view.active { display: block; }
.channel-rail { padding: 16px 18px; background: var(--ink); color: white; border-radius: 7px; display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 22px; box-shadow: var(--shadow); }
.rail-label span { display: block; color: #9cabb0; font-size: 11px; }
.rail-label strong { display: block; margin-top: 3px; font-size: 15px; }
.rail-slots { min-width: 0; display: grid; grid-template-columns: repeat(10, minmax(20px, 1fr)); gap: 7px; }
.rail-slot { height: 9px; border-radius: 2px; background: #3b494f; position: relative; overflow: hidden; }
.rail-slot.used { background: var(--teal); }
.rail-slot.live::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.25); animation: signal 1.8s ease-in-out infinite; }
@keyframes signal { 0%, 100% { transform: translateX(-100%); } 50% { transform: translateX(100%); } }

.metric-strip { margin: 14px 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.metric { min-width: 0; padding: 15px 17px; display: flex; align-items: center; gap: 12px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-icon { width: 34px; height: 34px; border-radius: 6px; display: grid; place-items: center; flex: 0 0 auto; }
.metric-icon svg { width: 17px; height: 17px; }
.metric-icon.teal { color: var(--teal); background: var(--teal-soft); }
.metric-icon.blue { color: var(--blue); background: var(--blue-soft); }
.metric-icon.amber { color: var(--amber); background: var(--amber-soft); }
.metric-icon.red { color: var(--red); background: var(--red-soft); }
.metric small { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; }
.metric strong { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; font-size: 18px; }

.table-panel, .gauge-panel, .system-facts { border: 1px solid var(--line); border-radius: 7px; background: var(--surface); overflow: hidden; }
.panel-heading { min-height: 58px; padding: 0 17px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
.panel-heading > div > span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.panel-heading > svg { width: 18px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { height: 36px; padding: 0 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); color: #718086; font-size: 10px; text-transform: uppercase; font-weight: 800; text-align: left; }
td { height: 70px; padding: 8px 12px; border-bottom: 1px solid #e7eceb; font-size: 12px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfc; }
th:nth-child(1) { width: 19%; } th:nth-child(2) { width: 10%; } th:nth-child(3) { width: 9%; } th:nth-child(4) { width: 12%; } th:nth-child(5) { width: 12%; } th:nth-child(6) { width: 27%; } th:nth-child(7) { width: 70px; }
.stream-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.stream-name > span:first-child { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 5px; background: var(--surface-2); color: var(--teal); flex: 0 0 auto; }
.stream-name svg { width: 15px; }
.stream-name strong, .stream-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stream-name strong { font-size: 12px; }
.stream-name small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.stream-name small b { margin-right: 6px; color: var(--blue); font-size: 8px; }
.status { display: inline-flex; align-items: center; gap: 6px; min-height: 23px; padding: 0 8px; border-radius: 4px; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.live { color: var(--teal); background: var(--teal-soft); }
.status.idle { color: var(--blue); background: var(--blue-soft); }
.status.starting { color: var(--amber); background: var(--amber-soft); }
.status.stopped { color: #6c777a; background: #e8eceb; }
.status.failed { color: var(--red); background: var(--red-soft); }
.viewer-count { display: flex; align-items: center; gap: 6px; }
.viewer-count svg { width: 14px; color: var(--muted); }
.endpoint { min-width: 0; display: flex; align-items: center; gap: 7px; }
.endpoint-list { min-width: 0; display: grid; gap: 4px; }
.protocol-label { width: 43px; color: var(--muted); flex: 0 0 auto; font-size: 8px; font-weight: 800; text-transform: uppercase; }
.endpoint code { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #405157; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.copy-mini { width: 25px; height: 25px; border: 0; background: transparent; color: #7a888d; cursor: pointer; display: grid; place-items: center; flex: 0 0 auto; }
.copy-mini:hover { color: var(--teal); }
.copy-mini svg { width: 13px; }
.row-menu { position: relative; }
.row-menu summary { list-style: none; }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu[open] .icon-button { color: var(--ink); border-color: #afbfbc; }
.menu-popover { position: absolute; right: 0; top: 38px; width: 156px; padding: 5px; border: 1px solid var(--line); border-radius: 6px; background: white; box-shadow: var(--shadow); z-index: 5; }
.menu-popover button { width: 100%; min-height: 33px; padding: 0 9px; border: 0; border-radius: 4px; background: transparent; display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 11px; text-align: left; }
.menu-popover button:hover { background: var(--surface-2); }
.menu-popover button.danger-text { color: var(--red); }
.menu-popover svg { width: 14px; }

.empty-state { min-height: 280px; display: grid; place-items: center; align-content: center; gap: 12px; color: var(--muted); text-align: center; }
.empty-state[hidden] { display: none; }
.empty-state > span { width: 46px; height: 46px; border-radius: 7px; display: grid; place-items: center; color: var(--teal); background: var(--teal-soft); }
.empty-state svg { width: 22px; }
.empty-state h3 { color: var(--ink); }
.video-list { display: grid; }
.video-item { min-height: 66px; padding: 10px 17px; display: grid; grid-template-columns: minmax(0, 1fr) 110px 145px 34px; align-items: center; gap: 16px; border-bottom: 1px solid #e7eceb; }
.video-item:last-child { border-bottom: 0; }
.video-file { display: flex; align-items: center; gap: 11px; min-width: 0; }
.video-file > span { width: 34px; height: 34px; border-radius: 6px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; flex: 0 0 auto; }
.video-file svg { width: 17px; }
.video-file strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.video-file small, .video-meta { color: var(--muted); font-size: 10px; }

.panel-actions { display: flex; align-items: center; gap: 12px; }
.capacity-label { color: var(--muted); font-size: 11px; font-weight: 750; }
.compositor-notice { min-height: 58px; margin-bottom: 14px; padding: 11px 15px; border: 1px solid #e4b3b5; border-radius: 7px; background: var(--red-soft); color: var(--red); display: flex; align-items: center; gap: 11px; }
.compositor-notice[hidden] { display: none; }
.compositor-notice > svg { width: 19px; flex: 0 0 auto; }
.compositor-notice strong, .compositor-notice span { display: block; }
.compositor-notice strong { font-size: 12px; }
.compositor-notice span { margin-top: 2px; font-size: 10px; }
.composite-list { display: grid; }
.composite-row { min-height: 118px; padding: 13px 16px; border-bottom: 1px solid #e7eceb; display: grid; grid-template-columns: 132px minmax(220px, 1.15fr) 160px minmax(205px, .85fr) 34px; align-items: center; gap: 16px; }
.composite-row:last-child { border-bottom: 0; }
.composite-row:hover { background: #fafcfc; }
.mosaic-preview { width: 132px; aspect-ratio: 16 / 9; padding: 3px; background: var(--ink); border-radius: 5px; display: grid; grid-auto-rows: minmax(0, 1fr); gap: 2px; overflow: hidden; }
.mosaic-columns-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.mosaic-columns-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mosaic-columns-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mosaic-columns-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mosaic-preview > span { min-width: 0; min-height: 0; padding: 3px; background: #34444a; color: #e8efed; display: flex; align-items: flex-start; gap: 3px; overflow: hidden; }
.mosaic-preview b { min-width: 13px; height: 13px; border-radius: 2px; background: var(--teal); color: white; display: grid; place-items: center; font-size: 7px; }
.mosaic-preview small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 7px; }
.composite-summary { min-width: 0; }
.composite-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.composite-title strong, .composite-title small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composite-title strong { font-size: 13px; }
.composite-title small { margin-top: 3px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.composite-facts { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 5px 12px; color: var(--muted); font-size: 9px; }
.composite-facts span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.composite-facts svg { width: 11px; }
.worker-error { max-width: 100%; margin-top: 7px; color: var(--red); display: flex; align-items: center; gap: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.worker-error svg { width: 11px; flex: 0 0 auto; }
.worker-stats { display: grid; gap: 7px; }
.worker-stats span { display: flex; justify-content: space-between; gap: 8px; }
.worker-stats small { color: var(--muted); font-size: 9px; }
.worker-stats strong { font-size: 10px; }
.composite-output { min-width: 0; display: grid; gap: 9px; }
.composite-output > span { color: var(--muted); display: flex; align-items: center; gap: 5px; font-size: 9px; }
.composite-output > span svg { width: 12px; }
.composite-menu { align-self: center; }

.system-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr); gap: 14px; }
.gauge-row { min-height: 300px; display: grid; grid-template-columns: repeat(3, 1fr); place-items: center; padding: 24px; }
.gauge { display: grid; justify-items: center; gap: 12px; }
.gauge > strong { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.gauge-ring { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; position: relative; background: conic-gradient(var(--teal) 0%, #e4eae8 0); }
.gauge-value-0 { background: conic-gradient(var(--teal) 0%, #e4eae8 0); }
.gauge-value-5 { background: conic-gradient(var(--teal) 5%, #e4eae8 0); }
.gauge-value-10 { background: conic-gradient(var(--teal) 10%, #e4eae8 0); }
.gauge-value-15 { background: conic-gradient(var(--teal) 15%, #e4eae8 0); }
.gauge-value-20 { background: conic-gradient(var(--teal) 20%, #e4eae8 0); }
.gauge-value-25 { background: conic-gradient(var(--teal) 25%, #e4eae8 0); }
.gauge-value-30 { background: conic-gradient(var(--teal) 30%, #e4eae8 0); }
.gauge-value-35 { background: conic-gradient(var(--teal) 35%, #e4eae8 0); }
.gauge-value-40 { background: conic-gradient(var(--teal) 40%, #e4eae8 0); }
.gauge-value-45 { background: conic-gradient(var(--teal) 45%, #e4eae8 0); }
.gauge-value-50 { background: conic-gradient(var(--teal) 50%, #e4eae8 0); }
.gauge-value-55 { background: conic-gradient(var(--teal) 55%, #e4eae8 0); }
.gauge-value-60 { background: conic-gradient(var(--teal) 60%, #e4eae8 0); }
.gauge-value-65 { background: conic-gradient(var(--teal) 65%, #e4eae8 0); }
.gauge-value-70 { background: conic-gradient(var(--teal) 70%, #e4eae8 0); }
.gauge-value-75 { background: conic-gradient(var(--teal) 75%, #e4eae8 0); }
.gauge-value-80 { background: conic-gradient(var(--teal) 80%, #e4eae8 0); }
.gauge-value-85 { background: conic-gradient(var(--teal) 85%, #e4eae8 0); }
.gauge-value-90 { background: conic-gradient(var(--teal) 90%, #e4eae8 0); }
.gauge-value-95 { background: conic-gradient(var(--teal) 95%, #e4eae8 0); }
.gauge-value-100 { background: conic-gradient(var(--teal) 100%, #e4eae8 0); }
.gauge-ring::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: white; }
.gauge-ring span { position: relative; font-size: 21px; font-weight: 800; }
.system-facts dl { margin: 0; padding: 8px 17px; }
.system-facts dl div { min-height: 49px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid #e7eceb; }
.system-facts dl div:last-child { border-bottom: 0; }
.system-facts dt { color: var(--muted); font-size: 11px; }
.system-facts dd { margin: 0; font-size: 12px; font-weight: 750; }

dialog { padding: 0; color: var(--ink); }
dialog::backdrop { background: rgba(15, 25, 29, .58); }
.drawer { width: min(430px, calc(100vw - 20px)); max-width: none; height: 100vh; max-height: 100vh; margin: 0 0 0 auto; border: 0; background: var(--surface); box-shadow: var(--shadow); }
.drawer[open] { display: flex; flex-direction: column; }
.drawer-head { min-height: 76px; padding: 0 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2, .credential-head h2 { font-size: 18px; }
.drawer-body { padding: 22px 20px; overflow-y: auto; }
.form-stack { display: grid; gap: 17px; }
.source-fields[hidden] { display: none; }
.form-stack label { display: grid; gap: 7px; color: #455359; font-size: 11px; font-weight: 700; }
input, select { width: 100%; min-height: 40px; padding: 0 11px; border: 1px solid #cdd7d5; border-radius: 5px; outline: none; background: white; color: var(--ink); }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(22,123,112,.1); }
input::placeholder { color: #9ba7aa; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.three { grid-template-columns: repeat(3, 1fr); }
.form-stack label small { color: var(--muted); font-size: 9px; font-weight: 500; }
.source-mode { padding: 3px; border: 1px solid #cdd7d5; border-radius: 6px; background: var(--surface-2); display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.source-mode label { display: block; cursor: pointer; }
.source-mode input { position: absolute; width: 1px; min-height: 1px; opacity: 0; }
.source-mode span { min-height: 36px; padding: 0 8px; border: 1px solid transparent; border-radius: 4px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 10px; font-weight: 750; }
.source-mode svg { width: 14px; }
.source-mode input:checked + span { border-color: var(--line); background: white; color: var(--teal); box-shadow: 0 1px 3px rgba(23,33,38,.08); }
.source-mode input:focus-visible + span { outline: 2px solid var(--teal); outline-offset: 1px; }
.source-fields { min-width: 0; }
.source-fields[hidden] { display: none; }
.toggle-row { min-height: 42px; padding: 0 11px; border: 1px solid #cdd7d5; border-radius: 5px; background: white; display: flex !important; align-items: center; justify-content: space-between; gap: 14px !important; }
.toggle-row input { width: 36px; min-height: 20px; height: 20px; margin: 0; padding: 0; border: 0; accent-color: var(--teal); flex: 0 0 auto; }
.input-prefix, .input-icon { display: flex; align-items: center; border: 1px solid #cdd7d5; border-radius: 5px; background: white; overflow: hidden; }
.input-prefix:focus-within, .input-icon:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(22,123,112,.1); }
.input-prefix > span { padding-left: 11px; color: var(--muted); }
.input-prefix input, .input-icon input { border: 0; box-shadow: none; }
.input-icon { padding-left: 11px; }
.input-icon svg { width: 15px; color: var(--muted); flex: 0 0 auto; }
.drop-zone { min-height: 190px; border: 1px dashed #9eb5b0; border-radius: 7px; background: #f6faf9; display: grid; place-items: center; align-content: center; gap: 9px; cursor: pointer; text-align: center; }
.drop-zone:hover { border-color: var(--teal); background: #f0f8f6; }
.drop-zone > span { width: 42px; height: 42px; border-radius: 6px; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal); }
.drop-zone svg { width: 20px; }
.drop-zone strong { font-size: 13px; }
.drop-zone small { color: var(--muted); font-size: 10px; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.selected-file { margin: 12px 0 18px; padding: 10px; border: 1px solid var(--line); border-radius: 5px; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clipboard-fallback { position: fixed; opacity: 0; }
.upload-progress { margin: 12px 0 18px; }
.upload-progress-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; color: var(--muted); font-size: 10px; }
.upload-progress-heading strong { color: var(--teal); }
.upload-progress progress { width: 100%; height: 8px; display: block; accent-color: var(--teal); }
.composite-drawer { width: min(560px, calc(100vw - 20px)); }
.composite-drawer .input-prefix > span { padding-right: 1px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; white-space: nowrap; }
.source-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.source-fieldset legend { width: 100%; margin-bottom: 7px; color: #455359; display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; }
.source-fieldset legend span { color: var(--muted); font-size: 9px; }
.source-picker { max-height: 230px; border: 1px solid #cdd7d5; border-radius: 5px; overflow-y: auto; background: white; }
.source-option { min-height: 51px; padding: 7px 10px; border-bottom: 1px solid #e7eceb; display: grid !important; grid-template-columns: 17px 24px minmax(0, 1fr); align-items: center; gap: 8px !important; cursor: pointer; }
.source-option:last-child { border-bottom: 0; }
.source-option:hover { background: var(--surface-2); }
.source-option.disabled { opacity: .5; cursor: not-allowed; }
.source-option input { width: 16px; min-height: 16px; margin: 0; accent-color: var(--teal); }
.source-option .source-order { width: 21px; height: 21px; border-radius: 4px; background: var(--surface-2); color: var(--teal); display: grid; place-items: center; font-size: 9px; font-weight: 800; }
.source-option strong, .source-option small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-option strong { color: var(--ink); font-size: 11px; }
.source-option small { margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 500; }
.source-empty { min-height: 90px; color: var(--muted); display: grid; place-items: center; font-size: 10px; }
.credential-dialog { width: min(560px, calc(100vw - 28px)); max-height: min(760px, calc(100vh - 28px)); border: 0; border-radius: 7px; background: var(--ink); color: white; box-shadow: var(--shadow); overflow-y: auto; }
.credential-head { padding: 22px 22px 16px; display: flex; align-items: center; gap: 13px; }
.credential-head > span { width: 40px; height: 40px; border-radius: 6px; display: grid; place-items: center; background: var(--teal); }
.credential-head svg { width: 19px; }
.credential-auth { margin: 0 22px 13px; display: grid; grid-template-columns: 1fr 1.35fr; gap: 8px; }
.credential-auth > div { min-width: 0; }
.credential-auth small, .credential-target > small { display: block; margin-bottom: 5px; color: #9caeb2; font-size: 9px; font-weight: 750; text-transform: uppercase; }
.credential-auth > div > span { min-height: 42px; padding: 4px 5px 4px 11px; border: 1px solid #45555b; border-radius: 5px; background: #202c31; display: flex; align-items: center; gap: 7px; }
.credential-auth code { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dbe6e4; font-size: 11px; }
.credential-target { margin: 0 22px 11px; }
.credential-target[hidden] { display: none; }
.credential-url { margin: 0; padding: 8px 6px 8px 13px; border: 1px solid #45555b; border-radius: 5px; background: #202c31; display: flex; align-items: center; gap: 8px; }
.credential-url code { min-width: 0; flex: 1; overflow-wrap: anywhere; font-size: 10px; color: #dbe6e4; }
.credential-url a { text-decoration: none; }
.credential-dialog > p { margin: 12px 22px 18px; color: #9caeb2; font-size: 10px; }
.credential-dialog form { padding: 0 22px 22px; }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: min(360px, calc(100vw - 44px)); padding: 11px 14px; border-radius: 6px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: 11px; transform: translateY(20px); opacity: 0; pointer-events: none; transition: .18s ease; z-index: 30; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); }
.spinning svg, svg.spinning { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #e8eeec; }
.login-body::before { content: ""; position: fixed; inset: 0 0 auto; height: 6px; background: var(--teal); }
.login-panel { width: min(370px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 7px; background: white; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.brand-mark.large { width: 42px; height: 42px; }
.login-brand strong { font-size: 18px; }
.login-status { margin: 18px 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.form-error { margin: 0; padding: 9px 10px; border-radius: 5px; background: var(--red-soft); color: var(--red); font-size: 10px; }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand > span:last-child, .nav-item span, .sidebar-footer span, .icon-text span { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .sidebar-footer { align-items: center; justify-items: center; }
  .workspace { padding-inline: 20px; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .system-grid { grid-template-columns: 1fr; }
  .composite-row { grid-template-columns: 112px minmax(0, 1fr) 34px; }
  .mosaic-preview { width: 112px; }
  .worker-stats { grid-column: 2; }
  .composite-output { grid-column: 2; }
  .composite-menu { grid-column: 3; grid-row: 1; }
}

@media (max-width: 720px) {
  body { padding-bottom: 64px; }
  .shell { display: block; }
  .sidebar { position: fixed; inset: auto 0 0; width: 100%; height: 62px; padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); display: block; border-top: 1px solid #344148; }
  .brand, .sidebar-footer { display: none; }
  .primary-nav { height: 100%; grid-template-columns: repeat(4, 1fr); gap: 3px; }
  .nav-item { min-height: 48px; display: flex; flex-direction: column; gap: 3px; font-size: 9px; }
  .nav-item span { display: block; }
  .nav-item.active { box-shadow: inset 0 -3px var(--teal); }
  .workspace { padding: 0 12px 24px; }
  .topbar { min-height: 76px; }
  .top-actions .button span { display: none; }
  .top-actions .button { width: 38px; padding: 0; }
  .channel-rail { grid-template-columns: 1fr; gap: 10px; padding: 14px; }
  .rail-label { display: flex; justify-content: space-between; align-items: center; }
  .rail-label strong { margin: 0; }
  .rail-slots { gap: 4px; }
  .metric { padding: 12px; gap: 9px; }
  .metric-icon { width: 30px; height: 30px; }
  .metric strong { font-size: 15px; }
  .table-wrap { overflow: visible; }
  table, thead, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody { padding: 0 12px; }
  tbody tr { position: relative; padding: 14px 40px 14px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  tbody tr:last-child { border-bottom: 0; }
  td { height: auto; padding: 0; border: 0; }
  td:nth-child(1), td:nth-child(6) { grid-column: 1 / -1; }
  td:nth-child(7) { position: absolute; right: 0; top: 14px; }
  .endpoint code { max-width: 75vw; }
  .protocol-label { width: 46px; }
  .menu-popover { position: fixed; right: 14px; top: auto; bottom: 72px; }
  .video-item { grid-template-columns: minmax(0, 1fr) 34px; gap: 10px; }
  .video-item > .video-meta { display: none; }
  .composite-metrics { grid-template-columns: repeat(2, 1fr); }
  .composite-row { padding: 13px 12px; grid-template-columns: 96px minmax(0, 1fr) 34px; gap: 10px; }
  .mosaic-preview { width: 96px; }
  .composite-title { display: grid; justify-content: stretch; }
  .composite-title .status { width: fit-content; }
  .composite-facts span:nth-child(n+3) { display: none; }
  .worker-stats { grid-column: 1 / 3; padding-top: 9px; border-top: 1px solid var(--line); grid-template-columns: repeat(3, 1fr); }
  .worker-stats span { display: grid; }
  .composite-output { grid-column: 1 / -1; }
  .composite-output .endpoint code { max-width: calc(100vw - 80px); }
  .panel-actions .capacity-label { display: none; }
  .gauge-row { min-height: 220px; padding: 15px 8px; }
  .gauge-ring { width: 84px; height: 84px; }
  .gauge-ring::before { inset: 8px; }
  .gauge-ring span { font-size: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .form-row.three { grid-template-columns: 1fr 1fr; }
  .drawer { width: 100%; max-width: 100%; margin: 0; }
  .credential-auth { grid-template-columns: 1fr; }
}

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