/* AMKS Audit PWA — Styles v11.0.0
   Industrial overhaul: flat, squared, dense, text-driven.
   Dark mode, glove-friendly, high contrast. */

:root {
  --bg-primary: #111113;
  --bg-secondary: #18181b;
  --bg-card: #1e1e22;
  --bg-input: #151517;
  --text-primary: #e4e4e8;
  --text-secondary: #8e8e96;
  --text-muted: #5a5a63;
  --accent: #5b8def;
  --accent-hover: #4a7ae0;
  --pass: #2ecc71;
  --fail: #e74c3c;
  --na: #6b6b76;
  --critical: #e74c3c;
  --high: #f39c12;
  --medium: #f1c40f;
  --low: #3498db;
  --border: #27272b;
  --radius: 2px;
  --radius-sm: 1px;
  --handrails: #5b8def;
  --guarding: #f39c12;
  --roofing: #e74c3c;
}

[data-theme="light"] {
  --bg-primary: #f0f0f2;
  --bg-secondary: #fafafa;
  --bg-card: #ffffff;
  --bg-input: #eaeaed;
  --text-primary: #141417;
  --text-secondary: #4a4a52;
  --text-muted: #8a8a92;
  --border: #d0d0d6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overscroll-behavior: none;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ── Status Bar ── */
.status-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 6px 12px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.82rem; gap: 6px; min-height: 40px;
}
.area-badge {
  background: var(--bg-input); color: var(--accent);
  border: 1px solid var(--border);
  padding: 3px 8px; border-radius: var(--radius);
  font-weight: 700; font-size: 0.75rem; white-space: nowrap;
  max-width: 45%; overflow: hidden; text-overflow: ellipsis;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.stats { display: flex; gap: 10px; font-size: 0.78rem; color: var(--text-secondary); }
.stats .count { font-weight: 700; color: var(--text-primary); }

/* ── Main Container ── */
.app-container {
  padding-top: 48px; padding-bottom: 56px;
  max-width: 800px; margin: 0 auto;
}
.view { display: none; padding: 12px; }
.view.active { display: block; }

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--bg-secondary);
  border-top: 2px solid var(--border);
  display: flex;
  padding: 0 0 env(safe-area-inset-bottom, 0);
}
.nav-btn {
  display: flex; align-items: center; justify-content: center;
  flex: 1; padding: 10px 4px; min-height: 44px;
  background: none; border: none; border-top: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.nav-btn .icon { display: none; }
.nav-btn.active { color: var(--accent); border-top-color: var(--accent); }
.nav-btn:active { color: var(--text-secondary); }

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: calc(56px + env(safe-area-inset-bottom, 0));
  right: 16px;
  width: 52px; height: 52px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1.6rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 90;
}
.fab:active { opacity: 0.85; }
.fab-icon { font-weight: 300; line-height: 1; }

/* ── Cards ── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  margin-bottom: 8px;
}
.card-title { font-size: 1rem; font-weight: 700; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; min-width: 48px; padding: 10px 20px;
  border: none; border-radius: var(--radius); font-size: 0.9rem; font-weight: 600;
  cursor: pointer; -webkit-user-select: none; user-select: none;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-pass { background: var(--pass); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }
.btn-danger { background: var(--fail); color: #fff; }
.btn-sm { min-height: 40px; padding: 6px 14px; font-size: 0.85rem; }
.btn-block { width: 100%; display: flex; }
.btn-group { display: flex; gap: 8px; width: 100%; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 0.82rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 4px;
}
.form-hint {
  display: block; font-size: 0.75rem; font-weight: 400;
  color: var(--text-muted); margin-bottom: 4px; font-style: italic;
}
.form-input, .form-select, .form-textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-size: 0.95rem; font-family: inherit; -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(91,141,239,0.2);
}
.form-textarea { min-height: 90px; resize: vertical; }
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0a0b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}

/* ── Pathway Selector ── */
.pathway-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pathway-option {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 14px 10px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; min-height: 100px; text-align: center;
}
.pathway-option:active { border-color: var(--text-muted); }
.pathway-option.selected {
  border-color: var(--accent);
  background: rgba(91,141,239,0.06);
}
.pathway-option.selected.pathway-guarding {
  border-color: var(--guarding);
  background: rgba(243,156,18,0.06);
}
.pathway-option.selected.pathway-roofing {
  border-color: var(--roofing);
  background: rgba(231,76,60,0.06);
}
.pw-icon { font-size: 1.8rem; }
.pw-label { font-size: 0.9rem; font-weight: 700; line-height: 1.2; }
.pw-standard { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; }
.pw-count { font-size: 0.7rem; color: var(--text-secondary); }

