/* ══════════════════════════════════════════════════════════════
   FS Kiosk Manager — Design System v3
   FamilySearch palette · Sora / Noto Sans · light + dark
   ══════════════════════════════════════════════════════════════ */

/* ── Tokens ────────────────────────────── */
/* Blue palette: navy #0C2742 · sky #52B0DE · aqua #80CFDF · ice #BDEBF8
   (legacy --fs-green* token names are kept so existing rules keep working) */
:root {
  --blue-navy: #0c2742;
  --blue-navy-2: #16395e;
  --blue-sky: #52b0de;
  --blue-aqua: #80cfdf;
  --blue-ice: #bdebf8;
  --blue-ice-soft: #e6f6fc;
  --blue-deep-text: #1f6d9c;

  --fs-green: var(--blue-sky);
  --fs-green-bright: #22a06b;   /* semantic online/success only */
  --fs-green-mid: var(--blue-aqua);
  --fs-green-deep: var(--blue-deep-text);
  --fs-forest: var(--blue-navy);
  --fs-mint: var(--blue-ice);
  --fs-mint-2: var(--blue-aqua);
  --fs-ink: #0f1d2c;

  --ac-navy: var(--blue-navy);
  --ac-sky: var(--blue-sky);
  --ac-cyan: var(--blue-aqua);
  --ac-ice: var(--blue-ice);
  --ac-purple: #5b6fb0;
  --ac-lavender: #8fa0d8;
  --ac-pink: #f3b1fb;
  --ac-red: #e5546f;
  --ac-lime: #c1d41f;
  --ac-rust: #974607;
  --ac-orange: #d45612;
  --ac-tangerine: #f39a3d;
  --ac-gold: #ffcb5f;

  /* Neutrals — cool blue-grey */
  --n-900: #0f1d2c;
  --n-800: #233446;
  --n-700: #3a4b5d;
  --n-600: #566779;
  --n-500: #748496;
  --n-400: #9aa8b6;
  --n-300: #c3cdd7;
  --n-200: #dce3ea;
  --n-100: #e9eef3;
  --n-50:  #f4f7fa;

  --t-sand: #ece5db;
  --t-rose: #fdf0f2;
  --t-sky:  var(--blue-ice-soft);
  --t-mint: var(--blue-ice-soft);

  /* ── Semantic (light) ── */
  --bg-0: #f3f6f9;
  --bg-1: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #fbfcfe;
  --bg-elev: #f8fafc;
  --bg-sunken: #edf2f6;
  --bg-input: #ffffff;
  --bg-modal: #ffffff;
  --bg-header: rgba(243, 246, 249, 0.82);

  --border: #dfe6ed;
  --border-soft: #ebf0f4;
  --border-strong: #c9d4de;
  --border-accent: rgba(82, 176, 222, 0.55);

  --text: #0f1d2c;
  --text-2: #2c3e51;
  --text-muted: #5e6e7f;
  --text-dim: #93a1af;

  --primary: var(--blue-navy);
  --primary-hover: var(--blue-navy-2);
  --primary-soft: var(--blue-ice-soft);
  --primary-fg: #ffffff;
  --primary-text: var(--blue-deep-text);
  --primary-glow: rgba(82, 176, 222, 0.28);

  --ok-bg: #e4f6ed;   --ok-fg: #1a7a52;  --ok-bd: #b4e4cc;
  --warn-bg: #fff3e0; --warn-fg: #a14408; --warn-bd: #ffd99a;
  --info-bg: var(--blue-ice-soft); --info-fg: #1f6d9c; --info-bd: var(--blue-ice);
  --danger-bg: #fdeff2; --danger-fg: #c42a4c; --danger-bd: #f6c3cd;
  --violet-bg: #eef1fa; --violet-fg: #44579a; --violet-bd: #d2daf1;
  --neutral-bg: #eef2f6; --neutral-fg: #3a4b5d; --neutral-bd: #dfe6ed;

  --success: #1f9a68;
  --warning: #d45612;
  --info: var(--blue-sky);
  --danger: #d6345a;
  --danger-deep: #b3203f;

  --hl-green: var(--fs-green);
  --hl-green-2: var(--primary-text);
  --hl-lime: var(--primary-text);
  --hl-cyan: var(--ac-sky);
  --hl-gold: var(--ac-gold);
  --hl-navy: var(--ac-navy);
  --hl-plum: var(--ac-purple);
  --primary-deep: var(--fs-green-deep);

  /* Sidebar — navy */
  --sb-bg: radial-gradient(420px 260px at 0% 0%, rgba(82, 176, 222, 0.22), transparent 70%), linear-gradient(185deg, #10304f 0%, #0c2742 45%, #081c30 100%);
  --sb-text: #f2f8fc;
  --sb-muted: rgba(226, 240, 250, 0.68);
  --sb-dim: rgba(226, 240, 250, 0.45);
  --sb-line: rgba(255, 255, 255, 0.10);
  --sb-hover: rgba(255, 255, 255, 0.07);
  --sb-accent: var(--blue-aqua);

  --font-display: 'Sora', 'Noto Sans', system-ui, sans-serif;
  --font-body: 'Noto Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  --r-xl: 22px;
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  --r-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(15, 29, 44, 0.06);
  --shadow-card: 0 1px 2px rgba(15, 29, 44, 0.04), 0 8px 24px -6px rgba(15, 29, 44, 0.10);
  --shadow-hover: 0 2px 4px rgba(15, 29, 44, 0.04), 0 18px 40px -10px rgba(12, 39, 66, 0.22);
  --shadow-pop: 0 30px 80px -12px rgba(8, 28, 48, 0.35), 0 0 0 1px rgba(15, 29, 44, 0.04);
  --ring: 0 0 0 4px rgba(82, 176, 222, 0.28);

  --overlay: rgba(8, 22, 38, 0.48);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

/* ── Dark theme ── */
:root[data-theme="dark"] {
  --bg-0: #0a1520;
  --bg-1: #0f1c29;
  --bg-card: #112131;
  --bg-card-hover: #152739;
  --bg-elev: #172a3d;
  --bg-sunken: #08121b;
  --bg-input: #08121b;
  --bg-modal: #102030;
  --bg-header: rgba(10, 21, 32, 0.8);

  --border: #1f3346;
  --border-soft: #182a3b;
  --border-strong: #2c4459;
  --border-accent: rgba(128, 207, 223, 0.5);

  --text: #eef5fa;
  --text-2: #cfdde8;
  --text-muted: #94a9bb;
  --text-dim: #6a8093;

  --primary: var(--blue-sky);
  --primary-hover: var(--blue-aqua);
  --primary-soft: rgba(82, 176, 222, 0.16);
  --primary-fg: #071a2b;
  --primary-text: var(--blue-ice);
  --primary-glow: rgba(82, 176, 222, 0.35);

  --ok-bg: rgba(34, 160, 107, 0.15);   --ok-fg: #7fe0b3; --ok-bd: rgba(34, 160, 107, 0.34);
  --warn-bg: rgba(243, 154, 61, 0.14); --warn-fg: #ffc27a; --warn-bd: rgba(243, 154, 61, 0.32);
  --info-bg: rgba(82, 176, 222, 0.15); --info-fg: var(--blue-ice); --info-bd: rgba(82, 176, 222, 0.34);
  --danger-bg: rgba(229, 84, 111, 0.14); --danger-fg: #ff9fb2; --danger-bd: rgba(229, 84, 111, 0.34);
  --violet-bg: rgba(143, 160, 216, 0.16); --violet-fg: #c2cdf2; --violet-bd: rgba(143, 160, 216, 0.36);
  --neutral-bg: rgba(255, 255, 255, 0.06); --neutral-fg: #b6c4d0; --neutral-bd: rgba(255, 255, 255, 0.1);

  --success: #2fc285;
  --warning: #f39a3d;
  --info: var(--blue-sky);
  --danger: #e5546f;

  --sb-bg: radial-gradient(420px 260px at 0% 0%, rgba(82, 176, 222, 0.16), transparent 70%), linear-gradient(185deg, #0c2742 0%, #081c30 50%, #05121f 100%);
  --sb-accent: var(--blue-aqua);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.25), 0 10px 28px -8px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.3), 0 22px 44px -12px rgba(0, 0, 0, 0.65);
  --shadow-pop: 0 30px 90px -10px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --ring: 0 0 0 4px rgba(82, 176, 222, 0.3);
  --overlay: rgba(2, 8, 14, 0.7);
  color-scheme: dark;
}

/* ── Base ──────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
::selection { background: var(--fs-mint); color: var(--fs-ink); }
[hidden] { display: none !important; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg-0);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
code { font-family: var(--font-mono); font-size: 0.9em; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.05); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }

/* ── Shell ─────────────────────────────── */
.app-container { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────── */
.sidebar {
  width: 248px; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
  background: var(--sb-bg); color: var(--sb-text);
  padding: 22px 14px 14px;
  display: flex; flex-direction: column;
  z-index: 60; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; margin-bottom: 26px; }
.brand-icon-box {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #80cfdf, #52b0de 50%, #1f6d9c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.kiosk-brand-icon { width: 26px; height: 26px; }
.brand-text-block { display: flex; align-items: baseline; gap: 5px; }
.brand-main-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.03em; color: var(--sb-text); }
.brand-sub-title { font-family: var(--font-display); font-size: 17px; font-weight: 300; letter-spacing: -0.03em; color: var(--sb-muted); }

.nav-menu { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 9px 10px; min-height: 40px;
  background: transparent; border: 0; border-radius: 10px;
  color: var(--sb-muted); font: 500 14px/1.2 var(--font-body);
  cursor: pointer; text-align: left; text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-item > i:first-child { width: 18px; text-align: center; font-size: 15px; opacity: 0.85; }
.nav-item:hover { background: var(--sb-hover); color: var(--sb-text); }
.nav-item.active { background: rgba(255, 255, 255, 0.1); color: var(--sb-text); font-weight: 600; }
.nav-item.active > i:first-child { color: var(--sb-accent); opacity: 1; }
.nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--sb-accent);
}
.count-pill { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--sb-dim); font-variant-numeric: tabular-nums; }
.nav-item.active .count-pill { color: var(--sb-muted); }
.nav-divider { height: 1px; background: var(--sb-line); margin: 12px 10px; }
.nav-ext { margin-left: auto; font-size: 10px !important; width: auto !important; opacity: 0.5; }
.nav-dropdown { position: relative; display: block; }
.nav-dropdown > summary { list-style: none; }
.nav-dropdown > summary::-webkit-details-marker { display: none; }
.nav-dropdown[open] > summary { background: var(--sb-hover); color: var(--sb-text); }
.nav-dropdown .dl-menu { top: auto; bottom: calc(100% + 6px); left: 0; right: 0; min-width: 0; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 16px; }
.sidebar-status { display: flex; flex-direction: column; gap: 4px; padding: 0 10px; }
.connection-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--sb-dim); }
.connection-status i { width: 8px; font-size: 10px; text-align: center; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sb-accent); flex-shrink: 0; animation: pulse 2.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(82, 176, 222, 0.5); } 70% { box-shadow: 0 0 0 7px rgba(82, 176, 222, 0); } 100% { box-shadow: 0 0 0 0 rgba(82, 176, 222, 0); } }
.user-profile-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.18); border: 1px solid var(--sb-line);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--fs-mint); color: var(--fs-forest);
  display: flex; align-items: center; justify-content: center;
  font: 600 13px var(--font-display);
}
.user-details { display: flex; flex-direction: column; min-width: 0; flex: 1; cursor: pointer; }
.user-name { font-size: 13px; font-weight: 600; color: var(--sb-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11.5px; color: var(--sb-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-actions { display: flex; gap: 0; align-items: center; }
.logout-btn {
  width: 28px; height: 28px; border-radius: 8px; border: 0; background: transparent;
  color: var(--sb-dim); cursor: pointer; font-size: 12.5px;
  display: inline-flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.logout-btn:hover { background: var(--sb-hover); color: var(--sb-text); }
#logoutBtn:hover { color: #ffb3c1; }
#themeToggleBtn .fa-sun, #themeToggleBtn .theme-label-light { display: none; }
:root[data-theme="dark"] #themeToggleBtn .fa-sun, :root[data-theme="dark"] #themeToggleBtn .theme-label-light { display: inline; }
:root[data-theme="dark"] #themeToggleBtn .fa-moon, :root[data-theme="dark"] #themeToggleBtn .theme-label-dark { display: none; }

.sidebar-toggle {
  display: none; width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  font-size: 15px; cursor: pointer; align-items: center; justify-content: center;
}
.sidebar-scrim { display: none; }

/* ── Main + header ─────────────────────── */
.main-content { flex: 1; min-width: 0; padding: 0 40px 56px; max-width: 1400px; margin: 0 auto; width: 100%; }
.top-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  margin: 0 -40px 24px; padding: 28px 40px 20px;
  background: var(--bg-header);
  backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
}
.header-title { min-width: 0; flex: 1; }
.header-title h2 { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: -0.035em; line-height: 1.15; color: var(--text); }
.header-title p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.header-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn 0.3s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Buttons ───────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: var(--r-pill);
  font: 600 13.5px/1 var(--font-body);
  border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-card); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--border-strong); background: var(--bg-elev); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--text); }
