:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1b1f24;
  --muted: #5d6673;
  --border: #dfe3e8;
  --navy: #2c3364;
  --blue: #00adef;
  --orange: #ef7000;
  --accent: #2c3364;
  --accent-text: #ffffff;
  --accent-soft: #e6e8f4;
  --ok: #0b6e4f;
  --ok-soft: #e3f3ec;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --danger: #a4282b;
  --danger-soft: #fde8e8;
  --info: #1d5aa6;
  --info-soft: #e5effb;
  --plate: #ffd200;
  --plate-text: #111111;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #191d3a;
    --surface-2: #222749;
    --text: #e8eaed;
    --muted: #9aa3ad;
    --border: #2f3560;
    --bg: #0f1226;
    --accent: #00adef;
    --accent-text: #0a1030;
    --accent-soft: #1a2147;
    --ok: #34b483;
    --ok-soft: #163428;
    --warn: #f0b84b;
    --warn-soft: #3a2e14;
    --danger: #f08a8c;
    --danger-soft: #3d1c1d;
    --info: #79aef0;
    --info-soft: #18283d;
    --shadow: none;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must win over component display rules (e.g. .btn is inline-flex). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    15px/1.5 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif;
}

a {
  color: var(--accent);
  text-decoration-color: var(--orange);
  text-underline-offset: 0.15em;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 24px;
  background: var(--navy);
  border-bottom: 4px solid var(--orange);
}

.brand {
  display: block;
  line-height: 0;
}

.brand img {
  display: block;
  height: 40px;
  width: auto;
}

.nav {
  display: flex;
  gap: 4px;
}

.nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: #d5d8ee;
  text-decoration: none;
  font-weight: 550;
  border-bottom: 2px solid transparent;
  border-radius: 8px 8px 0 0;
}

.nav a:hover {
  color: #fff;
}

.nav a.active {
  color: #fff;
  border-bottom-color: var(--orange);
}

.user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-name {
  color: #d5d8ee;
  font-size: 14px;
}

.main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 64px;
  outline: none;
}

h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

h2 {
  font-size: 17px;
  margin: 0 0 12px;
}

