:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #667380;
  --line: #d9e0e6;
  --panel: #ffffff;
  --panel-soft: #f6f8f7;
  --bg: #eef2f1;
  --green: #1f7a5f;
  --green-2: #35a57f;
  --orange: #e96b3c;
  --blue: #21618c;
  --red: #c54545;
  --shadow: 0 18px 48px rgba(22, 33, 43, .11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  background: #101820;
  color: #f7faf9;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--orange), #ffd08a);
  display: grid;
  place-items: center;
  color: #101820;
  font-weight: 900;
}

.brand-title {
  font-size: 18px;
  font-weight: 850;
}

.brand-subtitle {
  color: #aebbbb;
  font-size: 12px;
  margin-top: 1px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button,
.sidebar-action {
  color: #e8eeee;
  background: transparent;
  border-radius: 8px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.nav button:hover,
.sidebar-action:hover,
.nav button.active {
  background: rgba(255, 255, 255, .1);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.sync-box {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
}

.sync-box strong {
  display: block;
  margin-bottom: 4px;
}

.sync-box span {
  color: #c5d0d0;
  font-size: 13px;
}

.main {
  min-width: 0;
}

.topbar {
  min-height: 74px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 23px;
  letter-spacing: 0;
}

.context-line {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
}

.button.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.button.green {
  background: var(--green);
}

.button.danger {
  background: #fff;
  color: var(--red);
  border: 1px solid #efc6c6;
}

.button.icon {
  width: 40px;
  padding: 0;
}

.content {
  padding: 24px 28px 36px;
}

.grid {
  display: grid;
  gap: 16px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.two-col {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  align-items: start;
}

.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.panel h2,
.panel h3 {
  margin: 0;
  font-size: 17px;
}

.panel-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.stat-card {
  padding: 17px;
}

.ops-panel {
  margin-bottom: 16px;
}

.workflow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.step-card {
  min-height: 174px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.step-number {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 850;
}

.step-title {
  font-weight: 850;
}

.step-detail {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 850;
}

.stat-detail {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
  background: var(--green-2);
  box-shadow: 0 0 0 4px rgba(53, 165, 127, .14);
}

.status-dot.off {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(197, 69, 69, .13);
}

.status-dot.idle {
  background: #d99b29;
  box-shadow: 0 0 0 4px rgba(217, 155, 41, .15);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.table tr:last-child td {
  border-bottom: 0;
}

.name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.thumb {
  width: 58px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  background: #dce7e3;
  flex: 0 0 auto;
}

.pill {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--ink);
  background: #edf3f1;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.pill.live {
  color: #0f5f45;
  background: #ddf4ec;
}

.pill.warn {
  color: #895713;
  background: #fff0d3;
}

.pill.off {
  color: #8a2525;
  background: #fde2e2;
}

.device-list {
  display: grid;
  gap: 10px;
}

.device-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 13px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.device-title {
  font-weight: 800;
}

.device-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.filters,
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.form-field input,
.form-field select {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 11px;
  background: #fff;
  color: var(--ink);
}

.campaign-grid,
.media-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.campaign-card,
.media-card {
  overflow: hidden;
}

.campaign-cover,
.media-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #dce7e3;
}

video.media-cover {
  background: #05080b;
}

.card-body {
  padding: 14px;
}

.card-title {
  font-weight: 850;
  margin-bottom: 7px;
}

.card-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 13px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.segmented button {
  min-height: 38px;
  padding: 0 12px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  border-right: 1px solid var(--line);
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--ink);
  color: #fff;
}

.upload-drop {
  border: 1px dashed #a9b7bd;
  border-radius: 8px;
  min-height: 170px;
  display: grid;
  place-items: center;
  text-align: center;
  background: #fbfcfc;
  padding: 20px;
}

.upload-drop input {
  max-width: 100%;
}

.empty {
  padding: 26px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
}

.player-page {
  min-height: 100vh;
  background: #05080b;
  color: #fff;
  display: grid;
  grid-template-columns: 1fr 360px;
}

.stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background: #080d11;
}

.content-stage {
  position: absolute;
  inset: 0;
  background: #05080b;
}

.youtube-frame {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  border: 0;
  background: #05080b;
}

.youtube-fallback,
.internal-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px;
  background: linear-gradient(135deg, #101820, #1f7a5f 55%, #e96b3c);
}

.youtube-fallback {
  z-index: 0;
}

.youtube-fallback strong,
.internal-stage strong {
  display: block;
  font-size: clamp(34px, 5vw, 72px);
  margin-bottom: 12px;
}

.youtube-fallback span,
.internal-stage span {
  color: rgba(255,255,255,.78);
  font-size: 18px;
}

.stage img,
.stage video,
.video-sim {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  object-fit: contain;
  display: block;
  background: #05080b;
}

.video-sim {
  position: relative;
  background: linear-gradient(135deg, #0e1a24, #1f7a5f 52%, #e96b3c);
}

.video-sim::before {
  content: "";
  position: absolute;
  inset: 14%;
  border: 18px solid rgba(255,255,255,.24);
  border-radius: 8px;
}

.video-sim::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-42%, -50%);
  border-top: 90px solid transparent;
  border-bottom: 90px solid transparent;
  border-left: 140px solid rgba(255,255,255,.82);
}

.ad-break {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: #05080b;
}

.ad-break img,
.ad-break video,
.ad-break .video-sim {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  object-fit: contain;
  background: #05080b;
}

.ad-badge {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 4;
  border-radius: 999px;
  padding: 9px 13px;
  background: rgba(5, 8, 11, .68);
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.9);
  font-size: 13px;
  font-weight: 800;
}

