:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #1a1d23; --muted: #6b7280; --line: #e3e5e9;
  --accent: #2f5fd0; --accent-ink: #fff; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
h1 { font-size: 20px; margin: 8px 0 16px; }
h2 { font-size: 17px; margin: 0; }
code { background: #eef0f4; padding: 3px 6px; border-radius: 5px; font-size: 13px; word-break: break-all; }
.muted { color: var(--muted); }
input, select { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); min-width: 0; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }

.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 500; padding: 7px 13px; border-radius: 7px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f7f8fa; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.icon { padding: 4px 8px; }
.btn:disabled { opacity: .5; cursor: default; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; }
.login-card { background: var(--panel); padding: 32px; border-radius: 14px; box-shadow: var(--shadow); width: 320px; display: grid; gap: 12px; text-align: center; }
.error { color: var(--bad); min-height: 1em; }
.brand-mark { color: var(--accent); font-size: 18px; }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 650; display: flex; gap: 8px; align-items: center; }
.tabs { display: flex; gap: 4px; height: 100%; }
.tabs button { font: inherit; background: none; border: 0; padding: 0 12px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 550; }
main { max-width: 1180px; margin: 0 auto; padding: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 12px 0 28px; box-shadow: var(--shadow); }
.form { display: grid; gap: 14px; max-width: 460px; }
.form label, .field { display: grid; gap: 5px; font-weight: 500; font-size: 13px; }
.note { background: #fff7e6; border: 1px solid #f4d9a6; color: #7a4b00; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.empty { color: var(--muted); padding: 40px; text-align: center; }

/* screens */
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-title { font-weight: 650; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c4c8cf; flex: none; }
.dot.on { background: #22c55e; box-shadow: 0 0 0 3px #22c55e22; }
.dot.stale { background: #f59e0b; }
.status-line { color: var(--muted); font-size: 12.5px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row .field { flex: 1 1 140px; }
.check { display: flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 500; }
.sched { border-top: 1px solid var(--line); padding-top: 10px; }
.sched-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.sched-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 7px; background: #f7f8fa; margin-top: 6px; font-size: 13px; }
.sched-item .when { color: var(--muted); font-size: 12px; }
.sched-item.live { background: #ecfdf3; outline: 1px solid #bbf0cf; }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: #e0e7ff; color: #3730a3; }
.pill.live { background: #dcfce7; color: #166534; }

/* playlists */
.split { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
.side { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); position: sticky; top: 76px; }
.side .section-head { margin-bottom: 8px; }
.side-list { list-style: none; margin: 0; padding: 0; }
.side-list li { padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 6px; }
.side-list li:hover { background: #f3f4f7; }
.side-list li.active { background: #e8eefc; color: var(--accent); font-weight: 600; }
.side-list .count { color: var(--muted); font-weight: 400; font-size: 12px; }
.main-pane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-height: 300px; }
.pl-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.pl-head input { font-size: 17px; font-weight: 600; flex: 1; border-color: transparent; padding-left: 4px; }
.pl-head input:hover { border-color: var(--line); }
.pl-meta { color: var(--muted); font-size: 13px; margin: 0 0 14px 4px; }
.items { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.item { display: grid; grid-template-columns: 22px 96px 1fr auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.item.dragging { opacity: .4; }
.item.over { border-color: var(--accent); box-shadow: 0 -2px 0 var(--accent); }
.handle { cursor: grab; color: #9aa1ad; text-align: center; user-select: none; }
.thumb { width: 96px; height: 54px; border-radius: 5px; background: #111; object-fit: cover; display: block; }
.item-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 5px; font-size: 12.5px; color: var(--muted); }
.item-sub input { padding: 3px 6px; font-size: 12.5px; }
.item-sub input[type=number] { width: 70px; }
.item-sub .br { flex-basis: 100%; height: 0; }
.item-actions { display: flex; gap: 4px; }
.expired { opacity: .55; }
.footer-bar { display: flex; gap: 8px; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 14px; }
.dirty-note { color: var(--warn); font-size: 13px; font-weight: 500; }

/* media */
.drop { border: 2px dashed #c8ccd4; border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); margin-bottom: 16px; background: #fafbfc; }
.drop.over { border-color: var(--accent); background: #eef3ff; color: var(--accent); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); position: relative; }
.tile .thumb { width: 100%; height: auto; aspect-ratio: 16/9; border-radius: 0; }
.tile-body { padding: 9px 10px; }
.tile-name { font-weight: 550; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { color: var(--muted); font-size: 12px; margin-top: 2px; display: flex; justify-content: space-between; }
.tile-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-actions { opacity: 1; }
.tile-actions .btn { background: rgba(255,255,255,.95); }
.badge { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 99px; }
.tile.pick { cursor: pointer; }
.tile.pick.selected { outline: 3px solid var(--accent); }
.upload-row { display: flex; gap: 10px; align-items: center; font-size: 13px; margin-bottom: 8px; }
.upload-row .bar { flex: 1; height: 6px; background: #e5e7eb; border-radius: 9px; overflow: hidden; }
.upload-row .bar div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.upload-row .name { width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* modal + toast */
.modal { position: fixed; inset: 0; background: rgba(15,18,25,.45); display: grid; place-items: center; z-index: 20; padding: 20px; }
.modal-card { background: var(--panel); border-radius: 14px; padding: 22px; width: min(520px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); display: grid; gap: 14px; }
.modal-card.wide { width: min(980px, 100%); }
.modal-card h3 { margin: 0; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.days { display: flex; gap: 4px; flex-wrap: wrap; }
.days label { display: inline-flex; }
.days input { display: none; }
.days span { padding: 5px 10px; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 500; }
.days input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.code-input { font: 600 26px ui-monospace, Menlo, Consolas, monospace; letter-spacing: 6px; text-transform: uppercase; text-align: center; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1f2430; color: #fff; padding: 10px 16px; border-radius: 9px; z-index: 30; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); }

@media (max-width: 760px) {
  .top { gap: 10px; padding: 0 12px; overflow-x: auto; }
  main { padding: 14px; }
  .split { grid-template-columns: 1fr; }
  .side { position: static; }
  .cards { grid-template-columns: 1fr; }
  .item { grid-template-columns: 18px 72px 1fr; }
  .item-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .thumb { width: 72px; height: 40px; }
}
