/* Huginn base styles. Dark, tablet-first, no framework. */

:root {
  --bg: #0d0f14;
  --bg-elevated: #161a23;
  --bg-overlay: #1d2230;
  --border: #232838;
  --border-strong: #2e3447;
  --text: #e6e8ee;
  --text-dim: #98a0b3;
  --text-faint: #5e667a;
  --accent: #c47b3e;       /* raven amber */
  --accent-hover: #d68e51;
  --danger: #c7553f;
  --warn: #d96b3a;
  --ok: #4f9e6a;
  --priority-high: #d96b3a;

  --radius: 8px;
  --radius-lg: 12px;
  --space: 8px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

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

button, .btn {
  font: inherit;
  border: 0;
  cursor: pointer;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  display: inline-block;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #1a0f06; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; border: 1px solid var(--border-strong); }
.btn-danger { background: var(--danger); color: white; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }

input, select, textarea {
  font: inherit;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 10px;
  width: 100%;
}
textarea { resize: vertical; min-height: 80px; }
label { display: block; margin: 8px 0 4px; color: var(--text-dim); font-size: 13px; }

/* topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.topbar nav { display: flex; gap: 16px; align-items: center; }
.brand { font-weight: 700; font-size: 18px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand-mark { color: var(--accent); }
.cta { background: var(--accent); color: #1a0f06; padding: 6px 12px; border-radius: var(--radius); font-weight: 600; }

/* flash */
.flash-container { padding: 12px 24px; }
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 8px; }
.flash-error { background: rgba(199, 85, 63, 0.15); border: 1px solid var(--danger); }
.flash-success { background: rgba(79, 158, 106, 0.15); border: 1px solid var(--ok); }

/* verify-email banner — shown on every authenticated page until the
   logged-in user confirms their address. Sits below the topbar; keeps the
   rest of the layout calm by being a thin strip rather than a card. */
.verify-banner {
  background: rgba(199, 144, 63, 0.18);
  border-bottom: 1px solid rgba(199, 144, 63, 0.4);
  color: var(--text);
  padding: 8px 24px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.verify-banner .link {
  background: none; border: none; color: var(--accent);
  cursor: pointer; padding: 0; font: inherit; text-decoration: underline;
}

/* landing */
.hero {
  text-align: center;
  padding: 80px 24px 40px;
  max-width: 880px;
  margin: 0 auto;
}
.hero h1 { font-size: 44px; line-height: 1.1; margin: 0 0 16px; letter-spacing: -0.02em; }
.lede { font-size: 18px; color: var(--text-dim); margin: 0 auto 28px; max-width: 640px; }
.cta-row { display: flex; gap: 12px; justify-content: center; }
.hero-meta { color: var(--text-faint); margin-top: 20px; font-size: 13px; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  padding: 40px 24px;
  max-width: 1100px;
  margin: 0 auto;
}
.feature { background: var(--bg-elevated); padding: 24px; border-radius: var(--radius-lg); }
.feature h2 { margin: 0 0 8px; font-size: 18px; }
.feature p { margin: 0; color: var(--text-dim); }

.how-flow {
  max-width: 720px;
  margin: 40px auto;
  padding: 0 24px;
}
.how-flow h2 { font-size: 22px; }
.how-flow ol { padding-left: 20px; }
.how-flow li { padding: 4px 0; color: var(--text-dim); }

footer { text-align: center; padding: 40px 24px; color: var(--text-faint); }

/* auth pages */
.auth-card {
  max-width: 420px;
  margin: 60px auto;
  background: var(--bg-elevated);
  padding: 32px;
  border-radius: var(--radius-lg);
}
.auth-card h1 { margin-top: 0; }

/* dashboard */
.container { max-width: 1100px; margin: 24px auto; padding: 0 24px; }
.card { background: var(--bg-elevated); padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); }

/* live page */
.live-grid {
  display: grid;
  grid-template-columns: 320px 1fr 380px;
  gap: 12px;
  height: calc(100vh - 60px);
  padding: 12px;
}
.live-pane { background: var(--bg-elevated); border-radius: var(--radius-lg); border: 1px solid var(--border); overflow: auto; padding: 12px; }
.live-pane h2 { font-size: 12px; text-transform: uppercase; color: var(--text-faint); margin: 14px 0 6px; letter-spacing: 0.05em; }
.live-pane h2:first-child { margin-top: 0; }

.detection {
  display: flex;
  gap: 10px;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--bg-overlay);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.detection.high { border-color: var(--priority-high); background: rgba(217, 107, 58, 0.08); }
.detection img { width: 120px; height: 80px; object-fit: cover; border-radius: 4px; background: var(--bg); }
.detection .meta { flex: 1; min-width: 0; }
.detection .label { font-weight: 600; }
.detection .desc { color: var(--text-dim); margin-top: 4px; font-size: 13px; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; background: var(--bg); margin-right: 4px; }
.pill.yolo { background: #1a3a4a; }
.pill.yolo_world { background: #2a4a1f; }
.pill.claude { background: #3a2d6a; }

.detection { cursor: pointer; }
.detection:hover { border-color: var(--border-strong); }

/* Map: drone position marker (Leaflet divIcon) */
.drone-marker { background: transparent; border: 0; }
.drone-marker .drone-dot {
  width: 14px; height: 14px;
  margin: 4px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 4px rgba(196, 123, 62, 0.25);
  animation: drone-pulse 1.6s ease-in-out infinite;
}
@keyframes drone-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(196, 123, 62, 0.25); }
  50%      { box-shadow: 0 0 0 9px rgba(196, 123, 62, 0.05); }
}

/* Detection modal */
.modal[hidden] { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 10, 14, 0.7);
}
.modal-card {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 720px;
  width: 100%;
  max-height: calc(100vh - 48px);
  overflow: auto;
}
.modal-card h3 { margin: 0 0 12px; font-size: 16px; }
.modal-card img { width: 100%; border-radius: var(--radius); background: var(--bg); }
.modal-close {
  position: absolute; top: 8px; right: 12px;
  background: transparent; border: 0; color: var(--text-dim);
  font-size: 22px; cursor: pointer; padding: 4px 8px;
}
.modal-close:hover { color: var(--text); }
.modal-desc { color: var(--text); margin: 12px 0 0; line-height: 1.5; }
.modal-gps { color: var(--text-dim); margin: 8px 0 0; font-size: 14px; }
#modal-meta, #modal-items { margin: 8px 0 0; }

@media (max-width: 1100px) {
  .live-grid { grid-template-columns: 1fr; height: auto; }
}

/* Review page */
.review-page {
  max-width: 1200px;
  margin: 16px auto;
  padding: 0 16px;
  display: grid;
  gap: 12px;
}
.review-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap;
}
.review-header h1 { margin: 0 0 4px; font-size: 22px; }
.review-sub { margin: 0; color: var(--text-dim); font-size: 14px; }
.review-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  color: var(--text-faint); font-size: 13px; }

