/* ==========================================================================
   FMedia Signage — design system v2
   Light default + dark mode (system-aware, manual override via [data-theme])
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #fbfbfd;
  --bg-2: #f4f4f7;
  --surface: #ffffff;
  --surface-2: #f7f7fa;
  --ink: #1d1d1f;
  --ink-2: #424245;
  --ink-3: #6e6e73;
  --ink-4: #86868b;
  --line: rgba(0, 0, 0, 0.06);
  --line-strong: rgba(0, 0, 0, 0.12);
  --pi: #38b0f8;
  --pi-hover: #1a9ae8;
  --pi-ink: #ffffff;
  --pi-soft: rgba(56, 176, 248, 0.13);
  --pi-ring: rgba(56, 176, 248, 0.30);
  --magenta: #b030a8;
  --magenta-soft: rgba(176, 48, 168, 0.11);
  --ok: #1fb854;
  --ok-soft: rgba(31, 184, 84, 0.13);
  --warn: #f2a900;
  --warn-soft: rgba(242, 169, 0, 0.14);
  --bad: #ff3b30;
  --bad-ink: #c41f17;
  --bad-soft: rgba(255, 59, 48, 0.10);
  --shadow-xs: 0 1px 2px rgba(16, 20, 30, 0.05);
  --shadow-sm: 0 2px 10px rgba(16, 20, 30, 0.05), 0 1px 2px rgba(16, 20, 30, 0.04);
  --shadow-md: 0 10px 30px rgba(16, 20, 30, 0.09), 0 2px 8px rgba(16, 20, 30, 0.05);
  --shadow-lg: 0 24px 64px rgba(16, 20, 30, 0.16), 0 8px 20px rgba(16, 20, 30, 0.06);
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --r-pill: 999px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --blur: saturate(180%) blur(20px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --topbar-h: 60px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f14;
  --bg-2: #12151c;
  --surface: #161a23;
  --surface-2: #1c212c;
  --ink: #f2f3f7;
  --ink-2: #c9ccd6;
  --ink-3: #9298a6;
  --ink-4: #6d7383;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --pi: #45bdf9;
  --pi-hover: #6bcbfa;
  --pi-ink: #071018;
  --pi-soft: rgba(69, 189, 249, 0.16);
  --pi-ring: rgba(69, 189, 249, 0.35);
  --magenta: #d466cd;
  --magenta-soft: rgba(212, 102, 205, 0.16);
  --ok: #32d469;
  --ok-soft: rgba(50, 212, 105, 0.15);
  --warn: #f5b83d;
  --warn-soft: rgba(245, 184, 61, 0.15);
  --bad: #ff5c52;
  --bad-ink: #ff8078;
  --bad-soft: rgba(255, 92, 82, 0.14);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0f14;
    --bg-2: #12151c;
    --surface: #161a23;
    --surface-2: #1c212c;
    --ink: #f2f3f7;
    --ink-2: #c9ccd6;
    --ink-3: #9298a6;
    --ink-4: #6d7383;
    --line: rgba(255, 255, 255, 0.07);
    --line-strong: rgba(255, 255, 255, 0.14);
    --pi: #45bdf9;
    --pi-hover: #6bcbfa;
    --pi-ink: #071018;
    --pi-soft: rgba(69, 189, 249, 0.16);
    --pi-ring: rgba(69, 189, 249, 0.35);
    --magenta: #d466cd;
    --magenta-soft: rgba(212, 102, 205, 0.16);
    --ok: #32d469;
    --ok-soft: rgba(50, 212, 105, 0.15);
    --warn: #f5b83d;
    --warn-soft: rgba(245, 184, 61, 0.15);
    --bad: #ff5c52;
    --bad-ink: #ff8078;
    --bad-soft: rgba(255, 92, 82, 0.14);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
  }
}

/* ---------- base ---------- */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  letter-spacing: -0.015em;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; }
p { margin: 0; }
a { color: var(--pi); text-decoration: none; }
a:hover { color: var(--pi-hover); }
img { display: block; }
button { font-family: inherit; }
svg { width: 16px; height: 16px; flex: none; }
::selection { background: var(--pi-soft); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--topbar-h);
  padding: 8px clamp(14px, 2.5vw, 26px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}
