/* ShowerCheck — medical / clinical theme.
   Palette: white #F7F9FC bg, slate text, clinical blue #2563EB accent,
   severity chips (red/yellow/green), Inter typography, soft 12px radii. */

:root {
  --bg: #E8F0FA;            /* cool clinical blue-tinted page bg */
  --bg-deep: #DCE7F5;       /* slightly deeper blue for hover/active rows */
  --surface: #FFFFFF;
  --surface-2: #E5EDF7;     /* alt surface — bluer than slate */
  --text: #0F172A;
  --text-muted: #4D6485;    /* slate text leaning blue */
  --text-faint: #8DA3C2;    /* faint slate-blue */
  --border: #D4E1F0;        /* blue-tinted divider */
  --border-strong: #B7CCE3;
  --border-blue: #BFD9F4;   /* explicit clinical-blue trim */

  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-soft: #DBEAFE;   /* deeper blue tint for hover/highlights */
  --accent-softer: #EFF6FF; /* very pale blue for empty-state icons etc */

  --teal: #0E7490;

  --red: #DC2626;
  --red-bg: #FEE2E2;
  --red-border: #FCA5A5;

  --yellow: #D97706;
  --yellow-bg: #FEF3C7;
  --yellow-border: #FCD34D;

  --green: #059669;
  --green-bg: #D1FAE5;
  --green-border: #6EE7B7;

  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-lg: 0 8px 24px rgba(15,23,42,0.08), 0 2px 6px rgba(15,23,42,0.04);

  --r-card: 12px;
  --r-input: 8px;
  --r-chip: 6px;

  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button { font-family: inherit; cursor: pointer; }

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 2px solid var(--border-blue);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 rgba(37, 99, 235, 0.04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark { display: flex; align-items: center; }
.brand-prefix {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  padding-right: 6px;
  border-right: 1px solid var(--border);
  margin-right: 4px;
}
.brand-text {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--accent);
}
.brand-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border: 1px solid var(--border-blue);
  border-radius: var(--r-chip);
  background: var(--accent-soft);
}

.topnav {
  display: flex;
  gap: 4px;
}
.topnav a {
  padding: 8px 14px;
  border-radius: var(--r-chip);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  transition: all 0.15s ease;
}
.topnav a:hover {
  background: var(--surface-2);
  color: var(--text);
}
.topnav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.viewer-email {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ---------- Buttons ---------- */

.btn-primary {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
  padding: 8px 14px;
  border-radius: var(--r-input);
  font-weight: 500;
  font-size: 13px;
  transition: all 0.15s ease;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--r-input);
  font-weight: 500;
  font-size: 13px;
  transition: all 0.15s ease;
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-sm { padding: 6px 10px; font-size: 12px; }

.btn-danger-ghost {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red-border);
  padding: 6px 10px;
  border-radius: var(--r-input);
  font-size: 12px;
  font-weight: 500;
}

/* ---------- Layout ---------- */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 80px 0;
  font-size: 14px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

/* ---------- Toolbar (search + filter row) ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.search-input {
  flex: 1;
  max-width: 280px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Project list (chart-style table) ---------- */