.review-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.review-stats > div { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-faint); }
.stat-value { font-size: 20px; font-weight: 600; }

.review-table-card { padding: 12px; }
.review-table-head { display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 10px; }
.review-table-head h2 { margin: 0; font-size: 16px; }
.review-count { color: var(--text-faint); font-size: 13px; }

.review-list { display: grid; gap: 8px; }
.review-row {
  display: flex; gap: 10px; padding: 8px;
  background: var(--bg-overlay); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer;
}
.review-row:hover { border-color: var(--border-strong); }
.review-row img, .review-row .review-thumb-empty {
  width: 96px; height: 64px; flex: 0 0 auto;
  object-fit: cover; border-radius: 4px; background: var(--bg);
}
.review-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.review-row-headline { font-weight: 600; font-size: 14px; }
.review-row-time { color: var(--text-faint); font-weight: 400; }
.review-row-desc { color: var(--text-dim); font-size: 13px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.review-row-status { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-faint); margin-top: 2px; }
.review-status-confirmed { border-left: 3px solid var(--ok); }
.review-status-false_positive { border-left: 3px solid var(--text-faint); opacity: 0.6; }
.review-status-investigated { border-left: 3px solid var(--accent); }
.review-status-dismissed { opacity: 0.45; }
.review-empty { padding: 24px; color: var(--text-faint); text-align: center; }

/* Track endpoint markers */
.track-endpoint { background: transparent; border: 0; }
.track-endpoint span {
  display: block; width: 12px; height: 12px; margin: 2px;
  border-radius: 50%; border: 2px solid #fff;
}
.track-start span { background: var(--ok); }
.track-end span { background: var(--accent); }

