:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --fg: #1d2027;
  --muted: #6b7280;
  --line: #e4e6ea;
  --accent: #ff5a36;
  --spot: #2f8fe0;
  --ok: #22a55a;
  --bad: #d63c3c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318; --card: #1a1d24; --fg: #eceef2; --muted: #9298a5; --line: #2a2e38;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
button { cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--card); padding: 8px 14px; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
button.danger { color: var(--bad); }
button.sm { padding: 4px 10px; font-size: 13px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--fg); font-size: 15px; }
h2 { margin: 0 0 14px; font-size: 20px; }
h3 { margin: 0 0 10px; font-size: 16px; }
.muted { color: var(--muted); }
.err { color: var(--bad); min-height: 1em; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin: 0 0 6px; }

.top { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 18px; }
.company { display: flex; gap: 8px; flex: 1; min-width: 220px; }
.company select { flex: 1; max-width: 340px; }
.tabs { display: flex; gap: 4px; padding: 10px 20px 0; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--card); }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 10px 14px; color: var(--muted); white-space: nowrap; }
.tabs button.active { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
main { padding: 20px; max-width: 1280px; margin: 0 auto; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.row > button { flex: 0 0 auto; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.split { display: grid; grid-template-columns: 280px 1fr; gap: 16px; }
@media (max-width: 800px) { .split { grid-template-columns: 1fr; } .grid { grid-template-columns: 1fr; } main { padding: 14px; } }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line); }
.badge.music { background: #ff5a3622; color: var(--accent); }
.badge.spot { background: #2f8fe022; color: var(--spot); }
.badge.on { background: #22a55a22; color: var(--ok); }
.badge.off { background: #d63c3c22; color: var(--bad); }

.unit-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.now { padding: 12px; border-radius: 10px; background: var(--bg); }
.now .t { font-weight: 700; font-size: 17px; overflow-wrap: anywhere; }
.bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); }
.controls { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.controls input[type=range] { flex: 1; min-width: 100px; padding: 0; }
.qlist { list-style: none; margin: 0; padding: 0; }
.qlist li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.qlist li:last-child { border-bottom: 0; }

.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); transition: .15s; }
.drop.over { border-color: var(--accent); color: var(--fg); background: #ff5a3610; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.pl-list button { width: 100%; text-align: left; margin-bottom: 6px; display: flex; justify-content: space-between; }
.pl-list button.active { border-color: var(--accent); }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { flex-direction: row; align-items: center; gap: 4px; color: var(--fg); font-size: 14px; }
.inline { flex-direction: row; align-items: center; gap: 6px; color: var(--fg); }
.pick { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick label { flex-direction: row; align-items: center; gap: 8px; padding: 6px 10px; color: var(--fg); border-bottom: 1px solid var(--line); }
code.link { font-size: 12px; word-break: break-all; background: var(--bg); padding: 4px 6px; border-radius: 6px; display: block; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 50; max-width: calc(100% - 32px); }
