:root {
  --shiv-green: #b9924b;
  --shiv-green-hover: #c6a15a;
  --shiv-red: #9f1d20;
  --bg-1: #12110f;
  --bg-2: #1a1815;
  --bg-3: #100f0e;
  --panel: rgba(28, 25, 23, 0.9);
  --panel-2: rgba(12, 10, 9, 0.9);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f5f5f4;
  --text-strong: #fafaf9;
  --muted: #a8a29e;
  --amber: #d29a4a;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(185, 146, 75, 0.14), transparent 28rem),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 54%, var(--bg-3) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  overflow-x: hidden;
}

a, button, [role='button'], select, input, label { touch-action: manipulation; -webkit-touch-callout: none; }

header {
  align-items: center;
  backdrop-filter: blur(6px);
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  padding: 14px max(20px, calc((100vw - 1240px) / 2));
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand-block { align-items: baseline; display: flex; gap: 10px; }
.brand { font-family: var(--mono); font-size: 15px; font-weight: 700; letter-spacing: 0.5px; }
.brand-accent { color: var(--shiv-green); }
.brand-sub { color: var(--muted); font-size: 12px; }
.conn { align-items: center; display: flex; font-family: var(--mono); font-size: 12px; gap: 7px; }
.conn-dot { background: var(--muted); border-radius: 50%; height: 7px; width: 7px; }
.conn.live .conn-dot { background: var(--shiv-green); box-shadow: 0 0 8px var(--shiv-green); animation: pulse 1.8s ease-in-out infinite; }
.conn.error .conn-dot { background: var(--shiv-red); }
.conn.error { color: var(--shiv-red); }
@media (prefers-reduced-motion: reduce) { .conn.live .conn-dot { animation: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.statbar {
  display: grid;
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
  grid-template-columns: repeat(3, 1fr);
}
.statbar .stat { background: var(--panel-2); padding: 16px max(20px, calc((100vw - 1240px) / 2)); }
.statbar .stat span { color: var(--muted); display: block; font-size: 11px; letter-spacing: 0.6px; text-transform: uppercase; }
.statbar .stat strong { color: var(--text-strong); font-family: var(--mono); font-size: 24px; }

.quick-test {
  align-items: center;
  background: linear-gradient(180deg, rgba(185, 146, 75, 0.1), transparent);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px max(20px, calc((100vw - 1240px) / 2));
}
.quick-test-copy h2 { color: var(--text-strong); font-size: 14px; margin: 0 0 2px; }
.quick-test-copy p { color: var(--muted); font-size: 12px; margin: 0; max-width: 46ch; }
.quick-test form { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; margin-left: auto; }
.quick-test input[type='file'] { color: var(--muted); font-size: 12px; max-width: 220px; }
.quick-test select { min-height: 34px; padding: 6px 8px; width: auto; }
#quick-test-result { font-family: var(--mono); font-size: 12px; margin: 0; width: 100%; }

main { margin: 0 auto; max-width: 1240px; padding: 24px 20px 80px; }
h2 { color: var(--text-strong); font-size: 15px; font-weight: 700; margin: 0; }

.grid { display: grid; gap: 16px; grid-template-columns: 1.65fr 1fr; margin-bottom: 16px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
  padding: 18px;
}
.panel.wide { min-width: 0; }
.panel-heading { align-items: center; display: flex; justify-content: space-between; margin-bottom: 14px; }
.panel-tag { background: var(--panel-2); border-radius: 999px; color: var(--muted); font-family: var(--mono); font-size: 11px; padding: 3px 9px; }

.campaign-cards { display: flex; flex-direction: column; gap: 8px; }
.campaign-card {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  gap: 12px;
  padding: 10px 12px;
}
.campaign-card-media { flex-shrink: 0; height: 34px; width: 78px; }
.campaign-card-noart, .campaign-card-link, .preview-btn {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  font-size: 11px;
  gap: 5px;
  height: 100%;
  justify-content: center;
  text-decoration: none;
  width: 100%;
}
.campaign-card-link:hover, .preview-btn:hover { background: rgba(185, 146, 75, 0.14); border-color: var(--shiv-green); color: var(--shiv-green); }
.preview-btn { cursor: pointer; min-height: 0; }
.preview-btn svg { flex-shrink: 0; }
.campaign-card-body { flex: 1; min-width: 0; }
.campaign-card-top { align-items: center; display: flex; gap: 8px; justify-content: space-between; }
.campaign-card-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.campaign-card-meta { color: var(--muted); font-size: 12px; margin: 3px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.push-btn {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--shiv-green);
  display: flex;
  flex-shrink: 0;
  font-size: 12px;
  gap: 6px;
  min-height: 38px;
  padding: 8px 12px;
}
.push-btn:hover { background: rgba(185, 146, 75, 0.14); border-color: var(--shiv-green); }
.push-btn svg { flex-shrink: 0; }

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 0.6px; padding: 8px 6px; text-align: left; text-transform: uppercase; }
td { border-top: 1px solid var(--line); font-size: 13px; padding: 11px 6px; vertical-align: middle; }
td .mono { color: var(--muted); font-family: var(--mono); font-size: 11px; }

.pill { align-items: center; border-radius: 999px; display: inline-flex; font-family: var(--mono); font-size: 11px; font-weight: 600; gap: 5px; padding: 4px 9px; text-transform: uppercase; }
.pill::before { border-radius: 50%; content: ''; height: 6px; width: 6px; }
.online, .active { background: rgba(185, 146, 75, 0.16); color: var(--shiv-green); } .online::before, .active::before { background: var(--shiv-green); }
.offline, .ended { background: rgba(159, 29, 32, 0.16); color: #ef6a6c; } .offline::before, .ended::before { background: var(--shiv-red); }
.pending, .scheduled { background: rgba(210, 154, 74, 0.16); color: var(--amber); } .pending::before, .scheduled::before { background: var(--amber); }
.maintenance { background: rgba(168, 162, 158, 0.16); color: var(--muted); } .maintenance::before { background: var(--muted); }

form { display: grid; gap: 10px; }
.field-row { display: grid; gap: 10px; grid-template-columns: 1fr; }
label { color: var(--muted); display: grid; font-size: 11px; font-weight: 600; gap: 5px; letter-spacing: 0.3px; }
input, select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: 13px/1.4 var(--sans);
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}
input:focus-visible, select:focus-visible { border-color: var(--shiv-green); box-shadow: 0 0 0 3px rgba(185, 146, 75, 0.2); outline: none; }
.field-hint { color: var(--muted); font-size: 11px; margin: -2px 0 0; text-align: center; }

.device-picker { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; gap: 2px; max-height: 160px; overflow-y: auto; padding: 6px; }
.device-check { align-items: center; color: var(--text); cursor: pointer; display: flex; flex-direction: row; font-size: 13px; font-weight: 500; gap: 8px; letter-spacing: 0; padding: 6px 4px; text-transform: none; }
.device-check input[type='checkbox'] { accent-color: var(--shiv-green); height: 16px; min-height: 0; width: 16px; }

button {
  background: var(--shiv-green);
  border: 0;
  border-radius: 8px;
  color: #1c1512;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 10px 16px;
  transition: background-color 150ms ease;
}
button:hover { background: var(--shiv-green-hover); }
button:disabled { cursor: not-allowed; opacity: 0.5; }
button:focus-visible { outline: 2px solid var(--shiv-green); outline-offset: 2px; }

.form-result { color: var(--shiv-green); font-size: 12px; margin: 0; }
.form-result.error { color: #ef6a6c; }
.empty { color: var(--muted); font-size: 13px; padding: 14px 0; }
.empty.error { color: #ef6a6c; }

/* Prevent iOS Safari auto-zoom on focus + guarantee touch targets on phones. */
@media (max-width: 767px) {
  input, select, textarea { font-size: 16px !important; }
}

@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .statbar { grid-template-columns: 1fr; }
  header { padding: 12px 16px; }
  main { padding: 18px 14px 60px; }
  .quick-test { padding: 14px 16px; }
  .quick-test form { flex-direction: column; align-items: stretch; margin-left: 0; width: 100%; }
  .quick-test input[type='file'] { max-width: none; }
  .quick-test select { width: 100%; }
  .campaign-card-media { width: 40px; }
  .preview-btn span { display: none; }
  .push-btn span { display: none; }
  .push-btn { padding: 8px; }
}

/* Card-style tables instead of horizontal scroll on phones. */
@media (max-width: 620px) {
  .table-scroll table, .table-scroll thead, .table-scroll tbody, .table-scroll tr, .table-scroll td { display: block; width: 100%; }
  .table-scroll thead { position: absolute; height: 1px; width: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-scroll tr { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 4px 10px; }
  .table-scroll tr:last-child { margin-bottom: 0; }
  .table-scroll td { border-top: 1px solid var(--line); padding: 9px 0; }
  .table-scroll td:first-child { border-top: 0; }
  .table-scroll td::before { color: var(--muted); content: attr(data-label); display: block; font-size: 10px; letter-spacing: 0.5px; margin-bottom: 3px; text-transform: uppercase; }
}

.video-modal { align-items: center; display: flex; inset: 0; justify-content: center; padding: 24px; position: fixed; z-index: 50; }
.video-modal[hidden] { display: none; }
.video-modal-backdrop { background: rgba(6, 5, 4, 0.82); inset: 0; position: absolute; }
.video-modal-body { max-width: min(720px, 92vw); position: relative; width: 100%; }
.video-modal-close {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 12px;
  min-height: 34px;
  padding: 6px 14px;
  position: absolute;
  right: 0;
  top: -46px;
}
.video-modal-close:hover { border-color: var(--shiv-green); color: var(--shiv-green); }
#video-modal-player { background: #000; border-radius: 10px; display: block; max-height: 80vh; width: 100%; }