.chart-table {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--r-card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.chart-table-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 100px 100px 100px 110px 110px;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s ease;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.chart-table-row:last-child { border-bottom: none; }
.chart-table-row:hover { background: var(--accent-soft); }
.chart-table-row.head {
  background: var(--surface-2);
  cursor: default;
  padding: 10px 18px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.chart-table-row.head:hover { background: var(--surface-2); }

.cell-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cell-name-title {
  font-weight: 500;
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-name-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.cell-count {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--teal);
  font-weight: 500;
}

.cell-by {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: lowercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-date {
  font-size: 12px;
  color: var(--text-muted);
}

.cell-flags {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ---------- Severity chips (medical lab-result style) ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid transparent;
  font-family: var(--font-ui);
  letter-spacing: 0.01em;
}
.chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.chip.red { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }
.chip.red::before { background: var(--red); }
.chip.yellow { background: var(--yellow-bg); color: var(--yellow); border-color: var(--yellow-border); }
.chip.yellow::before { background: var(--yellow); }
.chip.green { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.chip.green::before { background: var(--green); }
.chip.neutral {
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--border);
}
.chip.neutral::before { background: var(--text-faint); }

.chip-status-draft { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.chip-status-analyzing { background: var(--accent-soft); color: var(--accent); border-color: #BFDBFE; }
.chip-status-analyzed { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.chip-status-reviewed { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.chip-status-archived { background: var(--surface-2); color: var(--text-faint); border-color: var(--border); }

/* ---------- Empty state ---------- */

.empty {
  text-align: center;
  padding: 64px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-card);
  color: var(--text-muted);
}
.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--accent-softer);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px;
}
.empty-body {
  font-size: 13px;
  margin: 0 0 20px;
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: 100%;
  overflow: hidden;
  animation: modal-in 0.15s ease;
}
@keyframes modal-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header {
  padding: 18px 20px 4px;
}
.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.modal-body { padding: 16px 20px; }
.modal-footer {
  padding: 14px 20px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.categorize-thumb {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 10px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 320px;
  overflow: hidden;
}
.categorize-thumb img {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--r-input);
  object-fit: contain;
  display: block;
}
.categorize-filename {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  word-break: break-all;
  margin-bottom: 4px;
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 70px; }

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

.project-detail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--r-card);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.project-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.project-meta-item { display: flex; gap: 6px; }
.project-meta-item strong { color: var(--text); font-weight: 500; }

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--border-blue);
  border-radius: var(--r-card);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.readiness-banner {
  background: var(--yellow-bg);
  border: 1px solid var(--yellow-border);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 4px 0 16px;
  color: #78350F;
}
.readiness-banner-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--yellow);
  margin-bottom: 4px;
}
.readiness-banner-sub {
  font-size: 13px;
  color: #78350F;
  margin-bottom: 10px;
  opacity: 0.9;
}
.readiness-missing-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.readiness-missing-list li {
  background: #FFFFFF;
  border: 1px solid var(--yellow-border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: #78350F;
}
.readiness-missing-list li::before {
  content: "✗ ";
  color: var(--yellow);
  font-weight: 700;
}

.findings-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.findings-last-analyzed {
  font-size: 12px;
  color: var(--text-muted);
}

.good-to-go {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--green-bg, #D1FAE5);
  border: 1px solid #6EE7B7;
  border-radius: 10px;
  padding: 18px 20px;
  margin: 4px 0;
}
.good-to-go-check {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--green, #059669);
  color: #FFFFFF;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.good-to-go-text {
  display: flex;
  flex-direction: column;
}
.good-to-go-title {
  font-size: 17px;
  font-weight: 700;
  color: #065F46;
}
.good-to-go-sub {
  font-size: 13px;
  color: #047857;
  margin-top: 2px;
}
.good-to-go-timestamp {
  font-size: 12px;
  color: #047857;
  opacity: 0.75;
  margin-top: 6px;
}
.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: middle;
}
.section-title > span:first-child::before {
  content: none;
}

/* ---------- Upload zone ---------- */

.upload-zone {
  display: block;
  border: 2px dashed var(--border-blue);
  border-radius: var(--r-card);
  padding: 40px 24px;
  text-align: center;
  transition: all 0.15s ease;
  cursor: pointer;
  background: var(--accent-softer);
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-zone-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 4px;
}
.upload-zone-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.upload-zone input[type="file"] { display: none; }

/* ---------- Screenshot strip ---------- */

.screenshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.screenshot-tile {
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  overflow: hidden;
  background: var(--surface-2);
  position: relative;
  cursor: zoom-in;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.screenshot-tile:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}
.screenshot-tile:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.screenshot-tile img {
  display: block;
  width: 100%;
  height: 130px;
  object-fit: cover;
  background: var(--surface-2);
}
.screenshot-tile-meta {
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
}
.role-tag {
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-weight: 600;
}
.role-tag.role-overview {
  background: #DBEAFE;
  color: #1D4ED8;
  border-color: #BFDBFE;
}
.role-tag.role-fittings_clamps {
  background: #D1FAE5;
  color: #047857;
  border-color: #6EE7B7;
}
.role-tag.role-fittings_hinges {
  background: #CCFBF1;
  color: #0F766E;
  border-color: #5EEAD4;
}
.role-tag.role-shop_drawing {
  background: #FEE2E2;
  color: #B91C1C;
  border-color: #FCA5A5;
}
.role-tag.role-hardware_spec {
  background: #EDE9FE;
  color: #6D28D9;
  border-color: #C4B5FD;
}
.role-tag.role-none {
  background: var(--surface-2);
  color: var(--text-faint);
  border-color: var(--border);
}

