/* BRIGO admin console. Colours are tokens on :root; dark mode follows the system
 * unless the page sets data-theme="light" (or "dark"). */
:root {
  --bg: #f5f7f4;
  --fg: #1d2421;
  --muted: #5d6963;
  --accent: #1f7a57;
  --accent-fg: #ffffff;
  --card: #ffffff;
  --line: #dfe5e1;
  --chip: #eef3f0;
  --ok: #1f7a57;
  --warn: #a15c00;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101513;
    --fg: #e8eee9;
    --muted: #9aa8a0;
    --accent: #46b080;
    --accent-fg: #0b1410;
    --card: #18201d;
    --line: #2a3530;
    --chip: #222d28;
    --ok: #6fd3a0;
    --warn: #e0a84a;
  }
}
:root[data-theme="dark"] {
  --bg: #101513;
  --fg: #e8eee9;
  --muted: #9aa8a0;
  --accent: #46b080;
  --accent-fg: #0b1410;
  --card: #18201d;
  --line: #2a3530;
  --chip: #222d28;
  --ok: #6fd3a0;
  --warn: #e0a84a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

h1 { font-size: 18px; margin: 0; }

/* ── top bar ──────────────────────────────────────────────────── */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.brand { display: flex; align-items: center; gap: 10px; }
.bolt { font-size: 20px; }
.account { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
  min-width: 0;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

.gate {
  text-align: center;
  color: var(--muted);
  font-size: 17px;
  padding: 56px 16px;
}

/* ── tabs ─────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.tabs button {
  appearance: none;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 10px 14px;
  margin-bottom: -1px;
  cursor: pointer;
}
.tabs button[aria-selected="true"] {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

/* ── controls ─────────────────────────────────────────────────── */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  padding: 7px 12px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.wide { display: block; width: 100%; margin-top: 14px; padding: 10px; }

select {
  font: inherit;
  font-size: 14px;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 4px 0 14px;
}
.field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.status { color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 16px 0; text-align: center; }
.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 12px 0 4px;
}

/* ── reports ──────────────────────────────────────────────────── */
.cards { display: grid; gap: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.card-head time { color: var(--muted); font-size: 13px; }
.card-head .who { color: var(--fg); font-weight: 600; font-size: 15px; }

.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 3px 14px;
  margin: 10px 0 0;
  font-size: 14px;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.comment {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--chip);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0;
}

.chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chips a {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--accent);
  background: var(--chip);
  border-radius: 6px;
  padding: 3px 8px;
  text-decoration: none;
}
.chips a:hover { text-decoration: underline; }

.status-select { font-size: 14px; }

.photos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.thumb {
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  color: var(--muted);
  font-size: 13px;
}
.thumb img {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--chip);
}
.thumb:disabled { cursor: default; }

/* ── sessions ─────────────────────────────────────────────────── */
.sessions-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.map {
  height: 62vh;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.table-col { min-width: 0; }
.table-wrap {
  max-height: 62vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: top;
}
th {
  position: sticky;
  top: 0;
  background: var(--card);
  color: var(--muted);
  font-weight: 600;
  z-index: 1;
}
tbody tr { cursor: pointer; }
tbody tr:hover,
tbody tr.active { background: var(--chip); }
tbody tr.no-pin { cursor: default; }
td.outcome-ok { color: var(--ok); font-weight: 600; }
td.outcome-other { color: var(--warn); }
td a { color: var(--accent); }

/* ── map popups ───────────────────────────────────────────────── */
.popup { min-width: 220px; font-size: 13px; }
.popup .facts { grid-template-columns: max-content minmax(0, 1fr); font-size: 13px; }
.popup a { color: var(--accent); }

/* ── lightbox ─────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.86);
  cursor: zoom-out;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}

/* ── phone ────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .sessions-grid { grid-template-columns: minmax(0, 1fr); }
  .map { height: 56vh; }
  .table-wrap { max-height: none; }
}
@media (max-width: 600px) {
  main { padding: 12px 16px 32px; }
  .topbar { padding: 10px 16px; }
  .thumb img { width: 80px; height: 80px; }
  .facts { grid-template-columns: max-content minmax(0, 1fr); }
}

.viewer-link { margin-left: 1rem; font-size: 0.9rem; opacity: 0.85; }
