/* =========================================================================
   Hosted Site Review Manager — design system
   MultiSensor AI navy (#1F3864) anchor, light + dark, no external assets.
   ========================================================================= */

:root {
  --brand: #1f3864;
  --brand-700: #182c50;
  --brand-500: #2c4e88;
  --accent: #2e7dd1;
  --accent-soft: #e8f1fc;

  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #be123c;
  --danger-soft: #fdeaef;
  --focus: #c2760a;
  --focus-soft: #fdf4e3;

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --border: #dbe2ed;
  --border-strong: #c3cddd;
  --text: #0f1a2c;
  --muted: #5c6c86;
  --muted-2: #7b8aa3;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 26, 44, .06), 0 1px 3px rgba(15, 26, 44, .04);
  --shadow: 0 4px 12px rgba(15, 26, 44, .08), 0 1px 3px rgba(15, 26, 44, .05);
  --shadow-lg: 0 18px 48px rgba(15, 26, 44, .18);

  --header-h: 56px;
  --sidebar-w: 236px;
  --row-h: 44px;

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

:root[data-theme="dark"] {
  --brand: #2b4d87;
  --brand-700: #1b3560;
  --brand-500: #3a63a6;
  --accent: #6aa9ec;
  --accent-soft: #17273f;

  --ok: #4ade80;
  --ok-soft: #12291d;
  --warn: #fbbf24;
  --warn-soft: #2b2113;
  --danger: #fb7185;
  --danger-soft: #2e1620;
  --focus: #fbbf24;
  --focus-soft: #2b2113;

  --bg: #0a1120;
  --surface: #111b2d;
  --surface-2: #16223a;
  --surface-3: #1b2941;
  --border: #23324c;
  --border-strong: #32435f;
  --text: #e6edf8;
  --muted: #9bacc7;
  --muted-2: #7e8faa;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 6px 18px rgba(0, 0, 0, .45);
  --shadow-lg: 0 22px 54px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body[data-density="compact"] { --row-h: 34px; font-size: 13px; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0 0 .6em; }
a { color: var(--accent); }

.icon { flex: none; vertical-align: -.15em; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.hidden, [hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); background-clip: content-box; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* =========================================================================
   App shell
   ========================================================================= */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
}
.app[data-sidebar="collapsed"] { grid-template-columns: 60px 1fr; }

/* ---------- header ---------- */

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-sm);
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #3f79c9, #7ec4e8);
  color: #0b1a33; font-weight: 800; font-size: 12px; letter-spacing: .02em;
  display: flex; align-items: center; justify-content: center;
}
.brand-text { line-height: 1.15; }
.brand-text strong { display: block; font-size: 14px; font-weight: 650; }
.brand-text span { font-size: 11px; color: rgba(255, 255, 255, .68); }

