/* ════════════════════════════════════════════
   RESET & VARIABLES
════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary-dark:  #0a1929;
  --primary-blue:  #1e3a5f;
  --accent-gold:   #d4a574;
  --accent-teal:   #2d7d8e;
  --text-dark:     #1a1a1a;
  --text-medium:   #4a4a4a;
  --text-light:    #6a6a6a;
  --bg-white:      #ffffff;
  --bg-cream:      #faf8f5;
  --bg-light-blue: #f4f7fa;
  --border-light:  #e5e5e5;
  --border-medium: #c5c5c5;
  --danger:        #dc2626;
  --success:       #16a34a;
  --edit-color:    #3b82f6;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Work Sans', sans-serif;
  color: var(--text-dark);
  background: var(--bg-cream);
  line-height: 1.7;
  overflow-x: hidden;
  transition: background .25s, color .25s;
}

/* ════════════════════════════════════════════
   DARK MODE
════════════════════════════════════════════ */
body.dark {
  --primary-dark:  #0d1117;
  --primary-blue:  #1c2e4a;
  --accent-teal:   #2d9da8;
  --text-dark:     #e6edf3;
  --text-medium:   #8b949e;
  --text-light:    #6e7681;
  --bg-white:      #0d1117;
  --bg-cream:      #161b22;
  --bg-light-blue: #161b22;
  --border-light:  #21262d;
  --border-medium: #30363d;
}
body.dark .app-container        { background: #0d1117; }
body.dark .example-box          { background: #161b22; }
body.dark .highlight-box        { background: linear-gradient(135deg,#1c2211,#1c1a11); }
body.dark .data-table tr:nth-child(even) td { background: #161b22; }
body.dark .data-table tr:hover td { background: #1c2a35; }
body.dark .checklist-container  { background: #161b22; border-color: #21262d; }
body.dark .mermaid-render       { background: #0d1117; }
body.dark .section-table        { border-color: #21262d; }
body.dark .table-head           { background: linear-gradient(135deg, #1a2744 0%, #1c2e4a 100%); border-bottom-color: #2d3f5e; }
body.dark .nav-progress         { background: #1e2535; color: #8b949e; }
body.dark .nav-progress.complete{ background: #0d2e1a; color: #4ade80; }
body.dark .modal-box            { background: #161b22; }
body.dark .modal-header,
body.dark .modal-footer         { border-color: #21262d; }
body.dark .form-group input,
body.dark .form-group textarea,
body.dark .form-group select    { background: #0d1117; color: #e6edf3; border-color: #30363d; }
body.dark .rte-toolbar          { background: #161b22; border-color: #21262d; }
body.dark .rte-editor           { background: #0d1117; color: #e6edf3; }
body.dark .cr-panel             { background: #161b22; }
body.dark .cr-body              { background: #161b22; }
body.dark .cr-item              { background: #0d1117; border-color: #21262d; }
body.dark .cr-footer            { border-color: #21262d; background: #161b22; }
body.dark .cr-search            { border-color: #21262d; }
body.dark .cr-search input      { background: #0d1117; color: #e6edf3; border-color: #30363d; }
body.dark .nav-link.active,
body.dark .nav-link:hover       { background: #0d1117; }
body.dark .sec-btn              { background: #161b22; border-color: #30363d; color: #8b949e; }
body.dark .section-intro        { background: #1e2535; }
body.dark mark                  { background: #3d3521; color: #e6edf3; }
body.dark .task-item            { border-color: #21262d; }
body.dark .section              { border-color: #21262d; }

/* ════════════════════════════════════════════
   EDIT BANNER
════════════════════════════════════════════ */
.edit-banner {
  display: none;
  background: linear-gradient(90deg, #1d4ed8, #2563eb);
  color: #fff;
  text-align: center;
  padding: .45rem 1rem;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 300;
}
body.edit-mode .edit-banner { display: block; }

/* ════════════════════════════════════════════
   HEADER
════════════════════════════════════════════ */
.app-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-blue) 100%);
  color: #fff;
  padding: 2.5rem 2rem 1.5rem;
  position: relative;
}
.app-header::before {
  content: '';
  position: absolute; inset: 0;
  background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="g" width="100" height="100" patternUnits="userSpaceOnUse"><path d="M 100 0 L 0 0 0 100" fill="none" stroke="rgba(255,255,255,0.03)" stroke-width="1"/></pattern></defs><rect width="100%25" height="100%25" fill="url(%23g)"/></svg>');
  opacity: .4;
}
.header-top { position: relative; max-width: 1200px; margin: 0 auto 1.5rem; text-align: center; }
.header-top h1 { font-family: 'Work Sans', sans-serif; font-size: 1.7rem; font-weight: 700; letter-spacing: -.01em; }
.header-top p  { font-size: 1rem; opacity: .85; font-weight: 300; letter-spacing: 1px; text-transform: uppercase; margin-top: .3rem; }

.header-controls {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: .55rem;
  align-items: center;
  flex-wrap: wrap;
}
.search-wrap { flex: 1; min-width: 180px; position: relative; }
.search-wrap svg { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); opacity: .5; width: 15px; height: 15px; }
#searchInput {
  width: 100%; padding: .6rem 1rem .6rem 2.4rem;
  border-radius: 6px; border: 1.5px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.1); color: #fff;
  font-family: 'Work Sans', sans-serif; font-size: .88rem; outline: none; transition: all .2s;
}
#searchInput::placeholder { color: rgba(255,255,255,.5); }
#searchInput:focus { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.5); }

.hbtn {
  padding: .58rem 1rem; border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.1); color: #fff;
  font-family: 'Work Sans', sans-serif; font-size: .82rem; font-weight: 500;
  cursor: pointer; transition: all .2s; white-space: nowrap;
}
.hbtn:hover  { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.5); }
.hbtn.active { background: var(--edit-color); border-color: var(--edit-color); }
.save-status      { font-size: .76rem; color: rgba(255,255,255,.6); white-space: nowrap; }
.save-status.saved { color: #86efac; }
.save-status.error { color: #fca5a5; }

/* ════════════════════════════════════════════
   LAYOUT
════════════════════════════════════════════ */
.app-container {
  display: flex;
  max-width: 1600px;
  margin: 0 auto;
  background: var(--bg-white);
  box-shadow: 0 0 60px rgba(0,0,0,.08);
  min-height: 100vh;
}

/* ════════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════════ */
.sidebar {
  width: 280px;
  background: var(--bg-light-blue);
  padding: 1.5rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--border-light);
  flex-shrink: 0;
}
.sidebar-heading {
  font-family: 'Work Sans', sans-serif; font-size: 1.1rem;
  padding: 0 1.25rem .75rem; color: var(--primary-blue);
  font-weight: 600; border-bottom: 1px solid var(--border-light);
  margin-bottom: .5rem;
}
.nav-list  { list-style: none; }
.nav-link  {
  display: flex; align-items: center; gap: .5rem;
  padding: .7rem 1.25rem; color: var(--text-medium);
  text-decoration: none; transition: all .2s;
  border-left: 3px solid transparent; font-size: .87rem; cursor: pointer;
}
.nav-link:hover  { background: var(--bg-white); color: var(--primary-blue); border-left-color: var(--accent-gold); }
.nav-link.active { background: var(--bg-white); color: var(--primary-blue); border-left-color: var(--accent-teal); font-weight: 600; }
.nav-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-progress {
  flex-shrink: 0; font-size: .67rem; font-weight: 700;
  padding: .15rem .45rem; border-radius: 20px;
  background: #e0e7ef; color: #4a5568; letter-spacing: .02em;
  transition: background .2s, color .2s;
}
.nav-progress.complete { background: #dcfce7; color: #166534; }
.nav-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 21px; height: 21px; background: var(--accent-teal);
  color: #fff; border-radius: 50%; font-size: .7rem; font-weight: 600; flex-shrink: 0;
}
.nav-add-section {
  margin: 1rem 1.25rem 0; display: none;
  width: calc(100% - 2.5rem); padding: .6rem;
  border-radius: 6px; border: 1.5px dashed var(--accent-teal);
  background: transparent; color: var(--accent-teal);
  font-family: 'Work Sans', sans-serif; font-size: .83rem; font-weight: 500;
  cursor: pointer; transition: all .2s;
}
.nav-add-section:hover { background: rgba(45,125,142,.08); }
body.edit-mode .nav-add-section { display: block; }

/* ════════════════════════════════════════════
   MAIN CONTENT
════════════════════════════════════════════ */
.main-content { flex: 1; padding: 3rem 4rem; min-width: 0; }

.loading-state { padding: 4rem; text-align: center; color: var(--text-light); }
.loading-spinner {
  width: 40px; height: 40px; margin: 0 auto 1rem;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent-teal);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════
   SECTION
════════════════════════════════════════════ */
.section {
  margin-bottom: 5rem; padding-bottom: 3rem;
  border-bottom: 1px solid var(--border-light);
  animation: fadeUp .5s ease forwards;
}
.section:last-child { border-bottom: none; }
@keyframes fadeUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }

.section-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.section-title-wrap { display: flex; align-items: center; gap: .75rem; flex: 1; }
.section-number {
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent-teal), var(--primary-blue));
  color: #fff; width: 42px; height: 42px; border-radius: 50%;
  font-weight: 600; font-size: 1rem; flex-shrink: 0;
}
.section-title {
  font-family: 'Work Sans', sans-serif; font-size: 1.5rem;
  color: var(--primary-dark); font-weight: 700; line-height: 1.25; letter-spacing: -.01em; outline: none;
}
body.edit-mode .section-title[contenteditable]:hover,
body.edit-mode .section-title[contenteditable]:focus { border-bottom: 2px dashed var(--edit-color); cursor: text; }

.status-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem; border-radius: 20px;
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap;
}
.status-badge.approved { background: #dcfce7; color: #166534; }
.status-badge.draft    { background: #fef9c3; color: #854d0e; }
.status-badge.review   { background: #dbeafe; color: #1e40af; }
body.edit-mode .status-badge { cursor: pointer; }

.section-actions { display: none; flex-direction: column; gap: .3rem; }
body.edit-mode .section-actions { display: flex; }
.sec-btn {
  padding: .28rem .48rem; border: 1px solid var(--border-medium);
  background: var(--bg-white); border-radius: 4px;
  font-size: .73rem; cursor: pointer; color: var(--text-medium); transition: all .15s; line-height: 1;
}
.sec-btn:hover { background: var(--bg-cream); color: var(--primary-blue); }
.sec-btn.danger:hover { background: #fee2e2; color: var(--danger); border-color: var(--danger); }

.section-intro {
  font-size: 1.05rem; color: var(--text-medium); margin-bottom: 2.5rem;
  line-height: 1.85; padding: 1.25rem 1.5rem 1.25rem 1.75rem;
  border-left: 4px solid var(--accent-gold); background: var(--bg-cream); border-radius: 4px; outline: none;
}
body.edit-mode .section-intro[contenteditable]:hover,
body.edit-mode .section-intro[contenteditable]:focus { outline: 2px dashed var(--edit-color); outline-offset: 2px; cursor: text; }
.section-meta { font-size: .74rem; color: var(--text-light); margin-bottom: 1.5rem; }

/* ════════════════════════════════════════════
   SUBSECTION
════════════════════════════════════════════ */
.subsection { margin-bottom: 2.5rem; }
.subsection-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.subsection-title {
  font-family: 'Work Sans', sans-serif; font-size: 1.1rem;
  color: var(--primary-blue); font-weight: 700; letter-spacing: -.005em;
  position: relative; padding-bottom: .4rem; outline: none;
}
.subsection-title::after {
  content: ''; position: absolute; bottom: 0; left: 0;
  width: 50px; height: 3px;
  background: linear-gradient(90deg, var(--accent-gold), transparent);
}
body.edit-mode .subsection-title[contenteditable]:hover,
body.edit-mode .subsection-title[contenteditable]:focus { border-bottom: 2px dashed var(--edit-color); cursor: text; }
.subsection-intro { color: var(--text-medium); font-size: .94rem; margin-bottom: .75rem; outline: none; }
body.edit-mode .subsection-intro[contenteditable]:hover,
body.edit-mode .subsection-intro[contenteditable]:focus { outline: 2px dashed var(--edit-color); outline-offset: 2px; border-radius: 3px; cursor: text; }
.subsec-actions { display: none; gap: .3rem; }
body.edit-mode .subsec-actions { display: flex; }

/* ════════════════════════════════════════════
   TASK LIST
════════════════════════════════════════════ */
.task-list { list-style: none; margin-bottom: 1.25rem; }
.task-item { display: flex; align-items: flex-start; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid var(--border-light); }
.task-item:last-child { border-bottom: none; }
.task-arrow { color: var(--accent-teal); font-weight: 700; font-size: 1.1rem; flex-shrink: 0; margin-top: .05rem; }
.task-text  { flex: 1; outline: none; line-height: 1.65; }
body.edit-mode .task-text[contenteditable]:hover,
body.edit-mode .task-text[contenteditable]:focus { background: #f0f9ff; border-radius: 3px; padding: 0 4px; cursor: text; }
.task-del { display: none; background: none; border: none; color: var(--danger); font-size: 1.1rem; cursor: pointer; padding: 0 .25rem; line-height: 1; opacity: .6; flex-shrink: 0; }
.task-del:hover { opacity: 1; }
body.edit-mode .task-del { display: block; }

/* shared "dashed add" button */
.dash-add-btn {
  display: none; align-items: center; gap: .4rem;
  background: none; border: 1.5px dashed var(--border-medium);
  color: var(--text-light); padding: .42rem .85rem;
  border-radius: 5px; font-size: .81rem; cursor: pointer;
  font-family: 'Work Sans', sans-serif; transition: all .15s; margin-top: .5rem;
}
.dash-add-btn:hover { border-color: var(--accent-teal); color: var(--accent-teal); background: rgba(45,125,142,.05); }
body.edit-mode .dash-add-btn { display: inline-flex; }

/* ════════════════════════════════════════════
   HIGHLIGHT BOX
════════════════════════════════════════════ */
.highlight-box {
  background: linear-gradient(135deg, #fff9f0, #fef5e7);
  border-left: 4px solid var(--accent-gold);
  padding: 1.25rem 1.5rem; margin: 1.5rem 0; border-radius: 6px;
}
.highlight-box strong { color: var(--primary-blue); display: block; margin-bottom: .4rem; font-size: .94rem; }
.highlight-content { color: var(--text-medium); font-size: .94rem; outline: none; }
body.edit-mode .highlight-content[contenteditable]:focus { outline: 2px dashed var(--edit-color); outline-offset: 2px; border-radius: 3px; }

/* ════════════════════════════════════════════
   EXAMPLE BOX
════════════════════════════════════════════ */
.example-box {
  background: var(--bg-white); border: 1px solid var(--border-light);
  border-left: 4px solid var(--accent-teal);
  padding: 1.5rem; margin: 1.5rem 0; border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.example-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.example-title   { font-family: 'Work Sans', sans-serif; font-size: 1.1rem; color: var(--accent-teal); font-weight: 600; }
.example-content { color: var(--text-medium); font-size: .92rem; line-height: 1.8; }
.example-content ul, .example-content ol { padding-left: 1.5rem; margin: .4rem 0; }
.example-content p  { margin: .3rem 0; }
.example-actions { display: none; gap: .3rem; flex-shrink: 0; }
body.edit-mode .example-actions { display: flex; }
.ex-placeholder { color: var(--text-light); font-style: italic; }
.add-example-btn {
  display: none; align-items: center; gap: .4rem;
  background: linear-gradient(135deg, var(--accent-teal), var(--primary-blue));
  color: #fff; border: none; padding: .6rem 1.2rem; border-radius: 6px;
  font-size: .84rem; font-family: 'Work Sans', sans-serif; cursor: pointer;
  margin-top: 1rem; transition: all .2s;
}
.add-example-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(45,125,142,.3); }
body.edit-mode .add-example-btn { display: inline-flex; }

/* ════════════════════════════════════════════
   IMAGES
════════════════════════════════════════════ */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(240px,1fr)); gap: 1rem; margin: 1.5rem 0; }
.section-img-wrap { position: relative; border-radius: 8px; overflow: hidden; background: #f0f0f0; }
.section-img-wrap img { width: 100%; display: block; border-radius: 8px; cursor: pointer; transition: opacity .2s; }
.section-img-wrap img:hover { opacity: .92; }
.img-del-btn { display: none; position: absolute; top: .5rem; right: .5rem; background: var(--danger); color: #fff; border: none; border-radius: 4px; padding: .22rem .48rem; font-size: .75rem; cursor: pointer; }
body.edit-mode .img-del-btn { display: block; }
.img-caption { font-size: .79rem; color: var(--text-light); text-align: center; margin-top: .4rem; font-style: italic; outline: none; }
body.edit-mode .img-caption[contenteditable]:focus { outline: 1px dashed var(--edit-color); border-radius: 3px; }

.img-drop-zone {
  background: linear-gradient(135deg,#f8f9fa,#e9ecef);
  border: 2px dashed var(--border-medium); border-radius: 8px;
  padding: 2.5rem 1.5rem; text-align: center; cursor: pointer;
  transition: all .2s; margin: 1rem 0;
}
.img-drop-zone:hover, .img-drop-zone.drag-over { border-color: var(--accent-teal); background: rgba(45,125,142,.06); }
.img-drop-zone svg { width: 44px; height: 44px; opacity: .3; margin-bottom: .65rem; }
.img-drop-zone p   { color: var(--text-light); font-size: .87rem; }

/* ════════════════════════════════════════════
   DATA TABLE
════════════════════════════════════════════ */
.section-table {
  margin: 2rem 0;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(30,58,95,.07), 0 1px 4px rgba(0,0,0,.04);
}
.table-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .875rem 1.25rem;
  background: linear-gradient(135deg, #f4f7fa 0%, #e8f0fb 100%);
  border-bottom: 1px solid #c5d9f0;
  gap: 1rem;
}
.table-head-left { display: flex; align-items: center; gap: .65rem; }
.table-icon { width: 17px; height: 17px; flex-shrink: 0; color: var(--primary-blue); opacity: .7; }
.table-title {
  font-family: 'Work Sans', sans-serif;
  font-size: .88rem; font-weight: 700;
  color: var(--primary-blue);
  letter-spacing: .04em; text-transform: uppercase;
  outline: none;
}
body.edit-mode .table-title[contenteditable]:hover,
body.edit-mode .table-title[contenteditable]:focus { border-bottom: 2px dashed var(--edit-color); cursor: text; }
.table-controls { display: none; gap: .3rem; flex-wrap: wrap; }
body.edit-mode .table-controls { display: flex; }
.tbl-scroll { overflow-x: auto; max-height: 480px; overflow-y: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 380px; }
.data-table th {
  background: var(--primary-blue); color: #fff;
  padding: .6rem .85rem; text-align: left; font-weight: 500; font-size: .83rem;
  position: sticky; top: 0; z-index: 2;
}
.data-table td { padding: .58rem .85rem; border-bottom: 1px solid var(--border-light); color: var(--text-medium); vertical-align: top; }
.data-table tr:nth-child(even) td { background: var(--bg-cream); }
.data-table tr:hover td { background: #f0f9ff; }
.data-table td[contenteditable]:focus,
.data-table th[contenteditable]:focus { outline: 2px solid var(--edit-color); outline-offset: -2px; background: var(--bg-white) !important; color: var(--text-dark) !important; }
.col-del-btn { background: none; border: none; color: rgba(255,255,255,.5); cursor: pointer; font-size: 1rem; padding: 0 .3rem; line-height: 1; }
.col-del-btn:hover { color: #fff; }
.row-del-cell { width: 28px; padding: .3rem !important; }

/* ════════════════════════════════════════════
   WORKFLOW (MERMAID)
════════════════════════════════════════════ */
.workflow-container {
  margin: 2rem 0;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(30,58,95,.08), 0 1px 4px rgba(0,0,0,.04);
}
.workflow-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .875rem 1.25rem;
  background: linear-gradient(135deg, #eaf1fb 0%, #dbeafe 100%);
  border-bottom: 1px solid #c5d9f0;
  gap: 1rem;
}
.workflow-head-left { display: flex; align-items: center; gap: .65rem; }
.workflow-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  color: var(--primary-blue); opacity: .75;
}
.workflow-title {
  font-family: 'Work Sans', sans-serif;
  font-size: .88rem; font-weight: 700;
  color: var(--primary-blue);
  letter-spacing: .04em; text-transform: uppercase;
  outline: none;
}
body.edit-mode .workflow-title[contenteditable]:hover,
body.edit-mode .workflow-title[contenteditable]:focus {
  border-bottom: 2px dashed var(--edit-color); cursor: text;
}
.workflow-controls { display: flex; gap: .5rem; }
.mermaid-render {
  background: #f9fbff;
  padding: 2rem 1.5rem;
  text-align: center; overflow-x: auto;
  min-height: 100px; display: flex; align-items: center; justify-content: center;
}
.mermaid-render svg {
  max-width: 100%; height: auto;
  filter: drop-shadow(0 2px 6px rgba(30,58,95,.10));
}
.mermaid-loading {
  color: var(--text-light); font-size: .85rem;
  display: flex; align-items: center; gap: .5rem;
}
.mermaid-loading::before {
  content: '';
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border-medium);
  border-top-color: var(--accent-teal);
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
.mermaid-error { color: var(--danger); font-size: .84rem; padding: 1rem; background: #fee2e2; border-radius: 6px; text-align: left; }
.wf-code-editor { font-family: 'Courier New', monospace; font-size: .82rem; background: #f8f9fa; }
body.dark .wf-code-editor { background: #0d1117; color: #e6edf3; }

/* Dark mode workflow */
body.dark .workflow-head {
  background: linear-gradient(135deg, #1a2744 0%, #1c2e4a 100%);
  border-bottom-color: #2d3f5e;
}
body.dark .mermaid-render { background: #0d1117; }
body.dark .mermaid-render svg { filter: drop-shadow(0 2px 8px rgba(0,0,0,.4)); }

/* ════════════════════════════════════════════
   SOP CHECKLIST
════════════════════════════════════════════ */
.checklist-container {
  margin: 1.75rem 0; background: var(--bg-white);
  border: 1px solid var(--border-light); border-radius: 8px;
  padding: 1.5rem; box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.checklist-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; gap: 1rem; }
.checklist-title-text {
  font-family: 'Work Sans', sans-serif; font-size: 1.2rem; color: var(--primary-blue); font-weight: 600; outline: none;
}
body.edit-mode .checklist-title-text[contenteditable]:hover,
body.edit-mode .checklist-title-text[contenteditable]:focus { border-bottom: 2px dashed var(--edit-color); cursor: text; }
.checklist-meta { font-size: .75rem; color: var(--text-light); display: flex; align-items: center; gap: .75rem; }
.progress-bar { height: 5px; background: var(--border-light); border-radius: 3px; margin-bottom: 1rem; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent-teal), var(--primary-blue)); border-radius: 3px; transition: width .35s ease; }
.checklist-item { display: flex; align-items: flex-start; gap: .75rem; padding: .62rem 0; border-bottom: 1px solid var(--border-light); }
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type="checkbox"] { width: 17px; height: 17px; margin-top: .18rem; cursor: pointer; accent-color: var(--accent-teal); flex-shrink: 0; }
.checklist-item label { flex: 1; cursor: pointer; font-size: .93rem; color: var(--text-medium); line-height: 1.6; transition: all .2s; }
.checklist-item.checked label { text-decoration: line-through; color: var(--text-light); }
.checklist-item .ci-text { flex: 1; outline: none; font-size: .93rem; color: var(--text-medium); line-height: 1.6; }
body.edit-mode .ci-text[contenteditable]:hover,
body.edit-mode .ci-text[contenteditable]:focus { background: #f0f9ff; border-radius: 3px; padding: 0 4px; cursor: text; }
.checklist-reset { background: none; border: 1px solid var(--border-medium); color: var(--text-light); padding: .3rem .75rem; border-radius: 4px; font-size: .78rem; cursor: pointer; font-family: 'Work Sans', sans-serif; transition: all .15s; }
.checklist-reset:hover { border-color: var(--accent-teal); color: var(--accent-teal); }

/* ════════════════════════════════════════════
   RICH TEXT EDITOR
════════════════════════════════════════════ */
.rte-wrap { border: 1.5px solid var(--border-medium); border-radius: 6px; overflow: hidden; }
.rte-wrap:focus-within { border-color: var(--accent-teal); }
.rte-toolbar { display: flex; gap: .2rem; flex-wrap: wrap; background: #f8f9fa; border-bottom: 1px solid var(--border-medium); padding: .4rem .5rem; }
.rte-btn { padding: .25rem .55rem; border: 1px solid transparent; background: none; cursor: pointer; border-radius: 4px; font-size: .82rem; color: var(--text-medium); transition: all .15s; font-family: 'Work Sans', sans-serif; line-height: 1.4; }
.rte-btn:hover { background: var(--bg-white); border-color: var(--border-medium); color: var(--primary-blue); }
.rte-divider { width: 1px; background: var(--border-medium); margin: .15rem .2rem; }
.rte-editor { padding: .75rem; min-height: 140px; outline: none; line-height: 1.75; font-size: .92rem; color: var(--text-dark); background: var(--bg-white); }
.rte-editor ul, .rte-editor ol { padding-left: 1.5rem; margin: .3rem 0; }

/* ════════════════════════════════════════════
   CANNED RESPONSES PANEL
════════════════════════════════════════════ */
.cr-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 800; display: none; }
.cr-backdrop.open { display: block; }
.cr-panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: 420px; max-width: 95vw;
  background: var(--bg-white); box-shadow: -4px 0 30px rgba(0,0,0,.14);
  z-index: 801; transform: translateX(100%); transition: transform .3s ease;
  display: flex; flex-direction: column;
}
.cr-backdrop.open .cr-panel { transform: translateX(0); }
.cr-panel-head { background: linear-gradient(135deg,var(--primary-dark),var(--primary-blue)); color: #fff; padding: 1.25rem 1.5rem; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.cr-panel-head h3 { font-family: 'Work Sans', sans-serif; font-size: 1.3rem; font-weight: 600; }
.cr-close { background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; line-height: 1; padding: .1rem .25rem; border-radius: 4px; }
.cr-close:hover { background: rgba(255,255,255,.15); }
.cr-search { padding: .85rem 1.25rem; border-bottom: 1px solid var(--border-light); flex-shrink: 0; }
.cr-search input { width: 100%; padding: .52rem .85rem; border: 1.5px solid var(--border-medium); border-radius: 6px; font-family: 'Work Sans', sans-serif; font-size: .87rem; outline: none; background: var(--bg-white); color: var(--text-dark); transition: border-color .15s; }
.cr-search input:focus { border-color: var(--accent-teal); }
.cr-body { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; background: var(--bg-white); }
.cr-category-label { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-light); padding: .6rem 0 .4rem; border-top: 1px solid var(--border-light); margin-top: .6rem; }
.cr-category-label:first-child { border-top: none; margin-top: 0; padding-top: .2rem; }
.cr-item { padding: .85rem; border: 1px solid var(--border-light); border-radius: 7px; margin-bottom: .5rem; transition: all .15s; background: var(--bg-white); }
.cr-item:hover { border-color: var(--accent-teal); box-shadow: 0 2px 8px rgba(45,125,142,.1); }
.cr-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; margin-bottom: .3rem; }
.cr-item-title { font-weight: 500; font-size: .88rem; color: var(--text-dark); flex: 1; }
.cr-item-btns  { display: flex; gap: .25rem; flex-shrink: 0; }
.cr-item-content { font-size: .8rem; color: var(--text-light); line-height: 1.55; white-space: pre-wrap; max-height: 56px; overflow: hidden; position: relative; }
.cr-item-content::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 18px; background: linear-gradient(transparent, var(--bg-white)); pointer-events: none; }
.cr-copy-btn { padding: .25rem .65rem; background: var(--accent-teal); color: #fff; border: none; border-radius: 4px; font-size: .73rem; font-weight: 600; cursor: pointer; font-family: 'Work Sans', sans-serif; white-space: nowrap; transition: background .15s, transform .1s; }
.cr-copy-btn:hover { background: var(--primary-blue); transform: scale(1.03); }
.cr-copy-btn.copied { background: #16a34a; }
.cr-footer { padding: .85rem 1.25rem; border-top: 1px solid var(--border-light); flex-shrink: 0; background: var(--bg-white); }
.cr-add-btn { display: none; width: 100%; padding: .6rem; border: 1.5px dashed var(--border-medium); background: none; border-radius: 6px; color: var(--text-light); cursor: pointer; font-family: 'Work Sans', sans-serif; font-size: .86rem; transition: all .15s; }
.cr-add-btn:hover { border-color: var(--accent-teal); color: var(--accent-teal); }
body.edit-mode .cr-add-btn { display: block; }

/* ════════════════════════════════════════════
   LIGHTBOX
════════════════════════════════════════════ */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 950; display: none; align-items: center; justify-content: center; cursor: pointer; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 90vw; max-height: 88vh; border-radius: 6px; object-fit: contain; box-shadow: 0 8px 40px rgba(0,0,0,.5); }
.lightbox-close { position: absolute; top: 1.25rem; right: 1.5rem; color: #fff; font-size: 2rem; cursor: pointer; line-height: 1; opacity: .7; transition: opacity .15s; }
.lightbox-close:hover { opacity: 1; }
.lightbox-caption { position: absolute; bottom: 1.5rem; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,.7); font-size: .85rem; white-space: nowrap; max-width: 80vw; overflow: hidden; text-overflow: ellipsis; }

/* ════════════════════════════════════════════
   MODAL
════════════════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,25,41,.55); z-index: 900; display: none; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--bg-white); border-radius: 10px; width: 90%; max-width: 600px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.2); animation: modalIn .2s ease; }
@keyframes modalIn { from { opacity:0; transform:scale(.96) translateY(8px); } to { opacity:1; transform:scale(1) translateY(0); } }
.modal-header { padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-header h3 { font-family: 'Work Sans', sans-serif; font-size: 1.35rem; color: var(--primary-dark); font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-light); line-height: 1; padding: .1rem .3rem; border-radius: 4px; }
.modal-close:hover { background: var(--bg-cream); color: var(--text-dark); }
.modal-body   { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: .65rem; flex-shrink: 0; }

.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; font-size: .84rem; font-weight: 500; color: var(--text-medium); margin-bottom: .4rem; }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%; padding: .62rem .82rem; border: 1.5px solid var(--border-medium);
  border-radius: 6px; font-family: 'Work Sans', sans-serif; font-size: .9rem;
  color: var(--text-dark); background: var(--bg-white); outline: none; transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--accent-teal); }
.form-group textarea { min-height: 110px; resize: vertical; line-height: 1.65; }
.form-hint { font-size: .78rem; color: var(--text-light); margin-top: .3rem; }

.btn { padding: .62rem 1.35rem; border-radius: 6px; font-family: 'Work Sans', sans-serif; font-size: .87rem; font-weight: 500; cursor: pointer; border: none; transition: all .2s; }
.btn-primary { background: linear-gradient(135deg,var(--accent-teal),var(--primary-blue)); color: #fff; }
.btn-primary:hover { box-shadow: 0 4px 12px rgba(45,125,142,.3); transform: translateY(-1px); }
.btn-ghost  { background: none; border: 1.5px solid var(--border-medium); color: var(--text-medium); }
.btn-ghost:hover { border-color: var(--text-medium); color: var(--text-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ════════════════════════════════════════════
   TOAST & SCROLL TOP
════════════════════════════════════════════ */
.toast { position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(4px); background: var(--primary-dark); color: #fff; padding: .65rem 1.35rem; border-radius: 8px; font-size: .86rem; font-weight: 500; box-shadow: 0 4px 16px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transition: all .25s; z-index: 999; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.scroll-top { position: fixed; bottom: 2rem; right: 2rem; width: 44px; height: 44px; border-radius: 50%; background: var(--accent-teal); color: #fff; border: none; cursor: pointer; font-size: 1.1rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(0,0,0,.15); opacity: 0; pointer-events: none; transition: all .2s; z-index: 100; }
.scroll-top.visible { opacity: 1; pointer-events: all; }
.scroll-top:hover { transform: translateY(-2px); }

/* ════════════════════════════════════════════
   FOOTER & SEARCH
════════════════════════════════════════════ */
.app-footer { background: var(--primary-dark); color: #fff; text-align: center; padding: 1.5rem; }
.app-footer p { opacity: .6; font-size: .84rem; }
mark { background: #fef08a; padding: 0 2px; border-radius: 2px; }
.section.search-hidden { display: none; }
.no-results { padding: 3rem 0; text-align: center; color: var(--text-light); display: none; }
.no-results.show { display: block; }

/* ════════════════════════════════════════════
   PRINT
════════════════════════════════════════════ */
@media print {
  .edit-banner, .header-controls, .sidebar,
  .section-actions, .subsec-actions, .example-actions,
  .task-del, .dash-add-btn, .add-example-btn,
  .img-del-btn, .img-drop-zone, .table-controls,
  .col-del-btn, .row-del-cell, .workflow-controls,
  .checklist-reset, .scroll-top, .app-footer,
  .modal-overlay, .cr-backdrop, .lightbox,
  .nav-add-section { display: none !important; }
  .app-container { box-shadow: none; }
  .main-content { padding: 1rem; }
  .section { break-inside: avoid; }
  .data-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; }
}

/* ════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .app-container { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .main-content { padding: 2rem 1.5rem; }
  .header-top h1 { font-size: 2rem; }
}
@media (max-width: 600px) {
  .header-controls { flex-direction: column; }
  .cr-panel { width: 100%; }
}

/* ══════════════════════════════════════════════════════════
   MULTI-PAGE LAYOUT — TOP BAR
══════════════════════════════════════════════════════════ */
.topbar {
  position: sticky; top: 0; z-index: 500;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  box-shadow: 0 1px 3px rgba(10,25,41,.04);
}
.topbar-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; gap: 1.25rem;
  padding: .65rem 1.5rem;
}
.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: inherit; flex-shrink: 0; }
.brand-icon {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary-blue), var(--accent-teal));
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
}
.brand-icon svg { width: 18px; height: 18px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-size: .92rem; font-weight: 700; color: var(--text-dark); letter-spacing: -.005em; }
.brand-sub   { font-size: .7rem; color: var(--text-light); }

.topnav { display: flex; align-items: center; gap: .15rem; flex: 1; margin-left: .75rem; }
.topnav-link {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem .8rem; border-radius: 7px;
  color: var(--text-medium); text-decoration: none;
  font-size: .87rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.topnav-link svg { width: 16px; height: 16px; }
.topnav-link:hover { background: var(--bg-light-blue); color: var(--primary-blue); }
.topnav-link.active { background: var(--primary-blue); color: #fff; }
.topnav-link.active:hover { background: var(--primary-dark); color: #fff; }

.topbar-right { display: flex; align-items: center; gap: .55rem; flex-shrink: 0; }
.topbar-search { position: relative; }
.topbar-search svg { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-light); pointer-events: none; }
.topbar-search input {
  padding: .5rem .75rem .5rem 2rem;
  border: 1px solid var(--border-light); border-radius: 7px;
  font-size: .85rem; font-family: inherit; width: 240px;
  background: var(--bg-light-blue); color: var(--text-dark);
  transition: border-color .15s, background .15s;
}
.topbar-search input:focus { outline: none; border-color: var(--accent-teal); background: var(--bg-white); }

.icon-btn {
  width: 34px; height: 34px; border-radius: 7px;
  background: var(--bg-light-blue); border: 1px solid var(--border-light);
  color: var(--text-medium);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--primary-blue); border-color: var(--accent-teal); }
.icon-btn.is-dark { color: var(--accent-gold); }

.save-pill {
  font-size: .72rem; font-weight: 600; color: var(--text-light);
  padding: .25rem .55rem; border-radius: 20px; background: var(--bg-light-blue);
  white-space: nowrap; letter-spacing: .02em;
}
.save-pill.saving { color: #92610a; background: #fef9e7; }
.save-pill.saved  { color: #166534; background: #dcfce7; }
.save-pill.error  { color: #991b1b; background: #fee2e2; }

.user-chip {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .25rem .35rem .25rem .3rem; border-radius: 20px;
  background: var(--bg-light-blue); border: 1px solid var(--border-light);
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-teal); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700;
}
.user-name { font-size: .82rem; font-weight: 500; color: var(--text-dark); padding-right: .2rem; }
.user-logout { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--text-light); text-decoration: none; }
.user-logout svg { width: 14px; height: 14px; }
.user-logout:hover { color: var(--danger); background: #fee2e2; }

.page-wrap { max-width: 1400px; margin: 0 auto; padding: 1.75rem 1.5rem; }

/* ══════════════════════════════════════════════════════════
   DOCS LAYOUT (two-column)
══════════════════════════════════════════════════════════ */
.docs-layout { display: grid; grid-template-columns: 260px 1fr; gap: 1.75rem; align-items: start; }
.docs-layout .sidebar {
  position: sticky; top: 70px;
  background: var(--bg-white); border: 1px solid var(--border-light); border-radius: 12px;
  padding: 1rem 0; max-height: calc(100vh - 90px); overflow-y: auto;
}
.docs-content { min-width: 0; }

/* ══════════════════════════════════════════════════════════
   BUTTONS — unified
══════════════════════════════════════════════════════════ */
.btn-primary, .btn-secondary {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .6rem 1.1rem; border: 1px solid transparent; border-radius: 8px;
  font-family: inherit; font-size: .87rem; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: transform .1s, box-shadow .15s, background .15s;
}
.btn-primary svg, .btn-secondary svg { width: 16px; height: 16px; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary-blue), #24507f);
  color: #fff; box-shadow: 0 2px 8px rgba(30,58,95,.2);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(30,58,95,.3); }
.btn-secondary {
  background: var(--bg-white); color: var(--primary-blue);
  border-color: var(--border-medium);
}
.btn-secondary:hover { background: var(--bg-light-blue); border-color: var(--accent-teal); }

/* ══════════════════════════════════════════════════════════
   DASHBOARD
══════════════════════════════════════════════════════════ */
.dashboard { display: flex; flex-direction: column; gap: 1.5rem; }
.dashboard-hero {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem;
  padding: 1.75rem 2rem;
  background: linear-gradient(135deg, #f4f7fa 0%, #e8f0fb 100%);
  border: 1px solid #c5d9f0; border-radius: 14px;
}
.dashboard-hero h1 { font-size: 1.7rem; font-weight: 700; color: var(--primary-dark); letter-spacing: -.015em; margin-bottom: .25rem; }
.dashboard-hero p  { color: var(--text-medium); font-size: .92rem; }
.dashboard-quickactions { display: flex; gap: .6rem; flex-shrink: 0; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.stat-card {
  background: var(--bg-white); border: 1px solid var(--border-light); border-radius: 12px;
  padding: 1.25rem; display: flex; align-items: center; gap: 1rem;
  box-shadow: 0 2px 8px rgba(10,25,41,.04);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(10,25,41,.08); }
.stat-card.skeleton { height: 86px; background: linear-gradient(90deg, #f0f2f5 25%, #e4e8ed 50%, #f0f2f5 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.stat-icon {
  width: 46px; height: 46px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-card.tone-blue   .stat-icon { background: #dbeafe; color: #1e40af; }
.stat-card.tone-teal   .stat-icon { background: #ccfbf1; color: #0f766e; }
.stat-card.tone-amber  .stat-icon { background: #fef3c7; color: #92400e; }
.stat-card.tone-violet .stat-icon { background: #ede9fe; color: #6d28d9; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; color: var(--text-dark); letter-spacing: -.02em; }
.stat-label { font-size: .78rem; color: var(--text-light); text-transform: uppercase; letter-spacing: .08em; margin-top: .3rem; font-weight: 600; }

.dashboard-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.dashboard-row .card:only-child { grid-column: 1 / -1; }

.card {
  background: var(--bg-white); border: 1px solid var(--border-light); border-radius: 12px;
  box-shadow: 0 2px 8px rgba(10,25,41,.04); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-light);
}
.card-head h3 { font-size: .95rem; font-weight: 700; color: var(--primary-dark); letter-spacing: -.005em; }
.card-link { font-size: .8rem; color: var(--accent-teal); text-decoration: none; font-weight: 600; }
.card-link:hover { color: var(--primary-blue); }
.card-body { padding: .5rem 0; }
.muted { color: var(--text-light); font-size: .87rem; padding: 1rem 1.25rem; }

.recent-row {
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: .85rem;
  padding: .7rem 1.25rem; text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--border-light);
  transition: background .12s;
}
.recent-row:last-child { border-bottom: none; }
.recent-row:hover { background: var(--bg-light-blue); }
.recent-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-light-blue); color: var(--primary-blue);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700;
}
.recent-meta { display: flex; flex-direction: column; min-width: 0; }
.recent-title { font-size: .88rem; font-weight: 600; color: var(--text-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-date { font-size: .72rem; color: var(--text-light); margin-top: .1rem; }

.overall-progress { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-light); }
.overall-progress-head { display: flex; justify-content: space-between; margin-bottom: .5rem; font-size: .85rem; color: var(--text-medium); }
.overall-progress-head strong { color: var(--text-dark); }
.overall-progress-bar { height: 8px; border-radius: 4px; background: var(--bg-light-blue); overflow: hidden; }
.overall-progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--accent-teal), #4ade80); transition: width .4s; }

.cl-progress-row {
  display: grid; grid-template-columns: 1fr auto 100px; gap: .85rem; align-items: center;
  padding: .65rem 1.25rem; text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--border-light);
}
.cl-progress-row:last-child { border-bottom: none; }
.cl-progress-row:hover { background: var(--bg-light-blue); }
.cl-title { font-size: .86rem; font-weight: 500; color: var(--text-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-count { font-size: .75rem; color: var(--text-light); font-weight: 600; font-variant-numeric: tabular-nums; }
.cl-bar   { display: block; height: 6px; border-radius: 3px; background: var(--bg-light-blue); overflow: hidden; }
.cl-bar > span { display: block; height: 100%; background: var(--accent-teal); }

.section-tiles {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .75rem; padding: 1rem 1.25rem;
}
.section-tile {
  display: flex; align-items: center; gap: .7rem;
  padding: .8rem 1rem; border: 1px solid var(--border-light); border-radius: 8px;
  text-decoration: none; color: inherit; background: var(--bg-white);
  transition: all .15s;
}
.section-tile:hover { border-color: var(--accent-teal); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(45,125,142,.12); }
.tile-num {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--bg-light-blue); color: var(--primary-blue);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; flex-shrink: 0;
}
.tile-title { flex: 1; font-size: .86rem; font-weight: 500; color: var(--text-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-arrow { width: 16px; height: 16px; color: var(--text-light); flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════
   TEMPLATES PAGE
══════════════════════════════════════════════════════════ */
.templates-page { display: flex; flex-direction: column; gap: 1.5rem; }
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem;
  padding-bottom: 1rem; border-bottom: 1px solid var(--border-light);
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); letter-spacing: -.015em; margin-bottom: .3rem; }
.page-header p  { color: var(--text-medium); font-size: .92rem; max-width: 620px; }

.templates-grid { display: flex; flex-direction: column; gap: 1.75rem; }
.tpl-group { display: flex; flex-direction: column; gap: .75rem; }
.tpl-cat { font-size: .72rem; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: .12em; }
.tpl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .85rem; }

.tpl-card {
  background: var(--bg-white); border: 1px solid var(--border-light); border-radius: 10px;
  padding: 1rem 1.15rem; display: flex; flex-direction: column; gap: .6rem;
  transition: all .15s;
}
.tpl-card:hover { border-color: var(--accent-teal); box-shadow: 0 4px 14px rgba(45,125,142,.1); }
.tpl-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.tpl-head h4 { font-size: .95rem; font-weight: 600; color: var(--text-dark); flex: 1; }
.tpl-actions { display: flex; gap: .3rem; flex-wrap: wrap; flex-shrink: 0; }
.tpl-body {
  font-family: inherit; font-size: .82rem; color: var(--text-medium); line-height: 1.6;
  white-space: pre-wrap; max-height: 180px; overflow: hidden; position: relative;
  background: var(--bg-light-blue); padding: .75rem; border-radius: 6px;
  border: 1px solid var(--border-light);
}
.tpl-body::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 30px; background: linear-gradient(transparent, var(--bg-light-blue)); pointer-events: none; }

/* ══════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════ */
.login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-blue) 100%);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Work Sans', sans-serif;
}
.login-wrap { width: 100%; max-width: 420px; padding: 1.5rem; }
.login-card {
  background: var(--bg-white); border-radius: 14px;
  padding: 2.5rem 2rem 2rem; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-brand {
  width: 56px; height: 56px; margin: 0 auto 1rem; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary-blue), var(--accent-teal));
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
}
.login-brand svg { width: 28px; height: 28px; }
.login-card h1 { font-size: 1.4rem; font-weight: 700; color: var(--text-dark); letter-spacing: -.01em; }
.login-sub { color: var(--text-light); font-size: .85rem; margin-top: .25rem; margin-bottom: 1.5rem; }
.login-card form { text-align: left; display: flex; flex-direction: column; gap: .75rem; }
.login-card label { font-size: .78rem; font-weight: 600; color: var(--text-medium); text-transform: uppercase; letter-spacing: .06em; }
.login-card input {
  padding: .65rem .85rem; border: 1px solid var(--border-medium); border-radius: 7px;
  font-family: inherit; font-size: .92rem;
  background: var(--bg-white); color: var(--text-dark);
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { outline: none; border-color: var(--accent-teal); box-shadow: 0 0 0 3px rgba(45,125,142,.15); }
.login-card button {
  margin-top: .5rem;
  padding: .7rem 1rem; border: none; border-radius: 7px; cursor: pointer;
  background: linear-gradient(135deg, var(--primary-blue), var(--accent-teal));
  color: #fff; font-family: inherit; font-size: .9rem; font-weight: 600;
  transition: transform .1s, box-shadow .15s;
}
.login-card button:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(30,58,95,.3); }
.login-error {
  margin-bottom: 1rem; padding: .65rem .85rem;
  background: #fee2e2; color: #991b1b;
  border-radius: 7px; font-size: .85rem; text-align: left;
}
.login-foot { margin-top: 1.5rem; font-size: .72rem; color: var(--text-light); }

/* Setup wizard — credentials display */
.setup-creds { display: flex; flex-direction: column; gap: .5rem; margin: 1.25rem 0; text-align: left; }
.setup-cred-row {
  display: grid; grid-template-columns: 110px 1fr auto; gap: .75rem; align-items: center;
  padding: .6rem .85rem; background: var(--bg-light-blue); border: 1px solid var(--border-light); border-radius: 7px;
}
.setup-cred-label { font-weight: 600; color: var(--primary-blue); font-size: .88rem; }
.setup-cred-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9rem; color: var(--text-dark); background: var(--bg-white);
  padding: .25rem .5rem; border-radius: 4px; user-select: all;
  border: 1px solid var(--border-light);
}
.setup-cred-tag { font-size: .68rem; color: var(--text-light); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }

/* ══════════════════════════════════════════════════════════
   DOCS EDIT BANNER (slim)
══════════════════════════════════════════════════════════ */
.edit-banner {
  display: none;
  background: linear-gradient(90deg, #fff7ed, #ffedd5);
  color: #9a3412; padding: .4rem 1rem; font-size: .8rem; font-weight: 600;
  border-bottom: 1px solid #fed7aa; text-align: center;
}
body.edit-mode .edit-banner { display: block; }

/* ══════════════════════════════════════════════════════════
   DARK MODE — new UI
══════════════════════════════════════════════════════════ */
body.dark .topbar            { background: #0d1117; border-bottom-color: #21262d; }
body.dark .topbar-search input{ background: #161b22; border-color: #30363d; color: #e6edf3; }
body.dark .topnav-link       { color: #8b949e; }
body.dark .topnav-link:hover { background: #161b22; color: #e6edf3; }
body.dark .topnav-link.active{ background: var(--accent-teal); color: #fff; }
body.dark .icon-btn          { background: #161b22; border-color: #30363d; color: #8b949e; }
body.dark .icon-btn:hover    { color: #4ade80; border-color: var(--accent-teal); }
body.dark .user-chip         { background: #161b22; border-color: #30363d; }
body.dark .user-name         { color: #e6edf3; }
body.dark .save-pill         { background: #161b22; color: #8b949e; }
body.dark .docs-layout .sidebar { background: #0d1117; border-color: #21262d; }
body.dark .dashboard-hero    { background: linear-gradient(135deg, #0d1117 0%, #161b22 100%); border-color: #30363d; }
body.dark .stat-card,
body.dark .card              { background: #0d1117; border-color: #21262d; }
body.dark .recent-row:hover,
body.dark .cl-progress-row:hover,
body.dark .section-tile:hover{ background: #161b22; }
body.dark .section-tile      { background: #0d1117; border-color: #21262d; }
body.dark .tpl-card          { background: #0d1117; border-color: #21262d; }
body.dark .tpl-body          { background: #161b22; border-color: #21262d; color: #c9d1d9; }
body.dark .tpl-body::after   { background: linear-gradient(transparent, #161b22); }
body.dark .btn-secondary     { background: #0d1117; color: #e6edf3; border-color: #30363d; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — multi-page
══════════════════════════════════════════════════════════ */
@media (max-width: 1000px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-layout .sidebar { position: static; max-height: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-row { grid-template-columns: 1fr; }
  .topnav { display: none; }
  .topbar-search input { width: 160px; }
}
@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; gap: .5rem; padding: .55rem 1rem; }
  .user-name, .user-role-tag { display: none; }
  .page-wrap { padding: 1rem; }
  .dashboard-hero { flex-direction: column; align-items: flex-start; padding: 1.25rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ══════════════════════════════════════════════════════════
   ROLE TAG (user chip)
══════════════════════════════════════════════════════════ */
.user-role-tag {
  font-size: .66rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: .15rem .45rem; border-radius: 10px; color: #fff;
}
.user-role-tag.role-admin      { background: #dc2626; }
.user-role-tag.role-compliance { background: #0f766e; }
.user-role-tag.role-senior     { background: #1e40af; }
.user-role-tag.role-cs,
.user-role-tag.role-agent      { background: #6b7280; }

/* Read-only mode — hide edit affordances entirely */
body.read-only .edit-banner,
body.read-only .section-actions,
body.read-only .dash-add-btn,
body.read-only .add-example-btn,
body.read-only .img-drop-zone,
body.read-only .table-controls,
body.read-only .workflow-controls,
body.read-only .checklist-reset,
body.read-only .example-actions,
body.read-only .img-del-btn,
body.read-only .task-del,
body.read-only .col-del-btn,
body.read-only .row-del-cell,
body.read-only .nav-add-section,
body.read-only .meta-pill.pill-add,
body.read-only .tpl-actions .sec-btn { display: none !important; }

/* ══════════════════════════════════════════════════════════
   SECTION META ROW — ownership / review pills
══════════════════════════════════════════════════════════ */
.section-meta-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  margin-top: .35rem; margin-bottom: 1.25rem;
  font-size: .78rem;
}
.section-meta {
  color: var(--text-light);
  font-size: .78rem;
  padding: .2rem 0;
}
.meta-pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .22rem .6rem; border-radius: 20px;
  font-size: .74rem; font-weight: 600; letter-spacing: .01em;
  background: var(--bg-light-blue); color: var(--primary-blue);
  border: 1px solid transparent;
  cursor: default;
}
.meta-pill svg { width: 13px; height: 13px; }
body.edit-mode .meta-pill { cursor: pointer; }
body.edit-mode .meta-pill:hover { border-color: var(--accent-teal); }
.pill-ownership { background: #eef2ff; color: #3730a3; }
.pill-review    { background: #f0fdf4; color: #166534; }
.pill-review-expired { background: #fef3c7; color: #92400e; }
.pill-add {
  background: transparent; color: var(--text-light); border: 1px dashed var(--border-medium);
  font-weight: 500;
}
.pill-add:hover { color: var(--accent-teal); border-color: var(--accent-teal); }

body.dark .meta-pill         { background: #1e2535; color: #c9d1d9; }
body.dark .pill-ownership    { background: #1e1b4b; color: #c7d2fe; }
body.dark .pill-review       { background: #0d2e1a; color: #86efac; }
body.dark .pill-review-expired { background: #3b2e12; color: #fde68a; }

/* ══════════════════════════════════════════════════════════
   DASHBOARD — activity + review status cards
══════════════════════════════════════════════════════════ */
.card-sub { font-size: .72rem; color: var(--text-light); }

.activity-row {
  display: grid; grid-template-columns: 28px 1fr; gap: .7rem; align-items: center;
  padding: .6rem 1.25rem; border-bottom: 1px solid var(--border-light);
}
.activity-row:last-child { border-bottom: none; }
.activity-icon {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-light-blue); color: var(--primary-blue);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.activity-icon svg { width: 14px; height: 14px; }
.activity-meta { display: flex; flex-direction: column; min-width: 0; font-size: .84rem; color: var(--text-medium); }
.activity-meta strong { color: var(--text-dark); font-weight: 600; }
.activity-ago { font-size: .7rem; color: var(--text-light); margin-top: .1rem; }

.rev-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-light);
}
.rev-tally {
  text-align: center; padding: .7rem .5rem; border-radius: 8px;
  border: 1px solid var(--border-light);
  display: flex; flex-direction: column; gap: .15rem;
}
.rev-tally strong { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; line-height: 1; }
.rev-tally span   { font-size: .7rem; color: var(--text-light); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.tally-ok   strong { color: #166534; }
.tally-ok          { background: #f0fdf4; border-color: #bbf7d0; }
.tally-warn strong { color: #92400e; }
.tally-warn        { background: #fffbeb; border-color: #fde68a; }
.tally-na   strong { color: #64748b; }

.rev-list { padding: .5rem 0; }
.rev-list-title { font-size: .72rem; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: .08em; padding: .5rem 1.25rem; }
.rev-row {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .55rem 1.25rem; text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--border-light);
}
.rev-row:last-child { border-bottom: none; }
.rev-row:hover { background: var(--bg-light-blue); }
.rev-title { font-size: .86rem; color: var(--text-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rev-date  { font-size: .74rem; color: var(--text-light); font-variant-numeric: tabular-nums; }

body.dark .rev-tally        { background: #0d1117; border-color: #21262d; }
body.dark .rev-tally.tally-ok    { background: #0f1f14; border-color: #14532d; }
body.dark .rev-tally.tally-warn  { background: #1f1a0a; border-color: #713f12; }
body.dark .activity-icon    { background: #1e2535; color: #c9d1d9; }