/* Coverage overlay (canvas painted into Leaflet's overlayPane) */
.coverage-canvas {
  position: absolute; left: 0; top: 0; pointer-events: none;
  /* mix-blend so tile labels remain readable through the wash */
  mix-blend-mode: screen;
}
.coverage-control { background: var(--bg-overlay); border: 1px solid var(--border-strong); }
.coverage-control .coverage-toggle {
  display: block; padding: 5px 10px; font-size: 12px; font-weight: 600;
  color: var(--text-dim); text-decoration: none; line-height: 18px;
  background: transparent;
}
.coverage-control .coverage-toggle:hover { background: var(--bg); color: var(--text); }
.coverage-control .coverage-toggle.on { color: #ffb56e; background: rgba(196,123,62,0.15); }
@media print {
  .coverage-canvas { display: none !important; }
  .coverage-control { display: none !important; }
}

/* Review export buttons row */
.review-actions { display: flex; align-items: center; }
.review-export-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Review filters */
.review-filters { display: flex; flex-direction: column; gap: 10px; }
.filter-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filter-field { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.filter-field input, .filter-field select { width: 100%; }
.filter-search { flex: 1; min-width: 200px; }
.filter-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-faint); margin: 0; }

.bulk-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--bg-overlay); border: 1px solid var(--border-strong);
  padding: 8px 10px; border-radius: var(--radius); }
.bulk-count { font-weight: 600; }
.bulk-spacer { flex: 1; }

/* Per-row select */
.review-row.selected { outline: 2px solid var(--accent); }
.row-select-wrap { display: flex; align-items: center; padding: 0 4px;
  cursor: pointer; }
.row-select { width: 18px; height: 18px; cursor: pointer; }
.select-all-row { display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-dim); margin-left: auto; }
.select-all-row input { width: auto; }

/* Modal triage */
.modal-triage { margin-top: 16px; padding-top: 12px;
  border-top: 1px solid var(--border); }
.modal-triage h4 { margin: 0 0 8px; font-size: 14px;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); }
.modal-triage-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.modal-triage-save { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
#modal-status { color: var(--ok); font-size: 13px; }

/* ---- Report page (printable) ---- */
.report { max-width: 980px; margin: 16px auto; padding: 0 24px; color: var(--text); }
.report-header { display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.report-header h1 { margin: 0; font-size: 26px; }
.report-sub { margin: 4px 0 0; color: var(--text-dim); }
.report-actions { display: flex; gap: 8px; }
.report-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 16px; padding: 12px 16px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
.report-meta-grid > div { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-faint); }
.report-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 16px; padding: 12px 16px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); }
.report-stats > div { display: flex; flex-direction: column; gap: 2px; }
.report-map-card, .report-table-card, .report-notes-card {
  margin-bottom: 16px; padding: 12px 16px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
}
.report-map-card h2, .report-table-card h2, .report-notes-card h2 {
  margin: 0 0 8px; font-size: 16px; }
.report-map-note { margin: 8px 0 0; color: var(--text-faint); font-size: 12px; }
.report-empty { color: var(--text-faint); padding: 12px 0; }
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th, .report-table td { padding: 6px 8px; border-bottom: 1px solid var(--border);
  vertical-align: top; text-align: left; }
.report-table th { color: var(--text-faint); text-transform: uppercase; font-size: 11px;
  letter-spacing: 0.05em; font-weight: 600; }