.global-search {
  flex: 1;
  max-width: 520px;
  position: relative;
  display: flex;
  align-items: center;
}
.global-search .icon { position: absolute; left: 10px; color: rgba(255, 255, 255, .7); }
.global-search input {
  width: 100%;
  height: 34px;
  padding: 0 70px 0 32px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font: inherit;
}
.global-search input::placeholder { color: rgba(255, 255, 255, .62); }
.global-search input:focus { outline: none; background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .5); }
.global-search kbd {
  position: absolute; right: 8px;
  font: 600 10px/1 var(--font);
  color: rgba(255, 255, 255, .72);
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 5px; padding: 4px 6px;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.sync-pill {
  display: flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .9);
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #62d99a; }
.sync-pill[data-status="live"] .sync-dot { animation: pulse 2.6s ease-in-out infinite; }
.sync-pill[data-status="error"] .sync-dot,
.sync-pill[data-status="offline"] .sync-dot { background: #ff9d9d; animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.presence-stack { display: flex; align-items: center; }
.presence-stack .avatar { margin-left: -6px; border: 2px solid var(--brand); }
.presence-stack .avatar:first-child { margin-left: 0; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  flex: none;
}
.avatar.sm { width: 22px; height: 22px; font-size: 9px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; min-width: 32px; padding: 0 8px;
  border-radius: 8px; border: 1px solid transparent;
  background: rgba(255, 255, 255, .1);
  color: #fff; cursor: pointer; font: inherit;
}
.icon-btn:hover { background: rgba(255, 255, 255, .2); }

/* ---------- sidebar ---------- */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-scroll { overflow-y: auto; padding: 10px 10px 18px; flex: 1; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--muted); font-weight: 600; font-size: 13px;
  background: none; border: 0; cursor: pointer; text-align: left; width: 100%;
  font-family: inherit;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item[aria-current="true"] { background: var(--accent-soft); color: var(--brand); }
:root[data-theme="dark"] .nav-item[aria-current="true"] { color: var(--accent); }
.nav-item .count {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: var(--surface-3); color: var(--muted);
  border-radius: 999px; padding: 1px 7px;
}
.nav-item[aria-current="true"] .count { background: #fff3; color: inherit; }

.side-heading {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10.5px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted-2); margin: 14px 4px 7px;
}
.side-heading button { background: none; border: 0; color: var(--accent); font: inherit; font-size: 11px; cursor: pointer; text-transform: none; letter-spacing: 0; }

.segmented {
  display: flex; background: var(--surface-3); border-radius: 8px; padding: 3px; gap: 2px;
}
.segmented button {
  flex: 1; border: 0; background: none; border-radius: 6px; cursor: pointer;
  padding: 5px 6px; font: 600 12px/1.4 var(--font); color: var(--muted);
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.status-filter { display: flex; flex-direction: column; gap: 1px; }
.status-filter button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 5px 8px; border-radius: 7px; border: 0; background: none;
  cursor: pointer; font: inherit; font-size: 12.5px; color: var(--muted); text-align: left;
}
.status-filter button:hover { background: var(--surface-3); color: var(--text); }
.status-filter button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); font-weight: 650; }
.status-filter .swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.status-filter .count { margin-left: auto; font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }

.app[data-sidebar="collapsed"] .nav-item span,
.app[data-sidebar="collapsed"] .side-block { display: none; }
.app[data-sidebar="collapsed"] .nav-item { justify-content: center; padding: 9px 0; }

/* ---------- main ---------- */