.player-hud {
  position: absolute;
  z-index: 5;
  left: 26px;
  right: 26px;
  bottom: 22px;
  display: grid;
  gap: 10px;
}

.progress {
  height: 7px;
  background: rgba(255,255,255,.24);
  border-radius: 999px;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: #fff;
}

.hud-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: rgba(255,255,255,.84);
  font-size: 14px;
}

.player-side {
  padding: 22px;
  background: #101820;
  border-left: 1px solid rgba(255,255,255,.12);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.player-page.kiosk {
  grid-template-columns: 1fr;
}

.player-page.kiosk .player-side {
  display: none;
}

.player-page.kiosk .stage img,
.player-page.kiosk .stage video,
.player-page.kiosk .video-sim {
  object-fit: contain;
}

.pair-code {
  font-size: 42px;
  letter-spacing: 4px;
  font-weight: 900;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}

.side-section h2 {
  font-size: 15px;
  margin: 0 0 10px;
}

.side-section p {
  color: #bfcaca;
  line-height: 1.5;
  margin: 0;
  font-size: 14px;
}

.queue {
  display: grid;
  gap: 8px;
}

.queue-item {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
  background: rgba(255,255,255,.07);
  border-radius: 8px;
  padding: 8px;
}

.queue-item img {
  width: 48px;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 6px;
}

.queue-title {
  font-size: 13px;
  font-weight: 750;
}

.queue-meta {
  font-size: 12px;
  color: #bfcaca;
  margin-top: 2px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 32, .48);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 50;
}

.modal {
  width: min(760px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0,0,0,.26);
  border: 1px solid var(--line);
}

.modal-head,
.modal-foot {
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  border-bottom: 0;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 18px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

@media (max-width: 1080px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    flex-direction: row;
    align-items: center;
    overflow: auto;
  }

  .nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
  }

  .sidebar-footer {
    display: none;
  }

  .stats-grid,
  .three-col,
  .campaign-grid,
  .media-grid,
  .two-col,
  .workflow {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .content {
    padding: 16px;
  }

  .stats-grid,
  .three-col,
  .campaign-grid,
  .media-grid,
  .two-col,
  .workflow,
  .filters,
  .form-grid,
  .check-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 14px;
  }

  .brand-subtitle {
    display: none;
  }

  .table {
    min-width: 720px;
  }

  .table-wrap {
    overflow-x: auto;
  }

  .player-page {
    grid-template-columns: 1fr;
  }

  .player-side {
    min-height: auto;
  }
}
