/* Signage control room — admin UI
   Palette: cool studio greys, ink, one signal blue for actions,
   tally-light red reserved for "on air". Playlist colours come from the
   classic broadcast colour-bar set and identify a programme everywhere. */
:root {
  --bg: #E7EAEC;
  --surface: #FFFFFF;
  --surface-2: #F4F6F7;
  --ink: #1B2430;
  --muted: #5B6875;
  --line: #CCD3D9;
  --line-soft: #DEE3E7;
  --action: #2347B8;
  --action-ink: #FFFFFF;
  --tally: #D6362A;
  --ready: #2F8A4E;
  --warn: #B7791F;
  --off: #9AA5AF;
  --rail: #18202B;
  --rail-ink: #C9D2DB;

  --font-ui: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;

  --r-sm: 4px;
  --r-md: 8px;
  --r-tv: 3px;          /* screens are nearly square-cornered, like real panels */
  --hour: 44px;         /* schedule grid row height */
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--font-ui);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--action); }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.rail {
  background: var(--rail); color: var(--rail-ink);
  display: flex; flex-direction: column; padding: 22px 14px 18px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 26px; color: #fff; }
.brand-mark { width: 26px; height: 18px; display: grid; grid-template-columns: repeat(6, 1fr); border-radius: 2px; overflow: hidden; }
.brand-mark i:nth-child(1) { background: #E8B931; } .brand-mark i:nth-child(2) { background: #2E9CB0; }
.brand-mark i:nth-child(3) { background: #4C9A5A; } .brand-mark i:nth-child(4) { background: #B0478A; }
.brand-mark i:nth-child(5) { background: #C8503C; } .brand-mark i:nth-child(6) { background: #3E5BA6; }
.brand b { font: 650 17px/1 var(--font-display); letter-spacing: -.01em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 10px; border-radius: var(--r-sm); color: var(--rail-ink); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: #222C39; color: #fff; }
.nav a[aria-current="page"] { background: #2A3646; color: #fff; box-shadow: inset 3px 0 0 #fff; }
.nav .count { font-size: 12px; color: #8D9AA8; }

.rail-clock { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid #2A3442; }
.rail-clock time { display: block; font: 600 38px/1 var(--font-display); color: #fff; letter-spacing: -.02em; }
.rail-clock span { font-size: 12.5px; color: #8D9AA8; }
.rail-clock button { margin-top: 12px; background: none; border: 0; color: #8D9AA8; padding: 0; cursor: pointer; font-size: 13px; }
.rail-clock button:hover { color: #fff; }

main { padding: 28px 36px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font: 650 34px/1.05 var(--font-display); letter-spacing: -.025em; margin: 0; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 62ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-weight: 550; white-space: nowrap;
}
.btn:hover { border-color: #AEB8C1; background: var(--surface-2); }
.btn.primary { background: var(--action); border-color: var(--action); color: var(--action-ink); }
.btn.primary:hover { background: #1C3A99; }
.btn.danger { color: #A3271D; }
.btn.danger:hover { border-color: #E3A39C; background: #FBEDEB; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(27, 36, 48, .06); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=date], input[type=time], select, textarea {
  height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); width: 100%;
}
textarea { height: auto; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px rgba(35, 71, 184, .15); }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 14px; }

.switch { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--line); position: relative; flex: none; margin: 1px 0 0; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--action); }
.switch input:checked::after { transform: translateX(14px); }
.switch b { font-weight: 600; display: block; }
.switch small { color: var(--muted); }

.days { display: flex; gap: 4px; }
.days label { flex: 1; }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days span { display: block; text-align: center; padding: 7px 0; border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; font-weight: 600; font-size: 13px; background: var(--surface); }
.days input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.days input:focus-visible + span { outline: 2px solid var(--action); outline-offset: 2px; }

.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; box-shadow: inset 0 0 0 2px #fff; }
.swatches button[aria-pressed="true"] { border-color: var(--ink); }

.empty { padding: 48px 24px; text-align: center; color: var(--muted); border: 1.5px dashed var(--line); border-radius: var(--r-md); background: rgba(255, 255, 255, .4); }
.empty h3 { color: var(--ink); font: 600 19px/1.3 var(--font-display); margin: 0 0 6px; }
.empty p { margin: 0 auto 16px; max-width: 46ch; }

/* ------------------------------------------------ screens */
.group-block { margin-bottom: 34px; }
.group-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.group-head h2 { font: 600 20px/1.2 var(--font-display); margin: 0; letter-spacing: -.01em; }
.group-head .meta { color: var(--muted); font-size: 13.5px; }
.group-head .actions { margin-left: auto; }

.tv-grid { display: grid; gap: 22px 18px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.tv { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.tv-panel {
  aspect-ratio: 16 / 9; background: #0E1319; border-radius: var(--r-tv); position: relative; overflow: hidden;
  border: 6px solid #232B35; border-bottom-width: 9px;
}
.tv-panel img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tv-panel .web { position: absolute; inset: 0; display: grid; place-items: center; color: #9FB1C2; font-size: 13px; padding: 10px; text-align: center; word-break: break-all; }
.tv-panel .idle { position: absolute; inset: 0; display: grid; place-items: center; color: #5F6D7B; font-size: 13px; }
.tv-panel .bars { position: absolute; inset: 0; display: flex; opacity: .22; }
.tv-panel .bars i { flex: 1; }
.tv:hover .tv-panel { border-color: #2F3A47; }
.tv:focus-visible { outline: none; }
.tv:focus-visible .tv-panel { outline: 3px solid var(--action); outline-offset: 3px; }
.tally { position: absolute; top: 8px; left: 8px; display: flex; align-items: center; gap: 6px; padding: 3px 8px 3px 6px; border-radius: 3px; background: rgba(10, 14, 19, .78); color: #fff; font-size: 12px; font-weight: 600; }
.tally i { width: 8px; height: 8px; border-radius: 50%; background: var(--off); }
.tally.on i { background: var(--tally); box-shadow: 0 0 0 3px rgba(214, 54, 42, .3); }
.tally.idle i { background: var(--warn); }
.tv-foot { padding: 9px 2px 0; }
.tv-foot b { display: block; font-weight: 600; font-size: 15.5px; }
.tv-foot .sub { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; margin-top: 2px; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); min-width: 0; }
.chip i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.waiting { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 28px; padding: 14px 16px; background: #FFF8E6; border: 1px solid #EBD9A6; border-radius: var(--r-md); align-items: center; }
.waiting b { font-weight: 600; }
.waiting code { font: 650 18px/1 var(--font-display); letter-spacing: .12em; }

/* ------------------------------------------------ schedule (the rundown) */
.sched-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.sched-bar select { width: auto; min-width: 220px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; }

.rundown { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.rundown-head { display: grid; grid-template-columns: 56px repeat(7, 1fr); border-bottom: 1px solid var(--line); background: var(--surface-2); position: sticky; top: 0; z-index: 3; }
.rundown-head div { padding: 9px 10px; font-weight: 600; font-size: 13.5px; }
.rundown-head div.today { color: var(--tally); }
.rundown-head small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.rundown-body { display: grid; grid-template-columns: 56px repeat(7, 1fr); position: relative; height: 620px; overflow-y: auto; }
.hours { position: relative; height: calc(var(--hour) * 24); }
.hours span { position: absolute; right: 8px; font-size: 11.5px; color: var(--muted); transform: translateY(-50%); }
.daycol { position: relative; height: calc(var(--hour) * 24); border-left: 1px solid var(--line-soft);
  background-image: linear-gradient(var(--line-soft) 1px, transparent 1px);
  background-size: 100% var(--hour); cursor: copy; }
.daycol.today { background-color: #FBFCFD; }
.block {
  position: absolute; border-radius: 3px; padding: 4px 7px; overflow: hidden; cursor: pointer;
  color: #fff; font-size: 12.5px; line-height: 1.25; border: 0; text-align: left;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
}
.block b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block span { opacity: .9; white-space: nowrap; }
.block.off { opacity: .4; background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255,255,255,.35) 6px 8px); }
.block.top { box-shadow: inset 0 0 0 2px var(--ink); }
.block:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--tally); z-index: 2; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--tally); }

.sched-list { margin-top: 26px; }
.sched-list h2 { font: 600 20px/1.2 var(--font-display); margin: 0 0 10px; }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
table.list th, table.list td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); font-size: 14px; vertical-align: middle; }
table.list th { font-size: 12.5px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #F7F9FA; }

/* ------------------------------------------------ playlists */
.split { display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: start; }
.pl-list { display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 6px; }
.pl-list button { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 10px; border-radius: var(--r-sm); cursor: pointer; text-align: left; }
.pl-list button:hover { background: var(--surface-2); }
.pl-list button[aria-current="true"] { background: #E9EEF8; }
.pl-list .bar { width: 5px; align-self: stretch; border-radius: 3px; }
.pl-list b { font-weight: 600; display: block; }
.pl-list small { color: var(--muted); }
.editor { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 22px; }
.editor-head { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.editor-head .field { flex: 1; min-width: 220px; }
.editor-head input.title { font: 600 22px/1 var(--font-display); height: 46px; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; padding: 16px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); margin-bottom: 18px; }
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.item { display: grid; grid-template-columns: 22px 28px 96px 1fr 120px auto; gap: 12px; align-items: center; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm); }
.item.dragging { opacity: .4; }
.item.over { border-color: var(--action); box-shadow: 0 -2px 0 var(--action); }
.item .grip { cursor: grab; color: var(--muted); display: grid; place-items: center; }
.item .n { color: var(--muted); font-size: 13px; text-align: right; }
.item .thumb { width: 96px; aspect-ratio: 16/9; border-radius: 2px; background: #1B2430 center/cover; display: grid; place-items: center; color: #9FB1C2; font-size: 11px; }
.item .name b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .name small { color: var(--muted); }
.item .dur { display: flex; align-items: center; gap: 6px; }
.item .dur input { width: 70px; height: 32px; }
.item .dur small { color: var(--muted); }
.total { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; color: var(--muted); }
.editor-foot { display: flex; gap: 8px; justify-content: space-between; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }

/* ------------------------------------------------ library */
.drop { border: 1.5px dashed #A9B4BE; border-radius: var(--r-md); padding: 26px; display: flex; gap: 18px; align-items: center; background: rgba(255, 255, 255, .55); margin-bottom: 22px; flex-wrap: wrap; }
.drop.hot { border-color: var(--action); background: #EEF2FC; }
.drop p { margin: 0; flex: 1; min-width: 220px; }
.drop p b { display: block; font: 600 18px/1.3 var(--font-display); }
.drop p span { color: var(--muted); }
.progress { height: 4px; background: var(--line-soft); border-radius: 2px; overflow: hidden; width: 100%; }
.progress i { display: block; height: 100%; background: var(--action); width: 0; transition: width .2s; }
.filters { display: flex; gap: 4px; margin-bottom: 14px; }
.filters button { border: 1px solid transparent; background: none; padding: 6px 12px; border-radius: 999px; cursor: pointer; font-weight: 550; color: var(--muted); }
.filters button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.media-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.media { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; display: flex; flex-direction: column; }
.media .thumb { aspect-ratio: 16/9; background: #1B2430 center/cover; position: relative; display: grid; place-items: center; color: #9FB1C2; font-size: 12px; padding: 8px; text-align: center; word-break: break-all; }
.media .kind { position: absolute; bottom: 6px; left: 6px; background: rgba(10, 14, 19, .75); color: #fff; font-size: 11.5px; padding: 2px 6px; border-radius: 2px; }
.media .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.media .body b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media .body small { color: var(--muted); }
.media .acts { display: flex; gap: 4px; padding: 0 8px 8px; margin-top: auto; }

/* ------------------------------------------------ dialogs & drawer */
dialog { border: 0; border-radius: var(--r-md); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(15, 22, 32, .35); color: var(--ink); }
dialog.wide { width: min(900px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(15, 22, 32, .5); }
dialog form, dialog .dlg { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
dialog h2 { font: 650 23px/1.2 var(--font-display); margin: 0; letter-spacing: -.015em; }
dialog .lead { color: var(--muted); margin: -8px 0 0; }
dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
dialog .foot .left { margin-right: auto; }
.code-input { display: flex; gap: 8px; }
.code-input input { width: 100%; height: 64px; text-align: center; font: 600 32px/1 var(--font-display); padding: 0; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 52vh; overflow: auto; padding: 2px; }
.picker label { cursor: pointer; border: 2px solid transparent; border-radius: var(--r-sm); background: var(--surface-2); overflow: hidden; display: flex; flex-direction: column; }
.picker label:has(input:checked) { border-color: var(--action); }
.picker input { position: absolute; opacity: 0; }
.picker .thumb { aspect-ratio: 16/9; background: #1B2430 center/cover; display: grid; place-items: center; color: #9FB1C2; font-size: 11px; }
.picker span { padding: 6px 8px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.cmds { display: flex; gap: 6px; flex-wrap: wrap; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: var(--r-sm); opacity: 0; transition: opacity .2s, transform .2s; z-index: 100; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #A3271D; }

/* ------------------------------------------------ login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--rail); }
.login form { background: var(--surface); width: min(380px, 100%); padding: 30px; border-radius: var(--r-md); display: flex; flex-direction: column; gap: 16px; }
.login h1 { font: 650 28px/1.1 var(--font-display); margin: 0; letter-spacing: -.02em; }
.login .err { color: #A3271D; font-size: 14px; min-height: 1.2em; margin: -6px 0 0; }

.settings { max-width: 640px; display: flex; flex-direction: column; gap: 22px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card h2 { font: 600 19px/1.2 var(--font-display); margin: 0; }
.card p { margin: 0; color: var(--muted); }
.card ol { margin: 0; padding-left: 20px; color: var(--ink); }
.card code { background: var(--surface-2); padding: 1px 5px; border-radius: 3px; font-size: 13px; }

/* ------------------------------------------------ responsive */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; gap: 10px; overflow-x: auto; }
  .brand { padding: 0 6px 0 0; }
  .nav { flex-direction: row; }
  .nav .count { display: none; }
  .rail-clock { display: none; }
  main { padding: 20px 16px 48px; }
  .split { grid-template-columns: 1fr; }
  .item { grid-template-columns: 22px 72px 1fr auto; }
  .item .n, .item .dur { display: none; }
  .item .thumb { width: 72px; }
  .rundown { overflow-x: auto; }
  .rundown-head, .rundown-body { min-width: 760px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