.main { overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.view { flex: 1; overflow: auto; padding: 18px 20px 40px; }
.view-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 14px; flex-wrap: wrap;
}
.view-title h2 { font-size: 19px; }
.view-title p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.view-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* =========================================================================
   Controls
   ========================================================================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 32px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font: 600 13px/1 var(--font); cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-500); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--border-strong); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { height: 27px; padding: 0 9px; font-size: 12px; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label,
.label {
  font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
.input, select.input, textarea.input {
  width: 100%; min-height: 34px; padding: 7px 10px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit;
}
textarea.input { min-height: 90px; resize: vertical; line-height: 1.55; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.input::placeholder { color: var(--muted-2); }
.input.mono { font-family: var(--mono); font-size: 13px; }
.input-group { display: flex; gap: 6px; align-items: center; }
.input-group .input { flex: 1; }

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .01em;
  white-space: nowrap;
}
.tag.outline { background: transparent; border: 1px solid currentColor; }
.tag-btn { border: 0; cursor: pointer; font-family: inherit; }
.tag-btn.off { background: var(--surface-3) !important; color: var(--muted) !important; opacity: .75; }
.tag-btn.off:hover { opacity: 1; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700;
  background: var(--surface-3); color: var(--muted);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.focus { background: var(--focus-soft); color: var(--focus); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* =========================================================================
   Stat tiles
   ========================================================================= */

.tiles {
  display: grid; gap: 10px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
}
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  cursor: pointer; text-align: left; font: inherit; color: inherit;
  display: flex; flex-direction: column; gap: 3px;
  transition: border-color .12s, box-shadow .12s;
}
.tile:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.tile[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.tile .tile-label { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.tile .tile-value { font-size: 25px; font-weight: 720; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .tile-note { font-size: 11.5px; color: var(--muted-2); }
.tile.is-focus .tile-value { color: var(--focus); }
.tile.is-attention .tile-value { color: var(--danger); }
.tile.is-ok .tile-value { color: var(--ok); }

/* =========================================================================
   Board view
   ========================================================================= */

.board { display: flex; gap: 12px; align-items: flex-start; padding-bottom: 12px; min-height: 60vh; }
.lane {
  width: 290px; flex: none;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column;
  max-height: calc(100vh - var(--header-h) - 190px);
}
.lane.drop-target { outline: 2px dashed var(--accent); outline-offset: 2px; }
.lane.dragging { opacity: .45; }
.lane-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: grab; user-select: none;
}
.lane-head:active { cursor: grabbing; }
.lane-head .lane-name { font-weight: 700; font-size: 12.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-head .lane-count {
  font-size: 11px; font-weight: 700; background: rgba(255, 255, 255, .25);
  border-radius: 999px; padding: 1px 8px; font-variant-numeric: tabular-nums;
}
.lane-body { padding: 8px; display: flex; flex-direction: column; gap: 7px; overflow-y: auto; }
.lane-empty { color: var(--muted-2); font-size: 12px; text-align: center; padding: 18px 8px; font-style: italic; }

.site-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 10px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color .12s, box-shadow .12s, transform .08s;
  text-align: left; font: inherit; color: inherit; width: 100%;
}
.site-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.site-card.pinned { border-left: 3px solid var(--focus); }
.site-card.flash { animation: flash 2.4s ease-out; }
@keyframes flash {
  0% { box-shadow: 0 0 0 2px var(--accent); background: var(--accent-soft); }
  100% { box-shadow: none; }
}
.site-card-top { display: flex; align-items: center; gap: 6px; }
.site-card-name { font-weight: 700; font-size: 13.5px; letter-spacing: -.01em; }
.site-card-note {
  font-size: 11.5px; color: var(--muted); line-height: 1.45;
  border-left: 2px solid var(--border-strong); padding-left: 7px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.site-card-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 11px; color: var(--muted-2); border-top: 1px solid var(--border); padding-top: 6px;
}
.site-card-meta .meta-item { display: inline-flex; align-items: center; gap: 4px; }

.star-btn {
  background: none; border: 0; cursor: pointer; padding: 2px; border-radius: 5px;
  color: var(--muted-2); display: inline-flex;
}
.star-btn:hover { background: var(--surface-3); color: var(--focus); }
.star-btn.on { color: var(--focus); }
.star-btn.on .icon { fill: currentColor; }

/* =========================================================================
   Table view
   ========================================================================= */

.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: auto; max-height: calc(100vh - var(--header-h) - 170px);
}
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.grid thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--muted);
  font-size: 10.5px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase;
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.grid thead th.sortable { cursor: pointer; user-select: none; }
table.grid thead th.sortable:hover { color: var(--text); }
table.grid tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid tbody tr.selected { background: var(--accent-soft); }
table.grid tbody tr.pinned td:first-child { box-shadow: inset 3px 0 0 var(--focus); }
table.grid .cell-site { font-weight: 650; }
table.grid .cell-tags { display: flex; flex-wrap: wrap; gap: 4px; }
table.grid .col-check { width: 34px; }
table.grid .col-actions { width: 96px; text-align: right; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; }
table.grid tbody tr:hover .row-actions { opacity: 1; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 60px 20px; color: var(--muted); text-align: center;
}
.empty-state .icon { color: var(--border-strong); }

.bulkbar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding: 10px 12px;
  background: var(--brand); color: #fff;
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.bulkbar .btn { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .25); color: #fff; }
.bulkbar .btn:hover { background: rgba(255, 255, 255, .26); }

/* =========================================================================
   Work queue + activity
   ========================================================================= */

.stack { display: flex; flex-direction: column; gap: 10px; }
.queue-group {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.queue-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.queue-head .site-name { font-weight: 700; }
.queue-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
}
.queue-item:last-child { border-bottom: 0; }
.queue-item input[type="checkbox"] { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--ok); cursor: pointer; }
.queue-item .queue-text { flex: 1; line-height: 1.45; }
.queue-item .queue-meta { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.queue-item.aged .queue-meta { color: var(--warn); font-weight: 600; }

.activity-row {
  display: flex; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid var(--border); align-items: flex-start;
}
.activity-row:last-child { border-bottom: 0; }
.activity-row .activity-body { flex: 1; min-width: 0; }
.activity-row .activity-text { line-height: 1.45; }
.activity-row .activity-meta { font-size: 11.5px; color: var(--muted-2); margin-top: 1px; }

/* =========================================================================
   Site panel (slide-over)
   ========================================================================= */

.scrim {
  position: fixed; inset: 0; background: rgba(9, 16, 30, .45);
  backdrop-filter: blur(1.5px); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .16s;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw);
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); z-index: 70;
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .2s cubic-bezier(.3, .8, .4, 1);
}
.panel.open { transform: translateX(0); }
.panel-head {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px; background: var(--surface-2);
}
.panel-title { display: flex; align-items: center; gap: 10px; }
.panel-title h3 { font-size: 20px; letter-spacing: -.02em; }
.panel-tabs { display: flex; gap: 2px; }
.panel-tabs button {
  border: 0; background: none; padding: 6px 10px; border-radius: 7px;
  font: 600 12.5px/1 var(--font); color: var(--muted); cursor: pointer;
}
.panel-tabs button:hover { background: var(--surface-3); color: var(--text); }
.panel-tabs button[aria-selected="true"] { background: var(--brand); color: #fff; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px; }
.panel-foot {
  border-top: 1px solid var(--border); padding: 10px 14px;
  display: flex; gap: 8px; align-items: center; background: var(--surface-2); flex-wrap: wrap;
}

.panel-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px; font-size: 12.5px;
  background: var(--warn-soft); color: var(--warn); font-weight: 600;
}

.section { margin-bottom: 18px; }
.section-title {
  display: flex; align-items: center; gap: 7px; margin-bottom: 9px;
  font-size: 11px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 560px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.copy-field { position: relative; }
.copy-field .input { padding-right: 62px; }
.copy-field .copy-actions {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: flex; gap: 1px;
}
.copy-field .copy-actions button {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  padding: 5px; border-radius: 6px; display: inline-flex;
}
.copy-field .copy-actions button:hover { background: var(--surface-3); color: var(--text); }

.log-entry {
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 10px;
  margin-bottom: 8px; background: var(--surface-2);
}
.log-entry.action { border-left: 3px solid var(--focus); }
.log-entry .log-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--muted-2); margin-bottom: 5px;
}
.log-entry .log-text { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.log-entry .log-tools { margin-left: auto; display: flex; gap: 1px; }
.log-entry .log-tools button {
  border: 0; background: none; padding: 4px; border-radius: 5px; color: var(--muted-2); cursor: pointer;
}
.log-entry .log-tools button:hover { background: var(--surface-3); color: var(--text); }
.log-entry .log-tools button.on { color: var(--focus); }

.camera-card {
  border: 1px solid var(--border); border-radius: 9px; padding: 10px; margin-bottom: 8px;
  background: var(--surface-2);
}
.camera-card .camera-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

/* =========================================================================
   Modals
   ========================================================================= */

.modal-root {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(9, 16, 30, .5); backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: min(720px, 100%); max-height: min(88vh, 900px);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { width: min(1100px, 100%); }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.modal-head h3 { font-size: 15px; flex: 1; }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); flex-wrap: wrap;
}