.report-table .report-time { white-space: nowrap; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.report-table .report-confpri { white-space: nowrap; }
.report-table .report-gps { white-space: nowrap; font-variant-numeric: tabular-nums; }
.report-table .report-notes { color: var(--text-dim); }
.report-table .report-status-confirmed td:first-child { border-left: 3px solid var(--ok); padding-left: 6px; }
.report-table .report-status-false_positive { opacity: 0.7; }
.report-notes-box { white-space: pre-wrap; padding: 8px; min-height: 60px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }

/* Share banner (public read-only views) */
.share-banner {
  background: var(--accent);
  color: #1a0f06;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.share-banner .brand-mark { color: #1a0f06; }

/* Share modal (operator-side, on live + review pages) */
.share-modal-list { display: grid; gap: 8px; margin-top: 12px; }
.share-modal-list > .share-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center;
  padding: 8px; background: var(--bg-overlay); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.share-modal-list .share-url {
  font-family: var(--font-mono); font-size: 12px; word-break: break-all;
  color: var(--text-dim);
}
.share-modal-list .share-meta { color: var(--text-faint); font-size: 12px; }

@media print {
  :root {
    --bg: #ffffff; --bg-elevated: #ffffff; --bg-overlay: #ffffff;
    --text: #111111; --text-dim: #333333; --text-faint: #666666;
    --border: #cccccc; --border-strong: #aaaaaa;
  }
  html, body { background: #fff; color: #111; }
  .topbar, .flash-container, .no-print, .report-actions { display: none !important; }
  main { padding: 0; }
  .report { max-width: none; margin: 0; padding: 0 12mm; }
  .report-header h1 { font-size: 22px; }
  .report-meta-grid, .report-stats, .report-map-card,
  .report-table-card, .report-notes-card {
    border: 1px solid #ccc; background: #fff; box-shadow: none;
    page-break-inside: avoid;
  }
  .report-table th, .report-table td { border-bottom: 1px solid #ddd; }
  .report-map-card { page-break-after: avoid; }
  .report-table { page-break-inside: auto; }
  .report-table tr { page-break-inside: avoid; }
  a { color: #111; text-decoration: none; }
  .leaflet-control-zoom, .leaflet-control-attribution { display: none !important; }
  /* drone setup card */
  .rtmp-url-display { background: #fff !important; border: 1px solid #999 !important; color: #000 !important; }
  .rtmp-qr { padding: 0; background: #fff; }
  .container { max-width: none; padding: 0 12mm; }
  .card { page-break-inside: avoid; }
}

/* ---- multi-stage pipeline UI -------------------------------------------- */

/* inline checkbox row used heavily in the live settings form */
.cb {
  display: flex; align-items: center; gap: 8px;
  margin: 6px 0; font-size: 13px;
}
.cb input { width: auto; }

/* settings-form tabs */
.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 4px 0 10px;
  border-bottom: 1px solid var(--border);
}
.settings-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  letter-spacing: 0.02em;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.settings-panel { padding-top: 4px; }

/* settings-form <details>/<summary> grouping */
#settings-form details {
  margin: 6px 0;
  padding: 6px 10px;
  background: var(--bg-overlay);
  border-radius: var(--radius);
}
#settings-form details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-dim);
  list-style: revert;
  outline: none;
}
#settings-form details[open] > summary { color: var(--text); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* evidence chips on detection cards and modals */
.evidence-row {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 6px;
}
.chip {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
}
.chip.saliency  { background: rgba(196,123,62,0.18);  color: #e0a571; border-color: #6a4421; }
.chip.yolo      { background: rgba(58,138,217,0.16);  color: #7ab2e8; border-color: #2c4a6f; }
.chip.track     { background: rgba(98,196,95,0.15);   color: #88d785; border-color: #2f5a2e; }
.chip.openvocab { background: rgba(98,196,95,0.20);   color: #99e399; border-color: #2f6c2c; }
.chip.claude    { background: rgba(164,122,217,0.16); color: #b69be0; border-color: #4f3a73; }
.chip.sahi      { background: rgba(217,107,58,0.16);  color: #ec9268; border-color: #6a3a1d; }
.chip.pose      { background: rgba(255,255,255,0.06); color: var(--text-dim); }
.chip.pose-prone   { background: rgba(217,67,59,0.20); color: #f08c81; border-color: #6f2722; }
.chip.pose-sitting { background: rgba(217,167,59,0.16); color: #e8c878; }
.chip.proj-precise { background: rgba(98,196,95,0.18); color: #99e399; border-color: #2f6c2c; }
.chip.proj-coarse  { background: rgba(255,255,255,0.04); color: var(--text-faint); }

/* highlight detections that became high-priority due to enrichment */
.detection.high { box-shadow: inset 4px 0 0 var(--priority-high); }

/* drone setup page: RTMP URL + QR side-by-side */
.rtmp-setup-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
}
.rtmp-setup-row .rtmp-setup-text { min-width: 0; }
.rtmp-qr {
  margin: 0;
  padding: 12px;
  background: #fff;
  border-radius: var(--radius);
  text-align: center;
}
.rtmp-qr canvas { display: block; max-width: 100%; height: auto; }
.rtmp-qr figcaption {
  margin-top: 8px;
  font-size: 11px;
  color: #444;
  max-width: 200px;
}
@media (max-width: 600px) {
  .rtmp-setup-row { grid-template-columns: 1fr; }
}

/* help-tooltip — small "?" icon next to settings labels */
.help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
  user-select: none;
}
.help:hover { color: var(--text); border-color: var(--accent); }
.cb .help { margin-left: 4px; }

/* audit log table */
.audit-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.audit-table th, .audit-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.audit-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}
.audit-table td.action { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); }
.audit-table td.meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); white-space: pre-wrap; word-break: break-word; max-width: 320px; }
.audit-table td.who { color: var(--text-dim); }
.audit-filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: end;
  margin-bottom: 12px;
}
.audit-filter-bar label { margin: 0; }
.audit-empty { padding: 24px; text-align: center; color: var(--text-faint); }

/* org settings page */
.danger-zone {
  border: 1px solid var(--danger);
  background: rgba(199, 85, 63, 0.06);
}
.danger-zone h2 { color: var(--danger); }

/* ============================================================
   Admin panel
   ============================================================ */

/* Topbar entry — only shown to ADMIN_EMAIL. Subtle pill. */
.topbar__admin {
  font-size: 12px;
  color: var(--text-dim);
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar__admin:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Admin layout: fixed-width sidebar + fluid content. */
.admin {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 60px);
  background: var(--bg);
}

/* ---- sidebar ---- */
.admin__nav {
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 24px 0 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  align-self: stretch;
  max-height: 100vh;
  overflow-y: auto;
}

.admin__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 18px;
  border-bottom: 1px solid var(--border);
}
.admin__brand-mark {
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
}
.admin__brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin__brand strong {
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
  font-weight: 600;
}
.admin__brand small {
  color: var(--text-faint);
  font-size: 11px;
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin__section-label {
  margin: 0 20px 6px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.admin__nav nav {
  display: flex;
  flex-direction: column;
  padding: 0 8px;
  gap: 2px;
}
.admin__nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 14px;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 14px;
  border-left: 2px solid transparent;
  margin-left: -2px;
  position: relative;
}
.admin__nav-link::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  flex-shrink: 0;
}
.admin__nav-link:hover {
  background: var(--bg-overlay);
  color: var(--text);
}
.admin__nav-link.is-active {
  color: var(--text);
  background: var(--bg-overlay);
  border-left-color: var(--accent);
}
.admin__nav-link.is-active::before {
  background: var(--accent);
  opacity: 1;
}
.admin__nav-link-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}
.admin__nav-link.is-active .admin__nav-link-count {
  color: var(--accent);
  border-color: var(--accent);
}

.admin__nav-foot {
  margin-top: auto;
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
}
.admin__nav-foot a { color: var(--text-dim); }
.admin__nav-foot a:hover { color: var(--accent); }

/* ---- content ---- */
.admin__content {
  padding: clamp(20px, 3vw, 36px) clamp(20px, 4vw, 44px);
  min-width: 0;
  max-width: 1280px;
}

.admin__header {
  margin: 0 0 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.admin__header-text { min-width: 0; }
.admin__header h1 {
  margin: 0 0 6px;
  font-size: clamp(22px, 2.4vw, 28px);
  letter-spacing: -0.015em;
  font-weight: 600;
}
.admin__subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
  max-width: 60ch;
}
.admin__header-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.admin__header-meta::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px rgba(79, 158, 106, 0.6);
}

/* ---- stat cards ---- */
.admin__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 0 0 28px;
}
.admin-stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  transition: border-color 150ms ease, transform 150ms ease, background 150ms ease;
}
.admin-stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--border-strong);
  transition: background 150ms ease;
}
.admin-stat:hover {
  border-color: var(--accent);
  background: var(--bg-overlay);
  transform: translateY(-1px);
  color: var(--text);
}
.admin-stat:hover::before { background: var(--accent); }
.admin-stat--alert::before { background: var(--warn); }
.admin-stat--inert { cursor: default; }
.admin-stat--inert:hover {
  border-color: var(--border);
  background: var(--bg-elevated);
  transform: none;
}
.admin-stat--inert:hover::before { background: var(--border-strong); }