/* ── Pathway Badge ── */
.pathway-badge {
  display: inline-block; padding: 2px 6px; border-radius: var(--radius);
  font-size: 0.7rem; font-weight: 700;
}
.pathway-badge-handrails { background: var(--handrails); color: #fff; }
.pathway-badge-guarding { background: var(--guarding); color: #1a1a2e; }
.pathway-badge-roofing { background: var(--roofing); color: #fff; }

/* ── Site Code Badge ── */
.site-code-badge {
  display: inline-block; padding: 2px 6px; border-radius: var(--radius);
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  background: rgba(91,141,239,0.15); color: var(--accent);
  letter-spacing: 0.03em; font-family: monospace;
}

/* ── Home ── */
.home-header { text-align: left; padding: 16px 0 8px; }
.home-header h1 { font-size: 1.2rem; font-weight: 800; letter-spacing: 0.02em; }
.home-header .subtitle { color: var(--text-secondary); font-size: 0.85rem; }

/* ── AMKS Branding ── */
.brand-logo { display: none; }

.home-admin-row {
  display: flex; gap: 6px; margin-bottom: 12px;
}

.session-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 6px;
  display: flex; justify-content: space-between;
  align-items: center; min-height: 56px;
  position: relative;
}
/* Status accent bar on left edge */
.session-card:has(.status-active) { border-left-color: var(--pass); }
.session-card:has(.status-paused) { border-left-color: var(--high); }
.session-card:has(.status-complete) { border-left-color: var(--accent); }

.session-card-body {
  flex: 1; min-width: 0; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
}
.session-card-body:active { opacity: 0.8; }
.session-info h3 { font-size: 0.9rem; }
.session-label { font-size: 0.8rem; color: var(--accent); font-style: italic; margin-top: 1px; }
.session-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 1px; }
.session-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.session-status {
  font-size: 0.7rem; padding: 2px 6px; border-radius: var(--radius); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.status-active { background: var(--pass); color: #fff; }
.status-paused { background: var(--high); color: #1a1a2e; }
.status-complete { background: var(--accent); color: #fff; }

/* Session overflow menu */
.session-menu-btn {
  width: 40px; height: 40px; min-width: 40px;
  background: none; border: none; color: var(--text-muted);
  font-size: 1.3rem; cursor: pointer; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-left: 4px;
}
.session-menu-btn:active { background: rgba(255,255,255,0.06); }

/* ═══ BOTTOM SHEET ═══ */
.bottom-sheet-overlay { align-items: flex-end; }
.bottom-sheet {
  background: var(--bg-secondary);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom, 0));
  width: 100%; max-width: 500px;
  max-height: 70vh; overflow-y: auto;
}
.sheet-handle {
  width: 32px; height: 3px; background: var(--border);
  border-radius: 1px; margin: 0 auto 12px;
}
.sheet-title { font-size: 1rem; font-weight: 700; margin-bottom: 2px; }
.sheet-subtitle { font-size: 0.82rem; color: var(--accent); font-style: italic; margin-bottom: 12px; min-height: 1em; }
.sheet-actions { display: flex; flex-direction: column; gap: 2px; }
.sheet-action {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 10px; min-height: 48px;
  background: none; border: none; border-radius: var(--radius);
  color: var(--text-primary); font-size: 0.9rem; font-weight: 500;
  cursor: pointer; text-align: left; width: 100%;
}
.sheet-action:active { background: rgba(255,255,255,0.04); }
.sheet-action .sa-icon { font-size: 1.1rem; width: 28px; text-align: center; flex-shrink: 0; }
.sheet-action .sa-text { flex: 1; }
.sheet-action .sa-hint { font-size: 0.75rem; color: var(--text-muted); flex-shrink: 0; }
.sheet-action-danger { color: var(--fail); }
.sheet-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ═══ SITE MANAGER ═══ */
.modal-header-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.modal-header-row h2 { margin-bottom: 0; }

.site-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px; margin-bottom: 6px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.site-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.site-name { font-weight: 600; }
.site-zones-count { font-size: 0.78rem; color: var(--text-muted); }
.site-actions { display: flex; gap: 4px; flex-shrink: 0; }

.add-site-form {
  display: none;
  border-top: 1px solid var(--border);
  padding-top: 10px; margin-top: 10px;
}
.add-site-form.active { display: block; }

.zone-edit-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.zone-code-input { max-width: 90px; min-height: 40px !important; }
.zone-name-input { flex: 1; min-height: 40px !important; }
.zone-remove { min-height: 40px !important; min-width: 40px !important; padding: 4px !important; }

/* ═══ FRAMEWORK MANAGER ═══ */
.modal-fw { max-width: 600px; }

.fw-help-text {
  font-size: 0.82rem; color: var(--text-muted);
  margin-bottom: 12px; line-height: 1.4;
}

.fw-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; margin-bottom: 6px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
}
.fw-card:active { border-color: var(--accent); }
.fw-card-icon { font-size: 1.4rem; flex-shrink: 0; width: 32px; text-align: center; }
.fw-card-info { flex: 1; min-width: 0; }
.fw-card-label { font-weight: 700; font-size: 0.9rem; line-height: 1.3; }
.fw-card-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 1px; }
.fw-card-actions { display: flex; gap: 4px; flex-shrink: 0; }

.fw-edit-form {
  display: none;
  border-top: 1px solid var(--border);
  padding-top: 10px; margin-top: 10px;
}
.fw-edit-form.active { display: block; }

.fw-form-grid { display: flex; gap: 10px; align-items: flex-start; }
@media (max-width: 480px) { .fw-form-grid { flex-wrap: wrap; } }

/* ── Framework Item Cards ── */
.fw-item-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px; margin-bottom: 6px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.fw-item-info { flex: 1; min-width: 0; }
.fw-item-header {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 3px; flex-wrap: wrap;
}
.fw-item-id {
  font-weight: 700; font-size: 0.78rem; color: var(--accent);
  font-family: monospace; background: rgba(91,141,239,0.08);
  padding: 1px 5px; border-radius: var(--radius);
}
.fw-item-clause { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }
.fw-item-severity {
  font-size: 0.62rem; font-weight: 700; padding: 1px 6px;
  border-radius: var(--radius); text-transform: uppercase;
}
.sev-CRITICAL { background: var(--critical); color: #fff; }
.sev-HIGH { background: var(--high); color: #1a1a2e; }
.sev-MEDIUM { background: var(--medium); color: #1a1a2e; }
.sev-LOW { background: var(--low); color: #fff; }
.fw-item-text { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.4; }

/* ═══ DEFECT CARDS ═══ */
.defect-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; margin-bottom: 6px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  min-height: 60px;
}
.defect-card:active { border-color: var(--accent); }

.defect-thumb {
  width: 48px; height: 48px; border-radius: var(--radius);
  overflow: hidden; flex-shrink: 0; background: var(--bg-input);
  display: flex; align-items: center; justify-content: center;
}
.defect-thumb img { width: 100%; height: 100%; object-fit: cover; }
.defect-thumb .no-photo { font-size: 1.3rem; opacity: 0.3; }

.defect-info { flex: 1; min-width: 0; }
.defect-header-row {
  display: flex; align-items: center; gap: 6px; margin-bottom: 1px;
}
.defect-number { font-weight: 700; font-size: 0.85rem; color: var(--accent); }
.defect-tag {
  font-size: 0.85rem; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.defect-meta { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-top: 3px; }

.equip-badge {
  font-size: 0.7rem; padding: 1px 5px; border-radius: var(--radius);
  background: var(--card-bg); border: 1px solid var(--border);
  color: var(--accent); font-family: monospace;
}

.zone-badge {
  display: inline-block; padding: 1px 6px; border-radius: var(--radius);
  font-size: 0.68rem; font-weight: 600;
  background: rgba(91,141,239,0.1); color: var(--accent);
  white-space: nowrap;
}
.subloc { font-size: 0.72rem; color: var(--text-muted); }

.risk-badge {
  display: inline-block; padding: 1px 6px; border-radius: var(--radius);
  font-size: 0.68rem; font-weight: 700; color: #fff;
}
.risk-extreme { background: var(--critical); }
.risk-high { background: var(--high); color: #1a1a2e; }
.risk-medium { background: var(--medium); color: #1a1a2e; }
.risk-low { background: var(--low); }

.defect-chevron { font-size: 1.2rem; color: var(--text-muted); flex-shrink: 0; }

/* ── Filter Bar ── */
.filter-bar { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.filter-chip {
  padding: 6px 12px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-secondary); font-size: 0.78rem; cursor: pointer;
  min-height: 36px; display: flex; align-items: center;
}
.filter-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ═══ DETAIL VIEW ═══ */
.detail-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.detail-header h2 { font-size: 1.1rem; flex: 1; }
.detail-time { font-size: 0.78rem; color: var(--text-muted); }

.detail-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  margin-bottom: 10px;
}
.section-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 10px; }

/* Photo grid */
.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 6px;
}
.photo-thumb {
  position: relative; aspect-ratio: 1; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.delete-photo {
  position: absolute; top: 3px; right: 3px; width: 24px; height: 24px;
  background: rgba(231,76,60,0.9); color: #fff; border: none;
  border-radius: var(--radius); font-size: 0.9rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.photo-capture-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-height: 90px; background: var(--bg-input);
  border: 1px dashed var(--border); border-radius: var(--radius);
  color: var(--text-muted); cursor: pointer; font-size: 0.78rem;
}
.photo-capture-btn .cam-icon { font-size: 1.6rem; }

/* Risk row */
.risk-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.risk-score-box {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-width: 56px; padding-bottom: 14px;
}
.risk-score {
  width: 44px; height: 44px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 800; color: #fff;
}
.risk-none { background: var(--bg-input); color: var(--text-muted); }
.risk-label { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; margin-top: 3px; color: var(--text-secondary); }

/* Mapped item detail */
.mapped-detail {
  background: rgba(0,0,0,0.12); border-radius: var(--radius);
  padding: 10px; margin-top: 6px;
}
.mapped-clause { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 3px; }
.mapped-text { font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; line-height: 1.4; }
.mapped-criteria {
  font-size: 0.82rem; color: var(--text-secondary); line-height: 1.4;
  border-top: 1px solid var(--border); padding-top: 6px;
}

/* ── Capture Modal ── */
.capture-preview {
  margin-bottom: 12px; border-radius: var(--radius); overflow: hidden;
  max-height: 180px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-input);
}
.capture-preview img {
  width: 100%; max-height: 180px; object-fit: cover; border-radius: var(--radius);
}
.no-photo-placeholder {
  padding: 24px; text-align: center; color: var(--text-muted); font-size: 0.85rem;
}

/* ── Summary Stats ── */
.summary-stats {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin-bottom: 12px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; text-align: center;
}
.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1; font-family: monospace; }
.stat-label {
  font-size: 0.7rem; color: var(--text-secondary);
  text-transform: uppercase; margin-top: 3px; letter-spacing: 0.03em;
}
.stat-pass .stat-value { color: var(--pass); }
.stat-fail .stat-value { color: var(--fail); }
.stat-total .stat-value { color: var(--accent); }

/* Priority list */
.priority-list { display: flex; flex-direction: column; gap: 6px; }
.prio-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--border);
}
.prio-row:last-child { border-bottom: none; }
.priority-badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius);
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
}
.priority-IMMEDIATE { background: var(--critical); color: #fff; }
.priority-NEXT_SHUTDOWN { background: var(--high); color: #1a1a2e; }
.priority-PLANNED { background: var(--accent); color: #fff; }
.priority-MONITOR { background: var(--na); color: #fff; }

/* ── Risk Matrix ── */
.matrix-wrap {
  display: flex; align-items: center; gap: 4px;
  overflow-x: auto; padding: 6px 0;
}
.matrix-ylabel {
  writing-mode: vertical-rl; text-orientation: mixed;
  font-size: 0.68rem; font-weight: 700; color: var(--text-muted);
  transform: rotate(180deg); padding: 0 3px;
}
.matrix-xlabel {
  text-align: center; font-size: 0.68rem; font-weight: 700;
  color: var(--text-muted); padding: 3px 0;
}
.matrix-grid {
  display: grid;
  grid-template-columns: 22px repeat(5, 1fr);
  gap: 2px; flex: 1;
}
.matrix-rlabel, .matrix-clabel {
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 600; color: var(--text-muted);
}
.matrix-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); font-size: 0.78rem; font-weight: 700;
  min-width: 32px; min-height: 32px;
}
.mcell-low { background: rgba(46,204,113,0.15); color: var(--pass); }
.mcell-medium { background: rgba(241,196,15,0.18); color: var(--medium); }
.mcell-high { background: rgba(243,156,18,0.22); color: var(--high); }
.mcell-extreme { background: rgba(231,76,60,0.22); color: var(--critical); }

/* Zone breakdown */
.zone-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 0; border-bottom: 1px solid var(--border);
}
.zone-row:last-child { border-bottom: none; }
.zone-count { font-weight: 700; min-width: 22px; text-align: right; font-family: monospace; }
.zone-bar { flex: 1; height: 4px; background: var(--bg-input); border-radius: 2px; overflow: hidden; }
.zone-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; }

