/* ==========================================================
   SiteVisor — Stylesheet  (Teal + Gold)
   ========================================================== */

:root {
  --navy-900: #093444;
  --navy-800: #0f4c5c;
  --navy-700: #0e7490;
  --navy-600: #155e75;
  --navy-400: #67b5c8;
  --navy-200: #bde8f1;
  --navy-50:  #f0f9f7;

  --teal-light: #d8eee9;

  --gold:    #C9A961;
  --gold-lt: #E3C98A;
  --gold-dk: #9E832F;

  --bg:        #eef6f4;
  --surface:   #FFFFFF;
  --border:    #E3E7EF;
  --text:      #1A2744;
  --text-muted:#5C6F93;
  --text-light:#8A98B3;
  --success:   #10B981;
  --warning:   #F59E0B;
  --danger:    #EF4444;
  --info:      #3B82F6;

  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 2px 8px rgba(9,52,68,.08);
  --shadow-lg: 0 8px 24px rgba(9,52,68,.13);

  --nav-h: 58px;

  --font: 'Rubik', 'Segoe UI', 'Assistant', Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}
input, select, textarea, button {
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 8px;
}
input[type="checkbox"], input[type="radio"], input[type="file"] {
  -webkit-appearance: auto; appearance: auto; border-radius: 0;
}
input[type="checkbox"], input[type="radio"] {
  width: 18px; height: 18px; cursor: pointer; accent-color: var(--navy-800);
}
@media (min-width: 769px) {
  input, select, textarea, button { font-size: 14px; }
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }
a { color: var(--navy-700); text-decoration: none; }
a:hover { color: var(--gold-dk); }

.screen { display: none; }

/* ===== LOGIN ===== */
#screen-login.active {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at top, rgba(201,169,97,.08), transparent 50%),
    linear-gradient(135deg, var(--navy-900) 0%, var(--navy-800) 100%);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  border-top: 3px solid var(--gold);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo h1 { font-size: 22px; color: var(--navy-800); font-weight: 600; }
