/* ---------------------------------------------------------------------
   Design tokens
   Palette: deep ink background, signal-colored status system (borrowed
   from departure boards / traffic signals — apt for a tool whose whole
   job is routing traffic to destinations).
--------------------------------------------------------------------- */
:root {
  --ink: #0E1116;
  --surface: #161B22;
  --surface-raised: #1D232C;
  --border: #262C36;
  --text: #E6E9EF;
  --text-muted: #8891A0;

  --accent: #4C8DFF;
  --accent-dim: #2C5CBF;

  --signal-go: #3ECF8E;
  --signal-warn: #F5A623;
  --signal-stop: #EF5350;

  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }

/* ---------------------------------------------------------------------
   Top bar
--------------------------------------------------------------------- */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand__mark { color: var(--accent); font-size: 20px; }
.brand__slash { color: var(--text-muted); }
.brand--center { justify-content: center; font-size: 22px; margin-bottom: 4px; }
.topbar__nav { display: flex; align-items: center; gap: 14px; }
.topbar__user { color: var(--text-muted); font-size: 14px; }

.shell { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; }

.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 24px;
}

/* ---------------------------------------------------------------------
   KPI strip
--------------------------------------------------------------------- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 600; }
.kpi-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------------------------------------------------------------------
   Panels (disclosure widgets for create/batch/edit forms)
--------------------------------------------------------------------- */
.panels { display: flex; flex-direction: column; gap: 10px; margin-bottom: 28px; }
.panel, .panel-static {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.panel__summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  list-style: none;
  user-select: none;
}
.panel__summary::-webkit-details-marker { display: none; }
.panel[open] .panel__summary { margin-bottom: 14px; }
.panel-title { font-family: var(--font-display); font-size: 15px; font-weight: 600; margin: 0 0 12px; }