/* ── Modal / Overlay ── */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 12px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-secondary); border-radius: var(--radius);
  padding: 20px; width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
}
.modal h2 { font-size: 1.1rem; margin-bottom: 12px; }

/* Photo Viewer */
.photo-viewer {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: #000; z-index: 300;
  display: none; align-items: center; justify-content: center;
}
.photo-viewer.active { display: flex; }
.photo-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.close-viewer {
  position: absolute; top: 12px; right: 12px;
  width: 44px; height: 44px; background: rgba(255,255,255,0.15);
  border: none; border-radius: var(--radius); color: #fff; font-size: 1.3rem; cursor: pointer;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 64px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); color: var(--text-primary);
  padding: 10px 20px; border-radius: var(--radius);
  border: 1px solid var(--border); font-size: 0.85rem; font-weight: 600;
  z-index: 500;
  opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ── Section Header ── */
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.section-header h2 { font-size: 1rem; font-weight: 700; margin: 0; }

/* ── Theme Toggle ── */
.theme-toggle {
  width: 40px; height: 40px; background: none; border: none;
  color: var(--text-secondary); font-size: 1.1rem; cursor: pointer;
  border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
}

/* ── Utility ── */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.camera-input { display: none; }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 36px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 10px; opacity: 0.5; }
.empty-state p { font-size: 0.9rem; line-height: 1.4; }