.login-logo .tag { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.login-card h2 { font-size: 16px; margin-bottom: 20px; font-weight: 500; text-align: center; }
.login-card .hint { margin-top: 16px; text-align: center; font-size: 12px; color: var(--text-light); }

/* ===== APP LAYOUT ===== */
#screen-app.active {
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ── Top Header ── */
.sv-header {
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
  padding: 12px 24px 46px;
  position: relative;
  flex-shrink: 0;
  -webkit-print-color-adjust: exact;
  box-shadow: 0 4px 20px rgba(201,169,97,0.18);
}
.sv-header::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--gold), var(--gold-lt));
}
.sv-header-inner {
  display: flex; align-items: center; gap: 12px; max-width: 1280px; margin: 0 auto;
}
.sv-logo-wrap {
  width: 40px; height: 40px; border-radius: 10px; overflow: hidden;
  flex-shrink: 0; background: var(--gold);
  display: flex; align-items: center; justify-content: center;
}
.sv-logo-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; }
#sv-logo-placeholder { font-size: 13px; font-weight: 800; color: var(--navy-900); line-height: 1; }
.sv-brand-block { flex-shrink: 0; text-align: right; line-height: 1.25; }
.sv-brand-sub { font-size: 10.5px; color: rgba(255,255,255,0.65); }
.sv-title-block { flex: 1; display: flex; align-items: center; justify-content: flex-end; }
.sv-app-logo-full {
  height: 28px; width: 157px; flex-shrink: 0;
  background: url('../assets/sitevisor-logo-header.png') center / contain no-repeat;
  filter:
    brightness(1.1)
    drop-shadow(1px  0   0 rgba(255,255,255,0.9))
    drop-shadow(-1px 0   0 rgba(255,255,255,0.9))
    drop-shadow(0    1px 0 rgba(255,255,255,0.9))
    drop-shadow(0   -1px 0 rgba(255,255,255,0.9))
    drop-shadow(0 0 8px  rgba(201,169,97,0.75))
    drop-shadow(0 0 18px rgba(201,169,97,0.40));
}
.sv-header-right {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.sv-header-btn {
  background: rgba(255,255,255,.12); color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  padding: 6px 13px; border-radius: var(--radius);
  font-size: 12px; font-weight: 500; cursor: pointer;
  font-family: inherit; text-decoration: none;
  transition: background .15s;
}
.sv-header-btn:hover { background: rgba(255,255,255,.22); color: #fff; }

/* ── Floating Nav ── */
.sv-nav-wrap {
  position: relative; z-index: 20;
  padding: 0 24px; margin-top: -28px; flex-shrink: 0;
}
.sv-nav {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(9,52,68,.18), 0 2px 8px rgba(0,0,0,.07);
  display: flex; align-items: center; padding: 5px 7px; gap: 2px;
  overflow-x: auto; max-width: 1280px; margin: 0 auto;
}
.sv-nav button {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 15px; border-radius: 10px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  white-space: nowrap; flex-shrink: 0;
  transition: background .15s, color .15s;
  border: none; background: none; cursor: pointer; font-family: inherit;
}
.sv-nav button:hover { background: var(--navy-50); color: var(--navy-800); }
.sv-nav button.active {
  background: var(--navy-700); color: #fff;
  font-weight: 600;
  box-shadow: 0 3px 12px rgba(14,116,144,0.32);
}
.sv-nav .nav-icon { display: flex; align-items: center; flex-shrink: 0; }
.sv-nav .nav-icon svg { display: block; }
.sv-nav-divider { width: 1px; height: 22px; background: var(--border); margin: 0 3px; flex-shrink: 0; }
.nav-privacy-link {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: 10px;
  font-size: 12px; color: var(--muted); text-decoration: none;
  white-space: nowrap; flex-shrink: 0;
  transition: color 0.15s;
}
.nav-privacy-link:hover { color: var(--gold); }
@media (max-width: 768px) { .nav-privacy-link { font-size: 11px; padding: 6px 8px; } }

/* ctx pill (project indicator) */
.ctx-pill {
  background: rgba(255,255,255,.15); color: #fff;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
}
.ctx-pill .num { color: var(--gold-lt); font-weight: 700; margin-left: 4px; }

.main {
  flex: 1; padding: 20px 24px;
  overflow-y: auto; max-width: 1280px; width: 100%; margin: 0 auto;
  box-sizing: border-box;
}

/* ===== Mobile ===== */
@media (max-width: 600px) {
  .sv-brand-block { display: none; }
  .sv-app-logo-full { width: 120px; height: 22px; }
}
@media (max-width: 768px) {
  .sv-header { padding: 10px 14px 42px; }
  .sv-nav-wrap { padding: 0 10px; }
  .sv-nav button { padding: 7px 11px; font-size: 12px; }
  .sv-nav button span:not(.nav-icon) { display: none; }
  .main { padding: 12px 14px; }
}

/* ===== Form controls ===== */
.input, .select, .textarea {
  display: block; width: 100%;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,169,97,.12);
}
.textarea { min-height: 80px; resize: vertical; font-family: inherit; }
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-weight: 500; font-size: 13px;
  color: var(--text);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  transition: background .15s, transform .05s;
  white-space: nowrap;
  min-height: 38px;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-primary:hover { background: var(--navy-600); }
.btn-gold { background: var(--gold); color: var(--navy-900); }
.btn-gold:hover { background: var(--gold-lt); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--navy-50); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 12px; min-height: 32px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Tables ===== */
.table {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table th, .table td {
  padding: 11px 14px;
  text-align: start;
  border-bottom: 1px solid var(--teal-light);
  font-size: 13px;
}
.table th {
  background: var(--navy-800);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.table tbody tr:nth-child(even) { background: var(--teal-light); }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: #c3e8e0 !important; cursor: pointer; }
.table tbody tr:last-child td { border-bottom: none; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  transition: transform .18s, box-shadow .18s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.card-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap; gap: 10px;
}
.card h3 { font-size: 16px; font-weight: 600; }

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: -8px -8px 24px -4px rgba(201,169,97,0.1), var(--shadow);
  border-top: 3px solid rgba(201,169,97,0.45);
  transition: transform .18s, box-shadow .18s;
  position: relative; overflow: hidden;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: -8px -8px 24px -4px rgba(201,169,97,0.15), var(--shadow-lg);
}
.stat-card .label { font-size: 12px; color: var(--text-muted); }
.stat-card .value { font-size: 26px; font-weight: 700; color: var(--navy-800); margin-top: 4px; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--navy-50);
  color: var(--navy-700);
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,26,46,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 600px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
}
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-head .close { font-size: 22px; line-height: 1; color: var(--text-muted); padding: 4px 10px; border-radius: 6px; }
.modal-head .close:hover { background: var(--navy-50); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { max-height: 92dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}

/* ===== Empty / placeholder ===== */
.empty {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted);
}
.empty .emoji { font-size: 36px; margin-bottom: 8px; }
.empty .hint { font-size: 12px; margin-top: 6px; color: var(--text-light); }

.muted { color: var(--text-muted); }
.danger { color: var(--danger); }
.success { color: var(--success); }

/* ===== Severity / status pills ===== */
.sev-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  color: #fff;
}