.btn-danger { background: var(--bg-card); border-color: var(--danger-bd); color: var(--danger-fg); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { height: 32px; padding: 0 13px; font-size: 13px; }
.btn-block { width: 100%; height: 44px; }
.btn-icon-only { width: 40px; padding: 0; }
.btn-sm.btn-icon-only { width: 32px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-link { background: none; border: 0; padding: 0; color: var(--primary-text); font: 600 13px var(--font-body); cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.btn-icon {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; color: var(--text-muted); cursor: pointer; font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--bg-sunken); color: var(--text); }
.btn-icon.danger:hover { background: var(--danger-bg); color: var(--danger-fg); }

/* Legacy button aliases (still used in a few modals) */
.btn-emerald, .btn-emerald-save, .btn-save-push {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border: 0; border-radius: var(--r-pill);
  background: var(--primary); color: var(--primary-fg); font: 600 13.5px var(--font-body); cursor: pointer; white-space: nowrap;
}
.btn-save-push { width: 100%; height: 44px; }
.btn-emerald:hover, .btn-emerald-save:hover, .btn-save-push:hover { background: var(--primary-hover); }
.btn-outline-emerald, .btn-header-danger {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 13px;
  border-radius: var(--r-pill); font: 600 13px var(--font-body); cursor: pointer; white-space: nowrap;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
}
.btn-header-danger { color: var(--danger-fg); border-color: var(--danger-bd); }
.btn-header-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-outline-emerald:hover { border-color: var(--border-strong); }

/* ── Dropdown (Get app) ────────────────── */
.dl-dropdown { position: relative; }
.dl-dropdown > summary { list-style: none; }
.dl-dropdown > summary::-webkit-details-marker { display: none; }
.dl-dropdown > summary::marker { content: ""; }
.dl-caret { transition: transform 0.2s var(--ease); }
.dl-dropdown[open] .dl-caret { transform: rotate(180deg); }
.dl-menu {
  position: absolute; z-index: 70; padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--bg-modal); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-pop);
  animation: fadeIn 0.15s var(--ease);
}
.dl-item, .dl-empty { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; color: var(--text); text-decoration: none; }
.dl-item[hidden], .dl-empty[hidden] { display: none; }
.dl-item:hover { background: var(--bg-sunken); }
.dl-empty { opacity: 0.5; }
.dl-icon { width: 20px; text-align: center; font-size: 16px; color: var(--text-muted); }
.dl-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.dl-meta strong { font-size: 13px; font-weight: 600; }
.dl-meta small { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-cta { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.dl-sep { height: 1px; background: var(--border, rgba(127,127,127,0.2)); margin: 6px 4px; }
.dl-note { margin: 2px 10px 6px; font-size: 11px; line-height: 1.35; color: var(--text-muted); }
.dl-note[hidden] { display: none; }

/* ── Stats strip ───────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-lg);
  margin-bottom: 24px; overflow: hidden;
}
.stat-card { display: flex; flex-direction: column; gap: 6px; padding: 18px 22px; }
.stat-card + .stat-card { border-left: 1px solid var(--border-soft); }
.stat-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.stat-dot { width: 8px; height: 8px; border-radius: 50%; }
.stat-dot.online { background: var(--fs-green-bright); }
.stat-dot.saver { background: var(--ac-tangerine); }
.stat-dot.locked { background: var(--ac-sky); }
.stat-dot.battery { background: var(--ac-lavender); }
.stat-value { font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -0.04em; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; }

/* ── Filter bar ────────────────────────── */
.fleet-filter-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.fleet-filter-bar .search-wrap { position: relative; flex: 1; max-width: 420px; min-width: 200px; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-dim); font-size: 13px; pointer-events: none; }
.fleet-filter-bar .search-wrap input { padding-left: 38px !important; padding-right: 34px !important; }
.search-clear-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 50%; border: 0; background: transparent;
  color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 11px;
}
.search-clear-btn:hover { background: var(--bg-sunken); color: var(--text); }
.filter-dropdowns { display: flex; align-items: center; gap: 8px; }
.filter-dropdowns .select-wrap { min-width: 165px; }
.btn-reset-filters { height: 40px; }
.terminal-count-pill { margin-left: auto; font-size: 13px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.filter-controls { display: flex; gap: 8px; align-items: center; }

/* ── Inputs ────────────────────────────── */
input[type="text"], input[type="url"], input[type="number"], input[type="email"], input[type="password"], select, textarea {
  width: 100%; height: 40px; padding: 0 13px;
  background-color: var(--bg-input); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font: 400 14px var(--font-body); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { height: auto; padding: 10px 13px; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input::placeholder, textarea::placeholder { color: var(--text-dim); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: var(--ring); }
select {
  cursor: pointer; appearance: none; -webkit-appearance: none; padding-right: 34px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e9192' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select option { background: var(--bg-modal); color: var(--text); }
input:-webkit-autofill { -webkit-text-fill-color: var(--text) !important; -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset !important; }
input[type="range"], input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
input[type="color"] { width: 40px; height: 40px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-input); cursor: pointer; flex-shrink: 0; }
.color-field { display: flex; gap: 8px; align-items: center; }

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.form-row, .form-row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-help { font-size: 12px; color: var(--text-muted); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.select-wrapper { position: relative; }
.input-with-icon { position: relative; }
.input-icon { display: none; }
.password-field-wrap { position: relative; display: flex; align-items: center; }
.password-field-wrap input { padding-right: 42px !important; }
.btn-toggle-password {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border: none; background: transparent;
  color: var(--text-dim); cursor: pointer; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: 13.5px; transition: color 0.15s, background 0.15s;
}
.btn-toggle-password:hover { color: var(--text); background: var(--bg-sunken); }
.input-with-unit { position: relative; display: flex; align-items: center; }
.input-with-unit input { padding-right: 46px !important; }
.unit-tag { position: absolute; right: 13px; color: var(--text-dim); font-size: 12.5px; pointer-events: none; }
.label-hint { font-size: 12px; color: var(--text-dim); font-weight: 400; }
.divider { border: 0; border-top: 1px solid var(--border-soft); margin: 4px 0 14px; }
.code-input { height: 64px !important; font: 600 30px var(--font-mono) !important; letter-spacing: 10px; text-align: center; color: var(--text) !important; text-transform: uppercase; }
.pin-code-input { font-family: var(--font-mono) !important; letter-spacing: 3px; }
.text-emerald { color: var(--primary-text); }
.modal-desc { font-size: 14px; color: var(--text-muted); line-height: 1.55; margin-bottom: 16px; }

/* Toggles */
.toggles-grid { display: flex; flex-direction: column; margin: 4px 0 0; }
.toggle-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; }
.toggles-grid .toggle-card + .toggle-card { border-top: 1px solid var(--border-soft); }
.toggle-row { margin-bottom: 8px; }
.toggle-card-info { display: flex; flex-direction: column; }
.toggle-card-info strong { font-size: 13.5px; font-weight: 600; color: var(--text); }
.toggle-card-info span { font-size: 12.5px; color: var(--text-muted); }
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch .slider { position: absolute; inset: 0; border-radius: 24px; background: var(--n-300); cursor: pointer; transition: background 0.2s; }
:root[data-theme="dark"] .toggle-switch .slider { background: var(--n-700); }
.toggle-switch .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.25s var(--ease); }
.toggle-switch input:checked + .slider { background: var(--primary); }
.toggle-switch input:checked + .slider::before { transform: translateX(16px); }
.toggle-switch input:focus-visible + .slider { box-shadow: var(--ring); }

/* ── Device cards ──────────────────────── */
.devices-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.device-card {
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px; border-radius: var(--r-lg);
  background: var(--bg-card); border: 1px solid var(--border);
  cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s var(--ease);
  animation: fadeIn 0.35s var(--ease) backwards;
}
.device-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-card); transform: translateY(-2px); }
.device-card.is-offline { background: var(--bg-elev); }
.device-card.is-offline .dc-title h4, .device-card.is-offline .dc-body { opacity: 0.6; }
.dc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dc-title { min-width: 0; }
.dc-title h4 { font-family: var(--font-display); font-size: 16px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.3; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dc-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 3px; font-size: 12.5px; color: var(--text-muted); }
.dc-meta i { font-size: 11px; }
.dc-sep { color: var(--border-strong); }
.dc-cap { text-transform: capitalize; }
.dc-body { display: flex; flex-direction: column; gap: 6px; }
.dc-line { display: flex; align-items: center; gap: 9px; min-width: 0; font-size: 13px; color: var(--text-2); }
.dc-line i { width: 14px; text-align: center; font-size: 12px; color: var(--text-dim); flex-shrink: 0; }
.dc-line span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dc-url { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.dc-url .lock-on { color: var(--ac-purple); }
:root[data-theme="dark"] .dc-url .lock-on { color: var(--ac-lavender); }
.dc-foot { display: flex; align-items: center; gap: 16px; padding-top: 12px; border-top: 1px solid var(--border-soft); font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.dc-battery { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); }
.dc-battery-bar { width: 26px; height: 8px; border-radius: 3px; background: var(--border); overflow: hidden; }
.dc-battery-bar > span { display: block; height: 100%; background: var(--fs-green-bright); border-radius: 3px; }
.dc-battery.mid .dc-battery-bar > span { background: var(--ac-tangerine); }
.dc-battery.low .dc-battery-bar > span { background: var(--ac-red); }
.dc-battery.low { color: var(--danger-fg); }
.dc-pin strong { font-family: var(--font-mono); font-weight: 600; color: var(--text-2); margin-left: 2px; }
.dc-seen { margin-left: auto; }

.status-badge { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; padding: 3px 10px 3px 8px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-badge.online { background: var(--ok-bg); color: var(--ok-fg); }
.status-badge.screensaver { background: var(--warn-bg); color: var(--warn-fg); }
.status-badge.signage { background: var(--info-bg); color: var(--info-fg); }
.dc-line.dc-signage i { color: var(--ac-sky); }
.status-badge.offline { background: var(--neutral-bg); color: var(--neutral-fg); }

/* Empty state */
.empty-state { grid-column: 1 / -1; text-align: center; padding: 56px 24px; border: 1.5px dashed var(--border); border-radius: var(--r-lg); color: var(--text-muted); }
.empty-state.compact { padding: 36px 24px; }
.empty-icon {
  width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  background: var(--primary-soft); color: var(--primary-text);
}
.empty-state h4 { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 14px; max-width: 420px; margin: 0 auto; line-height: 1.55; }
.empty-state .btn { margin-top: 18px; }

/* ── Generic panels ────────────────────── */
.card-box, .panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 24px; }
.panel-head { margin-bottom: 20px; }
.panel-head h3, .box-header h3 { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.025em; color: var(--text); }
.panel-head p, .box-header p { font-size: 13.5px; color: var(--text-muted); margin-top: 3px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ── Profiles ──────────────────────────── */
.profiles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.profile-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px; border-radius: var(--r-lg);
  background: var(--bg-card); border: 1px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.profile-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-card); }
