/* Roku Farm — dark "TV control room" theme. The Roku screen is the star; the chrome stays quiet. */
:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --bg-glow: radial-gradient(1200px 600px at 10% -10%, rgba(124, 58, 237, 0.14), transparent 60%),
             radial-gradient(900px 500px at 110% 0%, rgba(34, 211, 238, 0.07), transparent 60%);
  --surface: #151922;
  --surface-2: #1c2130;
  --border: #262c3b;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --faint: #6b7280;
  --accent: #8b5cf6;
  --accent-strong: #7c3aed;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --accent-text: #ffffff;
  --gradient: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
  --live: #22d3ee;
  --free: #10b981;
  --busy: #f43f5e;
  --warn: #f59e0b;
  --key: #232939;
  --key-hover: #2c3347;
  --key-active: #4c3a8a;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #c4b5fd; }
.mono { font-family: var(--mono); font-size: 0.92em; }

/* Icons */
.icon { display: inline-flex; width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.icon svg { width: 100%; height: 100%; }

/* Top bar ---------------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: rgba(11, 13, 18, 0.78);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 17px; letter-spacing: -0.01em; }
.brand:hover { color: var(--text); }
.brand b { font-weight: 700; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--gradient);
              color: #fff; box-shadow: 0 6px 20px -6px rgba(124, 58, 237, 0.7); }
.brand-mark .icon { width: 20px; height: 20px; }
.nav { display: flex; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 10px; color: var(--muted); font-size: 14px; font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.active { color: var(--text); background: var(--accent-soft); }
.nav a.active .icon { color: var(--accent); }
.user { margin-left: auto; display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2);
          border: 1px solid var(--border); color: var(--text); font-size: 12px; font-weight: 600; letter-spacing: 0.02em; }
.user-name { color: var(--text); font-weight: 500; }
.icon-link { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); }
.icon-link:hover { background: var(--surface); color: var(--text); }

main { padding: 28px 24px 48px; max-width: 1400px; margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.back-link:hover { color: var(--text); }

.banner {
  display: none;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fecdd3;
}
.banner.show { display: flex; }

/* Summary chips ---------------------------------------------------------------------------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface);
        border: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.chip b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.free { background: var(--free); }
.dot.busy, .dot.mine { background: var(--busy); }
.dot.offline, .dot.server_down { background: var(--warn); }
.dot.dirty { background: var(--warn); }
.dot.cleaning { background: var(--live); }
.dot.cleaning.pulse { color: rgba(34, 211, 238, 0.6); }
.holder button.small { margin-left: auto; }
.dot.live { background: var(--live); }
.dot.pulse { box-shadow: 0 0 0 0 currentColor; animation: pulse 2s infinite; }
.dot.free.pulse { color: rgba(16, 185, 129, 0.6); }
.dot.busy.pulse, .dot.mine.pulse { color: rgba(244, 63, 94, 0.6); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Internet exit per region and the admin remap button ----------------------------------------- */
.head-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.exits { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.exit { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 12px; background: var(--surface);
        border: 1px solid var(--border); font-size: 13px; color: var(--muted); min-width: 0; }
.exit b { color: var(--text); font-weight: 600; }
.exit .flag { font-size: 18px; line-height: 1; }
.exit .exit-state { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.exit .exit-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.exit.ok .exit-state { color: var(--free); }
.exit.ok .exit-state::before { background: var(--free); }
.exit.wrong_country, .exit.unreachable { border-color: rgba(244, 63, 94, 0.45); background: rgba(244, 63, 94, 0.1); }
.exit.wrong_country .exit-state, .exit.unreachable .exit-state { color: #fda4af; }
.exit.wrong_country .exit-state::before, .exit.unreachable .exit-state::before { background: var(--busy); }
@media (max-width: 640px) {
  .head-side { align-items: flex-start; }
  .exit { flex-wrap: wrap; }
}

/* Device cards ----------------------------------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.card:hover { transform: translateY(-2px); border-color: #353d52; }
.card .screen { position: relative; }
.thumb { width: 100%; aspect-ratio: 16 / 9; background: #05060a; display: block; object-fit: cover; }
.thumb:not([src]), .thumb.loading { background: linear-gradient(90deg, #11141c 0%, #1a1f2b 50%, #11141c 100%); background-size: 200% 100%;
                                    animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.screen .overlay-top { position: absolute; inset: 10px 10px auto 10px; display: flex; justify-content: space-between; gap: 8px; }
.glass { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
         background: rgba(8, 10, 15, 0.7); backdrop-filter: blur(6px); color: #fff; border: 1px solid rgba(255, 255, 255, 0.08); }
.card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.card .title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.card h2 { font-size: 17px; margin: 0; letter-spacing: -0.01em; }
.meta { color: var(--muted); font-size: 13px; margin: 0; }
.holder { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; min-height: 20px; }
.holder .avatar { width: 22px; height: 22px; font-size: 10px; }
.card button { width: 100%; }

.badge { font-size: 13px; margin: 0; }
.badge.free { color: var(--free); }
.badge.busy, .badge.mine { color: var(--busy); }
.badge.offline, .badge.server_down { color: var(--warn); }

/* Buttons ---------------------------------------------------------------------------------- */
button {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  background: var(--gradient);
  color: var(--accent-text);
  box-shadow: 0 6px 18px -8px rgba(124, 58, 237, 0.8);
  transition: filter 0.15s, transform 0.1s, background 0.15s;
}
button:hover { filter: brightness(1.1); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; filter: none; box-shadow: none; background: var(--key); color: var(--muted); }
button.secondary { background: var(--key); color: var(--text); box-shadow: none; }
button.secondary:hover { background: var(--key-hover); filter: none; }
button.danger { background: rgba(244, 63, 94, 0.14); color: #fda4af; box-shadow: none; border: 1px solid rgba(244, 63, 94, 0.35); }
button.danger:hover { background: rgba(244, 63, 94, 0.24); filter: none; }
button.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
button.ghost { background: transparent; color: var(--muted); box-shadow: none; border: 1px solid var(--border); }
button.ghost:hover, button.ghost.on { color: var(--text); background: var(--surface-2); filter: none; }

/* Control page ----------------------------------------------------------------------------- */
.control { display: grid; grid-template-columns: 1fr 280px; gap: 24px; align-items: start; }
.stage { display: flex; flex-direction: column; gap: 14px; }
.video-wrap { position: relative; border-radius: 18px; overflow: hidden; border: 1px solid var(--border);
              box-shadow: 0 30px 80px -30px rgba(124, 58, 237, 0.45), var(--shadow); background: #000; }
.video { width: 100%; aspect-ratio: 16 / 9; background: #000; display: block; object-fit: contain; }
.live-tag { position: absolute; top: 12px; right: 12px; }
.toolbar-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px; background: var(--surface);
               border: 1px solid var(--border); border-radius: var(--radius); }
.toolbar-bar .spacer { flex: 1; }
.hint { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
kbd { font-family: var(--mono); font-size: 11px; padding: 2px 6px; border-radius: 5px; background: var(--key); border: 1px solid var(--border);
      border-bottom-width: 2px; color: var(--text); }

.remote {
  background: linear-gradient(180deg, #1d2231 0%, #141824 100%);
  border: 1px solid var(--border);
  border-radius: 44px;
  padding: 28px 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  box-shadow: 0 30px 60px -25px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}
.remote .ir { width: 10px; height: 10px; border-radius: 50%; background: #2a3042; box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.8); }
.remote .remote-brand { font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--faint); margin-top: 4px; }
.row { display: flex; gap: 12px; justify-content: center; }

.key {
  background: var(--key);
  color: var(--text);
  min-width: 52px;
  height: 44px;
  border-radius: 14px;
  font-size: 16px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  padding: 0 12px;
}
.key:hover { background: var(--key-hover); filter: none; }
.key .icon { width: 20px; height: 20px; }
.key.power { color: var(--busy); }
.key.flash { background: var(--key-active); }

.dpad {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(3, 58px);
  padding: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, #2a2246 0%, #221c3a 60%, #1b1730 100%);
  border: 1px solid #3a3160;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.08), 0 10px 25px -10px rgba(124, 58, 237, 0.6);
}
.dpad .key { min-width: 0; height: 100%; background: transparent; box-shadow: none; border-radius: 12px; color: #d8ccff; padding: 0; }
.dpad .key:hover { background: rgba(255, 255, 255, 0.06); }
.dpad .key.flash { background: rgba(139, 92, 246, 0.35); }
.dpad .key .icon { width: 26px; height: 26px; }
.dpad .up { grid-area: 1 / 2; }
.dpad .left { grid-area: 2 / 1; }
.dpad .ok { grid-area: 2 / 2; }
.dpad .right { grid-area: 2 / 3; }
.dpad .down { grid-area: 3 / 2; }
.key.round { border-radius: 50%; font-weight: 700; font-size: 15px; background: var(--gradient) !important; color: #fff !important;
             box-shadow: 0 6px 16px -6px rgba(124, 58, 237, 0.9) !important; }
.dpad .ok.flash { filter: brightness(1.3); }

.release { width: 100%; }
.key.wide { min-width: 0; font-size: 14px; font-weight: 600; }
.key.recording { background: var(--busy); color: #fff; }
.key.recording .icon { animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.rec { position: absolute; top: 12px; left: 12px; display: inline-flex; align-items: center; gap: 8px; background: rgba(8, 10, 15, 0.75);
       color: #fb7185; font-weight: 700; font-size: 13px; padding: 5px 12px; border-radius: 999px; border: 1px solid rgba(244, 63, 94, 0.4); }
.rec span { color: #fff; font-weight: 500; font-family: var(--mono); font-size: 12px; }
.rec[hidden] { display: none; }
.pending { position: absolute; bottom: 12px; right: 12px; background: rgba(8, 10, 15, 0.75); color: #fff; font-size: 13px;
           padding: 5px 12px; border-radius: 999px; }
.pending[hidden] { display: none; }

/* Toast & overlay -------------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 12px);
  background: #1f2433;
  border: 1px solid var(--border);
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast a { color: #c4b5fd; font-weight: 600; }

.overlay { position: fixed; inset: 0; background: rgba(5, 6, 10, 0.75); backdrop-filter: blur(4px); display: none; align-items: center;
           justify-content: center; z-index: 40; padding: 16px; }
.overlay.show { display: flex; }
.overlay .box { background: var(--surface); border: 1px solid var(--border); padding: 28px; border-radius: 18px; text-align: center; max-width: 420px; }
.overlay .box p { margin: 0 0 16px; }

/* Stats, tables, admin --------------------------------------------------------------------- */
.notice { max-width: 520px; margin: 40px auto; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; }
.notice h2 { margin-top: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.stat .label .icon { color: var(--accent); }
h2.section { font-size: 16px; margin: 28px 0 10px; letter-spacing: -0.01em; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--faint); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; background: rgba(255, 255, 255, 0.015); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, tr:hover td { background: rgba(255, 255, 255, 0.02); }
td.detail { white-space: normal; color: var(--muted); font-size: 12px; max-width: 420px; }
td a { color: var(--text); font-weight: 600; }
td a:hover { color: var(--accent); }
.name-cell { display: flex; align-items: center; gap: 10px; }
.name-cell .avatar { width: 28px; height: 28px; font-size: 11px; }

.subnav { display: flex; gap: 6px; margin: 0 0 22px; padding: 4px; background: var(--surface); border: 1px solid var(--border);
          border-radius: 12px; width: fit-content; }
.subnav a { display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 9px; color: var(--muted); font-size: 14px; font-weight: 500; }
.subnav a.active { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 0 14px; }
.toolbar h2.section { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
td .actions { flex-wrap: nowrap; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
         display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.panel[hidden] { display: none; }
.panel label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.panel label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.panel input:not([type=checkbox]), .login-input {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); outline: none;
}
.panel input:focus, .login-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.panel p { margin: 0; }
.panel > button, .panel .actions { align-self: flex-start; }
.link-box { display: flex; gap: 8px; }
.link-box input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; vertical-align: middle; }
.pill.active { background: rgba(16, 185, 129, 0.14); color: #6ee7b7; }
.pill.paused { background: rgba(245, 158, 11, 0.14); color: #fcd34d; }
.pill.role { background: var(--accent-soft); color: #c4b5fd; }
.pill.neutral { background: var(--key); color: var(--muted); }
.meta.small { font-size: 12px; }

/* Dashboard charts (single series: one hue, hover tooltip, the table below is the data view) */
.charts { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 8px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.chart-card h3 { margin: 0; font-size: 15px; }
.chart-card .meta { margin: 2px 0 16px; }
.bars { position: relative; display: flex; align-items: flex-end; gap: 6px; height: 180px; border-bottom: 1px solid var(--border); }
.bars .bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; min-width: 0; }
.bars .bar { width: 100%; max-width: 34px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 0; transition: filter 0.15s; }
.bars .bar-col:hover .bar { filter: brightness(1.25); }
.bars-x { display: flex; gap: 6px; margin-top: 6px; }
.bars-x span { flex: 1; text-align: center; font-size: 11px; color: var(--faint); min-width: 0; overflow: hidden; white-space: nowrap; }
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar .track { height: 10px; border-radius: 0 4px 4px 0; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar .value { color: var(--muted); font-variant-numeric: tabular-nums; }
.tooltip { position: fixed; z-index: 60; pointer-events: none; background: #1f2433; border: 1px solid var(--border); border-radius: 8px;
           padding: 6px 10px; font-size: 12px; color: var(--text); box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.7); display: none; }
.tooltip b { display: block; font-size: 13px; }

/* Login ------------------------------------------------------------------------------------ */
.login-body { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
              background: radial-gradient(800px 500px at 0% 0%, rgba(124, 58, 237, 0.45), transparent 60%),
                          radial-gradient(700px 500px at 100% 100%, rgba(34, 211, 238, 0.18), transparent 60%), #0d0f16;
              border-right: 1px solid var(--border); }
.login-hero h2 { font-size: 40px; line-height: 1.1; letter-spacing: -0.03em; margin: 0 0 14px; max-width: 520px; }
.login-hero h2 span { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-hero p { color: var(--muted); max-width: 460px; margin: 0; font-size: 16px; }
.login-features { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.login-features li { display: flex; gap: 10px; align-items: center; color: var(--text); }
.login-features .icon { color: var(--live); width: 20px; height: 20px; }
.login-side { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.login-card p { margin: 0; }
.login-card button { padding: 12px; }
.login-error { color: #fda4af; font-size: 14px; background: rgba(244, 63, 94, 0.1); border: 1px solid rgba(244, 63, 94, 0.3);
               padding: 10px 12px; border-radius: 10px; }
.login-notice { color: #6ee7b7; font-size: 14px; background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.3);
                padding: 10px 12px; border-radius: 10px; }

/* Gallery ---------------------------------------------------------------------------------- */
.media-user { margin-bottom: 36px; }
.media-user > header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.media-user > header h2 { font-size: 18px; margin: 0; }
.media-user > header .avatar { width: 36px; height: 36px; font-size: 13px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: fit-content; }
.tabs button { background: transparent; box-shadow: none; color: var(--muted); padding: 7px 14px; font-weight: 500; }
.tabs button:hover { color: var(--text); filter: none; }
.tabs button.active { background: var(--surface-2); color: var(--text); }
.tabs .count { font-size: 12px; padding: 0 7px; border-radius: 999px; background: var(--key); color: var(--muted); }
.tab-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.media-group { margin-bottom: 26px; }
.media-group > header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.media-group h4 { font-size: 14px; margin: 0; font-weight: 600; color: var(--text); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.media-item { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
              box-shadow: var(--shadow); transition: border-color 0.15s, transform 0.15s; }
.media-item:hover { border-color: #353d52; transform: translateY(-1px); }
.media-item .preview { position: relative; }
.media-item img, .media-item video { width: 100%; aspect-ratio: 16 / 9; display: block; background: #000; object-fit: contain; }
.media-item .preview .glass { position: absolute; top: 8px; left: 8px; pointer-events: none; }
.media-item figcaption { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.media-item .cap-title { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item .cap-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.media-item .links { display: flex; gap: 4px; }
.media-item .links a { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--muted); }
.media-item .links a:hover { background: var(--surface-2); color: var(--text); }
.result { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; padding: 3px 9px; border-radius: 999px; }
.result.PASS { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }
.result.FAIL { background: rgba(244, 63, 94, 0.2); color: #fda4af; }
.result.INCOMPLETE, .result.pending { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.preview .result { position: absolute; top: 8px; left: 8px; backdrop-filter: blur(6px); }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 36px 16px; text-align: center; color: var(--muted);
         background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty .icon { width: 28px; height: 28px; color: var(--faint); }

/* Presentation mode ------------------------------------------------------------------------ */
.present-body { background: #05060a; overflow: hidden; }
.present-top { display: flex; align-items: center; gap: 20px; padding: 16px 28px; }
.present-top .clock { margin-left: auto; font-family: var(--mono); font-size: 22px; font-weight: 600; color: var(--text); }
/* Tiles keep 16:9 and the mosaic is as wide as the screen height allows; an odd last tile is centred. */
.present-grid { --gap: 16px; display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: var(--gap);
                padding: 0 28px 28px; height: calc(100vh - 74px); margin: 0 auto;
                max-width: calc((100vh - 102px - (var(--rows, 1) - 1) * var(--gap)) / var(--rows, 1) * 16 / 9 * var(--cols, 1)
                                + (var(--cols, 1) - 1) * var(--gap) + 56px); }
.tile { position: relative; border-radius: 18px; overflow: hidden; background: #000; border: 1px solid var(--border);
        width: calc((100% - (var(--cols, 1) - 1) * var(--gap)) / var(--cols, 1)); aspect-ratio: 16 / 9; }
.tile img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile .tile-info { position: absolute; inset: auto 0 0 0; padding: 70px 18px 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
                   background: linear-gradient(transparent, rgba(0, 0, 0, 0.7) 45%, rgba(0, 0, 0, 0.92)); }
.tile .tile-info h2 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.tile .tile-info .meta { color: #cbd5e1; }
.tile.busy, .tile.mine { border-color: rgba(244, 63, 94, 0.55); box-shadow: 0 0 0 1px rgba(244, 63, 94, 0.25), 0 0 40px -10px rgba(244, 63, 94, 0.5); }
.tile.free { border-color: rgba(16, 185, 129, 0.35); }
.tile .live-tag { position: absolute; top: 14px; left: 14px; right: auto; }

@media (max-width: 1000px) {
  .charts { grid-template-columns: 1fr; }
  .login-body { grid-template-columns: 1fr; }
  .login-hero { padding: 32px 24px; border-right: 0; border-bottom: 1px solid var(--border); }
  .login-hero h2 { font-size: 28px; }
  .present-body { overflow: auto; }
  .present-grid { height: auto; max-width: none; }
  .tile { width: 100%; }
}

@media (max-width: 800px) {
  .topbar { gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
  .nav { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a span:not(.icon) { white-space: nowrap; }
  .user-name { display: none; }
  main { padding: 18px 16px 40px; }
  .control { grid-template-columns: 1fr; }
  .remote { border-radius: 28px; }
  .grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
#record:not(.recording) .icon { color: var(--busy); }
.stat .value.long { font-size: 18px; line-height: 1.6; }

/* Region filter (México / Brasil / Todos) and the region tag on each card */
.screen .overlay-top .tags { display: flex; gap: 6px; }
.glass.region { font-weight: 600; }
.region-switch .tabs button { padding: 5px 12px; }
@media (max-width: 800px) { .present-top { flex-wrap: wrap; gap: 12px; } }

/* Install app (sideload) and debug log on the control page */
.video-wrap.drop { outline: 2px dashed var(--accent); outline-offset: 4px; }
.key.on { border-color: var(--accent); color: var(--text); }
.install-result { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); }
.install-result.ok { border-color: color-mix(in srgb, var(--free) 50%, var(--border)); }
.install-result.ok > .icon { color: var(--free); }
.install-result.error { border-color: color-mix(in srgb, var(--busy) 50%, var(--border)); }
.install-result.error > .icon { color: var(--busy); }
.install-result > div { flex: 1; min-width: 0; }
.install-result pre { margin: 6px 0 0; white-space: pre-wrap; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.debug { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; }
.debug header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.debug h3 { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.debug .spacer { flex: 1; }
.log-lines { margin: 0; height: 320px; overflow: auto; padding: 10px 12px; background: #07090d; font-family: var(--mono);
  font-size: 12px; line-height: 1.5; color: #c9d1d9; white-space: pre-wrap; word-break: break-word; }
.log-lines .error { color: #fb7185; }
.log-lines .warn { color: var(--warn); font-weight: 600; }
.log-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.log-form input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); }

/* App library ---------------------------------------------------------------------------------- */
.app-id { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 16px; }
.app-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
tr.archived td { opacity: 0.6; }
label.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
label.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); cursor: pointer;
               padding: 7px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.app-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px; background: var(--surface);
           border: 1px solid var(--border); border-radius: var(--radius); }
.app-bar select { flex: 1; min-width: 220px; font: inherit; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
                  background: var(--bg); color: var(--text); }
.app-bar .current { font-size: 13px; color: var(--muted); }
.app-bar .current b { color: var(--text); }
.banner.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--text); }
.banner .spacer { flex: 1; }
.remote.locked .key { opacity: 0.35; pointer-events: none; }
.remote .locked-note { display: none; font-size: 12px; color: var(--muted); text-align: center; max-width: 180px; }
.remote.locked .locked-note { display: block; }
.remote.closed .key:not([data-key="back"]):not([data-key="home"]) { opacity: 0.35; pointer-events: none; }
.media-picker { margin-bottom: 16px; }
.media-picker select { flex: 0 1 360px; }
#accounts select, #devices select, label.toggle select { font: inherit; padding: 6px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); }

.fleet-status { white-space: nowrap; }
.fleet-status.maint { color: var(--warn); font-weight: 600; }
