:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1c1f26;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #d92d20;
  --accent-text: #ffffff;
  --ok: #12a150;
  --warn: #d97706;
  --off: #9ca3af;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1d2026;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --line: #2d3138;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

header { display: flex; align-items: center; gap: 20px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
nav { display: flex; gap: 4px; flex: 1; }
nav button { background: none; border: 0; padding: 8px 14px; border-radius: 6px; color: var(--muted); cursor: pointer; font: inherit; }
nav button.active { background: var(--bg); color: var(--text); font-weight: 600; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--off); }
.conn.on { background: var(--ok); }
main { max-width: 1100px; margin: 0 auto; padding: 20px; }

.card, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.error { color: var(--accent); min-height: 1.2em; margin: 0; }

button, select, input, .btn { font: inherit; }
button { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--accent); }
button.link { border: 0; background: none; color: var(--muted); }
button.small { padding: 2px 8px; }
input[type=text], input[type=password], input[type=number], input[type=time], input[type=date], select {
  border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 6px; padding: 6px 10px;
}

.login { min-height: 100vh; display: grid; place-items: center; }
.login .card { width: 320px; display: grid; gap: 12px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.display { margin: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--off); margin-right: 6px; }
.dot.playing { background: var(--ok); }
.dot.paused, .dot.idle { background: var(--warn); }
.dot.away { background: #3b82f6; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.actions { white-space: nowrap; text-align: right; }
.thumb { width: 64px; height: 36px; object-fit: cover; border-radius: 4px; background: var(--bg); display: block; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--bg); color: var(--muted); }
.disabled-row { opacity: .5; }

.dropzone { border: 2px dashed var(--line); border-radius: 10px; padding: 24px; text-align: center; color: var(--muted); }
.dropzone.over { border-color: var(--accent); color: var(--text); }
.progress { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: var(--accent); width: 0; }

.split { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } header { flex-wrap: wrap; } }
.list button.item { display: block; width: 100%; text-align: left; margin-bottom: 6px; }
.list button.item.active { border-color: var(--accent); }

.days label { display: inline-flex; align-items: center; gap: 3px; margin-right: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; align-items: end; }
.form-grid label { display: grid; gap: 3px; color: var(--muted); font-size: 12px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 20; }
.toast.err { background: var(--accent); color: #fff; }
button.small.active { border-color: var(--accent); color: var(--accent); }