/* ═══ QUICK WINS ═══ */

/* Autocomplete Dropdown */
.ac-wrap { position: relative; }
.ac-dropdown {
  display: none;
  position: absolute; left: 0; right: 0; top: 100%;
  z-index: 250;
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 200px; overflow-y: auto;
}
.ac-item {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item:active { background: rgba(91,141,239,0.08); }
.ac-num {
  font-weight: 700; font-family: monospace;
  color: var(--accent); font-size: 0.9rem;
  white-space: nowrap;
}
.ac-desc {
  font-size: 0.82rem; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Quick Tags */
.quick-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.qtag {
  padding: 6px 12px; border-radius: var(--radius);
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 0.78rem; font-weight: 600;
  cursor: pointer;
  -webkit-user-select: none; user-select: none;
  min-height: 32px; display: inline-flex; align-items: center;
}
.qtag:active { opacity: 0.8; }
.qtag.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Repeat Button */
.btn-repeat {
  background: rgba(243,156,18,0.1);
  border: 1px solid var(--high);
  color: var(--high);
  font-size: 0.85rem;
  min-height: 44px;
}
.btn-repeat:active { background: rgba(243,156,18,0.2); }

/* ── Cloud Sync ── */
.sync-indicator {
  background: none; border: none;
  font-size: 1rem; cursor: pointer;
  padding: 3px 5px; border-radius: var(--radius);
  min-width: 32px; text-align: center;
}
.sync-indicator:active { background: rgba(255,255,255,0.06); }
.sync-syncing { animation: spin-sync 1s linear infinite; }
@keyframes spin-sync { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.sync-error { color: var(--fail); }

/* ── v9.0.0 Equipment-Centric ── */

.equip-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px; margin-bottom: 6px; cursor: pointer;
}
.equip-card:active { background: var(--bg-input); }
.equip-thumb { width: 48px; height: 48px; border-radius: var(--radius); overflow: hidden; flex-shrink: 0; background: var(--bg-secondary); display: flex; align-items: center; justify-content: center; }
.equip-thumb-empty { font-size: 20px; opacity: 0.3; }
.equip-thumb-img { width: 100%; height: 100%; object-fit: cover; }
.equip-info { flex: 1; min-width: 0; }
.equip-header-row { display: flex; align-items: center; gap: 6px; margin-bottom: 1px; }
.equip-tag { font-weight: 700; font-size: 0.95rem; color: var(--text-primary); font-family: monospace; }
.equip-review-badge { font-size: 0.65rem; background: var(--fail); color: #fff; padding: 1px 5px; border-radius: var(--radius); }
.equip-desc { font-size: 0.82rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.equip-meta { display: flex; gap: 6px; align-items: center; margin-top: 3px; font-size: 0.75rem; color: var(--text-muted); flex-wrap: wrap; }

.equip-detail-info { padding: 0 0 10px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.equip-detail-desc { font-size: 0.95rem; color: var(--text-primary); margin-bottom: 3px; }
.equip-detail-meta { display: flex; gap: 6px; align-items: center; font-size: 0.82rem; color: var(--text-muted); }

.defect-equip-ref { display: flex; gap: 6px; align-items: center; padding: 6px 10px; background: var(--bg-secondary); border-radius: var(--radius); margin-bottom: 10px; }
.equip-desc-sm { font-size: 0.82rem; color: var(--text-muted); }

/* AS 4024 Risk scoring */
.risk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.risk-result { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--bg-secondary); border-radius: var(--radius); margin-bottom: 6px; }
.risk-score { font-size: 1.8rem; font-weight: 800; min-width: 56px; text-align: center; padding: 6px 14px; border-radius: var(--radius); font-family: monospace; }
.risk-label { font-size: 0.85rem; font-weight: 600; }

.risk-low { background: #27ae6018; color: #27ae60; }
.risk-medium { background: #f39c1218; color: #f39c12; }
.risk-high { background: #e67e2218; color: #e67e22; }
.risk-vhigh { background: #e74c3c18; color: #e74c3c; }
.risk-none { background: var(--bg-secondary); color: var(--text-muted); }

.risk-badge { display: inline-block; padding: 1px 6px; border-radius: var(--radius); font-size: 0.72rem; font-weight: 700; }
.risk-badge.risk-low { background: #27ae6018; color: #27ae60; }
.risk-badge.risk-medium { background: #f39c1218; color: #f39c12; }
.risk-badge.risk-high { background: #e67e2218; color: #e67e22; }
.risk-badge.risk-vhigh { background: #e74c3c18; color: #e74c3c; }

.risk-bands { display: flex; flex-direction: column; gap: 4px; }
.risk-band { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; }

.phrase-dropdown { max-height: 180px; overflow-y: auto; }

.undo-btn { background: transparent; border: 1px solid #fff; color: #fff; padding: 3px 10px; border-radius: var(--radius); font-size: 0.78rem; cursor: pointer; margin-left: 10px; }
.undo-btn:active { background: rgba(255,255,255,0.15); }


/* ── v12.0.0 Mode Toggle ── */
.mode-toggle {
  padding: 3px 8px; border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.68rem; font-weight: 800;
  letter-spacing: 0.06em; cursor: pointer;
  text-transform: uppercase; min-width: 56px;
  text-align: center; background: none;
  color: var(--text-secondary); min-height: 28px;
}
.mode-field { border-color: var(--pass); color: var(--pass); }
.mode-review { border-color: var(--accent); color: var(--accent); }

/* ── Field Severity Buttons ── */
.field-severity-btns {
  display: flex; gap: 6px;
}
.fs-btn {
  flex: 1; min-height: 48px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text-secondary); font-size: 0.82rem; font-weight: 700;
  cursor: pointer; text-align: center;
}
.fs-btn:active { opacity: 0.8; }
.fs-ok.active { background: rgba(46,204,113,0.15); border-color: var(--pass); color: var(--pass); }
.fs-concern.active { background: rgba(243,156,18,0.15); border-color: var(--high); color: var(--high); }
.fs-defect.active { background: rgba(231,76,60,0.15); border-color: var(--fail); color: var(--fail); }

/* ── Field Severity Badges ── */
.fs-badge {
  font-size: 0.62rem; font-weight: 700; padding: 1px 6px;
  border-radius: var(--radius); text-transform: uppercase;
  letter-spacing: 0.02em;
}
.fs-badge-ok { background: rgba(46,204,113,0.15); color: var(--pass); }
.fs-badge-concern { background: rgba(243,156,18,0.15); color: var(--high); }
.fs-badge-defect { background: rgba(231,76,60,0.15); color: var(--fail); }

/* ── Field Severity Summary (equipment list) ── */
.fs-summary {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; font-weight: 700;
}
.fs-dot-defect, .fs-dot-concern {
  display: inline-flex; align-items: center; gap: 2px;
}
.fs-dot-defect::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--fail); margin-right: 1px;
}
.fs-dot-concern::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--high); margin-right: 1px;
}

/* ── Quick-Capture Button (equipment list) ── */
.equip-capture-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-secondary); color: var(--accent);
  font-size: 1.1rem; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.equip-capture-btn:active { background: var(--accent); color: #fff; }

/* ── Burst Capture Bar ── */
.burst-bar {
  position: fixed; bottom: 60px; left: 0; right: 0;
  background: var(--bg-card); border-top: 2px solid var(--accent);
  padding: 10px 16px; display: none; align-items: center; gap: 12px;
  z-index: 500; box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
  transform: translateY(100%); transition: transform 0.2s ease;
}
.burst-bar.active { display: flex; transform: translateY(0); }
.burst-bar-info { flex: 1; min-width: 0; }
.burst-bar-tag { font-weight: 700; font-size: 0.9rem; color: var(--text-primary); font-family: monospace; }
.burst-bar-count { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }
.burst-bar-capture {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  font-size: 1.5rem; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(59,130,246,0.4);
  -webkit-tap-highlight-color: transparent;
}
.burst-bar-capture:active { transform: scale(0.92); }
.burst-bar-done {
  padding: 8px 16px; border-radius: var(--radius);
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border); font-size: 0.85rem;
  cursor: pointer; flex-shrink: 0; font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.burst-bar-done:active { background: var(--bg-input); }


/* ═══════════════════════════════════════════════════════════════
   HANDRAIL MODE — Section Register & Deficiency Capture
   ═══════════════════════════════════════════════════════════════ */

/* Section cards in register list */
.section-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.section-card:active { border-color: var(--accent); }
.section-card-body { flex: 1; min-width: 0; }
.section-id { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.section-type-label { font-size: 0.8rem; color: var(--text-secondary); margin-left: 6px; }
.section-desc { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; display: flex; gap: 12px; }
.section-type-icon { font-size: 1.4rem; flex-shrink: 0; width: 36px; text-align: center; }

/* Section result badges (C / NC / NI) */
.section-result {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.hr-result-c { background: rgba(76,175,80,0.15); color: #4caf50; }
.hr-result-nc { background: rgba(244,67,54,0.15); color: #f44336; }
.hr-result-ni { background: rgba(158,158,158,0.15); color: #9e9e9e; }

/* Section type selector (button grid) */
.hr-type-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.hr-type-btn {
  flex: 1 1 auto;
  min-width: 80px;
  padding: 8px 4px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.hr-type-btn.selected {
  border-color: var(--accent);
  background: rgba(33,150,243,0.15);
}
.hr-type-btn .type-icon { display: block; font-size: 1.3rem; margin-bottom: 2px; }

/* Result selector (C / NC / NI toggle) */
.hr-result-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.hr-res-btn {
  flex: 1;
  padding: 10px 8px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.hr-res-btn.sel-c { border-color: #4caf50; background: rgba(76,175,80,0.2); color: #4caf50; }
.hr-res-btn.sel-nc { border-color: #f44336; background: rgba(244,67,54,0.2); color: #f44336; }
.hr-res-btn.sel-ni { border-color: #9e9e9e; background: rgba(158,158,158,0.2); color: #9e9e9e; }

/* Priority selector (CRITICAL / HIGH / MEDIUM / LOW) */
.hr-priority-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.hr-prio-btn {
  flex: 1;
  padding: 8px 4px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.hr-prio-btn.sel-h5 { border-color: #d32f2f; background: rgba(211,47,47,0.2); color: #d32f2f; }
.hr-prio-btn.sel-h4 { border-color: #e65100; background: rgba(230,81,0,0.2); color: #e65100; }
.hr-prio-btn.sel-h3 { border-color: #f9a825; background: rgba(249,168,37,0.2); color: #b8860b; }
.hr-prio-btn.sel-h2 { border-color: #fdd835; background: rgba(253,216,53,0.2); color: #b8860b; }
.hr-prio-btn.sel-h1 { border-color: #66bb6a; background: rgba(102,187,106,0.2); color: #66bb6a; }

/* Quick-pick chips (scrollable) */
.hr-chip-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  max-height: 120px;
  overflow-y: auto;
  padding: 4px 0;
}
.hr-chip {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.hr-chip:active, .hr-chip.selected {
  background: rgba(33,150,243,0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* Area filter chips */
.hr-area-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px 0;
}
.hr-area-chip {
  padding: 4px 10px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.hr-area-chip.active {
  background: rgba(33,150,243,0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* Quick stats bar */
.hr-quick-stats {
  display: flex;
  gap: 12px;
  padding: 8px 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border);
}
.hr-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.hr-stat .count { font-weight: 700; color: var(--text); }

/* Red Flag reference panel */
.rf-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 2000;
  overflow-y: auto;
  padding: 16px;
}
.rf-panel {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  border-radius: 12px;
  background: var(--bg);
}
.rf-card {
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  border-left: 4px solid var(--accent);
  background: var(--card);
}
.rf-trigger { font-weight: 700; color: var(--text); margin-bottom: 4px; }
.rf-detail { font-size: 0.85rem; color: var(--text-secondary); }
.rf-meaning { font-size: 0.8rem; color: var(--text-secondary); font-style: italic; margin-top: 4px; }
.rf-check { font-size: 0.8rem; color: var(--accent); margin-top: 4px; }
.rf-clause { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; opacity: 0.7; }

/* Deficiency list in section detail */
.hr-deficiency-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  margin-bottom: 6px;
  cursor: pointer;
}
.hr-deficiency-card:active { border-color: var(--accent); }
.hr-def-num { font-weight: 700; font-size: 0.85rem; color: var(--accent); min-width: 28px; }
.hr-def-body { flex: 1; min-width: 0; }
.hr-def-desc { font-size: 0.85rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hr-def-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }

/* Section detail header */
.section-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
}
.section-detail-icon { font-size: 2rem; }
.section-detail-info { flex: 1; }
.section-detail-id { font-size: 1.1rem; font-weight: 700; }
.section-detail-type { font-size: 0.85rem; color: var(--text-secondary); }

/* Clause dropdown */
.hr-clause-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

/* ═══════════════════════════════════════════════════════════════
   RISK MATRIX — 2-factor Exposure × Consequence
   ═══════════════════════════════════════════════════════════════ */

/* Exposure selector (section level) */
.rm-exposure-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.rm-exp-btn {
  flex: 1 1 auto;
  min-width: 80px;
  padding: 10px 6px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}
.rm-exp-btn.selected {
  border-color: var(--exp-color);
  background: color-mix(in srgb, var(--exp-color) 15%, transparent);
  color: var(--exp-color);
}
.rm-exp-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
}
.rm-exp-guide {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.rm-exp-btn.selected .rm-exp-guide { color: var(--exp-color); opacity: 0.7; }

/* Exposure badge (section list) */
.rm-exp-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius);
  font-size: 0.65rem;
  font-weight: 700;
  margin-left: 4px;
}

/* Consequence selector (defect level) */
.rm-consequence-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.rm-con-btn {
  flex: 1 1 auto;
  min-width: 80px;
  padding: 10px 6px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}
.rm-con-btn.selected {
  border-color: var(--con-color);
  background: color-mix(in srgb, var(--con-color) 15%, transparent);
  color: var(--con-color);
}
.rm-con-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
}
.rm-con-guide {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.rm-con-btn.selected .rm-con-guide { color: var(--con-color); opacity: 0.7; }

/* Risk result card */
.rm-risk-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}
.rm-risk-factors {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.rm-factor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.rm-factor-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}
.rm-factor-value {
  font-size: 0.9rem;
  font-weight: 700;
}
.rm-factor-x, .rm-factor-eq {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
}
.rm-risk-result {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 800;
}
.rm-risk-action, .rm-risk-timeframe {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.rm-action-label {
  font-weight: 700;
  color: var(--text-primary);
}
.rm-risk-pending {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 8px 0;
  font-style: italic;
}

/* Override selector */
.rm-override-selector {
  display: flex;
  gap: 4px;
}
.rm-ovr-btn {
  flex: 1;
  padding: 6px 2px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.rm-ovr-btn.selected {
  border-color: var(--ovr-color);
  background: color-mix(in srgb, var(--ovr-color) 20%, transparent);
  color: var(--ovr-color);
}

/* Summary risk matrix visual */
.rm-matrix-visual {
  position: relative;
  padding: 4px 0;
}
.rm-matrix-ylabel {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.rm-matrix-xlabel {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  text-align: center;
  margin-top: 4px;
}
.rm-matrix-grid {
  display: grid;
  grid-template-columns: 40px repeat(5, 1fr);
  gap: 2px;
}
.rm-matrix-corner {
  /* empty top-left */
}
.rm-matrix-clabel, .rm-matrix-rlabel {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 2px;
}
.rm-matrix-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 0.72rem;
  font-weight: 700;
  min-height: 32px;
  aspect-ratio: 1;
}


/* ── Glencore Condition Code selector ── */
.hr-condcode-selector {
  display: flex; gap: 6px;
}
.hr-cc-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 10px 4px; border-radius: 8px; border: 2px solid var(--border);
  background: var(--bg-card); cursor: pointer; transition: all 0.15s;
}
.hr-cc-btn .cc-num {
  font-size: 1.3rem; font-weight: 700; line-height: 1;
}
.hr-cc-btn .cc-desc {
  font-size: 0.7rem; color: var(--text-muted); margin-top: 2px;
}
.hr-cc-btn.cc-sel {
  border-color: var(--accent); background: var(--accent-dim);
}
.hr-cc-btn.cc-sel .cc-num { color: var(--accent); }
.cc-badge {
  display: inline-block; font-size: 0.65rem; font-weight: 700; padding: 1px 5px;
  border-radius: 3px; background: var(--bg-input); color: var(--text-secondary);
  margin-left: 4px; vertical-align: middle;
}

/* ── Finding Status selector ── */
.hr-status-selector {
  display: flex; gap: 6px;
}
.hr-sts-btn {
  flex: 1; padding: 10px 6px; border-radius: 8px; border: 2px solid var(--border);
  background: var(--bg-card); color: var(--text-primary); cursor: pointer;
  font-size: 0.82rem; font-weight: 600; transition: all 0.15s;
}
.hr-sts-btn.sts-sel {
  border-color: var(--accent); background: var(--accent-dim); color: var(--accent);
}

/* ── Ready Reference Panel ─────────────────────────────── */
.ref-panel-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); z-index: 250;
  display: none; justify-content: flex-end;
}
.ref-panel-overlay.active { display: flex; }
.ref-panel {
  background: var(--bg-secondary); width: 100%; max-width: 420px;
  height: 100%; overflow-y: auto; padding: 16px;
  animation: refSlideIn 0.2s ease-out;
  box-shadow: -4px 0 20px rgba(0,0,0,0.4);
}
@keyframes refSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.ref-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.ref-panel-header h2 { margin: 0; font-size: 1.1rem; color: var(--text); }

/* Tabs */
.ref-tabs {
  display: flex; gap: 4px; overflow-x: auto; padding-bottom: 8px;
  margin-bottom: 12px; border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
.ref-tab {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text-secondary); cursor: pointer;
  min-width: 44px; font-size: 0.7rem; flex-shrink: 0;
  transition: all 0.15s;
}
.ref-tab.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.ref-tab-icon { font-size: 1rem; line-height: 1.2; }
.ref-tab-label { font-weight: 700; }

/* Content */
.ref-type-header {
  font-size: 1.05rem; font-weight: 700; color: var(--text);
  margin-bottom: 12px; padding: 6px 0;
}
.ref-section { margin-bottom: 16px; }
.ref-section-title {
  font-size: 0.85rem; font-weight: 700; color: var(--accent);
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px;
}

/* Dimensions table */
.ref-dim-list { display: flex; flex-direction: column; gap: 2px; }
.ref-dim-row {
  display: grid; grid-template-columns: 1fr 1fr auto;
  gap: 8px; padding: 6px 8px; border-radius: 6px;
  background: var(--bg); font-size: 0.82rem; align-items: start;
}
.ref-dim-row:nth-child(odd) { background: rgba(255,255,255,0.03); }
.ref-dim-check { font-weight: 600; color: var(--text); }
.ref-dim-value { color: var(--accent); font-weight: 500; }
.ref-dim-clause {
  font-size: 0.72rem; color: var(--text-muted); white-space: nowrap;
  background: rgba(255,255,255,0.06); padding: 2px 6px; border-radius: 4px;
}

/* Look-for list */
.ref-look-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.ref-look-list li {
  padding: 6px 8px 6px 24px; font-size: 0.82rem; color: var(--text-secondary);
  position: relative; border-radius: 6px; background: var(--bg);
}
.ref-look-list li::before {
  content: '→'; position: absolute; left: 8px; top: 6px;
  color: var(--accent); font-weight: 700;
}
.ref-cusm-divider {
  font-weight: 700 !important; color: #e65100 !important;
  font-size: 0.78rem !important; padding-left: 8px !important;
  margin-top: 4px !important; background: transparent !important;
}
.ref-cusm-divider::before { content: '' !important; display: none; }
.ref-look-list li.ref-cusm { color: #e65100; }
.ref-look-list li.ref-cusm::before { color: #e65100; }

/* Clause list */
.ref-clause-list { display: flex; flex-direction: column; gap: 2px; }
.ref-clause-row {
  padding: 5px 8px; font-size: 0.78rem; color: var(--text-secondary);
  border-radius: 4px; background: var(--bg);
}
.ref-clause-row:nth-child(odd) { background: rgba(255,255,255,0.03); }

/* Reference button in toolbar */
.btn-ref {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: 6px;
  padding: 4px 8px; font-size: 0.85rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.btn-ref:active { background: var(--accent); color: #fff; }
