/* ---------------------------------------------------------------------------
   app.css — shared design system for Billboard Remote Control.

   The category standard, executed at full fidelity: light neutral ground,
   Inter, one blue accent, state color only where it carries meaning
   (green live, amber standby, red failure). 8px spacing rhythm, hairline
   borders, one soft offset shadow. No framework, no build step.
--------------------------------------------------------------------------- */

:root {
  --ink: #0f172a;      /* headings */
  --body: #334155;     /* body text */
  --muted: #64748b;    /* secondary text */
  --bg: #f8fafc;       /* page ground */
  --surface: #ffffff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-press: #1e40af;
  --accent-soft: #dbeafe;
  --accent-ink: #1e40af;

  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --ok-ink: #15803d;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --warn-ink: #b45309;
  --err: #dc2626;
  --err-soft: #fee2e2;
  --err-ink: #b91c1c;

  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.08);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--ink); margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }

/* Browser surfaces ship with the design, not with defaults. */
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, button, textarea { font: inherit; color: inherit; }
input { caret-color: var(--accent); }

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* --- Wordmark ------------------------------------------------------------- */

.wordmark {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.wordmark::after { content: "."; color: var(--accent); }

/* --- Status chip ---------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--body);
}
.chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.chip[data-state="standby"] .dot { background: var(--warn); }
.chip[data-state="live"] .dot { background: var(--ok); }
.chip[data-state="expired"] .dot { background: var(--err); }
.chip[data-state="reconnecting"] .dot {
  background: var(--err);
  animation: chip-pulse 1.2s ease-in-out infinite;
}
@keyframes chip-pulse { 50% { opacity: 0.35; } }

/* --- Card ----------------------------------------------------------------- */

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

/* --- Form fields ---------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
}
.field .hint {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
}

.input,
.select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:hover, .select:hover { border-color: var(--line-strong); }
.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--muted); }

.select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

/* --- Buttons ---------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.btn svg { flex: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }
.btn-primary:disabled {
  background: #bfdbfe;
  color: #1e3a8a;
  cursor: not-allowed;
}

/* Quiet outline variant — used only by the geolocation capture action. */
.btn-outline {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-outline:active { background: var(--accent-soft); }
.btn-outline:disabled { color: var(--muted); border-color: var(--line); cursor: not-allowed; }

.btn .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Callouts ---------------------------------------------------------------- */

.callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.55;
}
.callout svg { flex: none; margin-top: 2px; }
.callout strong { font-weight: 600; }

.callout[data-kind="ok"] { background: var(--ok-soft); color: var(--ok-ink); }
.callout[data-kind="warn"] { background: var(--warn-soft); color: var(--warn-ink); }
.callout[data-kind="error"] { background: var(--err-soft); color: var(--err-ink); }
.callout[data-kind="info"] { background: var(--accent-soft); color: var(--accent-ink); }

/* --- Admin lists ------------------------------------------------------------ */

.admin-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.admin-head h1 {
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.admin-head .sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.admin-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.admin-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.admin-row:last-child { border-bottom: 0; }
.admin-row .grow { flex: 1; min-width: 0; }
.admin-row .title { font-weight: 600; color: var(--ink); }
.admin-row .sub {
  margin-top: 2px;
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-row .actions { display: flex; align-items: center; gap: 8px; flex: none; flex-wrap: wrap; }
.admin-empty { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 0.9375rem; }

@media (max-width: 640px) {
  .admin-row { flex-wrap: wrap; }
  .admin-row .grow { flex-basis: 100%; }
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.btn-sm { height: 36px; padding: 0 12px; font-size: 0.875rem; font-weight: 600; }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover { background: var(--bg); color: var(--ink); }

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--body);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.icon-btn:disabled { color: var(--line-strong); cursor: not-allowed; }

/* --- Form extras ------------------------------------------------------------ */

.textarea {
  width: 100%;
  min-height: 140px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea:hover { border-color: var(--line-strong); }
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 10px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); }

.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
}
.checkline input { width: 18px; height: 18px; accent-color: var(--accent); }

/* --- Motion discipline ------------------------------------------------------- */

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