.pc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pc-head h4 { font-family: var(--font-display); font-size: 16px; font-weight: 600; letter-spacing: -0.025em; color: var(--text); line-height: 1.3; }
.orient-tag { flex-shrink: 0; font-size: 11.5px; font-weight: 600; text-transform: capitalize; color: var(--info-fg); background: var(--info-bg); padding: 2px 9px; border-radius: var(--r-pill); }
.profile-card-desc { font-size: 13.5px; color: var(--text-muted); line-height: 1.5; }
.pc-specs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.profile-actions-footer { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.profile-actions-footer .btn-deploy-profile { margin-left: auto; }
.profile-actions-footer .btn-edit-profile { margin-left: -8px; }

/* ── Content library ───────────────────── */
.lib-tabs, .tabs-header-segmented { display: flex; gap: 22px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.lib-tabs::-webkit-scrollbar, .tabs-header-segmented::-webkit-scrollbar { display: none; }
.lib-tab, .tabs-header-segmented .subtab {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
  padding: 10px 0; margin-bottom: -1px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-muted); font: 600 14px var(--font-body); cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.lib-tab i { font-size: 13px; }
.lib-tab:hover, .tabs-header-segmented .subtab:hover { color: var(--text); }
.lib-tab.active, .tabs-header-segmented .subtab.active { color: var(--text); border-bottom-color: var(--primary); }
.lib-pane { display: none; }
.lib-pane.active { display: block; animation: fadeIn 0.25s var(--ease); }
.pane-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.pane-toolbar p { font-size: 14px; color: var(--text-muted); }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.media-card { display: flex; flex-direction: column; border-radius: var(--r-lg); overflow: hidden; background: var(--bg-card); border: 1px solid var(--border); transition: border-color 0.2s, box-shadow 0.2s; }
.media-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-card); }
.media-thumb { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--bg-sunken); border-bottom: 1px solid var(--border-soft); }
.media-thumb iframe { position: absolute; top: 0; left: 0; width: 400%; height: 400%; transform: scale(0.25); transform-origin: top left; border: 0; pointer-events: none; }
.media-thumb video, .media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-body { display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 14px; }
.media-text { min-width: 0; flex: 1; }
.media-text h4 { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-sub { display: block; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
a.media-sub:hover { color: var(--primary-text); }

.nav-themes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.nav-theme-card { border-radius: var(--r-lg); overflow: hidden; background: var(--bg-card); border: 1px solid var(--border); transition: border-color 0.2s, box-shadow 0.2s; }
.nav-theme-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-card); }
.nav-theme-preview { height: 56px; display: flex; align-items: center; padding: 0 14px; position: relative; overflow: hidden; }
.nav-theme-preview img.bg-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.nav-theme-preview .preview-inner { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; }
.nav-theme-preview .preview-title { flex: 1; text-align: center; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-theme-preview .preview-logo { height: 26px; width: 26px; object-fit: contain; }
.nav-theme-info { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 10px 12px 14px; }
.nav-theme-info-name { font-size: 14px; font-weight: 600; color: var(--text); }
.nav-theme-info-meta { display: flex; align-items: center; gap: 6px; font: 12px var(--font-mono); color: var(--text-muted); margin-top: 2px; }
.swatch { width: 10px; height: 10px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.nav-theme-actions { display: flex; gap: 2px; }

/* ── Fleet actions ─────────────────────── */
.bulk-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.bulk-form .form-actions { padding-top: 6px; }
.action-list { display: flex; flex-direction: column; }
.action-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; }
.action-list .action-row + .action-row { border-top: 1px solid var(--border-soft); }
.action-list .action-row:first-child { padding-top: 0; }
.action-icon { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--bg-sunken); color: var(--text-2); font-size: 14px; }
.action-icon.danger { background: var(--danger-bg); color: var(--danger-fg); }
.action-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.action-text strong { font-size: 14px; font-weight: 600; color: var(--text); }
.action-text span { font-size: 13px; color: var(--text-muted); }

/* ── Users table ───────────────────────── */
.table-container { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--bg-card); }
.users-table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; min-width: 640px; }
.users-table th, .users-table td { padding: 12px 18px; border-bottom: 1px solid var(--border-soft); color: var(--text); vertical-align: middle; }
.users-table th { font-size: 12.5px; font-weight: 600; color: var(--text-muted); background: var(--bg-elev); }
.users-table tbody tr:hover td { background: var(--bg-elev); }
.users-table tr:last-child td { border-bottom: 0; }
.users-table td.muted { color: var(--text-muted); }
.col-actions { text-align: right; width: 1%; white-space: nowrap; }
.row-actions { display: inline-flex; align-items: center; gap: 2px; }
.user-cell { display: flex; align-items: center; gap: 12px; }
.user-cell-avatar { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary-text); font: 600 13px var(--font-display); }
.user-cell strong { font-weight: 600; }
.user-cell small { display: block; font-size: 12.5px; color: var(--text-muted); }
.you-tag { font-size: 11px; font-weight: 600; color: var(--text-muted); background: var(--bg-sunken); padding: 1px 7px; border-radius: var(--r-pill); margin-left: 4px; }
.role-tag { display: inline-flex; padding: 2px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; }
.role-tag.super { background: var(--violet-bg); color: var(--violet-fg); }
.role-tag.manager { background: var(--ok-bg); color: var(--ok-fg); }
.role-tag.viewer { background: var(--info-bg); color: var(--info-fg); }
.status-tag { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; }
.status-tag.active { color: var(--text-2); }
.status-tag.active .status-dot { background: var(--fs-green-bright); }
.status-tag.blocked { color: var(--danger-fg); }