/* ===== Contractor view (token-gated, mobile-first) ===== */
body.contractor-mode .sidebar,
body.contractor-mode .app-header,
body.contractor-mode #screen-app,
body.contractor-mode #screen-login { display: none !important; }

#screen-contractor { display: none; min-height: 100vh; flex-direction: column; }
#screen-contractor.active { display: flex; }

.cv-header {
  background: var(--navy-800); color: #fff;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.cv-brand { font-weight: 700; font-size: 16px; }
.cv-meta { font-size: 13px; margin-top: 4px; opacity: .92; }
.cv-meta .muted { color: var(--navy-200); }

.cv-main { flex: 1; padding: 14px; max-width: 760px; margin: 0 auto; width: 100%; }
.cv-foot { padding: 14px; text-align: center; font-size: 11px; }

.cv-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.cv-pill {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: #fff;
}

.cv-cards { display: flex; flex-direction: column; gap: 10px; }
.cv-card {
  display: flex; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  cursor: pointer; transition: box-shadow .15s, transform .15s;
}
.cv-card:active { transform: scale(.99); }
.cv-card:hover { box-shadow: var(--shadow-lg); }
.cv-thumb {
  flex: 0 0 90px; height: 90px;
  background-size: cover; background-position: center;
  background-color: var(--navy-50);
}
.cv-thumb-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: var(--text-light);
}
.cv-card-body { flex: 1; padding: 10px 12px; min-width: 0; }
.cv-card-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.cv-sev {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; color: #fff;
}
.cv-status { font-size: 12px; font-weight: 600; }
.cv-title { font-size: 14px; line-height: 1.35; }
.cv-small { font-size: 11px; }

/* Defect modal (contractor) */
.cv-modal h4 { margin: 14px 0 6px; font-size: 13px; }
.cv-desc { padding: 10px; background: var(--navy-50); border-radius: var(--radius); margin: 10px 0; font-size: 13px; }
.cv-photos { display: flex; flex-wrap: wrap; gap: 6px; }
.cv-photo {
  position: relative;
  width: 110px; height: 110px;
  border-radius: 6px; overflow: hidden;
  border: 1px solid var(--border);
}
.cv-photo img { width: 100%; height: 100%; object-fit: cover; }
.cv-tag {
  position: absolute; bottom: 4px; right: 4px;
  background: var(--gold); color: #fff;
  padding: 1px 6px; border-radius: 4px;
  font-size: 10px; font-weight: 600;
}
.cv-tag-grey { background: var(--navy-400); }

.cv-actions { margin: 12px 0; }
.cv-status-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.cv-status-btn { flex: 1 1 auto; min-width: 180px; padding: 10px 12px; }
.cv-locked {
  padding: 10px; background: var(--navy-50); border-radius: var(--radius);
  text-align: center;
}

.cv-comments { max-height: 220px; overflow-y: auto; }
.cv-comment {
  padding: 8px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.cv-comment-mine { background: #fef9ed; border-radius: 6px; border-bottom: none; margin-bottom: 4px; }
.cv-comment-row { display: flex; gap: 6px; margin-top: 8px; }
.cv-comment-row .input { flex: 1; }

.cv-error {
  max-width: 480px; margin: 80px auto; padding: 30px;
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); text-align: center;
}
.cv-error .emoji { font-size: 48px; margin-bottom: 12px; }
.cv-error h2 { margin-bottom: 10px; color: var(--danger); }

@media (max-width: 480px) {
  .cv-thumb { flex: 0 0 70px; height: 70px; }
  .cv-status-btn { min-width: 100%; }
  .cv-photo { width: 90px; height: 90px; }
}

/* ============================================================
   Timeline (audit log) — used in DefectDetail + ContractorView
   ============================================================ */
.timeline {
  position: relative;
  padding: 4px 4px 4px 0;
  margin: 4px 0 8px 0;
}
.tl-row {
  position: relative;
  display: flex;
  gap: 10px;
  padding: 6px 0;
  align-items: flex-start;
}
.tl-row:last-child .tl-line { display: none; }
.tl-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  position: relative;
  z-index: 1;
}
.tl-line {
  position: absolute;
  top: 32px;
  right: 13px;
  width: 2px;
  height: calc(100% - 22px);
  background: #e5e7eb;
}
.tl-body {
  flex: 1;
  padding-top: 2px;
  min-width: 0;
}
.tl-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}
.tl-label {
  font-weight: 600;
  font-size: 13px;
  color: #1a2744;
}
.tl-meta {
  font-size: 11px;
  color: #64748b;
}
.tl-detail {
  font-size: 12px;
  color: #475569;
  margin-top: 2px;
  word-wrap: break-word;
}
.timeline-compact .tl-row { padding: 4px 0; }
.timeline-compact .tl-dot { width: 22px; height: 22px; font-size: 11px; }
.timeline-compact .tl-line { right: 10px; top: 26px; }