.topbar-left { display: flex; align-items: center; gap: 11px; min-width: 0; margin-right: 6px; }
.topbar-left img { height: 32px; width: auto; }
.topbar-name { font-size: 0.98rem; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.topbar-sub { margin-top: -2px; font-size: 0.72rem; color: var(--ink-4); font-weight: 500; white-space: nowrap; }
.topbar-btns { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topbar-btns::-webkit-scrollbar { display: none; }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

nav button, .navbtn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  border-radius: var(--r-pill);
  padding: 8px 14px;
  font: 600 0.87rem/1.1 var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
nav button:hover, .navbtn:hover { background: rgba(128, 128, 140, 0.12); color: var(--ink); }
nav button.on, .navbtn.on { background: var(--magenta-soft); color: var(--magenta); }

/* icon button */
.iconbtn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex: none;
}
.iconbtn:hover { border-color: var(--line-strong); color: var(--ink); }
.iconbtn svg { width: 17px; height: 17px; }
.iconbtn.sm { width: 29px; height: 29px; border-radius: 9px; }
.iconbtn.sm svg { width: 14px; height: 14px; }

/* groups panel rows with hover actions */
.grow { display: flex; align-items: center; gap: 2px; }
.grow .group-row { flex: 1; min-width: 0; }
.grow-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.12s var(--ease); }
.grow:hover .grow-actions, .grow.on .grow-actions { opacity: 1; }
.grow-actions .iconbtn { width: 28px; height: 28px; border-radius: 8px; }
.grow-actions .iconbtn svg { width: 13px; height: 13px; }

/* ---------- layout ---------- */

.shell { width: min(1180px, 100%); margin: 0 auto; padding: 30px clamp(16px, 3vw, 32px) 90px; }
.workspace {
  display: block;
  width: 100%;
  height: calc(100vh - var(--topbar-h));
  border: 0;
  background: var(--bg);
}
.hidden { display: none !important; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title { font-size: clamp(1.6rem, 3vw, 2.1rem); letter-spacing: -0.04em; }
.page-desc { margin: 7px 0 0; color: var(--ink-3); font-size: 1rem; max-width: 62ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.section-gap { margin-top: 26px; }

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  background: var(--pi);
  color: var(--pi-ink);
  border-radius: var(--r-pill);
  padding: 10px 17px;
  font: 600 0.88rem/1.1 var(--font);
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(56, 176, 248, 0.26);
  transition: background 0.15s var(--ease), transform 0.08s var(--ease), box-shadow 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--pi-hover); color: var(--pi-ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn svg { width: 15px; height: 15px; }

.btn.quiet, .btn.ghost {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-xs);
}
.btn.quiet:hover, .btn.ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn.soft { background: var(--pi-soft); color: var(--pi); box-shadow: none; }
.btn.soft:hover { background: var(--pi-soft); filter: brightness(1.06); color: var(--pi); }

.btn.magenta { background: var(--magenta); color: #fff; box-shadow: 0 6px 18px rgba(176, 48, 168, 0.24); }
.btn.magenta:hover { filter: brightness(1.07); }

.btn.danger {
  color: var(--bad-ink);
  background: var(--bad-soft);
  border: 1px solid rgba(255, 59, 48, 0.2);
  box-shadow: none;
}
.btn.danger:hover { background: var(--bad); color: #fff; border-color: transparent; }

.btn.sm { padding: 7px 12px; font-size: 0.8rem; }
.btn.lg { padding: 13px 22px; font-size: 0.95rem; }

.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---------- chips (filter pills) ---------- */

.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--r-pill);
  padding: 6px 13px;
  font: 600 0.8rem/1.2 var(--font);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
}
.chip:hover { border-color: var(--pi); color: var(--pi); }
.chip.on { background: var(--pi-soft); border-color: transparent; color: var(--pi); }
.chip .n { opacity: 0.55; font-weight: 500; margin-left: 4px; }

/* ---------- forms ---------- */

input, select, textarea {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-md);
  padding: 10px 13px;
  font: 500 0.92rem/1.3 var(--font);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(56, 176, 248, 0.75);
  box-shadow: 0 0 0 4px var(--pi-ring);
}
input::placeholder { color: var(--ink-4); }
select { cursor: pointer; }
textarea { width: 100%; resize: vertical; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 0.8rem; font-weight: 600; color: var(--ink-3); }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  padding: 0 14px;
  height: 38px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search:focus-within { border-color: rgba(56, 176, 248, 0.75); box-shadow: 0 0 0 4px var(--pi-ring); }