/* ── Modals ────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000; padding: 24px;
  display: flex; align-items: center; justify-content: center;
  background: var(--overlay); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.25s, visibility 0.25s;
}
.modal-overlay.active { opacity: 1; visibility: visible; pointer-events: auto; }
.modal-card, .modal-dialog {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--bg-modal); color: var(--text);
  border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-pop);
  animation: modalIn 0.3s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.wide-modal { max-width: 820px; }
.device-modal-card, .device-modal-card.wide-modal { max-width: 1080px; }
.sm-modal { max-width: 440px !important; }
.modal-header {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 20px 24px; background: var(--bg-modal); border-bottom: 1px solid var(--border-soft);
}
.modal-header h2, .modal-header h3 { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -0.03em; color: var(--text); display: flex; align-items: center; gap: 10px; }
.modal-header h2 > i, .modal-header h3 > i { display: none; }
.modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px 20px; border-top: 1px solid var(--border-soft); }
.close-btn, .modal-close {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; border: 0;
  background: transparent; color: var(--text-muted); font-size: 20px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: background 0.15s, color 0.15s;
}
.close-btn:hover, .modal-close:hover { background: var(--bg-sunken); color: var(--text); }

/* Device modal */
.device-modal-card {
  max-width: 1040px !important;
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 !important;
}
.device-modal-card .modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-card);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.device-modal-card .modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.device-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.modal-title-group { display: flex; align-items: center; gap: 12px; min-width: 0; }
.modal-title-text { min-width: 0; }
.modal-title-text h3 { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.modal-subtitle { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; font-size: 13px; color: var(--text-muted); }
.modal-subtitle .mono { font-size: 12px; }
.modal-sub-dot { color: var(--border-strong); }
.status-indicator-ring { width: 12px; height: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.status-indicator { width: 10px; height: 10px; border-radius: 50%; background: var(--n-400); }
.status-indicator.online { background: var(--fs-green-bright); box-shadow: 0 0 0 4px var(--primary-soft); }
.modal-header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.modal-layout { display: grid; grid-template-columns: 340px 1fr; gap: 28px; align-items: start; }
.modal-preview-column { position: sticky; top: 0; display: flex; flex-direction: column; gap: 12px; }
.modal-settings-column { min-width: 0; }

.screen-kiosk-bezel { background: #0d1b2a; border-radius: 18px; padding: 8px; box-shadow: 0 16px 40px -18px rgba(15, 30, 28, 0.6); }
.screen-frame { border-radius: 11px; overflow: hidden; background: #08121b; }
.screen-header-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; font-size: 11px; color: #a7a9aa; }
.screen-header-left { display: flex; align-items: center; gap: 8px; }
.live-tag { display: flex; align-items: center; gap: 6px; color: #e3f7ec; font-weight: 600; }
.pulse-green { color: var(--fs-green-bright); font-size: 7px; animation: livePulse 1.8s infinite; }
@keyframes livePulse { 50% { opacity: 0.35; } }
.orientation-pill { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; color: #8e9192; }
.time-tag { font-family: var(--font-mono); font-size: 10.5px; }
.screen-display { position: relative; aspect-ratio: 16 / 10; display: flex; align-items: center; justify-content: center; overflow: hidden; background: radial-gradient(circle at 50% 40%, #1f2b2c, #0e1214 70%); }
.screen-display img { width: 100%; height: 100%; object-fit: contain; display: block; }
.screen-placeholder { text-align: center; padding: 20px; }
.screen-placeholder-icon { width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.06); color: #8e9192; font-size: 16px; }
.placeholder-main { font-size: 13px; font-weight: 600; color: #eeeeee; }
.placeholder-sub { font-size: 12px; color: #8e9192; margin-top: 2px; }
.screen-loading-overlay { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: rgba(14, 18, 20, 0.82); color: var(--fs-mint); font-size: 12px; font-weight: 600; }
.loading-spinner { width: 28px; height: 28px; border: 3px solid rgba(245, 243, 240, 0.2); border-top-color: var(--sb-accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-preview-refresh { position: absolute; right: 10px; bottom: 10px; z-index: 4; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.12); color: #fff; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px); transition: background 0.15s; }
.btn-preview-refresh:hover { background: var(--primary); color: var(--primary-fg); }

.live-url-banner { display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 14px; border-radius: 12px; background: var(--bg-elev); border: 1px solid var(--border-soft); }
.live-pulse-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--fs-green-bright); animation: livePulse 1.8s infinite; }
.live-url-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.live-url-label { font-size: 12px; color: var(--text-muted); }
.live-url-sync-time { color: var(--text-dim); }
.live-url-link { font: 500 12.5px var(--font-mono); color: var(--text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-url-link:hover { color: var(--primary-text); text-decoration: underline; }
.btn-copy-url { position: relative; width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.btn-copy-url:hover { background: var(--bg-sunken); color: var(--text); }
.copy-tooltip { position: absolute; top: -28px; right: 0; padding: 3px 8px; border-radius: 6px; background: var(--fs-ink); color: #fff; font-size: 11px; font-weight: 600; white-space: nowrap; opacity: 0; transform: translateY(4px); transition: all 0.2s; pointer-events: none; }
.btn-copy-url.copied .copy-tooltip { opacity: 1; transform: none; }

.remote-action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.btn-action {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 6px; border-radius: 12px; cursor: pointer;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-2);
  font: 600 12.5px var(--font-body); transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.btn-action i { font-size: 15px; color: var(--text-muted); }
.btn-action:hover { border-color: var(--primary); color: var(--primary-text); }
.btn-action:hover i { color: var(--primary-text); }
.btn-action:disabled { opacity: 0.5; cursor: not-allowed; }

/* Kiosk Rail Telemetry Card */
.kiosk-rail-card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kiosk-rail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  gap: 8px;
}
.rail-label {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.rail-label i { font-size: 11px; opacity: 0.8; }
.rail-value {
  font-weight: 500;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.tabs-header-segmented { margin-bottom: 16px; }
.subtab-pane { display: none; }
.subtab-pane.active { display: block; animation: fadeIn 0.2s var(--ease); }

.active-profile-card { display: flex; flex-direction: column; gap: 10px; padding: 14px; margin-bottom: 16px; border-radius: 14px; background: var(--bg-elev); border: 1px solid var(--border-soft); }
.active-profile-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.active-profile-tag { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--primary-text); }
.active-profile-info h4 { font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); margin-top: 2px; }
.active-profile-selector-row { display: flex; align-items: center; gap: 8px; }
.active-profile-selector-row .btn { height: 38px; }

/* Section Headers (Clean, replaces accordions) */
.form-section-header {
  display: flex;
  align-items: center;
  margin: 22px 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.form-section-header:first-of-type {
  margin-top: 10px;
}
.form-section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-soft);
  margin-left: 12px;
}

.kv-list { display: flex; flex-direction: column; margin-bottom: 16px; }
.kv-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.kv-row dt { font-size: 13.5px; color: var(--text-muted); flex-shrink: 0; }
.kv-row dd { font-size: 13.5px; font-weight: 500; color: var(--text); text-align: right; word-break: break-word; }
.kv-row dd.mono { font-size: 12.5px; }
.ota-action-card { padding: 14px; border-radius: 14px; background: var(--bg-elev); border: 1px solid var(--border-soft); }

.logs-pane-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.logs-title { display: flex; align-items: center; gap: 8px; }
.logs-title strong { font-size: 14px; font-weight: 600; color: var(--text); }
.logs-actions { display: flex; align-items: center; gap: 4px; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 600; background: var(--bg-sunken); color: var(--text-muted); }
#deviceLogsTerminal {
  height: 400px; overflow-y: auto; padding: 12px 14px; border-radius: 12px;
  background: #111618; color: #e0e1e2; font: 11.5px/1.65 var(--font-mono);
  white-space: pre-wrap; word-break: break-all; scrollbar-width: thin;
}
.logs-empty { color: #8e9192; font-style: italic; }

/* ── Login ─────────────────────────────── */
#loginModal { background: radial-gradient(900px 600px at 15% 0%, rgba(82, 176, 222, 0.45), transparent 60%), radial-gradient(700px 500px at 100% 100%, rgba(128, 207, 223, 0.22), transparent 60%), linear-gradient(160deg, #10304f, #071a2b); backdrop-filter: none; }
.login-card { max-width: 400px !important; padding: 36px 32px 30px !important; border: 0 !important; }
.login-card input[type="text"],
.login-card input[type="email"],
.login-card input[type="password"] {
  background-color: var(--bg-sunken);
  border: 1px solid var(--border-strong);
}
.login-card input:focus {
  background-color: var(--bg-input);
  border-color: var(--primary);
}
.login-header { text-align: center; margin-bottom: 24px; }
.login-icon-container { width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px; display: flex; align-items: center; justify-content: center; background: linear-gradient(145deg, #80cfdf, #52b0de 50%, #1f6d9c); }
.login-kiosk-icon { width: 36px; height: 36px; }
.login-header h2 { font-family: var(--font-display); font-size: 23px; font-weight: 600; letter-spacing: -0.035em; }
.login-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.login-card .btn-block { margin-top: 6px; }
.login-error, .pair-error { margin-bottom: 12px; padding: 10px 12px; border-radius: 10px; font-size: 13px; font-weight: 500; text-align: center; color: var(--danger-fg); background: var(--danger-bg); }
.login-success { margin-bottom: 12px; padding: 10px 12px; border-radius: 10px; font-size: 13px; font-weight: 500; text-align: center; color: var(--ok-fg) !important; background: var(--ok-bg); }

/* ── Alerts + toasts ───────────────────── */
.storage-alert { display: none; align-items: center; gap: 12px; margin-bottom: 20px; padding: 12px 16px; border-radius: 12px; background: var(--warn-bg); color: var(--warn-fg); font-size: 13.5px; line-height: 1.5; }
.storage-alert > i { flex-shrink: 0; }
.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--fs-ink); color: #fff; font-size: 13.5px; line-height: 1.45; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.45); animation: toastIn 0.3s var(--ease); }
.toast i { margin-top: 2px; color: var(--fs-green-bright); }
.toast.error i { color: #ff9fb2; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all 0.25s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── Responsive ────────────────────────── */
@media (max-width: 1100px) {
  .bulk-layout { grid-template-columns: 1fr; }
  .modal-layout { grid-template-columns: 1fr; }
  .modal-preview-column { position: static; }
  .device-modal-card, .device-modal-card.wide-modal { max-width: 640px; }
}
@media (max-width: 1020px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-105%); transition: transform 0.3s var(--ease); box-shadow: var(--shadow-pop); }
  body.nav-open .sidebar { transform: none; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity 0.3s; }
  body.nav-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .main-content { padding: 0 20px 48px; }
  .top-header { margin: 0 -20px 18px; padding: 16px 20px; }
  .header-title h2 { font-size: 22px; }
  .header-title p { display: none; }
}
@media (max-width: 760px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card:nth-child(3) { border-left: 0; }
  .stat-card:nth-child(n+3) { border-top: 1px solid var(--border-soft); }
  .fleet-filter-bar { flex-wrap: wrap; }
  .fleet-filter-bar .search-wrap { max-width: none; flex-basis: 100%; }
  .filter-dropdowns { flex: 1; }
  .filter-dropdowns .select-wrap { flex: 1; width: auto; }
  .terminal-count-pill { display: none; }
  .devices-grid, .profiles-grid, .media-grid, .nav-themes-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-grid { grid-template-columns: 1fr; }
  .pane-toolbar { align-items: flex-start; }
  .header-actions .btn-primary { padding: 0 14px; }
  .modal-overlay { padding: 10px; }
  .modal-body { padding: 18px; }
  .modal-header { padding: 16px 18px; }
  .btn-header-save { padding: 0 12px; }
}

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

/* ══════════════════════════════════════════════════════════════
   Animated Screensaver Designer (ssx-)
   ══════════════════════════════════════════════════════════════ */
.ssx-lib-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ssx-card.modal-card { max-width: 1240px; width: 100%; max-height: 94vh; display: flex; flex-direction: column; overflow: hidden; }
.ssx-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); gap: 0; min-height: 0; flex: 1; overflow: hidden; }
.ssx-form { overflow-y: auto; padding: 18px 26px 26px; display: flex; flex-direction: column; gap: 18px; border-right: 1px solid var(--border-soft); }
.ssx-section { display: flex; flex-direction: column; gap: 12px; }
.ssx-section + .ssx-section { padding-top: 18px; border-top: 1px solid var(--border-soft); }
.ssx-h { font-family: var(--font-display); font-size: 14px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; letter-spacing: -0.01em; }
.ssx-h > i { color: var(--primary-text); }
.ssx-seg { display: inline-flex; padding: 3px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--r-pill); width: max-content; }
.ssx-seg button { border: 0; background: transparent; color: var(--text-muted); font: 600 12.5px var(--font-body); padding: 7px 14px; border-radius: var(--r-pill); cursor: pointer; display: inline-flex; gap: 7px; align-items: center; }
.ssx-seg button.active { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow-xs); }
.ssx-colors { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.ssx-color { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.ssx-color input[type="color"] { width: 100%; height: 38px; padding: 3px; }
.ssx-checks { justify-content: flex-end; gap: 8px; }
.ssx-check { font-weight: 500 !important; font-size: 13px !important; color: var(--text) !important; cursor: pointer; }
.ssx-check input { width: 16px; height: 16px; accent-color: var(--primary); }
.ssx-row { display: flex; gap: 10px; align-items: center; }
.ssx-row input { flex: 1; min-width: 0; }
.ssx-file { position: relative; overflow: hidden; cursor: pointer; }
.ssx-file input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ssx-slides-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ssx-slides { display: flex; flex-direction: column; gap: 12px; }
.ssx-slide { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg-elev); overflow: hidden; }
.ssx-slide-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border-soft); background: var(--bg-card); }
.ssx-slide-num { width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); font: 700 12px var(--font-display); display: grid; place-items: center; flex-shrink: 0; }
.ssx-slide-title { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ssx-slide-tools { display: flex; gap: 4px; }
.ssx-slide-tools .btn-icon { width: 30px; height: 30px; }
.ssx-slide-tools .btn-icon:disabled { opacity: 0.35; cursor: not-allowed; }
.ssx-slide-tools .ssx-danger:hover:not(:disabled) { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-bd); }
.ssx-slide-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.ssx-slide-body textarea { resize: vertical; min-height: 54px; font-family: var(--font-body); }
.ssx-row-3 { grid-template-columns: minmax(0, 1fr) 110px; }
.ssx-photo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ssx-thumb { width: 56px; height: 56px; border-radius: 10px; border: 1px solid var(--border); overflow: hidden; flex-shrink: 0; display: grid; place-items: center; color: var(--text-dim);
  background: repeating-conic-gradient(var(--n-200) 0% 25%, var(--bg-card) 0% 50%) 50% / 12px 12px; }
.ssx-thumb img { width: 100%; height: 100%; object-fit: contain; }
.ssx-thumb.empty { background: var(--bg-sunken); }
.ssx-fit summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-2); padding: 2px 0; }
.ssx-fit[open] summary { margin-bottom: 10px; }
.ssx-sliders { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; margin-top: 10px; }
.ssx-sliders label { display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--text-muted); }
.ssx-sliders input[type="range"], .ssx-preview input[type="range"], #ssxLogoScale { accent-color: var(--primary); width: 100%; }
.ssx-sliders .btn { grid-column: 1 / -1; justify-self: start; }

.ssx-preview { padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 12px; background: var(--bg-sunken); overflow-y: auto; }
.ssx-stage { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.ssx-stage canvas { display: block; max-width: 100%; max-height: min(62vh, calc(94vh - 340px)); width: auto; height: auto; border-radius: 14px; box-shadow: 0 18px 40px -18px rgba(0,0,0,0.45), 0 0 0 1px rgba(0,0,0,0.06); background: #000; }
.ssx-transport { display: flex; align-items: center; gap: 10px; }
.ssx-transport input { flex: 1; }
.ssx-play { width: 36px; height: 36px; padding: 0 !important; justify-content: center; border-radius: 50% !important; }
.ssx-time { font: 500 12px var(--font-mono); color: var(--text-muted); min-width: 92px; text-align: right; }
.ssx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ssx-chip { border: 1px solid var(--border); background: var(--bg-card); color: var(--text-muted); border-radius: var(--r-pill); padding: 5px 10px; font: 600 11.5px var(--font-body); cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ssx-chip.active { border-color: var(--primary); color: var(--primary-text); background: var(--primary-soft); }
.ssx-export { display: flex; gap: 8px; flex-wrap: wrap; }
.ssx-progress { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-muted); }
.ssx-bar { flex: 1; height: 6px; border-radius: 6px; background: var(--border); overflow: hidden; }
.ssx-bar span { display: block; height: 100%; width: 0; background: var(--primary); transition: width 0.15s; }

/* Library cards */
.ssx-thumbwrap { position: relative; height: 178px; background: var(--fs-ink); overflow: hidden; display: flex; justify-content: center; }
.ssx-thumbwrap img { height: 100%; width: auto; max-width: 100%; object-fit: contain; display: block; }
.ssx-thumb-empty { display: grid; place-items: center; width: 100%; color: var(--n-400); font-size: 28px; }
.ssx-badge { position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,0.6); color: #fff; font: 600 11px var(--font-body); padding: 4px 9px; border-radius: var(--r-pill); display: inline-flex; gap: 6px; align-items: center; backdrop-filter: blur(4px); }
.ssx-meta { font-size: 12px; color: var(--text-muted); margin-top: -4px; }
.ssx-ok { color: var(--ok-fg); } .ssx-warn { color: var(--warn-fg); }
.ssx-card-actions { display: flex; gap: 8px; align-items: center; }
.ssx-card-actions .btn-header-danger { margin-left: auto; }

@media (max-width: 900px) {
  .ssx-body { grid-template-columns: 1fr; overflow-y: auto; }
  .ssx-form { overflow: visible; border-right: 0; order: 2; padding: 16px; }
  .ssx-preview { order: 1; overflow: visible; padding: 16px; }
  .ssx-stage canvas { max-height: 46vh; }
  .ssx-colors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ssx-sliders { grid-template-columns: 1fr; }
}


/* ── Device modal v2.1: tidy settings column + orientation-aware preview ── */
.screen-kiosk-bezel.is-portrait { width: 62%; margin: 0 auto; }
.screen-kiosk-bezel.is-portrait .screen-display { aspect-ratio: 9 / 16; }
.screen-kiosk-bezel.is-portrait .screen-header-bar { padding: 7px 10px; }
.screen-kiosk-bezel.is-portrait .time-tag { display: none; }
.screen-display img { object-fit: cover; }

#subtab-config .dm-section { padding: 18px 0; border-top: 1px solid var(--border-soft); }
#subtab-config .dm-section:first-child { padding-top: 0; border-top: 0; }
#subtab-config .dm-section h5 { font: 600 14.5px var(--font-body); color: var(--text); margin-bottom: 12px; }
.dm-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dm-section-head h5 { margin-bottom: 0 !important; }
.dm-inline { display: flex; gap: 8px; }
.dm-inline select { flex: 1; min-width: 0; }
.dm-section .form-help { margin-top: 6px; }
.dm-section .form-group:last-child { margin-bottom: 0; }
.dm-section .form-group > input[type="url"] { margin-top: 8px; }
.dm-section .toggle-card { padding: 0; margin: 0; background: none !important; border: 0 !important; }
.dm-section .toggle-card + .form-group, .dm-section .form-group + .toggle-card { margin-top: 14px; }
.dm-navbar .dm-navbar-fields { margin-top: 14px; }
.dm-navbar:has(#settingNavbarEnabled:not(:checked)) .dm-navbar-fields { display: none; }
.dm-pin { max-width: 220px; }
.pin-code-input { letter-spacing: 0.08em !important; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

.dm-footer-actions { display: flex; gap: 8px; align-items: center; }
.btn-danger-text { color: var(--danger-fg); padding-left: 12px; padding-right: 12px; }
.btn-danger-text:hover { background: var(--danger-bg); color: var(--danger-fg); }
.dm-section .form-row-grid .form-group { margin-bottom: 0; }
.dm-section .form-row-grid + .form-group { margin-top: 14px; }


/* ── Device modal v2.2: experience-first settings ── */
.dm-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.dm-chip { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 5px 11px; border-radius: var(--r-pill); background: var(--bg-sunken); border: 1px solid var(--border-soft); font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-chip i { font-size: 11px; color: var(--text-dim); }
.dm-custom-note { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-fg); font-size: 13px; }
.dm-custom-note[hidden] { display: none !important; }
.dm-custom-note .btn-link { color: var(--warn-fg); white-space: nowrap; }

.dm-custom { border-top: 1px solid var(--border-soft); }
.dm-custom > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 1fr auto; column-gap: 12px; padding: 16px 0; user-select: none; }
.dm-custom > summary::-webkit-details-marker { display: none; }
.dm-custom > summary::after {
  content: '\f078';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 11px;
  color: var(--text-dim);
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  justify-self: center;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  background: var(--bg-sunken);
  transition: transform 0.2s var(--ease), background 0.15s, color 0.15s;
}
.dm-custom > summary:hover::after {
  background: var(--border-soft);
  color: var(--text);
}
.dm-custom[open] > summary::after { transform: rotate(180deg); }
.dm-custom-title { font: 600 14.5px var(--font-body); color: var(--text); }
.dm-custom-sub { font-size: 12.5px; color: var(--text-muted); }
.dm-custom > summary:hover .dm-custom-title { color: var(--primary-text); }
.dm-custom-body { margin: 0 0 18px; padding: 0 16px; border-radius: 14px; background: var(--bg-elev); border: 1px solid var(--border-soft); }
#subtab-config .dm-custom-body .dm-section:first-child { padding-top: 16px; border-top: 0; }
#subtab-config .dm-custom-body .dm-section:last-child { padding-bottom: 16px; }

/* ── Device view tabs ───────────────────────────── */
.device-view-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.device-view-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--r-pill);
  background: var(--bg-card); color: var(--text-muted);
  font: 600 13px var(--font-body); cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.device-view-tab:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-elev); }
.device-view-tab.active { color: var(--primary-text); background: var(--primary-soft); border-color: var(--primary); }
.device-view-tab .view-count {
  font-size: 11px; font-weight: 700; opacity: 0.75;
  background: rgba(0, 0, 0, 0.06); padding: 1px 7px; border-radius: var(--r-pill);
}
.device-view-tab.active .view-count { background: rgba(4, 147, 106, 0.15); }

/* ── Device grouping ───────────────────────────── */
.device-group-header {
  grid-column: 1 / -1;
  width: 100%;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin: 14px 0 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
  letter-spacing: 0.01em;
}

/* ══════════════════════════════════════════════════════════════
   Signage Studio (sgx-)
   ══════════════════════════════════════════════════════════════ */
#createSignageModal { padding: 14px; }
.sgx-card.modal-card { max-width: 1480px; width: 100%; height: calc(100vh - 28px); max-height: none; display: flex; flex-direction: column; overflow: hidden; border-radius: 20px; padding: 0; background: var(--bg-modal); }
.sgx-shell { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.sgx-top { display: flex; align-items: center; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--border-soft); background: var(--bg-modal); }
.sgx-top-left { display: flex; flex-direction: column; min-width: 0; flex: 1 1 240px; }
.sgx-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--primary-text); }
.sgx-name { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; height: 30px !important; font: 600 20px var(--font-display) !important; letter-spacing: -.02em; color: var(--text); }
.sgx-name:focus { box-shadow: none !important; }
.sgx-top-mid { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sgx-top-right { display: flex; align-items: center; gap: 8px; }
.sgx-seg { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--bg-sunken); border: 1px solid var(--border-soft); }
.sgx-seg button { border: 0; background: transparent; color: var(--text-muted); font: 600 12.5px var(--font-body); padding: 7px 13px; border-radius: var(--r-pill); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.sgx-seg button.active { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow-xs); }
.sgx-theme { display: flex; gap: 6px; padding: 4px; border-radius: var(--r-pill); background: var(--bg-sunken); border: 1px solid var(--border-soft); }
.sgx-swatch { width: 26px; height: 26px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; background: conic-gradient(var(--s2) 0 33%, var(--s3) 0 66%, var(--s1) 0); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); transition: transform .15s; }
.sgx-swatch:hover { transform: scale(1.1); }
.sgx-swatch.active { box-shadow: 0 0 0 2px var(--bg-sunken), 0 0 0 4px var(--blue-sky); }
.sgx-font { width: auto !important; height: 34px !important; border-radius: var(--r-pill) !important; font-size: 13px !important; }