/* command palette */
.palette { width: min(620px, 100%); align-self: flex-start; margin-top: 12vh; }
.palette input {
  width: 100%; border: 0; border-bottom: 1px solid var(--border);
  padding: 15px 16px; font-size: 15px; background: transparent; color: var(--text);
}
.palette input:focus { outline: none; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 8px; border: 0; background: none;
  cursor: pointer; font: inherit; color: inherit; text-align: left;
}
.palette-item[aria-selected="true"] { background: var(--accent-soft); }
.palette-item .palette-sub { font-size: 11.5px; color: var(--muted); }

/* toasts */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 120;
  display: flex; flex-direction: column; gap: 8px; max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 9px; padding: 10px 12px; box-shadow: var(--shadow);
  animation: slide-in .18s ease-out;
}
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast .toast-text { font-size: 13px; line-height: 1.45; }
.toast .toast-detail { font-size: 11.5px; color: var(--muted); }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* =========================================================================
   Settings + checklist
   ========================================================================= */

.setting-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.setting-row:last-child { border-bottom: 0; }
.setting-row .drag-handle { cursor: grab; color: var(--muted-2); display: flex; }
.setting-row.dragging { opacity: .4; }
.setting-row input[type="color"] {
  width: 30px; height: 26px; padding: 0; border: 1px solid var(--border-strong);
  border-radius: 6px; background: none; cursor: pointer;
}
.panelcard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 16px;
}
.panelcard > header {
  padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  display: flex; align-items: center; gap: 9px;
}
.panelcard > header h3 { font-size: 13.5px; flex: 1; }
.panelcard > .body { padding: 14px; }

