[hidden] { display: none !important; }
:root {
  --bg: #e9edf1;
  --panel: #ffffff;
  --ink: #18212b;
  --muted: #5c6977;
  --line: #d3dae2;
  --accent: #0b6e79;
  --accent-ink: #ffffff;
  --accent-soft: #d9eef0;
  --on: #1e9e5a;
  --off: #d98a1c;
  --idle: #9aa5b1;
  --danger: #b83a2e;
  --screen: #0e1318;
  --screen-ink: #b9c4cf;
  --radius-lg: 14px;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --panel: #19212a;
    --ink: #e4e9ef;
    --muted: #93a0ae;
    --line: #2b3542;
    --accent: #4cc3cc;
    --accent-ink: #062226;
    --accent-soft: #163a3f;
    --danger: #ef7a6c;
    --screen: #07090c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Segoe UI Variable Text", "Segoe UI", -apple-system, "SF Pro Text", system-ui, Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 650; margin-bottom: 14px; }
h3 { font-size: 0.95rem; font-weight: 650; }
p { margin: 0; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.strong { font-weight: 600; color: var(--ink); text-decoration: none; }
a.strong:hover { text-decoration: underline; }
.grow { flex: 1; min-width: 0; }
.pad { padding: 4px 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.02rem; }
.brand-mark {
  width: 26px; height: 18px; border-radius: 4px; background: var(--screen); position: relative;
  box-shadow: inset 0 0 0 2px var(--accent);
}
.brand-mark::after {
  content: ""; position: absolute; left: 10px; top: 5px;
  border-left: 7px solid var(--accent); border-top: 4px solid transparent; border-bottom: 4px solid transparent;
}
.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
.nav a:hover { color: var(--accent); }
.nav form { margin: 0; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); cursor: pointer; font-weight: 500; }
.linkbtn:hover { color: var(--accent); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px; }
.crumbs { font-size: 0.85rem; color: var(--muted); margin-bottom: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs .sep { opacity: 0.5; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin-top: 4px; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.card.narrow { max-width: 560px; }
.card.empty { text-align: center; padding: 48px 24px; display: grid; gap: 14px; justify-items: center; }
.card.empty p { max-width: 52ch; }
.cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack-lg { display: grid; gap: 20px; }
@media (max-width: 880px) { .cols { grid-template-columns: 1fr; } }

/* flash */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.flash-ok { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.flash-error { border-color: var(--danger); color: var(--danger); background: transparent; }

/* forms */
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 550; font-size: 0.9rem; }
label.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; }
label.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
input[type=text], input:not([type]), input[type=password], input[type=file] {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px; width: 100%;
}
input[type=file] { padding: 7px; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 0.9rem; line-height: 1;
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
.btn.small { padding: 7px 12px; font-size: 0.82rem; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--danger); border-color: var(--danger); }
.danger-btn { background: var(--danger); border-color: var(--danger); color: #fff; }
.danger-btn:hover { color: #fff; border-color: var(--danger); filter: brightness(1.08); }

details.danger { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; }
details.danger summary { cursor: pointer; color: var(--danger); font-weight: 600; font-size: 0.88rem; }
details.danger form { margin-top: 12px; }

/* logos */
.logo {
  width: 44px; height: 44px; border-radius: 10px; flex: none; overflow: hidden;
  display: grid; place-items: center; background: var(--bg); border: 1px solid var(--line);
}
.logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.logo-lg { width: 60px; height: 60px; border-radius: 12px; }
.logo-initials { font-weight: 700; color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.logo-lg.logo-initials { font-size: 1.2rem; }
.logo-edit { display: flex; gap: 14px; align-items: end; }

/* dashboard */
.loc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 20px; }
.loc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.loc-head.plain { margin: 0; }
.loc-title { flex: 1; min-width: 0; }
.loc-title h2 { margin: 0 0 2px; font-size: 1.1rem; }
.loc-title h2 a { color: var(--ink); text-decoration: none; }
.loc-title h2 a:hover { color: var(--accent); }

.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.tile { display: grid; gap: 3px; text-decoration: none; color: var(--ink); }
.tile-name { font-weight: 600; font-size: 0.92rem; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile:hover .monitor { box-shadow: 0 0 0 2px var(--accent); }

/* The monitor: each screen drawn as a small display */
.monitor {
  position: relative; aspect-ratio: 16 / 9; border-radius: 6px; background: var(--screen);
  border: 3px solid #2a323c; display: grid; place-items: center; padding: 10px; overflow: hidden;
}
.monitor::after { /* stand */
  content: ""; position: absolute; bottom: -3px; left: 50%; width: 22%; height: 3px; transform: translateX(-50%); background: #2a323c;
}
.monitor-text { color: #6f7a86; font-size: 0.72rem; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.monitor.has-video { background: radial-gradient(120% 90% at 30% 20%, color-mix(in srgb, var(--accent) 45%, var(--screen)) 0%, var(--screen) 70%); }
.monitor.has-video .monitor-text { color: var(--screen-ink); }

.tally { width: 9px; height: 9px; border-radius: 50%; background: var(--idle); flex: none; display: inline-block; }
.monitor .tally { position: absolute; top: 7px; right: 7px; }
.tally-on { background: var(--on); box-shadow: 0 0 0 3px color-mix(in srgb, var(--on) 30%, transparent); }
.tally-off { background: var(--off); }
.status { display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 0; }
.list form { margin: 0; }
.add-screen { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }

/* screen page */
.preview { aspect-ratio: 16 / 9; background: var(--screen); border-radius: 10px; overflow: hidden; border: 4px solid #2a323c; }
.preview video { width: 100%; height: 100%; display: block; background: #000; }
.empty-preview { display: grid; place-items: center; align-content: center; gap: 12px; color: #8a96a3; font-size: 0.9rem; }
.meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin: 16px 0; }
.meta div { min-width: 0; }
.meta dt { font-size: 0.78rem; color: var(--muted); }
.meta dd { margin: 2px 0 0; overflow-wrap: anywhere; font-weight: 500; }

.uploader .drop {
  display: grid; gap: 6px; place-items: center; text-align: center; cursor: pointer;
  padding: 34px 18px; border: 2px dashed var(--line); border-radius: 12px; font-weight: 400;
}
.uploader .drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.uploader .drop:hover, .uploader.dragging .drop { border-color: var(--accent); background: var(--accent-soft); }
.uploader .drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop-main { font-weight: 600; font-size: 1rem; }
.uploader.busy .drop { opacity: 0.5; pointer-events: none; }
.progress { margin-top: 14px; display: grid; gap: 8px; }
.bar { height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; border: 1px solid var(--line); }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s linear; }
.uploader.failed .bar span { background: var(--danger); }
.uploader.failed .upload-status { color: var(--danger); }

.links { display: grid; gap: 18px; margin-top: 14px; }
.link-row { display: grid; gap: 5px; }
.link-label { font-weight: 600; font-size: 0.88rem; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-size: 0.8rem; }

/* auth */
.auth { max-width: 420px; margin: 40px auto; display: grid; gap: 16px; }

@media (max-width: 560px) {
  .wrap { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .meta { grid-template-columns: 1fr; }
  .logo-edit { flex-direction: column; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