.grid-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.grid-form--tight { gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.field--grow { flex: 1 1 100%; }
.field--checkbox { flex-direction: row; align-items: center; gap: 8px; }
.field__label { font-size: 12px; color: var(--text-muted); }

.fieldset { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 12px; margin: 0; flex: 1 1 100%; }
.fieldset legend { font-size: 12px; color: var(--text-muted); padding: 0 6px; }

.input {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 11px;
  font-size: 14px;
  font-family: var(--font-body);
  min-width: 0;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.input--mono { font-family: var(--font-mono); }
.textarea { resize: vertical; font-family: var(--font-mono); }

.form-message { font-size: 13px; margin-left: 10px; }
.form-message--error { color: var(--signal-stop); }
.form-message--success { color: var(--signal-go); }

.batch-results { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); max-height: 160px; overflow-y: auto; }

/* ---------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 9px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dim); text-decoration: none; }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn--ghost:hover { border-color: var(--accent); text-decoration: none; }
.btn--sm { padding: 6px 10px; font-size: 12px; }
.btn--block { width: 100%; justify-content: center; }
.inline-form { display: inline; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 14px;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn--danger:hover { color: var(--signal-stop); border-color: var(--signal-stop); }

/* ---------------------------------------------------------------------
   The "departures board" — the link manifest table
--------------------------------------------------------------------- */
.board-toolbar { margin-bottom: 12px; }
.board-filters { display: flex; gap: 10px; }
.board-filters .input[name="q"] { flex: 1; }

.board {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.board__row {
  display: grid;
  grid-template-columns: 1.1fr 2fr 0.6fr 0.8fr 0.9fr 1.1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  animation: rowIn 260ms ease both;
}
.board__row:last-child { border-bottom: none; }
.board__row--head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  animation: none;
}
.board__code { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.board__dest {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}
.board__actions { display: flex; gap: 6px; }
.board__empty { padding: 32px; text-align: center; color: var(--text-muted); }

@keyframes rowIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .board__row { animation: none; }
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge--active { background: rgba(62,207,142,0.15); color: var(--signal-go); }
.badge--inactive { background: rgba(239,83,80,0.15); color: var(--signal-stop); }
.badge--expired { background: rgba(245,166,35,0.15); color: var(--signal-warn); }

.pagination { display: flex; gap: 6px; margin-top: 14px; }
.page-link {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 13px;
  color: var(--text-muted);
}
.page-link--active { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------------
   Auth / status screens (login, unlock, 404, 500)
--------------------------------------------------------------------- */
.auth-screen, .status-screen {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card, .status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.auth-subtitle { color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }
.alert { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 14px; text-align: left; }
.alert--error { background: rgba(239,83,80,0.12); color: var(--signal-stop); }

.status-code { font-family: var(--font-display); font-size: 56px; font-weight: 700; color: var(--accent); }
.status-code--error { color: var(--signal-stop); }
.status-title { font-family: var(--font-display); margin: 6px 0 8px; }
.status-body { color: var(--text-muted); margin: 0 0 20px; }

/* ---------------------------------------------------------------------
   Link detail page
--------------------------------------------------------------------- */
.back-link { display: inline-block; margin-bottom: 16px; font-size: 13px; color: var(--text-muted); }
.detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.detail-title { font-family: var(--font-display); font-size: 24px; margin: 0 0 4px; }
.detail-dest { font-size: 13px; word-break: break-all; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 14px; }
.qr-preview { width: 160px; height: 160px; background: #fff; border-radius: var(--radius-sm); padding: 8px; display: block; margin-bottom: 10px; }
.bar-list { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.bar-row { display: flex; justify-content: space-between; gap: 10px; color: var(--text-muted); }
.bar-row strong { color: var(--text); font-weight: 500; }

/* ---------------------------------------------------------------------
   Modal (QR preview)
--------------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal[hidden] { display: none; }
.modal__panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; text-align: center; position: relative;
}
.modal__close {
  position: absolute; top: 10px; right: 10px; background: transparent; border: none;
  color: var(--text-muted); font-size: 16px; cursor: pointer;
}
#qr-image { background: #fff; border-radius: var(--radius-sm); padding: 10px; }

/* ---------------------------------------------------------------------
   Pricing page
--------------------------------------------------------------------- */
.pricing-head { text-align: center; margin-bottom: 32px; }
.pricing-title { font-family: var(--font-display); font-size: 32px; margin: 0 0 6px; }
.pricing-controls { display: flex; justify-content: center; align-items: flex-end; gap: 20px; margin-top: 20px; }

.toggle {
  display: inline-flex; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px;
}
.toggle__option {
  background: transparent; border: none; color: var(--text-muted); font-size: 13px; font-weight: 600;
  padding: 8px 16px; border-radius: 999px; cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.toggle__option--active { background: var(--accent); color: #fff; }
.toggle__badge { font-size: 10px; opacity: 0.85; }

.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.plan-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; display: flex; flex-direction: column; gap: 12px;
}
.plan-card--featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan-name { font-family: var(--font-display); font-size: 20px; margin: 0; }
.plan-tagline { margin: 0; font-size: 13px; }
.plan-price { display: flex; align-items: baseline; gap: 6px; margin-top: 6px; }
.plan-price__amount { font-family: var(--font-display); font-size: 32px; font-weight: 700; }
.plan-price__period { color: var(--text-muted); font-size: 13px; }
.plan-limit { font-size: 13px; color: var(--text-muted); margin: 0; }
.plan-features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.plan-features li { font-size: 13px; color: var(--text-muted); padding-left: 18px; position: relative; }
.plan-features li::before { content: '✓'; position: absolute; left: 0; color: var(--signal-go); }
.pricing-footnote { text-align: center; font-size: 12px; margin-top: 8px; }

.plan-badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 3px 10px;
}
.usage-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 18px; margin-bottom: 20px; font-size: 13px;
}
.usage-banner--full { border-color: var(--signal-warn); }
.usage-banner strong { color: var(--text); }

/* ---------------------------------------------------------------------
   Responsive
--------------------------------------------------------------------- */
@media (max-width: 860px) {
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .board__row { grid-template-columns: 1fr; gap: 4px; }
  .board__row--head { display: none; }
  .board__row { padding: 14px 16px; }
  .plan-grid { grid-template-columns: 1fr; }
  .pricing-controls { flex-direction: column; align-items: center; }
}