.search svg { width: 15px; height: 15px; color: var(--ink-4); flex: none; }
.search input {
  border: 0;
  background: transparent;
  padding: 0;
  border-radius: 0;
  min-width: 150px;
  height: 100%;
}
.search input:focus { box-shadow: none; border: 0; }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 40px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track {
  position: absolute; inset: 0;
  background: rgba(128, 128, 140, 0.3);
  border-radius: 999px;
  transition: background 0.18s var(--ease);
  cursor: pointer;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s var(--ease);
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(16px); }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 1.08rem; }
.card h3 { font-size: 0.95rem; color: var(--ink-2); }
.card .meta { margin-top: 4px; }
.card-link { text-align: left; width: 100%; cursor: pointer; }
.card-link:hover { border-color: var(--pi); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.screens-layout { display: grid; grid-template-columns: minmax(230px, 300px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .grid-2, .screens-layout { grid-template-columns: 1fr; } }

/* ---------- stat tiles ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
}
.stat .k { font-size: 0.76rem; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.04em; margin-top: 4px; }
.stat .s { font-size: 0.8rem; color: var(--ink-4); margin-top: 2px; }
.stat.tone-ok .v { color: var(--ok); }
.stat.tone-bad .v { color: var(--bad); }
.stat.tone-warn .v { color: var(--warn); }
.stat.tone-pi .v { color: var(--pi); }

/* ---------- status ---------- */

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ink-4); margin-right: 7px; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.idle { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.off { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad-ink); border-color: transparent; }
.pill.pi { background: var(--pi-soft); color: var(--pi); border-color: transparent; }
.pill.magenta { background: var(--magenta-soft); color: var(--magenta); border-color: transparent; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--r-pill);
  background: var(--pi-soft);
  color: var(--pi);
  font-size: 0.72rem;
  font-weight: 700;
}

.meta, .page-desc { color: var(--ink-3); }
.meta { font-size: 0.86rem; }
.err { color: var(--bad-ink); font-weight: 500; }
.ok-text { color: var(--ok); font-weight: 500; }

/* ---------- tables ---------- */

.tbl-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 0.9rem; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background 0.12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .name { font-weight: 600; }
.tbl .num { font-variant-numeric: tabular-nums; }
.tbl .actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: nowrap; }

/* ---------- screen cards (Now playing) ---------- */