.sgx-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 240px minmax(0, 1fr) 340px; }

/* Rail */
.sgx-rail { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border-soft); background: var(--bg-elev); }
.sgx-rail-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 8px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.sgx-rail-head b { color: var(--text); margin-left: 4px; }
.sgx-total { font-weight: 500; }
.sgx-slides { flex: 1; overflow-y: auto; padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.sgx-slide { position: relative; display: grid; grid-template-columns: 18px 1fr; grid-template-rows: auto auto; column-gap: 8px; row-gap: 6px; padding: 6px; border-radius: 12px; cursor: pointer; border: 1px solid transparent; transition: background .15s, border-color .15s; }
.sgx-slide:hover { background: var(--bg-card); }
.sgx-slide.active { background: var(--bg-card); border-color: var(--blue-sky); box-shadow: 0 0 0 3px var(--primary-glow); }
.sgx-slide.dragging { opacity: .4; }
.sgx-slide.drop-target { box-shadow: 0 -3px 0 var(--blue-sky); }
.sgx-slide-num { grid-row: 1; font: 600 11px var(--font-mono); color: var(--text-dim); padding-top: 4px; }
.sgx-thumb { grid-column: 2; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #0c2742; pointer-events: none; }
.sgx-slides.portrait .sgx-thumb { aspect-ratio: 9 / 16; width: 62%; }
.sgx-slide-meta { grid-column: 2; display: flex; justify-content: space-between; gap: 8px; font-size: 12px; min-width: 0; }
.sgx-slide-title { font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sgx-slide-dur { color: var(--text-dim); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.sgx-slide-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.sgx-slide:hover .sgx-slide-tools { opacity: 1; }
.sgx-slide-tools .btn-icon { width: 26px; height: 26px; font-size: 11px; background: rgba(8, 22, 38, .7); color: #fff; backdrop-filter: blur(6px); }
.sgx-slide-tools .btn-icon:hover { background: rgba(8, 22, 38, .9); color: #fff; }
.sgx-slide-tools .btn-icon.danger:hover { background: var(--danger); }
.sgx-add { position: relative; padding: 12px; border-top: 1px solid var(--border-soft); }
.sgx-add-menu { position: absolute; left: 12px; bottom: calc(100% - 4px); width: 420px; z-index: 30; padding: 14px; border-radius: 16px; background: var(--bg-modal); border: 1px solid var(--border); box-shadow: var(--shadow-pop); animation: fadeIn .18s var(--ease); }
.sgx-add-title { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin: 2px 2px 10px; }
.sgx-templates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.sgx-template { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; font: 600 12px var(--font-body); color: var(--text-2); display: flex; flex-direction: column; gap: 6px; }
.sgx-template-thumb { aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #0c2742; box-shadow: 0 0 0 1px var(--border); transition: box-shadow .15s, transform .15s; pointer-events: none; }
.sgx-template:hover .sgx-template-thumb { box-shadow: 0 0 0 2px var(--blue-sky); transform: translateY(-1px); }
.sgx-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sgx-types button { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-2); font: 600 12.5px var(--font-body); cursor: pointer; }
.sgx-types button i { color: var(--blue-sky); width: 14px; text-align: center; }
.sgx-types button:hover { border-color: var(--blue-sky); color: var(--text); }

/* Stage */
.sgx-stage-wrap { min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; background:
  radial-gradient(800px 500px at 50% 40%, rgba(82, 176, 222, .10), transparent 70%), var(--bg-sunken); }
.sgx-stage { width: 100%; max-width: 100%; aspect-ratio: 16 / 9; max-height: calc(100% - 64px); border-radius: 14px; overflow: hidden; background: #000; box-shadow: 0 30px 60px -24px rgba(8, 22, 38, .55), 0 0 0 1px rgba(8, 22, 38, .08); }
.sgx-stage.portrait { width: auto; height: calc(100% - 64px); aspect-ratio: 9 / 16; }
.sgx-transport { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-pill); background: var(--bg-card); border: 1px solid var(--border); box-shadow: var(--shadow-xs); }
.sgx-play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--primary); color: var(--primary-fg); cursor: pointer; font-size: 14px; display: grid; place-items: center; }
.sgx-play:hover { background: var(--primary-hover); }
.sgx-pos { font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 86px; text-align: center; }

/* Inspector */
.sgx-inspector { min-height: 0; overflow-y: auto; border-left: 1px solid var(--border-soft); padding: 4px 18px 24px; background: var(--bg-modal); }
.sgx-inspector.is-empty > * { opacity: .4; pointer-events: none; }
.sgx-section { padding: 16px 0; border-bottom: 1px solid var(--border-soft); }
.sgx-section:last-child { border-bottom: 0; }
.sgx-section h4 { font: 600 13.5px var(--font-body); color: var(--text); margin-bottom: 12px; }
.sgx-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sgx-section-head h4 { margin: 0; }
.sgx-section-head output { font: 600 13px var(--font-mono); color: var(--primary-text); }
.sgx-section.is-muted .sgx-chips { opacity: .45; }
.sgx-type-select { width: auto !important; height: 32px !important; font-size: 13px !important; border-radius: var(--r-pill) !important; }
.sgx-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.sgx-field:last-child { margin-bottom: 0; }
.sgx-field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.sgx-field textarea { resize: vertical; min-height: 46px; font-size: 14px; line-height: 1.4; }
.sgx-src-row { display: flex; gap: 6px; }
.sgx-src-row input { flex: 1; min-width: 0; }
.sgx-src-row .btn { height: 40px; width: 40px; padding: 0; }
.sgx-media-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-height: 210px; overflow-y: auto; padding: 8px; border-radius: 12px; background: var(--bg-sunken); }
.sgx-media-item { border: 0; padding: 0; background: var(--bg-card); border-radius: 8px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; font-size: 10.5px; color: var(--text-muted); box-shadow: 0 0 0 1px var(--border); }
.sgx-media-item img, .sgx-media-item i { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: grid; place-items: center; font-size: 20px; color: var(--blue-sky); background: var(--bg-elev); }
.sgx-media-item span { padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sgx-media-item:hover { box-shadow: 0 0 0 2px var(--blue-sky); }
.sgx-media-empty { grid-column: 1 / -1; font-size: 12.5px; color: var(--text-muted); padding: 6px; }
.sgx-sublabel { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 4px 0 8px; }
.sgx-sublabel:not(:first-of-type) { margin-top: 14px; }
.sgx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sgx-chip { border: 1px solid var(--border); background: var(--bg-card); color: var(--text-2); cursor: pointer; font: 600 12px var(--font-body); transition: border-color .15s, background .15s, color .15s, box-shadow .15s; }
.sgx-chip:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); }
.sgx-chip.active { border-color: var(--blue-sky); background: var(--blue-ice-soft); color: var(--blue-navy); box-shadow: 0 0 0 3px var(--primary-glow); }
:root[data-theme="dark"] .sgx-chip.active { background: rgba(82, 176, 222, .16); color: var(--blue-ice); }
.sgx-chip:disabled { opacity: .35; cursor: not-allowed; }
.sgx-pill { padding: 6px 12px; border-radius: var(--r-pill); }
.sgx-layouts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sgx-chip-layout { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 6px 7px; border-radius: 12px; }
.sgx-chip-layout svg { width: 100%; height: 34px; border-radius: 6px; background: var(--blue-navy); fill: var(--blue-ice); }
.sgx-chip-layout span { font-size: 11.5px; }
.sgx-bgs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.sgx-chip-bg { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 6px 7px; border-radius: 12px; }
.sgx-chip-bg span { font-size: 11px; }
.sgx-bg-swatch { display: block; width: 100%; height: 34px; border-radius: 7px; background-color: var(--blue-navy); position: relative; overflow: hidden; }
.sgx-bg-swatch { --c1: #1e4788; --c2: #3a85df; --c3: #56b8fa; --c4: #8bd5ff; background-color: var(--c1); }
.sgx-bg-shapes { background:
  radial-gradient(circle at 78% 105%, var(--c2) 0 34%, transparent 35%),
  radial-gradient(circle at 18% 0%, var(--c3) 0 22%, transparent 23%), var(--c1); }
.sgx-bg-layers { background:
  linear-gradient(var(--c2), var(--c2)) 70% 0 / 40% 70% no-repeat,
  radial-gradient(circle at 18% 110%, rgba(139, 213, 255, .7) 0 30%, transparent 31%), var(--c1); }
.sgx-bg-grid { background:
  linear-gradient(var(--c2), var(--c2)) 100% 0 / 26% 55% no-repeat,
  linear-gradient(var(--c4), var(--c4)) 100% 100% / 26% 45% no-repeat,
  linear-gradient(var(--c3), var(--c3)) 0 100% / 16% 40% no-repeat, var(--c1); }
.sgx-bg-glow { background: radial-gradient(60% 90% at 20% 20%, var(--c2), transparent), radial-gradient(60% 90% at 90% 80%, rgba(86, 184, 250, .6), transparent), var(--c1); background-size: 160% 160%; animation: sgxSw 6s ease-in-out infinite alternate; }
.sgx-bg-solid { background: var(--c1); }
.sgx-logo-toggle { display: inline-flex; align-items: center; gap: 6px; font: 600 12.5px var(--font-body); color: var(--text-2); padding: 0 12px; height: 34px; border-radius: var(--r-pill); background: var(--bg-sunken); border: 1px solid var(--border-soft); cursor: pointer; }
.sgx-logo-toggle input { width: 15px; height: 15px; }
@keyframes sgxSw { 0% { background-position: 0% 50%; } 100% { background-position: 100% 50%; } }
#sgDuration { width: 100%; }

/* Present (full-screen) */
.sgx-present { position: fixed; inset: 0; z-index: 4000; background: #000; }
.sgx-present-stage { position: absolute; inset: 0; }
.sgx-present-close { position: absolute; top: 18px; right: 18px; z-index: 5; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 24px; cursor: pointer; backdrop-filter: blur(8px); opacity: .5; transition: opacity .2s; }
.sgx-present:hover .sgx-present-close { opacity: 1; }

@media (max-width: 1180px) {
  .sgx-body { grid-template-columns: 200px minmax(0, 1fr) 300px; }
  .sgx-top { flex-wrap: wrap; }
}
@media (max-width: 900px) {
  .sgx-body { grid-template-columns: 1fr; grid-template-rows: auto auto auto; overflow-y: auto; }
  .sgx-rail { max-height: 220px; border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .sgx-slides { flex-direction: row; overflow-x: auto; }
  .sgx-slide { width: 160px; flex-shrink: 0; }
  .sgx-stage-wrap { min-height: 320px; }
  .sgx-inspector { border-left: 0; }
}
.sg-lib-thumb { border: 0; padding: 0; cursor: pointer; display: block; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; position: relative; background: var(--blue-navy); border-bottom: 1px solid var(--border-soft); }
.sg-lib-stage { position: absolute; inset: 0; display: block; pointer-events: none; }
.sg-lib-play { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; background: rgba(8, 22, 38, .35); color: #fff; font-size: 22px; transition: opacity .2s; }
.sg-lib-play i { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.18); backdrop-filter: blur(8px); }
.sg-lib-thumb:hover .sg-lib-play, .sg-lib-thumb:focus-visible .sg-lib-play { opacity: 1; }

.sgx-hint { font-size: 11.5px; color: var(--text-dim); }
#sgMosaicFields input + input { margin-top: 6px; }
.sgx-shapes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.sgx-chip-shape { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px; border-radius: 10px; }
.sgx-chip-shape svg { width: 100%; height: 30px; fill: var(--blue-sky); color: var(--blue-sky); }
.sgx-chip-shape span { font-size: 10.5px; }
.sgx-bg-bloom { background:
  radial-gradient(circle at 80% 20%, var(--c3) 0 30%, transparent 31%),
  repeating-linear-gradient(90deg, rgba(255,255,255,.25) 0 1px, transparent 1px 12px), var(--c1); }

/* ══════════════════════════════════════════════════════════════
   Device panel — touch kiosk vs signage screen
   ══════════════════════════════════════════════════════════════ */
.device-modal-card.is-kiosk [data-for="signage"],
.device-modal-card.is-signage [data-for="kiosk"] { display: none !important; }
.device-modal-card .dm-lbl-signage, .device-modal-card.is-signage .dm-lbl-kiosk { display: none; }
.device-modal-card.is-signage .dm-lbl-signage { display: inline; }
#createSignageModal { z-index: 1200; }
.sgx-present { z-index: 4100; }

.dm-type { padding-top: 0 !important; border-top: 0 !important; }
.dm-type-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 4px; border-radius: 16px; background: var(--bg-sunken); border: 1px solid var(--border-soft); }
.dm-type-opt { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid transparent; background: transparent; cursor: pointer; text-align: left; color: var(--text-muted); transition: background .15s, box-shadow .15s, color .15s; }
.dm-type-opt i { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 15px; background: var(--bg-card); color: var(--text-muted); flex-shrink: 0; }
.dm-type-opt span { display: flex; flex-direction: column; min-width: 0; }
.dm-type-opt strong { font-size: 14px; color: var(--text-2); }
.dm-type-opt small { font-size: 12px; color: var(--text-dim); }
.dm-type-opt:hover { color: var(--text); }
.dm-type-opt.active { background: var(--bg-card); box-shadow: var(--shadow-xs); border-color: var(--border); }
.dm-type-opt.active i { background: var(--primary); color: var(--primary-fg); }
.dm-type-opt.active strong { color: var(--text); }

.dm-playlist-card { display: grid; grid-template-columns: 200px 1fr; gap: 14px; align-items: center; }
.dm-playlist-preview { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; border: 0; padding: 0; cursor: pointer; background: var(--blue-navy); box-shadow: 0 10px 24px -14px rgba(8, 22, 38, .6); }
.dm-playlist-preview.is-empty { cursor: default; background: var(--bg-sunken); box-shadow: inset 0 0 0 1px var(--border); }
.dm-playlist-stage { position: absolute; inset: 0; display: block; pointer-events: none; }
.dm-playlist-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-dim); font-size: 22px; }
.dm-playlist-preview:hover .sg-lib-play { opacity: 1; }
.dm-playlist-pick { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dm-playlist-meta { font-size: 12.5px; color: var(--text-muted); }

.dm-extras { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dm-extra { position: relative; cursor: pointer; }
.dm-extra input { position: absolute; opacity: 0; pointer-events: none; }
.dm-extra span { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-card); font: 600 12.5px var(--font-body); color: var(--text-2); text-align: center; transition: border-color .15s, background .15s, box-shadow .15s; }
.dm-extra span i { font-size: 16px; color: var(--text-muted); }
.dm-extra input:checked + span { border-color: var(--blue-sky); background: var(--blue-ice-soft); color: var(--blue-navy); box-shadow: 0 0 0 3px var(--primary-glow); }
:root[data-theme="dark"] .dm-extra input:checked + span { background: rgba(82, 176, 222, .16); color: var(--blue-ice); }
.dm-extra input:checked + span i { color: var(--blue-sky); }
.dm-extra input:focus-visible + span { box-shadow: var(--ring); }
.dm-extra-fields { display: none; margin-top: 14px; }
.dm-section:has(#settingOverlayWeather:checked) .dm-extra-fields[data-extra="weather"],
.dm-section:has(#dmTickerToggle:checked) .dm-extra-fields[data-extra="ticker"],
.dm-section:has(#dmLogoToggle:checked) .dm-extra-fields[data-extra="logo"] { display: block; }
.dm-extra-fields .form-group:last-child { margin-bottom: 0; }
#settingScheduleSlots:not(:empty) { margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.device-modal-card.is-signage .remote-action-grid { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) {
  .dm-type-switch { grid-template-columns: 1fr; }
  .dm-playlist-card { grid-template-columns: 1fr; }
  .dm-extras { grid-template-columns: repeat(2, 1fr); }
}
.sgx-top-mid { flex-wrap: nowrap; gap: 8px; }
.sgx-theme { gap: 3px; padding: 3px; }
.sgx-swatch { width: 22px; height: 22px; }
@media (max-width: 1360px) { .sgx-top-mid { flex-wrap: wrap; } }
.sgx-layouts { grid-template-columns: repeat(4, 1fr); }
.sgx-bg-globe { background: radial-gradient(ellipse 22% 48% at 50% 50%, transparent 60%, var(--c2) 61% 78%, transparent 79%), radial-gradient(circle at 50% 50%, var(--c2) 0 46%, transparent 47%), var(--c1); }
#sgSize { width: 100%; }
#sgSizeSection .sgx-hint { display: block; margin-top: 6px; }

/* Ticker editor (device panel + studio) */
.tk-rows { display: flex; flex-direction: column; gap: 8px; }
.tk-row { display: grid; grid-template-columns: 118px minmax(0, 1fr) 30px; gap: 8px; align-items: center; }
.tk-row input { height: 38px; margin: 0; }
.tk-row .tk-label { font-weight: 700; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--blue-sky); }
.tk-row .tk-label::placeholder { text-transform: none; letter-spacing: 0; font-weight: 500; }
.tk-del { width: 30px; height: 30px; font-size: 12px; color: var(--text-dim); }
.tk-del:hover { color: var(--danger); }
.tk-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.tk-speed { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--bg-sunken); border: 1px solid var(--border-soft); }
.tk-speed button { border: 0; background: none; padding: 5px 12px; border-radius: var(--r-pill); font: 600 12px var(--font-body); color: var(--text-muted); cursor: pointer; }
.tk-speed button.active { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 3px rgba(12, 39, 66, .12); }
.dm-extra-fields[data-extra="ticker"] .form-help { margin-top: 10px; }

/* Studio ticker button + popover */
.sgx-ticker-btn { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 8px; padding: 9px 12px; border-radius: 10px; border: 1px dashed var(--border); background: none; color: var(--text-2); font: 600 13px var(--font-body); cursor: pointer; transition: border-color .15s, background .15s; }
.sgx-ticker-btn i { color: var(--text-dim); width: 14px; }
.sgx-ticker-btn em { margin-left: auto; font-style: normal; font-weight: 500; font-size: 12px; color: var(--text-dim); }
.sgx-ticker-btn:hover { border-color: var(--blue-sky); }
.sgx-ticker-btn.on { border-style: solid; border-color: var(--blue-sky); background: var(--primary-glow); }
.sgx-ticker-btn.on i, .sgx-ticker-btn.on em { color: var(--blue-sky); }
.sgx-ticker-menu { width: 520px; }
.sgx-ticker-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.sgx-ticker-head p { margin: -4px 2px 0; font-size: 12.5px; color: var(--text-muted); }
@media (max-width: 700px) { .sgx-ticker-menu { width: calc(100vw - 48px); } .tk-row { grid-template-columns: 90px minmax(0, 1fr) 30px; } }

/* Split screen layouts */
.zl-layouts { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.zl-opt { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 8px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-2); font: 600 12px var(--font-body); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.zl-opt:hover { border-color: var(--blue-sky); }
.zl-opt.active { border-color: var(--blue-sky); box-shadow: 0 0 0 3px var(--primary-glow); color: var(--text); }
.zl-mini { position: relative; width: 64px; aspect-ratio: 16 / 9; border-radius: 4px; overflow: hidden; }
.zl-mini.portrait { width: 30px; aspect-ratio: 9 / 16; }
.zl-cell { position: absolute; box-sizing: border-box; border: 1.5px solid var(--bg-card); border-radius: 3px; background: var(--blue-aqua, #80cfdf); }
.zl-cell:first-child { background: var(--blue-sky, #52b0de); }
.zl-opt.active .zl-cell { background: #0c2742; }
.zl-opt.active .zl-cell:first-child { background: var(--blue-sky, #52b0de); }
.zl-editor { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; margin-top: 16px; }
.zl-editor[hidden] { display: none; }
.zl-preview { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; box-shadow: 0 0 0 1px var(--border); }
.zl-preview.portrait { aspect-ratio: 9 / 16; max-width: 220px; justify-self: center; width: 100%; }
.zl-stage { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.zl-marks { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.zl-mark { position: absolute; box-sizing: border-box; border: 1px solid rgba(255, 255, 255, .55); background: none; padding: 0; cursor: pointer; display: grid; place-items: center; }
.zl-mark b { position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: rgba(12, 39, 66, .85); color: #fff; font: 700 11px var(--font-body); }
.zl-mark.empty { background: repeating-linear-gradient(135deg, rgba(255,255,255,.06) 0 8px, transparent 8px 16px); }
.zl-mark span { font: 600 11px var(--font-body); color: rgba(255, 255, 255, .75); }
.zl-mark:hover { border-color: var(--blue-sky); box-shadow: inset 0 0 0 2px var(--blue-sky); }
.zl-regions { display: flex; flex-direction: column; gap: 8px; }
.zl-region { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--border-soft); background: var(--bg-card); transition: box-shadow .2s; }
.zl-region.flash { box-shadow: 0 0 0 3px var(--primary-glow); border-color: var(--blue-sky); }
.zl-badge { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #0c2742; color: #fff; font: 700 11px var(--font-body); }
.zl-region-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.zl-region-name { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.zl-region select { margin: 0; height: 34px; }
@media (max-width: 760px) { .zl-editor { grid-template-columns: 1fr; } }

/* Device ID used by more than one machine */
.dc-line.dc-conflict { color: var(--warn-fg, #9a5b00); font-weight: 600; }
.dc-line.dc-conflict i { color: var(--warn-fg, #c77700); }

/* Library cards with several actions: title row on top, actions below */
.media-body.is-stacked { flex-direction: column; align-items: stretch; gap: 12px; padding: 14px; }
.media-meta { margin-top: 3px; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-actions { display: flex; align-items: center; gap: 6px; }
.media-actions .btn { white-space: nowrap; }
.media-actions-icons { margin-left: auto; display: flex; gap: 2px; }
.media-badges { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.media-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; background: rgba(12, 39, 66, .72); color: #fff; font: 600 10.5px var(--font-body); text-decoration: none; }
.media-badge i { font-size: 9px; }
.media-badge.is-live i { color: #8fe3a7; }
.media-badge.is-draft i { color: #f6c35b; }
a.media-badge.is-live:hover { background: rgba(12, 39, 66, .9); }

/* Experience profile editor */
.ep-card.modal-card { max-width: 720px; display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.ep-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.ep-form > .modal-body { overflow-y: auto; flex: 1; min-height: 0; padding-top: 8px; padding-bottom: 8px; }
.ep-form.is-kiosk [data-for="signage"], .ep-form.is-signage [data-for="kiosk"] { display: none !important; }
#expProfileModal .dm-section { padding: 18px 0; border-top: 1px solid var(--border-soft); }
#expProfileModal .dm-section.ep-basics { border-top: 0; }
#expProfileModal .dm-custom-body .dm-section { border-top: 0; padding: 16px 0; }
#expProfileModal .dm-section h5 { font: 600 14.5px var(--font-body); color: var(--text); margin-bottom: 12px; }
#expProfileModal .dm-section > .toggle-card { padding: 0; }
#expProfileModal .dm-section > .toggle-card + .ep-reveal, #expProfileModal .form-group + .toggle-card { margin-top: 14px; }
#expProfileModal .dm-type { padding-top: 0; border-top: 0; }
#expProfileModal .form-group > input[type="url"] { margin-top: 8px; }
#expProfileModal .form-row-grid .form-group { margin-bottom: 0; }
.ep-basics .form-group:last-child { margin-bottom: 0; }
.ep-opt { font-weight: 400; color: var(--text-dim); margin-left: 4px; }
.ep-reveal { display: none; margin-top: 14px; }
.ep-reveal .form-group:last-child { margin-bottom: 0; }
#expProfileModal .dm-section:has(#expProfileNavbarEnabled:checked) .ep-reveal[data-when="expProfileNavbarEnabled"],
#expProfileModal .dm-section:has(#expProfileSaverEnabled:checked) .ep-reveal[data-when="expProfileSaverEnabled"],
#expProfileModal .dm-section:has(#expProfileOverlayWeather:checked) .ep-reveal[data-when="expProfileOverlayWeather"],
#expProfileModal .dm-section:has(#epTickerToggle:checked) .ep-reveal[data-when="epTickerToggle"],
#expProfileModal .dm-section:has(#epLogoToggle:checked) .ep-reveal[data-when="epLogoToggle"] { display: block; }
.ep-saver-grid { grid-template-columns: minmax(0, 1fr) 140px; }
.ep-suffix { position: relative; }
.ep-suffix input { padding-right: 46px; }
.ep-suffix span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--text-muted); pointer-events: none; }
.ep-footer { flex-shrink: 0; background: var(--bg-modal); }
#expProfileScheduleSlots:not(:empty) { margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 600px) { .ep-saver-grid { grid-template-columns: 1fr; } #expProfileModal .dm-extras { grid-template-columns: repeat(2, 1fr); } }

/* Per-slide colour chips (signage studio) */
.sgx-pals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.sgx-chip-pal { flex-direction: column; gap: 5px; padding: 8px 4px; font-size: 11px; }
.sgx-chip-pal span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sgx-pal-swatch { display: block; width: 100%; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--s1) 0 55%, var(--s2) 55% 78%, var(--s3) 78%); box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.sgx-pal-swatch.is-inherit { background: repeating-linear-gradient(135deg, var(--bg-sunken) 0 6px, var(--bg-card) 6px 12px); box-shadow: inset 0 0 0 1px var(--border); }

/* Screensaver studio: shares the Signage Studio layout (.sgx-*) */
.ssx-studio .sgx-top-mid { flex-wrap: wrap; }
.ssx-canvas-stage { display: grid; place-items: center; }
.ssx-canvas-stage canvas { display: block; width: 100%; height: 100%; }
.ssx-studio .sgx-thumb canvas { display: block; width: 100%; height: 100%; }
.ssx-studio .sgx-slides.portrait .sgx-thumb { aspect-ratio: 9 / 16; width: 62%; }
.ssx-studio .ssx-transport { width: min(760px, 100%); gap: 10px; padding-right: 10px; }
.ssx-studio .ssx-transport input[type="range"] { flex: 1; min-width: 80px; accent-color: var(--primary); }
.ssx-studio .ssx-progress { width: min(760px, 100%); }
.ssx-more-wrap { position: relative; }
.ssx-more.sgx-add-menu { top: calc(100% + 8px); bottom: auto; left: auto; right: 0; width: 360px; }
.ssx-more .ssx-colors { margin-bottom: 14px; }
.ssx-more-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 10px; align-items: center; margin-bottom: 10px; }
.ssx-more-row select { height: 36px; }
.ssx-range { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.ssx-range input { flex: 1; min-width: 0; accent-color: var(--primary); }
.ssx-range output { font: 600 11px var(--font-mono); color: var(--text-2); min-width: 34px; text-align: right; }
.ssx-more .ssx-logo-custom { margin-bottom: 12px; }
.ssx-more .ssx-check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ssx-status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: var(--r-pill); font: 600 12px var(--font-body); background: var(--bg-sunken); color: var(--text-muted); white-space: nowrap; }
.ssx-status i { font-size: 7px; }
.ssx-status.is-live i { color: var(--ok-fg, #1f9254); }
.ssx-status.is-changed { background: var(--warn-bg); color: var(--warn-fg); }
.ssx-status.is-draft i { color: #e0a326; }
.ssx-photo-row { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 4px; }
.ssx-photo-row .ssx-thumb { width: 76px; height: 76px; background: repeating-conic-gradient(var(--bg-sunken) 0 25%, var(--bg-card) 0 50%) 0 0 / 14px 14px; }
.ssx-photo-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ssx-studio .ssx-sliders { grid-template-columns: 1fr; gap: 8px; margin: 0 0 8px; }
.ssx-studio .ssx-sliders label { flex-direction: row; align-items: center; gap: 10px; }
.ssx-studio .ssx-sliders label input { flex: 1; }
.ssx-studio .ssx-sliders label { display: grid; grid-template-columns: 82px 1fr; }
.ssx-studio .sgx-inspector input[type="range"] { accent-color: var(--primary); width: 100%; }
.ssx-slide-colors { margin-top: 12px; }
.sgx-pal-swatch.is-custom { background: conic-gradient(#e7503e, #e4b62a, #4f8e40, #3a85df, #8466b5, #e7503e); }
.ssx-studio [hidden] { display: none !important; }

/* Fleet: touch kiosks vs signage screens */
.fleet-type { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 4px; margin: 0 0 16px; border-radius: 16px; background: var(--bg-sunken); border: 1px solid var(--border-soft); }
.fleet-type-opt { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; border: 1px solid transparent; background: transparent; cursor: pointer; text-align: left; color: var(--text-muted); transition: background .15s, box-shadow .15s; }
.fleet-type-opt i { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 15px; background: var(--bg-card); color: var(--text-muted); flex-shrink: 0; }
.fleet-type-opt span { display: flex; flex-direction: column; min-width: 0; }
.fleet-type-opt strong { font-size: 14px; color: var(--text-2); }
.fleet-type-opt small { font-size: 12px; color: var(--text-dim); }
.fleet-type-opt:hover strong { color: var(--text); }
.fleet-type-opt.active { background: var(--bg-card); border-color: var(--border); box-shadow: var(--shadow-xs); }
.fleet-type-opt.active i { background: var(--primary); color: var(--primary-fg); }
.fleet-type-opt.active strong { color: var(--text); }
.stat-dot.offline { background: var(--text-dim); }
.stat-dot.kiosk { background: var(--blue-sky, #52b0de); }
.stat-dot.signage { background: var(--blue-aqua, #80cfdf); }
.device-group-header.is-type { display: flex; align-items: center; gap: 10px; font: 600 15px var(--font-body); color: var(--text); margin-top: 6px; }
.device-group-header.is-type ~ .device-group-header.is-type { margin-top: 18px; }
.device-group-header.is-type i { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--bg-card); border: 1px solid var(--border-soft); color: var(--primary-text); font-size: 13px; }
.device-group-header.is-type em { font-style: normal; font-weight: 500; font-size: 12.5px; color: var(--text-muted); }
.device-card.is-signage-card { padding-top: 0; overflow: hidden; }
.dc-sg-thumb { position: relative; margin: 0 -18px -2px; aspect-ratio: 16 / 6; overflow: hidden; background: var(--bg-sunken); border-bottom: 1px solid var(--border-soft); }
.dc-sg-thumb.is-empty { background: repeating-linear-gradient(135deg, var(--bg-sunken) 0 8px, var(--bg-card) 8px 16px); }
.device-card.is-offline .dc-sg-thumb { filter: grayscale(1); opacity: .55; }
@media (max-width: 700px) { .fleet-type-opt small { display: none; } .fleet-type-opt i { display: none; } }

/* ── Mobile pass ─────────────────────────────────────────── */
.main-content, .tab-pane, .modal-layout > *, .modal-card, .device-modal-card { min-width: 0; }
@media (max-width: 760px) {
  html, body { overflow-x: hidden; }
  .main-content { padding: 0 14px 40px; }
  .top-header { margin: 0 -14px 14px; padding: 12px 14px; gap: 10px; }
  .header-actions { gap: 6px; }
  .header-actions .btn-primary { height: 38px; padding: 0 14px; font-size: 13px; }

  /* Fleet */
  .fleet-type { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 3px; }
  .fleet-type-opt { justify-content: center; padding: 9px 6px; text-align: center; }
  .fleet-type-opt strong { font-size: 13px; line-height: 1.2; }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 26px; }
  .device-view-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -14px; margin-right: -14px; padding: 0 14px 2px; }
  .device-view-tabs::-webkit-scrollbar { display: none; }
  .device-view-tab { flex-shrink: 0; }
  .filter-dropdowns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; width: 100%; }
  .filter-dropdowns .select-wrap { min-width: 0; width: auto; }
  .filter-dropdowns select { font-size: 13px; padding-left: 10px !important; padding-right: 26px !important; text-overflow: ellipsis; }
  .devices-grid, .profiles-grid, .media-grid, .nav-themes-grid { grid-template-columns: minmax(0, 1fr) !important; gap: 12px; }
  .device-card { min-width: 0; }
  .dc-head, .dc-title { min-width: 0; }
  .dc-title h4 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dc-sg-thumb { aspect-ratio: 16 / 7; }

  /* Modals: full width, scroll inside, buttons always reachable */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-card, .modal-dialog { max-width: 100% !important; width: 100%; max-height: 94vh; border-radius: 18px 18px 0 0; }
  .device-modal-card { height: 94vh; }
  .modal-layout { gap: 16px; }
  .device-modal-footer { flex-wrap: wrap; gap: 8px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
  .device-modal-footer #btnDeleteDevice { order: 2; width: 100%; justify-content: center; }
  .dm-footer-actions { width: 100%; }
  .dm-footer-actions .btn { flex: 1; justify-content: center; }
  .remote-action-grid, .device-modal-card.is-signage .remote-action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .live-url-banner, .kiosk-rail-card { max-width: 100%; }
  .kiosk-rail-row .rail-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .modal-footer { flex-wrap: wrap; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
  .modal-footer .btn { flex: 1; justify-content: center; }
  .zl-layouts { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }

  /* Studios (signage + screensaver): full screen, stacked */
  .sgx-card.modal-card { height: 100vh; max-height: 100vh; border-radius: 0; }
  .sgx-top { padding: 10px 14px; gap: 10px; }
  .sgx-top-left { flex: 1 1 100%; }
  .sgx-top-mid { order: 3; flex: 1 1 100%; overflow-x: auto; flex-wrap: nowrap !important; scrollbar-width: none; padding-bottom: 2px; }
  .sgx-top-mid::-webkit-scrollbar { display: none; }
  .sgx-top-mid > * { flex-shrink: 0; }
  .sgx-top-right { flex: 1 1 100%; justify-content: flex-end; gap: 6px; }
  .sgx-top-right .btn { height: 36px; padding: 0 12px; font-size: 13px; }
  .sgx-stage-wrap { min-height: 0; padding: 14px; }
  .sgx-stage.portrait { height: 52vh; }
  .sgx-transport { width: 100%; }
  .sgx-inspector { padding: 4px 14px 24px; }
  .ssx-more.sgx-add-menu, .sgx-add-menu { position: fixed; left: 10px !important; right: 10px !important; width: auto !important; top: auto; bottom: 10px; max-height: 70vh; overflow-y: auto; }
  .ssx-status { display: none; }

  /* Page header: actions drop to their own row when the title needs the room */
  .top-header { flex-wrap: wrap; }
  .header-title { min-width: 0; flex: 1 1 auto; }
  .header-actions { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
  /* Device modal: keep the live preview compact so the controls are near the top */
  .screen-kiosk-bezel.is-portrait { width: 44%; }
  /* Studio grid children must be allowed to shrink */
  .sgx-body { grid-template-columns: minmax(0, 1fr) !important; }
  .sgx-body > *, .sgx-shell, #signageForm { min-width: 0; max-width: 100%; }
  .sgx-stage { max-width: 100%; }

  /* Users table: let it scroll sideways inside its card */
  .table-container { max-width: 100%; }
}
