/* ============================================================
   GLOBAL BASE STYLES (unchanged from your original)
   ============================================================ */
html, body { scroll-behavior: smooth; }
:target { scroll-margin-top: 60px; }

html { -webkit-text-size-adjust: 100%; }

body {
  background-color: #ffffff;
  color: #000000;
  font-family: "Segoe UI", "Helvetica Neue", Roboto, Arial, sans-serif;
  line-height: 1.65;
  margin: 2rem auto;
  padding: 0 1.5rem;
  max-width: 1100px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark {
  background-color: #121212;
  color: #f0f0f0;
}

@media print {

  /* Never print the toolbar */
  #navigator-controls {
    display: none !important;
  }

  /* Normal print: full document */
  body:not(.sop-print-mode) #sop-canvas {
    display: none !important;
  }

  /* SOP print mode: hide everything except SOP canvas */
  body.sop-print-mode > *:not(#sop-canvas) {
    display: none !important;
  }

  /* Show only SOP canvas */
  body.sop-print-mode #sop-canvas {
    display: block !important;
    position: static !important;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: #fff !important;
    box-shadow: none !important;
  }

  /* PAGE BREAK FIX */
  body.sop-print-mode #sop-canvas > div:nth-child(n+3) {
    page-break-before: always;
    break-before: page;
  }
}

/* Typography */
h1, h2, h3, h4, h5 {
  color: #005f73;
  font-weight: 600;
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

body.dark h1,
body.dark h2,
body.dark h3,
body.dark h4,
body.dark h5 {
  color: #7de0d6;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  border-bottom: 2px solid #4dd0e1;
  padding-bottom: 0.4rem;
}

/* Table styling */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 12px rgba(0,0,0,0.3);
}

th,
td {
  border: 1px solid #ccc;
  padding: 0.75rem 1rem;
}

th {
  background-color: #f2f2f2;
}

tr:nth-child(even) {
  background-color: #f9f9f9;
}

body.dark table {
  background-color: #1e1e1e;
  color: #f0f0f0;
  border-color: #444;
}

body.dark th {
  background-color: #2a2a2a;
}

body.dark td {
  background-color: #1a1a1a;
  border-color: #555;
}

body.dark tr:nth-child(even) {
  background-color: #222;
}

/* Links */
a {
  color: #0066cc;
  text-decoration: none;
  border-bottom: 1px dotted #0066cc;
}

a:hover {
  color: #004a99;
  border-bottom: 1px solid #004a99;
}

body.dark a {
  color: #4dd0e1;
  border-bottom: 1px dotted #4dd0e1;
}

/* TOC active section link */
#toc a {
  font-weight: 400;
}

#toc a.active {
  font-weight: 700;
  color: #003b4f;
  border-bottom: 2px solid #003b4f;
}

body.dark #toc a.active {
  color: #7de0d6;
  border-bottom: 2px solid #7de0d6;
}

/* Notes */
.add-notes {
  display: inline-block;
  margin-left: 10px;
  font-size: 12px;
  color: #777;
  text-decoration: underline;
  cursor: pointer;
}

.form-notes {
  width: 98%;
  margin: 6px 0 10px 0;
  padding: 6px;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background-color: #fafafa;
  display: none;
  resize: vertical;
}

body.dark .form-notes {
  background-color: #1e1e1e;
  border: 1px solid #555;
  color: #eee;
}

/* INDENTATION FIX */
details details { margin-left: 20px; }
details details details { margin-left: 40px; }
details details details details { margin-left: 60px; }

/* ============================================================
   UPDATED RESPONSIVE CONTROL PANEL – UPPER LEFT (COMPACT VERSION)
   ============================================================ */

#navigator-controls {
  position: fixed;
  top: 1rem;
  left: 1rem;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.40);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  white-space: nowrap;
  z-index: 3000;
}

body.dark #navigator-controls {
  background: rgba(50,50,50,0.40);
}

#navigator-controls button,
#navigator-controls a,
#navigator-controls select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  background: #ffffff;
  border: 1px solid #dcdcdc;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  white-space: nowrap;
  opacity: 0.9;
  transition: opacity 0.2s;
}

#navigator-controls button:hover,
#navigator-controls a:hover,
#navigator-controls select:hover {
  opacity: 1;
}

body.dark #navigator-controls button,
body.dark #navigator-controls a,
body.dark #navigator-controls select {
  background: #2f2f2f !important;
  color: #f2f2f2 !important;
  border-color: #4a4a4a !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5) !important;
}

body.dark #navigator-controls button:hover,
body.dark #navigator-controls a:hover,
body.dark #navigator-controls select:hover {
  background: #3a3a3a !important;
  border-color: #5c5c5c !important;
}

/* SOP mode canvas */
#sop-canvas {
  display: none;
  margin-top: 80px;
  margin-bottom: 24px;
  padding: 24px;
  border-radius: 12px;
  border: 2px solid #4dd0e1;
  background: rgba(0,95,115,0.04);
}

#sop-canvas .sop-meta {
  opacity: 0.75;
  margin-top: -0.25rem;
}

#sop-canvas .sop-block {
  margin-bottom: 2rem;
}

#sop-canvas .sop-block h2 {
  border-bottom: 2px solid #4dd0e1;
  padding-bottom: 0.35rem;
  margin-bottom: 1rem;
}

#sop-canvas .sop-card {
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  padding: 16px;
}

body.dark #sop-canvas .sop-card {
  background: rgba(30,30,30,0.85);
  border-color: rgba(255,255,255,0.08);
}

/* ---------- Section Break (Light Mode) ---------- */
.section-break {
  display: block;
  width: 100%;
  height: 60px;
  margin: 3em 0;
  background-color: #222;
  border: none;
  border-radius: 4px;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* ---------- Section Break (Dark Mode Override) ---------- */
body.dark .section-break {
  background-color: #444 !important;
  box-shadow: 0 0 8px rgba(255,255,255,0.15) !important;
}

.toggle-btn {
  padding: 6px 14px;
  font-size: 14px;
  border: 1px solid #ccc;
  background-color: #f4f4f4;
  cursor: pointer;
  border-radius: 4px;
  margin-right: 6px;
}

.toggle-btn:hover {
  background-color: #e6e6e6;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 2rem;
  font-size: 0.95rem;
}

thead th {
  background: #003b4f;
  color: #fff;
  padding: 0.6rem;
  text-align: left;
  border: 1px solid #ccc;
}

tbody td {
  border: 1px solid #ccc;
  vertical-align: top;
  padding: 0.6rem;
}

tr.category td {
  background: #f2f2f2;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-top: 2px solid #bbb;
}

/* ============================================================
   SOP TABLE READABILITY TUNING (AUDIT-OPTIMIZED)
   ============================================================ */

/* Increase breathing room in table cells */
tbody td {
  padding: 0.85rem 1rem;
  line-height: 1.5;
}

/* Keep headers compact but readable */
thead th {
  padding: 0.75rem 0.9rem;
  line-height: 1.35;
}

/* Improve vertical separation for QC anchors */
td .qc-anchor {
  display: block;
}

td .qc-anchor + .qc-anchor {
  margin-top: 0.4rem;
}

/* Give scope qualifiers visual separation */
td em {
  display: block;
  margin-top: 0.6rem;
  line-height: 1.45;
}

/* Slightly reduce visual dominance of Regulatory Anchors column */
td.regulatory,
th.regulatory {
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Optional: improve row scanability without adding noise */
tbody tr {
  transition: background-color 0.15s ease;
}

tbody tr:hover {
  background-color: rgba(0, 95, 115, 0.04);
}

thead th {
  background: #003b4f;
  color: #fff;
}