/* ============================================================
   Image Annotator (Phase 2)
   ============================================================ */
.ann-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.95);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.ann-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #1a2744;
  border-bottom: 1px solid #2a3a5e;
  flex-wrap: wrap;
}
.ann-bar-bot {
  border-bottom: none;
  border-top: 1px solid #2a3a5e;
}
.ann-tools {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.ann-colors {
  display: flex;
  gap: 6px;
  margin-right: auto;
}
.ann-color {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
  padding: 0;
}
.ann-color.active {
  border-color: #c9a961;
  box-shadow: 0 0 0 2px #1a2744, 0 0 0 4px #c9a961;
}
.ann-btn {
  background: #2a3a5e;
  color: #fff;
  border: 1px solid #3b4a6e;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.ann-btn:hover { background: #3b4a6e; }
.ann-btn.active, .ann-tool.active {
  background: #c9a961;
  color: #1a2744;
  border-color: #c9a961;
  font-weight: 700;
}
.ann-btn-cancel { background: #475569; }
.ann-btn-save {
  background: #10b981;
  border-color: #10b981;
}
.ann-btn-save:hover { background: #059669; }
.ann-spacer { flex: 1; }
.ann-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background:
    linear-gradient(45deg, #1e293b 25%, transparent 25%),
    linear-gradient(-45deg, #1e293b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1e293b 75%),
    linear-gradient(-45deg, transparent 75%, #1e293b 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: #0f172a;
}
.ann-canvas {
  background: #fff;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  cursor: crosshair;
  touch-action: none;
  max-width: 100%;
  max-height: 100%;
}

@media (max-width: 600px) {
  .ann-bar { padding: 8px; gap: 6px; }
  .ann-btn { padding: 5px 9px; font-size: 12px; }
  .ann-color { width: 24px; height: 24px; }
}

/* ============================================================
   PDF Preview Overlay (v0.9.5)
   ============================================================ */
.pdf-preview-overlay {
  position: fixed;
  inset: 0;
  background: #0f172a;
  z-index: 9990;
  display: flex;
  flex-direction: column;
}
.pdf-preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #1a2744;
  color: #fff;
  border-bottom: 2px solid #c9a961;
  flex-wrap: wrap;
}
.pdf-preview-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pdf-preview-ver {
  background: #c9a961;
  color: #1a2744;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
}
.pdf-preview-actions {
  display: flex;
  gap: 6px;
}
.pdf-preview-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}
@media (max-width: 600px) {
  .pdf-preview-bar { padding: 8px; }
  .pdf-preview-title { font-size: 11px; }
}

/* =====================================================
   STITCH DESIGN SYSTEM — v0.36
   ===================================================== */

/* Material Symbols base */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  display: inline-block; line-height: 1;
  text-transform: none; letter-spacing: normal;
  word-wrap: normal; white-space: nowrap; direction: ltr;
  font-size: 20px;
}

/* === App layout: switch to block (fixed header) === */
#screen-app.active { display: block !important; }

/* === Header: now fixed at top === */
.sv-header {
  position: fixed !important;
  top: 0; left: 0; right: 0; z-index: 50;
  height: 64px !important;
  padding: 0 20px !important;
  display: flex !important;
  align-items: center;
  border-bottom: 4px solid var(--gold) !important;
  box-shadow: 0 2px 16px rgba(9,52,68,.2);
}
.sv-header::after { display: none !important; }
.sv-header-inner { width: 100%; max-width: 100%; }
@media (max-width: 768px) {
  .sv-header { padding: 0 12px !important; }
}

/* Hide old floating nav */
.sv-nav-wrap { display: none !important; }

/* === Stitch Sidebar === */
.stitch-sidebar {
  display: none;
  position: fixed;
  right: 0; top: 64px;
  width: 280px;
  height: calc(100vh - 64px);
  background: #eeeeef;
  border-left: 1px solid #c1c7cc;
  z-index: 40;
  flex-direction: column;
  overflow-y: auto;
}
@media (min-width: 769px) {
  .stitch-sidebar { display: flex; }
}
.stitch-sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex; flex-direction: column; gap: 1px;
}
.stitch-sidebar-nav button {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  width: 100%;
  border-radius: 9999px 0 0 9999px;
  font-size: 13.5px; font-weight: 500;
  color: #41484b;
  text-align: right;
  transition: background .15s, color .15s;
  font-family: inherit;
}
.stitch-sidebar-nav button:hover:not(.active) {
  background: rgba(9,52,68,.06);
  color: #093444;
}
.stitch-sidebar-nav button.active {
  background: #c2e8fd;
  color: #001f2a;
  font-weight: 600;
}
.stitch-nav-divider {
  height: 1px; background: #c1c7cc;
  margin: 6px 12px;
}
.stitch-sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid #c1c7cc;
  font-size: 11px;
}
.stitch-sidebar-footer a {
  color: #72787c;
  display: flex; align-items: center; gap: 4px;
  text-decoration: none;
}
.stitch-sidebar-footer a:hover { color: var(--gold); }

/* === Stitch Bottom Nav (mobile only) === */
.stitch-bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 72px;
  background: #f9f9fa;
  border-top: 1px solid #c1c7cc;
  z-index: 50;
  flex-direction: row-reverse;
  justify-content: space-around;
  align-items: center;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 769px) {
  .stitch-bottom-nav { display: none; }
}
.stitch-bottom-nav button {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; min-width: 52px; padding: 6px 8px;
  font-size: 10px; font-weight: 500;
  color: #72787c;
  border-radius: 14px;
  transition: all .15s;
  font-family: inherit;
}
.stitch-bottom-nav button.active {
  color: #093444;
  background: rgba(194,232,253,.7);
}
.stitch-bottom-nav button .material-symbols-outlined { font-size: 22px; }