.checklist-row {
  display: grid; grid-template-columns: 1.4fr 2.4fr 70px 40px; gap: 12px;
  padding: 9px 12px; border-bottom: 1px solid var(--border); align-items: start;
}
.checklist-row.done { background: var(--ok-soft); }
.checklist-row .step { font-weight: 600; }
.checklist-row .process { font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-word; }
.checklist-head {
  display: grid; grid-template-columns: 1.4fr 2.4fr 70px 40px; gap: 12px;
  padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 10.5px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
}

.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: 26px; text-align: center; color: var(--muted); cursor: pointer;
  background: var(--surface-2);
}
.dropzone:hover, .dropzone.hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }

/* =========================================================================
   Report
   ========================================================================= */

.report-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .report-layout { grid-template-columns: 1fr; } }
.report-scroll { max-height: calc(100vh - var(--header-h) - 150px); overflow: auto; background: var(--surface-3); border-radius: var(--radius); padding: 16px; }

.report-page {
  width: 210mm; min-height: 297mm; margin: 0 auto; padding: 16mm 15mm;
  background: #fff; color: #10192b; box-shadow: var(--shadow);
  font-size: 10.5pt;
}
.report-page h1 { font-size: 21pt; color: #1f3864; letter-spacing: -.02em; }
.report-page h2 { font-size: 9pt; letter-spacing: .1em; text-transform: uppercase; color: #64748b; margin-bottom: 7px; }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 2px solid #e2e8f0; padding-bottom: 14px; }
.report-logo { max-height: 74px; max-width: 250px; object-fit: contain; }
.report-logo-fallback {
  width: 64px; height: 64px; border-radius: 10px; background: #1f3864; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15pt;
}
.report-section { margin-top: 16px; break-inside: avoid; }
.report-stats { display: grid; gap: 8px; grid-template-columns: repeat(3, 1fr); }
.report-stat { border: 1px solid #e2e8f0; border-radius: 8px; padding: 9px 11px; background: #f8fafc; }
.report-stat .v { font-size: 17pt; font-weight: 750; line-height: 1.1; }
.report-stat .l { font-size: 7.5pt; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #64748b; }
.report-table { width: 100%; border-collapse: collapse; font-size: 8.5pt; }
.report-table th {
  text-align: left; background: #f1f5f9; border: 1px solid #e2e8f0;
  padding: 6px 8px; font-size: 7.5pt; letter-spacing: .06em; text-transform: uppercase; color: #334155;
}
.report-table td { border: 1px solid #e2e8f0; padding: 6px 8px; vertical-align: top; break-inside: avoid; }
.report-badge {
  display: inline-block; padding: 2px 7px; border-radius: 999px; color: #fff;
  font-size: 7pt; font-weight: 800; text-transform: uppercase; margin: 1px 2px 1px 0; white-space: nowrap;
}
.report-note { font-family: var(--mono); font-size: 7.5pt; color: #64748b; border-left: 2px solid #cbd5e1; padding-left: 6px; margin-top: 4px; }
.report-foot { margin-top: 26px; padding-top: 12px; border-top: 1px solid #e2e8f0; display: flex; justify-content: space-between; font-size: 8pt; color: #64748b; }

@media print {
  body { overflow: visible; background: #fff; }
  .topbar, .sidebar, .view-head, .report-controls, .toasts, .panel, .scrim { display: none !important; }
  .app { display: block; height: auto; }
  .view, .report-scroll { overflow: visible; padding: 0; max-height: none; background: #fff; }
  .report-page { width: auto; min-height: 0; box-shadow: none; margin: 0; padding: 0; }
  .report-section, .report-table tr { break-inside: avoid; }
  @page { size: A4 portrait; margin: 14mm; }
}

/* =========================================================================
   Boot / error screens
   ========================================================================= */

.boot {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: var(--bg); color: var(--text); z-index: 200; text-align: center; padding: 24px;
}
.boot .spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot .boot-card {
  max-width: 460px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow);
}

@media (max-width: 860px) {
  .app { grid-template-columns: 0 1fr; }
  .sidebar { position: fixed; top: var(--header-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 50; transform: translateX(-100%); transition: transform .18s; }
  .app[data-sidebar="expanded"] .sidebar { transform: none; }
  .brand-text { display: none; }
}
