:root {
  --bg: #f5f5f4; --card: #fff; --text: #1c1917; --muted: #78716c; --line: #e7e5e4;
  --live: #15803d; --clip: #b91c1c; --prep: #b45309; --off: #a8a29e;
  --btn: #1c1917; --btn-text: #fff; --focus: #2563eb; --error: #b91c1c;
  --shadow: 0 1px 2px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0a09; --card: #1c1917; --text: #f5f5f4; --muted: #a8a29e; --line: #292524;
    --live: #4ade80; --clip: #f87171; --prep: #fbbf24; --off: #57534e;
    --btn: #f5f5f4; --btn-text: #0c0a09; --focus: #60a5fa; --error: #f87171;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 15px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

header { display: flex; align-items: center; gap: 20px; padding: 10px 20px; background: var(--card);
         border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav button { background: none; border: 0; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); }
nav button.on { background: var(--bg); color: var(--text); font-weight: 600; }
.who { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 14px; flex-wrap: wrap; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--error); min-height: 1.2em; margin: 8px 0 0; }

button.primary, button.secondary, button.danger {
  border-radius: 8px; padding: 9px 14px; cursor: pointer; border: 1px solid transparent; font-weight: 600; }
button.primary { background: var(--btn); color: var(--btn-text); }
button.secondary { background: transparent; border-color: var(--line); }
button.danger { background: transparent; border-color: var(--line); color: var(--error); }
button.link { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; }
button:disabled { opacity: .4; cursor: default; }
button.big { padding: 14px 16px; font-size: 16px; }

.login { max-width: 360px; margin: 10vh auto; background: var(--card); border: 1px solid var(--line);
         border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
label input, label select { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
label.check input { width: auto; margin: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 6px; font-size: 18px; }
.state { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 6px 0 2px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--off); flex: none; }
.s-live .dot { background: var(--live); } .s-clip .dot { background: var(--clip); }
.s-preparing .dot, .s-wait .dot { background: var(--prep); }
.meta { color: var(--muted); font-size: 13px; min-height: 1.3em; }
.warn { color: var(--error); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.msg { font-size: 13px; color: var(--muted); min-height: 1.2em; margin-top: 8px; }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
th { border-top: 0; color: var(--muted); font-weight: 600; font-size: 13px; background: var(--card); }
td .row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.group { margin: 28px 0 10px; font-weight: 700; }
.tablewrap { overflow-x: auto; }
code { font-size: 12.5px; word-break: break-all; }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--card); color: var(--text);
         width: min(640px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog form { padding: 22px; }
dialog .buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.box { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 10px 0; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress div { height: 100%; width: 0; background: var(--btn); transition: width .2s; }
.secret { display: flex; gap: 8px; align-items: center; }
.secret code { flex: 1; padding: 8px; background: var(--bg); border-radius: 8px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--btn); color: var(--btn-text);
         padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#toast.on { opacity: 1; }
@media (max-width: 560px) { .actions { grid-template-columns: 1fr; } header { gap: 10px; } }