.admin-stat__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  font-weight: 500;
}
.admin-stat__num {
  font-size: 36px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.02em;
}
.admin-stat__num--alert { color: var(--warn); }
.admin-stat__sub {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* ---- two-column panel grid ---- */
.admin__cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.admin__cols .card {
  padding: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.admin__panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.admin__panel-head h2 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  font-weight: 600;
}
.admin__panel-head a {
  font-size: 12px;
  color: var(--accent);
  font-family: var(--font-mono);
}

.admin__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.admin__list li {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.admin__list li:last-child { border-bottom: 0; padding-bottom: 0; }
.admin__list li:first-child { padding-top: 0; }
.admin__list-when {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}
.admin__list-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin__list-main strong {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin__list-sub {
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- pills (status badges in lists) ---- */
.admin__pill {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  white-space: nowrap;
}
.admin__pill--ok   { color: var(--ok);   border-color: var(--ok);   background: rgba(79, 158, 106, 0.10); }
.admin__pill--warn { color: var(--warn); border-color: var(--warn); background: rgba(217, 107, 58, 0.10); }

/* ---- empty + search states ---- */
.admin__empty,
.admin__empty-card {
  color: var(--text-faint);
  text-align: center;
  padding: 32px 16px;
  font-size: 14px;
}
.admin__empty-card {
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.admin__search {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
}
.admin__search input { max-width: 360px; }

/* ---- tables ---- */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table th, .admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  font-weight: 500;
  background: var(--bg);
  border-bottom: 1px solid var(--border-strong);
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover td { background: var(--bg-overlay); }
.admin-table code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* ---- responsive: collapse the sidebar to a horizontal nav ---- */
@media (max-width: 880px) {
  .admin { grid-template-columns: 1fr; }
  .admin__nav {
    position: static;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: none;
    padding: 12px 16px;
  }
  .admin__brand { border: 0; padding: 0; flex: 0 0 auto; }
  .admin__section-label { display: none; }
  .admin__nav nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0;
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: 4px;
  }
  .admin__nav-link {
    border-left: 0;
    border-bottom: 2px solid transparent;
    padding: 6px 10px;
  }
  .admin__nav-link::before { display: none; }
  .admin__nav-link.is-active {
    border-left: 0;
    border-bottom-color: var(--accent);
    background: transparent;
  }
  .admin__nav-foot {
    margin: 0;
    border: 0;
    padding: 0 0 0 8px;
    font-size: 11px;
  }
  .admin__cols { grid-template-columns: 1fr; }
  .admin__list li { grid-template-columns: 70px minmax(0, 1fr) auto; }
}

/* admin: access requests */
.ar-tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 16px 0 20px;
}
.ar-tab {
  padding: 8px 14px;
  color: var(--text-dim);
  font-size: 13px;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.ar-tab:hover { color: var(--text); }
.ar-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.ar-tab__count {
  display: inline-block;
  margin-left: 4px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
}

.ar-list { display: grid; gap: 14px; }
.ar-card {
  border-left: 3px solid var(--border-strong);
  display: grid;
  gap: 12px;
}
.ar-status--pending   { border-left-color: var(--warn); }
.ar-status--contacted { border-left-color: var(--accent); }
.ar-status--approved  { border-left-color: var(--ok); }
.ar-status--rejected  { border-left-color: var(--danger); opacity: 0.7; }

.ar-card__head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; flex-wrap: wrap;
}
.ar-card__who { display: flex; flex-direction: column; gap: 2px; }
.ar-card__who strong { font-size: 16px; }
.ar-card__when {
  display: flex; gap: 10px; align-items: baseline;
  color: var(--text-faint); font-size: 12px; font-family: var(--font-mono);
}

.ar-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
}
.ar-badge--pending   { color: var(--warn);   border-color: var(--warn);   background: rgba(217, 107, 58, 0.08); }
.ar-badge--contacted { color: var(--accent); border-color: var(--accent); background: rgba(196, 123, 62, 0.08); }
.ar-badge--approved  { color: var(--ok);     border-color: var(--ok);     background: rgba(79, 158, 106, 0.10); }
.ar-badge--rejected  { color: var(--danger); border-color: var(--danger); background: rgba(199, 85, 63, 0.08); }

.ar-card__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px 16px;
  margin: 0;
}
.ar-card__meta > div { display: flex; flex-direction: column; gap: 2px; }
.ar-card__meta dt {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}
.ar-card__meta dd { margin: 0; color: var(--text); font-size: 14px; }

.ar-card__msg {
  margin: 0;
  padding: 10px 14px;
  border-left: 2px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  white-space: pre-wrap;
}

.ar-card__ua {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  word-break: break-all;
}

.ar-card__actions {
  display: grid;
  grid-template-columns: minmax(180px, auto) 1fr auto;
  gap: 12px 16px;
  align-items: end;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.ar-card__actions form { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.ar-card__actions label { margin: 0; }
.ar-card__actions select,
.ar-card__actions textarea { width: 100%; }
.ar-card__actions .ar-status-form { flex-direction: row; align-items: end; gap: 8px; }
.ar-card__actions .ar-status-form label { flex: 1; }
.ar-card__actions .ar-delete-form { justify-self: end; }

@media (max-width: 720px) {
  .ar-card__actions { grid-template-columns: 1fr; }
  .ar-card__actions .ar-delete-form { justify-self: stretch; }
}