h3 {
  font-size: 15px;
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ---------- forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

label,
.label {
  font-weight: 600;
  font-size: 14px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

input[type='text'],
input[type='tel'],
input[type='search'],
input[type='email'],
input[type='number'],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

input:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}

input.vrn-input {
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.consent {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.consent q {
  display: block;
  font-size: 16px;
  margin: 6px 0 12px;
  quotes: '“' '”';
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.error-box {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 12px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background: var(--surface-2);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover {
  background: var(--accent);
  filter: brightness(1.08);
}

.btn-danger {
  color: var(--danger);
}

.btn-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- plate, chips ---------- */

.plate {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--plate);
  color: var(--plate-text);
  font-weight: 800;
  letter-spacing: 0.08em;
  font-family: 'Arial Narrow', Arial, sans-serif;
  border: 1px solid rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

.plate.big {
  font-size: 22px;
  padding: 4px 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.chip::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.chip.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.chip.wait {
  background: var(--info-soft);
  color: var(--info);
}

.chip.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.chip.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- list ---------- */

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar input[type='search'] {
  max-width: 260px;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr.row {
  cursor: pointer;
}

.table tr.row:hover td {
  background: var(--surface-2);
}

.empty {
  text-align: center;
  padding: 40px 10px;
  color: var(--muted);
}

/* ---------- detail ---------- */

.detail-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  color: var(--muted);
  font-size: 14px;
  margin-top: 8px;
}

.actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cols {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.slots {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.slot {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.thumb {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-2);
  display: block;
}

.thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}

.gallery a {
  display: block;
  position: relative;
}

.gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  background: var(--surface-2);
}

.gallery .tag {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
}

video {
  width: 100%;
  max-height: 420px;
  border-radius: 8px;
  background: #000;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
}

.timeline li {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.timeline time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.timeline .bubble {
  white-space: pre-wrap;
}

.timeline .in {
  color: var(--info);
  font-weight: 600;
}

/* ---------- report ---------- */

.report-banner {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.summary {
  font-size: 16px;
  margin: 0 0 16px;
}

.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kv div {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
}

.kv .k {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.items {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.items th {
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.items td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.items .note {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.items .facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.items .fact {
  font-size: 12px;
  background: var(--surface-2);
  border-radius: 4px;
  padding: 1px 6px;
}

.evidence {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.evidence img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

.evidence .frame {
  font-size: 11px;
  background: var(--surface-2);
  border-radius: 4px;
  padding: 2px 5px;
  color: var(--muted);
}

.sev {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  border-radius: 4px;
  font-weight: 700;
  padding: 0 6px;
}

.sev-1 {
  background: var(--ok-soft);
  color: var(--ok);
}

.sev-2 {
  background: var(--info-soft);
  color: var(--info);
}

.sev-3 {
  background: var(--warn-soft);
  color: var(--warn);
}

.sev-4 {
  background: var(--danger-soft);
  color: var(--danger);
}

.flag-list {
  margin: 0;
  padding-left: 18px;
}

.caveat {
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 16px;
}

.callout {
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.callout.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.callout.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 10px 16px;
  }

  .user {
    margin-left: 0;
  }

  .form-grid,
  .cols {
    grid-template-columns: 1fr;
  }

  .table .hide-sm {
    display: none;
  }

  .actions {
    margin-left: 0;
  }
}

.section-gap {
  margin-top: 16px;
}

/* Quiet buttons sit on the navy top bar. */
.topbar .btn-quiet {
  color: #d5d8ee;
}

.topbar .btn-quiet:hover {
  background: rgba(255, 255, 255, 0.12);
}

h1,
h2 {
  color: var(--heading, var(--text));
}

.card {
  border-top: 3px solid var(--orange);
}

/* ---------- admin centre ---------- */

.subnav {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.subnav a {
  padding: 8px 14px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
}

.subnav a.active {
  color: var(--text);
  border-bottom-color: var(--orange);
}

.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.tenant-name {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

.tenant-switch {
  width: auto;
  padding: 6px 10px;
}

.secret-box {
  border: 2px solid var(--orange);
  border-radius: var(--radius);
  background: var(--warn-soft);
  padding: 16px;
  margin-bottom: 16px;
}

.secret-box code {
  display: block;
  margin: 8px 0;
  padding: 10px;
  background: var(--surface);
  border-radius: 8px;
  word-break: break-all;
  user-select: all;
}

.kv > div {
  padding: 3px 0;
}

.kv .k {
  display: inline-block;
  min-width: 200px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    gap: 8px 16px;
  }
}

/* ---------- dashboard ---------- */

.range-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}

.range-presets,
.range-custom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.range-custom input[type='date'] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.metric-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  margin: 4px 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.metric-note {
  color: var(--muted);
  font-size: 13px;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 160px;
  border-bottom: 1px solid var(--border);
}

.bars-dense {
  gap: 1px;
}

.bar {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
}

.bar-stack {
  width: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 3px 3px 0 0;
  overflow: hidden;
  min-height: 0;
}

.bar-done {
  background: var(--ok);
}

.bar-rest {
  background: var(--border);
}

.bars-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
}

.legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
}

.swatch-done {
  background: var(--ok);
}

.swatch-rest {
  background: var(--border);
}

.dash-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.table th.num,
.table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .dash-cols {
    grid-template-columns: 1fr;
  }
}

/* ---------- audit table ---------- */

.table-wrap {
  overflow-x: auto;
}

.table.audit td {
  vertical-align: top;
}

.nowrap {
  white-space: nowrap;
}

.who {
  word-break: break-word;
}

.who .chip {
  margin-left: 6px;
}

.detail {
  max-width: 340px;
  overflow-wrap: anywhere;
  color: var(--muted);
}