/* === Main content area === */
.stitch-main {
  padding-top: 80px !important;
  padding-bottom: 90px !important;
  min-height: 100vh;
}
@media (min-width: 769px) {
  .stitch-main {
    width: calc(100% - 280px) !important;
    margin-right: 280px !important;
    padding-bottom: 28px !important;
  }
}
@media (max-width: 768px) {
  .stitch-main { padding: 72px 12px 90px !important; }
}

/* === Dashboard stat cards === */
.stitch-dash-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 640px) {
  .stitch-dash-stats { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}
.stitch-stat {
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(9,52,68,.07);
  border-top: 3px solid var(--border);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: default;
}
.stitch-stat:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(9,52,68,.15);
}
.stitch-stat .stitch-stat-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.stitch-stat .stitch-stat-icon .material-symbols-outlined { font-size: 20px; }
.stitch-stat .stitch-val {
  font-size: 28px; font-weight: 700; color: var(--navy-800); line-height: 1;
}
.stitch-stat .stitch-lbl {
  font-size: 11px; color: var(--text-muted); font-weight: 500; margin-top: 4px;
}
.stitch-stat-blue  { border-top-color: var(--navy-900); }
.stitch-stat-blue  .stitch-stat-icon { background: rgba(9,52,68,.1); color: var(--navy-900); }
.stitch-stat-green { border-top-color: var(--navy-900); }
.stitch-stat-green .stitch-stat-icon { background: rgba(9,52,68,.1); color: var(--navy-900); }
.stitch-stat-amber { border-top-color: var(--gold); }
.stitch-stat-amber .stitch-stat-icon { background: rgba(201,169,97,.15); color: var(--gold-dk); }
.stitch-stat-red   { border-top-color: var(--navy-900); }
.stitch-stat-red   .stitch-stat-icon { background: rgba(9,52,68,.1); color: var(--navy-900); }

.stitch-dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 900px) {
  .stitch-dash-grid { grid-template-columns: 1fr 300px; }
}