.now-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.screen-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.screen-card .shot-wrap { position: relative; aspect-ratio: 16 / 9; background: #0b0d12; }
:root[data-theme="dark"] .screen-card .shot-wrap { background: #05070b; }
.screen-card .shot-wrap img.shot {
  width: 100%; height: 100%;
  object-fit: contain;
  transition: opacity 0.3s var(--ease);
}
.screen-card .shot-ph {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--ink-4);
  font-size: 0.8rem;
  gap: 6px;
  grid-auto-flow: row;
}
.screen-card .shot-ph svg { width: 26px; height: 26px; opacity: 0.5; }
.screen-card .shot-state {
  position: absolute;
  top: 10px; left: 10px;
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow-xs);
}
.screen-card .shot-tag {
  position: absolute;
  right: 10px; bottom: 10px;
  background: rgba(10, 12, 18, 0.66);
  color: #fff;
  border-color: transparent;
  backdrop-filter: var(--blur);
  font-size: 0.68rem;
}
.screen-card .body { padding: 15px 17px 13px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.screen-card .title-row { display: flex; align-items: center; gap: 2px; min-width: 0; }
.screen-card .title-row h2 {
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.screen-card .vitals { color: var(--ink-4); font-size: 0.8rem; display: flex; gap: 6px; flex-wrap: wrap; }
.screen-card .foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 6px; }
.screen-card .quick { display: flex; gap: 6px; flex-wrap: wrap; }
.screen-card .takeover { display: flex; gap: 6px; }
.screen-card .takeover input { flex: 1; min-width: 0; padding: 8px 12px; font-size: 0.86rem; border-radius: 12px; }

/* ---------- library grid ---------- */

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 13px; }
.lib-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, transform 0.15s var(--ease), box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}
.lib-tile:hover { border-color: var(--pi); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.lib-tile .thumb {
  aspect-ratio: 16 / 10;
  background: var(--bg-2);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}
.lib-tile .thumb img { width: 100%; height: 100%; object-fit: cover; }
.lib-tile .thumb video { width: 100%; height: 100%; object-fit: cover; }
.lib-tile .thumb .ftype { color: var(--ink-4); display: grid; place-items: center; gap: 4px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.lib-tile .thumb .ftype svg { width: 26px; height: 26px; opacity: 0.6; }
.lib-tile .thumb .dur {
  position: absolute;
  right: 7px; bottom: 7px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  border-radius: 7px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  font-variant-numeric: tabular-nums;
}
.lib-tile .info { padding: 10px 12px 11px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.lib-tile .nm { font-size: 0.84rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-tile .sub { font-size: 0.74rem; color: var(--ink-4); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* drop zone */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: var(--blur);
}
.drop-overlay .inner {
  border: 2px dashed var(--pi);
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 46px 64px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}
.drop-overlay .inner svg { width: 40px; height: 40px; color: var(--pi); margin: 0 auto 10px; }
.drop-overlay h2 { font-size: 1.3rem; }

/* upload progress */
.upl-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.upl-row { display: flex; align-items: center; gap: 10px; font-size: 0.84rem; }
.upl-row .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upl-bar { height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; flex: 1.2; }
.upl-bar i { display: block; height: 100%; background: var(--pi); border-radius: 999px; transition: width 0.2s var(--ease); }
.upl-row.done .upl-bar i { background: var(--ok); }
.upl-row.fail .upl-bar i { background: var(--bad); }
.upl-row .st { width: 60px; text-align: right; color: var(--ink-4); font-variant-numeric: tabular-nums; }

/* ---------- playlist editor ---------- */

.pl-layout { display: grid; grid-template-columns: minmax(230px, 280px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .pl-layout { grid-template-columns: 1fr; } }
.pl-list { display: flex; flex-direction: column; gap: 4px; }
.pl-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font: 500 0.9rem/1.2 var(--font);
  color: var(--ink-2);
  text-align: left;
  transition: background 0.12s;
  width: 100%;
}
.pl-item:hover { background: var(--surface-2); }
.pl-item.on { background: var(--pi-soft); color: var(--pi); border-color: transparent; font-weight: 600; }
.pl-item .badge { margin-left: auto; }
.pl-item svg { width: 15px; height: 15px; flex: none; opacity: 0.7; }

.asset-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  margin-bottom: 8px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.asset-row.dragging { opacity: 0.45; border-style: dashed; }
.asset-row.drag-over { border-color: var(--pi); box-shadow: 0 0 0 3px var(--pi-ring); }
.asset-row .grip { color: var(--ink-4); cursor: grab; display: flex; padding: 2px; }
.asset-row .grip svg { width: 16px; height: 16px; }
.asset-row .th { width: 74px; aspect-ratio: 16 / 10; border-radius: 9px; overflow: hidden; background: var(--bg-2); display: grid; place-items: center; flex: none; }
.asset-row .th img { width: 100%; height: 100%; object-fit: cover; }
.asset-row .th svg { width: 20px; height: 20px; color: var(--ink-4); }
.asset-row .nm { flex: 1; min-width: 0; font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-row .dur-field { display: flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 0.8rem; }
.asset-row .dur-field input { width: 64px; padding: 6px 9px; font-size: 0.85rem; border-radius: 10px; text-align: right; }
.asset-row .iconbtn { width: 30px; height: 30px; border-radius: 9px; }
.asset-row .iconbtn svg { width: 14px; height: 14px; }

/* drawer (asset picker) */
.drawer-wrap { position: fixed; inset: 0; z-index: 80; display: flex; justify-content: flex-end; }
.drawer-wrap .scrim { position: absolute; inset: 0; background: rgba(8, 10, 16, 0.42); backdrop-filter: blur(3px); }
.drawer {
  position: relative;
  width: min(400px, 94vw);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: drawer-in 0.25s var(--ease);
}
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.drawer .drawer-body { flex: 1; overflow: auto; padding: 14px 16px 30px; }
.drawer .pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.drawer .pick {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--surface);
  padding: 0;
  transition: border-color 0.12s, transform 0.12s var(--ease);
  text-align: left;
}
.drawer .pick:hover { border-color: var(--pi); transform: translateY(-1px); }
.drawer .pick .thumb { aspect-ratio: 16 / 10; background: var(--bg-2); display: grid; place-items: center; overflow: hidden; }
.drawer .pick .thumb img { width: 100%; height: 100%; object-fit: cover; }
.drawer .pick .thumb svg { width: 18px; height: 18px; color: var(--ink-4); }
.drawer .pick .nm { padding: 6px 8px; font-size: 0.74rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- modals & dialogs ---------- */

dialog.fm-modal {
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--ink);
  padding: 26px;
  width: min(480px, 92vw);
  box-shadow: var(--shadow-lg);
  max-height: 88vh;
  overflow: auto;
}
dialog.fm-modal::backdrop { background: rgba(8, 10, 16, 0.45); backdrop-filter: blur(3px); }
dialog.fm-modal h2 { font-size: 1.15rem; margin-bottom: 4px; }
dialog.fm-modal .modal-sub { color: var(--ink-3); font-size: 0.9rem; margin-bottom: 18px; }
dialog.fm-modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
dialog.fm-modal.wide { width: min(680px, 94vw); }
dialog.fm-modal.preview-media img, dialog.fm-modal.preview-media video { width: 100%; border-radius: var(--r-md); background: #000; max-height: 55vh; object-fit: contain; }

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: min(380px, calc(100vw - 44px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 12px 15px;
  font-size: 0.88rem;
  font-weight: 500;
  animation: toast-in 0.25s var(--ease);
}
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.toast.ok svg { color: var(--ok); }
.toast.err svg { color: var(--bad); }
.toast.info svg { color: var(--pi); }
.toast.gone { animation: toast-out 0.3s var(--ease) forwards; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(8px); opacity: 0; } }

/* ---------- empty / skeleton ---------- */

.empty {
  text-align: center;
  padding: 54px 24px;
  color: var(--ink-3);
}
.empty svg { width: 42px; height: 42px; opacity: 0.4; margin: 0 auto 12px; display: block; }
.empty h2 { font-size: 1.1rem; color: var(--ink); margin-bottom: 4px; }
.empty p { font-size: 0.92rem; max-width: 42ch; margin: 0 auto; }
.empty .btn { margin-top: 16px; }

.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--bg-2) 45%, var(--surface-2) 65%);
  background-size: 200% 100%;
  animation: skel 1.3s infinite linear;
  border-radius: var(--r-sm);
}
@keyframes skel { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- week planner ---------- */

.week-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.slot { display: flex; flex-direction: column; gap: 10px; }
.slot .slot-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.slot .slot-head select { min-width: 200px; }
.slot .days { display: flex; gap: 5px; flex-wrap: wrap; }
.slot .days .chip { min-width: 44px; text-align: center; }
.slot .times { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; color: var(--ink-3); font-size: 0.86rem; }
.slot .times input { padding: 7px 10px; font-size: 0.88rem; }
.slot .hint { font-size: 0.8rem; color: var(--ink-4); }

.uptime-bar { height: 7px; border-radius: 999px; background: var(--bg-2); overflow: hidden; min-width: 90px; }
.uptime-bar i { display: block; height: 100%; border-radius: 999px; background: var(--ok); }

/* ---------- groups panel (Screens) ---------- */

.group-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font: 500 0.92rem/1.2 var(--font);
  color: var(--ink-2);
  text-align: left;
  transition: background 0.12s;
}
.group-row:hover { background: var(--surface-2); }
.group-row.on { background: var(--pi-soft); color: var(--pi); font-weight: 600; }
.group-row .n { margin-left: auto; }

/* ---------- misc ---------- */

ul.plain { list-style: none; padding: 0; margin: 8px 0 0; }
ul.plain li { display: flex; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
ul.plain li:last-child { border-bottom: 0; }

pre.code {
  background: #0b0e14;
  color: #d9f0ff;
  border-radius: var(--r-md);
  padding: 15px 17px;
  overflow: auto;
  font: 12.5px/1.5 var(--mono);
}
:root[data-theme="dark"] pre.code { border: 1px solid var(--line); }

.kbd {
  font: 0.8em var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--line-strong);
  border-top-color: var(--pi);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-note { text-align: center; color: var(--ink-4); font-size: 0.88rem; padding: 18px; }

.report-table { width: 100%; border-collapse: collapse; }
.report-table th, .report-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.report-table th { color: var(--ink-3); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* rows helper (kept for legacy pages) */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.row button.on { background: var(--magenta-soft); color: var(--magenta); box-shadow: none; }
.days button.on { background: var(--magenta-soft); color: var(--magenta); border-color: transparent; }

/* ---------- docs page (docs.html) ---------- */

.docs { max-width: 780px; margin: 0 auto; padding: 36px 28px 96px; }
.docs h2 { margin: 36px 0 8px; font-size: 1.35rem; letter-spacing: -0.03em; }
.docs h3 { margin: 22px 0 6px; font-size: 1.05rem; }
.docs p, .docs li { color: var(--ink-2); font-size: 0.95rem; }
.docs ol, .docs ul { padding-left: 1.2rem; }
.docs li { margin: 6px 0; }
.docs code { font: 0.86em var(--mono); background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.docs .toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 8px 18px; box-shadow: var(--shadow-sm); }
.docs .toc a { display: block; padding: 9px 0; text-decoration: none; font-weight: 600; color: var(--ink); border-bottom: 1px solid var(--line); }
.docs .toc a:last-child { border-bottom: 0; }
.docs .toc a:hover { color: var(--pi); }
.docs table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-sm); }
.docs th, .docs td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 0.92rem; }
.docs th { color: var(--ink-3); font-size: 0.76rem; font-weight: 600; }
.docs figure { margin: 18px 0 28px; }
.docs figure img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-sm); background: var(--surface); }
.docs figcaption { color: var(--ink-4); font-size: 0.85rem; margin-top: 8px; }

/* ---------- login page ---------- */

body.login-body { margin: 0; background: var(--bg); }
.login-split { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr); }
.login-blueprint { display: grid; place-items: center; padding: 28px 24px; background: #071525; }
.login-blueprint img { width: min(680px, 100%); height: auto; }
.login-pane { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
@media (max-width: 900px) {
  .login-split { grid-template-columns: 1fr; }
  .login-blueprint { padding: 16px 8px 0; }
  .login-blueprint img { width: min(560px, 100%); }
  .login-pane { padding: 20px 16px 40px; }
}

/* ---------- responsive ---------- */

@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; padding-bottom: 4px; }
  .topbar-btns { order: 3; flex-basis: 100%; }
  .shell { padding: 22px 14px 70px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .now-grid, .card-grid { grid-template-columns: 1fr; }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