.screenshot-tile-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  opacity: 0.5;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  z-index: 2;
}
.screenshot-tile-delete:hover {
  opacity: 1;
  color: var(--red);
  border-color: var(--red-border);
  background: rgba(255, 255, 255, 0.95);
}
.screenshot-tile-delete:focus-visible {
  outline: none;
  opacity: 1;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Lightbox ---------- */

.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 32px 64px 64px;
  animation: lightbox-in 0.15s ease;
}
@keyframes lightbox-in { from { opacity: 0; } to { opacity: 1; } }

.lightbox-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
}
.lightbox-img {
  max-width: 100%;
  max-height: calc(100vh - 140px);
  object-fit: contain;
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  cursor: default;
  display: block;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  color: white;
  font-size: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.lightbox-close:hover {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.3);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.lightbox-nav:hover {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.3);
}
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-prev:hover { transform: translateY(-50%) translateX(-2px); }
.lightbox-next:hover { transform: translateY(-50%) translateX(2px); }

.lightbox-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  text-align: center;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
.lightbox-counter {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.6);
}
.lightbox-meta {
  font-size: 12px;
  color: rgba(255,255,255,0.85);
}

.lightbox-role-bar {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  padding: 6px 10px 6px 12px;
  border-radius: 999px;
  pointer-events: auto;
  align-self: center;
}
.lightbox-role-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
  font-family: var(--font-mono);
}
.lightbox-role-select {
  font-family: inherit;
  font-size: 13px;
  color: white;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
  appearance: auto;
}
.lightbox-role-select:focus {
  border-color: rgba(37, 99, 235, 0.7);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
/* Options inherit dark from the OS — but force light text on dark in case of overrides */
.lightbox-role-select option {
  background: #1E293B;
  color: white;
}
.lightbox-role-status {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  font-style: italic;
  min-width: 50px;
}
.lightbox-role-status.saving { color: rgba(255,255,255,0.7); }
.lightbox-role-status.saved { color: #6EE7B7; font-style: normal; }
.lightbox-role-status.error { color: #FCA5A5; font-style: normal; }

@media (max-width: 720px) {
  .lightbox-backdrop { padding: 16px 16px 64px; }
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
}

/* ---------- Findings list (lab-result style) ---------- */

.finding-card {
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 16px 18px;
  margin-bottom: 10px;
  background: var(--surface);
  display: flex;
  gap: 14px;
}
.finding-card.fatal { border-left: 4px solid #7F1D1D; background: linear-gradient(90deg, #FEF2F2 0%, var(--surface) 25%); }
.finding-card.red { border-left: 3px solid var(--red); }
.finding-card.yellow { border-left: 3px solid var(--yellow); }
.finding-card.info { border-left: 3px solid var(--green); }

/* High-priority warning — finding messages that lead with ⚠️. Used for
   non-fatal rules whose miss has serious downstream consequences (e.g.,
   transom flush-mount reminder). Visually distinct from regular yellow
   so the user can't scroll past it. */
.finding-card.high-priority {
  border-left-width: 6px;
  border-top: 1px solid var(--yellow-border);
  border-right: 1px solid var(--yellow-border);
  border-bottom: 1px solid var(--yellow-border);
  background: linear-gradient(90deg, #FFFBEB 0%, var(--yellow-bg) 50%, var(--surface) 100%);
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.18);
  animation: hp-attn 1.6s ease-out 1;
}
.finding-card.high-priority .finding-title {
  color: #92400E;
  font-weight: 700;
}
.finding-card.high-priority .finding-message {
  color: #78350F;
  font-weight: 500;
  font-size: 14px;
}
.finding-card.high-priority .chip {
  background: var(--yellow);
  color: #FFFFFF;
  border-color: var(--yellow);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.finding-card.high-priority .chip::before { background: #FFFFFF; }
@keyframes hp-attn {
  0%   { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.55); }
  70%  { box-shadow: 0 0 0 12px rgba(217, 119, 6, 0); }
  100% { box-shadow: 0 2px 8px rgba(217, 119, 6, 0.18); }
}

.finding-body { flex: 1; min-width: 0; }
.finding-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
}
.finding-message {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 8px;
  line-height: 1.5;
}
.finding-message a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.finding-message a:hover {
  color: var(--accent-hover);
}
.finding-evidence {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-chip);
  padding: 8px 10px;
  margin-top: 8px;
}

/* ---------- Login splash ---------- */

.login-splash {
  max-width: 420px;
  margin: 80px auto 0;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: var(--r-card);
  padding: 40px 32px;
  box-shadow: var(--shadow);
}
.login-splash-title {
  font-size: 22px;
  font-weight: 600;
  margin: 12px 0 6px;
  letter-spacing: -0.01em;
}
.login-splash-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 24px;
  line-height: 1.6;
}
.login-splash .btn-primary {
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
}

/* ---------- Helpers ---------- */

.row-actions { display: flex; gap: 6px; }
.flex-spacer { flex: 1; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }

@media (max-width: 720px) {
  /* Compact topbar — keep nav visible, drop the prefix tag and email */
  .topbar { padding: 0 14px; height: auto; min-height: 56px; flex-wrap: wrap; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .brand { gap: 6px; }
  .brand-prefix { display: none; }
  .brand-tag { display: none; }
  .brand-text { font-size: 15px; }
  .topnav { display: flex; order: 3; width: 100%; gap: 2px; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }
  .topnav a { flex: 1; text-align: center; padding: 8px 10px; font-size: 13px; }
  .viewer-email { display: none; }
  .topbar-right { gap: 6px; }
  .btn-sm { padding: 6px 10px; font-size: 12px; }

  /* Layout */
  main#view, .container, .main { padding-left: 14px !important; padding-right: 14px !important; }
  body { font-size: 14px; }

  /* Page header — stack actions */
  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-actions { width: 100%; }
  .page-actions .btn-primary { width: 100%; }

  /* Project list rows + chart rows */
  .chart-table-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }
  .chart-table-row .cell-status,
  .chart-table-row .cell-count,
  .chart-table-row .cell-date,
  .chart-table-row .cell-by { display: none; }

  /* Rule rows */
  .rule-row { grid-template-columns: 1fr; padding: 14px; }
  .rule-row .rule-id { width: fit-content; }
  .rule-actions { justify-content: stretch; }
  .rule-actions > * { flex: 1; min-width: 0; }
  .rule-desc { font-size: 13px; }

  /* Modal — full-screen on mobile */
  .modal-backdrop { padding: 0 !important; }
  .modal { width: 100%; max-width: 100% !important; max-height: 100vh; border-radius: 0; min-height: 100vh; }
  .modal-body { padding: 16px !important; }
  .row { flex-direction: column; }
  .row > .field { min-width: 0; }
  .modal-footer-row { flex-direction: column-reverse; gap: 8px; }
  .modal-footer-row > * { width: 100%; }

  /* Forms */
  .input, input[type="text"], textarea, select { font-size: 16px; }  /* prevents iOS zoom-on-focus */

  /* Findings */
  .finding-card { flex-direction: column; gap: 10px; }
}

/* ---------- Rules library ---------- */

.chip.fatal {
  background: #7F1D1D;
  color: #FFFFFF;
  border-color: #7F1D1D;
}
.chip.fatal::before { background: #FFFFFF; }

.page-actions { display: flex; align-items: center; gap: 10px; }

.rules-list { display: flex; flex-direction: column; gap: 10px; }

.rule-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 16px;
  align-items: start;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.rule-row:hover { border-color: var(--border-strong); }
.rule-row.inactive { opacity: 0.55; }

.rule-id {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border-blue);
  border-radius: 6px;
  padding: 6px 10px;
  text-align: center;
  letter-spacing: 0.02em;
  height: fit-content;
}

.rule-title { font-weight: 600; font-size: 15px; color: var(--text); margin-bottom: 6px; }
.rule-desc { color: var(--text-muted); font-size: 13.5px; line-height: 1.5; }
.rule-meta { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.rule-applies {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: var(--r-chip);
}
.rule-disabled {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}
.rule-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.btn-tertiary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 8px 12px;
  border-radius: var(--r-input);
  font-family: var(--font-ui);
  font-size: 13px;
  cursor: pointer;
}
.btn-tertiary:hover { color: var(--text); background: var(--surface-2); }

.btn-danger {
  background: var(--surface);
  color: var(--red);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--r-input);
  font-family: var(--font-ui);
  font-size: 13px;
  cursor: pointer;
}
.btn-danger:hover { background: var(--red-bg); border-color: var(--red-border); }

/* Rule editor modal form */
.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}
.field-hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.field-check { display: flex; align-items: center; gap: 8px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }
.modal-footer-row { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 720px) {
  .rule-row { grid-template-columns: 1fr; }
  .rule-actions { justify-content: flex-end; }
}