/* === Defect cards === */
.stitch-defect-list { margin-top: 8px; }
.stitch-defect-card {
  background: #fff;
  border-radius: 12px;
  padding: 13px 16px;
  margin-bottom: 10px;
  border-right: 4px solid var(--border);
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(9,52,68,.07);
  transition: transform .12s, box-shadow .12s;
  display: flex; align-items: flex-start; gap: 10px;
}
.stitch-defect-card:hover {
  transform: translateX(-2px);
  box-shadow: 0 4px 14px rgba(9,52,68,.12);
}
.stitch-defect-check { padding-top: 2px; flex-shrink: 0; }
.stitch-defect-body { flex: 1; min-width: 0; }
.stitch-defect-critical { border-right-color: #ef4444; }
.stitch-defect-major    { border-right-color: #f97316; }
.stitch-defect-minor    { border-right-color: #eab308; }
.stitch-defect-note     { border-right-color: #22c55e; }
.stitch-defect-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 3px;
}
.stitch-defect-title { font-weight: 600; font-size: 14px; color: var(--text); line-height: 1.3; }
.stitch-defect-desc  { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }
.stitch-defect-meta  { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.stitch-chip-filter {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.stitch-chip {
  flex-shrink: 0; padding: 5px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: #eeeeef; color: #41484b;
  border: none; cursor: pointer; transition: all .15s; font-family: inherit;
}
.stitch-chip.active { background: #093444; color: #fff; }

/* === Dark mode === */
html.dark {
  --bg: #0d1117;
  --surface: #161b22;
  --border: rgba(255,255,255,.1);
  --text: #f9f9fa;
  --text-muted: #a6cce0;
  --text-light: #789db0;
}
html.dark body { background: var(--bg); color: var(--text); }
html.dark .sv-header {
  background: linear-gradient(135deg, #061d29 0%, #0a3646 100%) !important;
}
html.dark .stitch-sidebar {
  background: #161b22;
  border-left-color: rgba(255,255,255,.07);
}
html.dark .stitch-sidebar-nav button { color: #a6cce0; }
html.dark .stitch-sidebar-nav button:hover:not(.active) {
  background: rgba(255,255,255,.05); color: #c2e8fd;
}
html.dark .stitch-sidebar-nav button.active {
  background: rgba(194,232,253,.1); color: #c2e8fd;
}
html.dark .stitch-nav-divider { background: rgba(255,255,255,.07); }
html.dark .stitch-sidebar-footer { border-top-color: rgba(255,255,255,.07); }
html.dark .stitch-sidebar-footer a { color: #72787c; }
html.dark .stitch-bottom-nav {
  background: #0d1117;
  border-top-color: rgba(255,255,255,.07);
}
html.dark .stitch-bottom-nav button { color: #72787c; }
html.dark .stitch-bottom-nav button.active {
  color: #c2e8fd; background: rgba(194,232,253,.1);
}
html.dark .stitch-stat { background: #161b22; }
html.dark .stitch-stat .stitch-val { color: #f9f9fa; }
html.dark .card { background: #161b22; border-color: rgba(255,255,255,.07); }
html.dark .stat-card { background: #161b22; }
html.dark .stat-card .label { color: #a6cce0; }
html.dark .stat-card .value { color: #f9f9fa; }
html.dark .table { color: #f9f9fa; }
html.dark .table th { background: #1a2027; color: #a6cce0; border-color: rgba(255,255,255,.05); }
html.dark .table td { border-color: rgba(255,255,255,.05); }
html.dark .table tr:hover { background: rgba(255,255,255,.03); }
html.dark .input, html.dark .select {
  background: #1a2027; border-color: rgba(255,255,255,.15); color: var(--text);
}
html.dark .btn-secondary {
  background: #1a2027; border-color: rgba(255,255,255,.2); color: var(--text);
}
html.dark .modal-card { background: #161b22; border: 1px solid rgba(255,255,255,.1); }
html.dark .stitch-defect-card { background: #161b22; }
html.dark .stitch-defect-title { color: #f9f9fa; }
html.dark .stitch-chip { background: #1a2027; color: #a6cce0; }
html.dark .stitch-chip.active { background: #0f3040; color: #c2e8fd; }
html.dark .login-card { background: #161b22; }
html.dark h3, html.dark h4 { color: #e2e8f0; }
html.dark .muted { color: #a6cce0 !important; }
