:root {
  --navy: #16375e;
  --navy-dark: #0f2740;
  --teal: #2c8b93;
  --green: #6fbf4f;
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --border: #e2e5ea;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --gradient: linear-gradient(90deg, var(--navy) 0%, var(--teal) 55%, var(--green) 100%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

body { display: flex; flex-direction: column; }

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--card-bg);
  border-bottom: 3px solid transparent;
  border-image: var(--gradient) 1;
  flex-shrink: 0;
}

header img { height: 26px; }

#sidebar-toggle {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--navy);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}
#sidebar-toggle:hover { background: var(--bg); }

#body-row { flex: 1; display: flex; overflow: hidden; min-width: 0; min-height: 0; }

#sidebar {
  width: 190px;
  flex-shrink: 0;
  background: var(--navy-dark);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.15s ease, margin-left 0.15s ease;
}
#sidebar.collapsed { width: 0; margin-left: -190px; }

#sidebar-nav { list-style: none; margin: 0; padding: 10px 0; flex: 1; overflow-y: auto; }
#sidebar-bottom {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

#sidebar-nav li, #sidebar-bottom li {
  padding: 10px 20px;
  color: #cbd5e1;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  border-left: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}
#sidebar-nav li:hover, #sidebar-bottom li:hover { background: rgba(255, 255, 255, 0.06); }
#sidebar-nav li.active, #sidebar-bottom li.active {
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-weight: 600;
  border-left-color: var(--green);
}

.avatar-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

#tabbar {
  display: flex;
  align-items: stretch;
  background: var(--navy-dark);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  overflow-x: auto;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  color: #cbd5e1;
  font-size: 13px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.tab:hover { background: rgba(255, 255, 255, 0.06); }

.tab.active {
  background: var(--bg);
  color: var(--navy);
  font-weight: 600;
}

.tab .close {
  color: #9aa7b6;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
}

.tab .close:hover { background: rgba(255, 255, 255, 0.2); color: white; }
.tab.active .close:hover { background: rgba(0, 0, 0, 0.1); color: var(--navy); }

#content { flex: 1; overflow: auto; min-width: 0; min-height: 0; }

.pane { display: none; height: 100%; flex-direction: column; min-width: 0; }
.pane.active { display: flex; }

.pane-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 20px;
  flex-shrink: 0;
}

.view-toggle { display: flex; flex-shrink: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.view-toggle button {
  padding: 8px 12px;
  border: none;
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  border-left: 1px solid var(--border);
}
.view-toggle button:first-child { border-left: none; }
.view-toggle button:hover { background: var(--bg); }
.view-toggle button.active { background: var(--navy); color: white; }

#search {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  flex-shrink: 0;
}

table { width: 100%; border-collapse: collapse; background: var(--card-bg); }

th, td {
  text-align: left;
  padding: 8px 20px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

th { background: #f9fafb; color: var(--text-muted); font-weight: 600; position: sticky; top: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #eef2f6; }

#status, .empty-state {
  padding: 24px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

#count { padding: 0 20px 8px; color: var(--text-muted); font-size: 13px; }

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.task-row:last-child { border-bottom: none; }
.task-row.done .task-subject { text-decoration: line-through; color: var(--text-muted); }
.task-check { margin-top: 3px; flex-shrink: 0; }
.task-main { flex: 1; min-width: 0; }
.task-subject { font-size: 13px; font-weight: 600; color: var(--text); }
.task-role {
  display: inline-block;
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  margin-right: 4px;
}
.task-body { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: pre-line; }
.task-due { font-size: 12px; color: var(--text-muted); flex-shrink: 0; white-space: nowrap; }

.add-task-row { display: flex; gap: 8px; margin-top: 12px; }
.new-task-input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.add-task-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--navy);
  font-size: 13px;
  cursor: pointer;
}

/* Kept deliberately tight -- this sits above the tab bar on every case screen, and
   real screen space below it (the Documents previewer especially) matters more than
   header breathing room. Case Info + the stage/badge row were 2 more stacked rows
   before; now they share one row via .case-meta-row. */
.facesheet-header {
  padding: 10px 24px 8px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.facesheet-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.facesheet-header h2 { margin: 0; font-size: 18px; color: var(--navy); }
.facesheet-header .db-name { color: var(--text-muted); font-size: 13px; }
.case-client-id { font-size: 12px; color: var(--text-muted); font-weight: 400; margin-left: 10px; }
.badge-board-wrap { flex-shrink: 0; }

.case-meta-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }

/* Case Info folded inline into the header instead of its own card/tab -- every field
   always shows its label, even blank ("--"), so it reads as real content rather than
   one lone word that's easy to miss entirely. */
.case-info-inline { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 12px; }
.case-info-chip { display: inline-flex; align-items: baseline; gap: 5px; color: var(--text); }
.case-info-chip-label {
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.case-info-edit-btn {
  flex-shrink: 0;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--navy);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.case-info-edit-btn:hover { border-color: var(--teal); color: var(--teal); }

.stage-badge-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.stage-pill-wrap { position: relative; }
.stage-pill {
  border: none;
  color: white;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.stage-pill:hover { filter: brightness(1.05); }
.stage-pill-caret { font-size: 10px; }

.stage-pill-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  background: white;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}
.stage-pill-menu[hidden] { display: none; }
.stage-pill-option {
  border: none;
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  text-align: left;
}
.stage-pill-option:hover { filter: brightness(1.08); }
.stage-pill-option.current { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6); }

.badge-summary { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.badge-light { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* Badges as patches pinned to a real cork pushpin board -- sized to fit only what it
   holds (not stretched to fill the header row), sitting up beside the case name.
   Cork texture is a speckled radial-gradient stack (no image asset needed), framed by
   a wood-tone border. Each patch gets a small pushpin head and always shows its own
   distinct icon (dim before earned, bright once earned) rather than a blank circle. */
.badge-board {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 10px 7px;
  width: fit-content;
  background-color: #c8975f;
  background-image: radial-gradient(circle at 22% 28%, rgba(255, 255, 255, 0.1) 1px, transparent 1.4px),
    radial-gradient(circle at 68% 62%, rgba(0, 0, 0, 0.12) 1px, transparent 1.4px),
    radial-gradient(circle at 80% 18%, rgba(255, 255, 255, 0.08) 1.2px, transparent 1.6px),
    radial-gradient(circle at 38% 82%, rgba(0, 0, 0, 0.1) 1px, transparent 1.4px),
    radial-gradient(circle at 10% 70%, rgba(0, 0, 0, 0.08) 1px, transparent 1.4px);
  background-size: 14px 14px, 18px 18px, 22px 22px, 16px 16px, 20px 20px;
  border: 4px solid #8a5a32;
  border-radius: 6px;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.3), 0 2px 5px rgba(0, 0, 0, 0.15);
}
.patch { position: relative; width: 46px; text-align: center; cursor: pointer; user-select: none; padding-top: 5px; }
.patch::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #6b6b6b, #1a1a1a);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  z-index: 2;
}
.patch-icon {
  width: 34px;
  height: 34px;
  margin: 0 auto 3px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #b9bfc7;
  background: repeating-conic-gradient(#e2e5ea 0% 25%, #ecedf0 0% 50%);
  border: 2px dashed #cfd3d9;
  transition: all 0.15s ease;
}
.patch:hover .patch-icon { border-color: var(--teal); }
.patch.earned .patch-icon {
  background: linear-gradient(135deg, var(--teal), var(--green));
  border: 2px solid var(--navy);
  color: #fff9e0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.patch-label { font-size: 8px; color: #5a3b1e; line-height: 1.1; font-weight: 700; }
.patch.earned .patch-label { color: #3a2510; font-weight: 800; }

/* Documents badge only: follows the same stoplight states as the Documents scan
   instead of a plain earned/unearned toggle. */
.patch.doc-state-red .patch-icon,
.patch.doc-state-amber .patch-icon {
  border: 2px solid var(--navy);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  color: white;
}
.patch.doc-state-red .patch-icon { background: #c0392b; }
.patch.doc-state-amber .patch-icon { background: #d98c2b; }
.patch.doc-state-red .patch-label,
.patch.doc-state-amber .patch-label { color: #3a2510; font-weight: 800; }

/* The case face sheet's own second-level tab bar, right under the header. */
.facesheet-tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.facesheet-tab-btn {
  padding: 10px 16px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.facesheet-tab-btn:hover { color: var(--navy); }
.facesheet-tab-btn.active { color: var(--navy); border-bottom-color: var(--teal); }

.facesheet-tab-panels { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.facesheet-tab-panel { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px; }
.facesheet-tab-panel[hidden] { display: none; }

.facesheet-panel-toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; flex-shrink: 0; }
.facesheet-toolbar-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--navy);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.facesheet-toolbar-btn:hover { border-color: var(--teal); color: var(--teal); }
.facesheet-toolbar-btn:disabled { opacity: 0.5; cursor: default; }

/* Documents tab: no outer page scroll -- fills the tab panel exactly, only the
   checklist column and the preview pane scroll their own overflow internally.
   This is what kills the "double scroll" (was: scroll the whole card stack to reach
   Documents, then scroll again inside the preview). */
.facesheet-tab-panel.doc-tab-panel { overflow: hidden; display: flex; flex-direction: column; padding: 12px 20px; }
/* Same specificity as .doc-tab-panel above (two classes each) -- without this,
   source order alone decides the tie and [hidden] silently loses, so the Documents
   panel never actually hides and shows through under every other tab. */
.facesheet-tab-panel.doc-tab-panel[hidden] { display: none; }
.doc-tab-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.facesheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 24px;
  align-items: stretch;
}

.alphabet-picker { display: flex; flex-wrap: wrap; gap: 3px; padding: 4px 20px 10px; flex-shrink: 0; }
.alphabet-picker button {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--navy);
  font-size: 11px;
  padding: 4px 7px;
  border-radius: 4px;
  cursor: pointer;
  min-width: 24px;
}
.alphabet-picker button:hover { border-color: var(--teal); }
.alphabet-picker button.active { background: var(--navy); color: white; border-color: var(--navy); }

.split-body { display: flex; flex: 1; overflow: hidden; min-width: 0; min-height: 0; }
.split-body .list-scroll { flex: 1; overflow: auto; min-width: 0; }

.side-column {
  width: 220px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--card-bg);
  padding: 14px 16px;
  overflow-y: auto;
}
.side-column h4 {
  margin: 0 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.recent-list li {
  font-size: 13px;
  color: var(--navy);
  cursor: pointer;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.recent-list li:hover { color: var(--teal); }
.recent-list li.empty-state { color: var(--text-muted); cursor: default; border-bottom: none; }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--navy); }
th.sortable .arrow { font-size: 10px; }

.settings-layout { display: flex; flex: 1; overflow: hidden; min-width: 0; min-height: 0; }
.settings-nav {
  width: 180px;
  flex-shrink: 0;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 0;
}
.settings-nav div {
  padding: 8px 18px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.settings-nav div:hover { color: var(--navy); background: var(--bg); }
.settings-nav div.active { color: var(--navy); font-weight: 600; background: var(--bg); }
.settings-content { flex: 1; overflow: auto; padding: 20px 24px; min-width: 0; }

.badge.stage { font-weight: 600; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  padding: 4px 20px 20px;
  overflow: auto;
  flex: 1;
  align-content: start;
  min-width: 0;
}

.record-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: box-shadow 0.1s ease, border-color 0.1s ease;
}
.record-card:hover { border-color: var(--teal); box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08); }

.record-card .name { font-weight: 600; color: var(--navy); font-size: 14px; margin-bottom: 2px; }
.record-card .badges { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.record-card .contact-line { font-size: 12px; color: var(--text); margin-top: 2px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: #eef2f6;
  color: var(--navy);
}
.badge.chapter { background: rgba(44, 139, 147, 0.12); color: var(--teal); }
.badge.status { background: rgba(111, 191, 79, 0.15); color: #4a8f2f; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.card h3 {
  margin: 0;
  padding: 12px 16px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--navy);
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
}

.card .body { padding: 14px 16px; overflow-x: auto; }
.card .empty-state { padding: 14px 16px; font-size: 13px; }

.info-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  row-gap: 8px;
  font-size: 13px;
}

.info-grid dt { color: var(--text-muted); }
.info-grid dd { margin: 0; }

/* Free Case Evaluation form */
.eval-section { margin-bottom: 16px; }
.eval-section:last-child { margin-bottom: 0; }
.eval-section h4 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--teal);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.eval-stack { display: flex; flex-direction: column; gap: 10px; }
.eval-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.eval-field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.eval-field input,
.eval-field select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: white;
}
.eval-other-input { margin-top: 6px; }
.eval-yesno-row { display: flex; align-items: center; gap: 14px; }
.eval-radio {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
}
.eval-radio input { width: auto; padding: 0; }
.eval-notes-input { flex: 1; min-width: 0; }

/* Documents module (Phase 1 completeness scan) */

/* A single lit signal light (like a caution-light lamp) with the completeness %
   right on the lamp face — one compact element instead of 3 lamps + a separate number,
   so a column can do double duty and other columns get the freed-up space. */
.completeness-light {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 800;
  color: #cfd3d9;
  background: radial-gradient(circle at 35% 30%, #4a5468, #232a38 75%);
  border: 2px solid #171c27;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
}
.completeness-light[data-state="red"] {
  color: white;
  background: radial-gradient(circle at 35% 30%, #ff8f8f, #c0392b 75%);
  box-shadow: 0 0 10px 3px rgba(229, 72, 77, 0.75), inset 0 0 5px rgba(0, 0, 0, 0.25);
  border-color: #7a241c;
}
.completeness-light[data-state="amber"] {
  color: white;
  background: radial-gradient(circle at 35% 30%, #ffd27f, #d98c2b 75%);
  box-shadow: 0 0 10px 3px rgba(245, 166, 35, 0.75), inset 0 0 5px rgba(0, 0, 0, 0.25);
  border-color: #8a5a16;
}
.completeness-light[data-state="green"] {
  color: white;
  background: radial-gradient(circle at 35% 30%, #a8e08f, #6fbf4f 75%);
  box-shadow: 0 0 10px 3px rgba(111, 191, 79, 0.75), inset 0 0 5px rgba(0, 0, 0, 0.25);
  border-color: #2f5c1d;
}
.completeness-light-large { width: 68px; height: 68px; font-size: 18px; border-width: 3px; }

/* Full per-section chips for the all-cases list (e.g. "BS — BOA (4/6)") — every
   category, same red/amber/green/review coloring as the case-sheet checklist. */
.doc-chip-cell { max-width: 420px; }
.doc-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin: 2px 4px 2px 0;
}
.doc-chip-red { background: rgba(192, 57, 43, 0.12); color: #c0392b; }
.doc-chip-amber { background: rgba(217, 140, 43, 0.15); color: #a3630f; }
.doc-chip-review { background: rgba(127, 147, 171, 0.16); color: #55677e; }
.doc-chip-green { background: rgba(111, 191, 79, 0.15); color: #4a8a34; }
.doc-chip-na { background: rgba(44, 139, 147, 0.14); color: #1f6d74; }
.doc-row-rescan {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--navy);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.doc-row-rescan:disabled { opacity: 0.6; cursor: default; }

/* Full checklist for the case face sheet. */
.doc-scan-summary { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; flex-shrink: 0; }
.doc-scan-summary-text { flex: 1; }
.doc-scan-status-label { font-size: 12px; color: var(--text-muted); }
.doc-scan-actions { display: flex; gap: 8px; flex-shrink: 0; }
.doc-toggle-all-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--navy);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.doc-finding-groups { display: flex; flex-direction: column; gap: 2px; }

/* Section headers matching the firm's own Prefiling Doc Checklist categories, with a
   total file count on the right -- collapsed by default, same as the items inside. */
.doc-section-group { border-bottom: 1px solid var(--border); }
.doc-section-group:last-child { border-bottom: none; }
.doc-section-group summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.doc-section-group summary::-webkit-details-marker { display: none; }
.doc-section-group summary:hover { background: var(--bg-alt, #f4f6f8); }
.doc-section-label {
  flex: 1;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--navy);
}
.doc-section-count { font-size: 11px; color: var(--text-muted); font-weight: 600; flex-shrink: 0; }
.doc-section-body { padding-left: 16px; }

.doc-finding-group { border-bottom: 1px solid var(--border); }
.doc-finding-group:last-child { border-bottom: none; }
.doc-finding-group summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.doc-finding-group summary::-webkit-details-marker { display: none; }
.doc-finding-group summary:hover { background: var(--bg-alt, #f4f6f8); }
.doc-finding-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.doc-finding-label { font-size: 13px; color: var(--text); flex: 1; }
.doc-finding-status { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.doc-na-btn {
  flex-shrink: 0;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}
.doc-na-btn:hover { border-color: var(--teal); color: var(--teal); }
.doc-finding-files { padding: 2px 0 8px 24px; display: flex; flex-direction: column; gap: 3px; }
.doc-finding-empty { font-size: 12px; color: var(--text-muted); }
.doc-file-link {
  font-size: 12px;
  color: var(--teal);
  cursor: pointer;
  text-decoration: underline;
  width: fit-content;
}
.doc-file-link:hover { color: var(--navy); }
.doc-file-link.active { color: var(--navy); font-weight: 700; text-decoration: none; }

/* Live preview pane (Windows Explorer style) — sits beside the checklist, content
   swaps in place as a different file is clicked, no per-file popup. */
.doc-body-split { display: flex; gap: 0; align-items: stretch; flex: 1; min-height: 0; }
.doc-checklist-col { flex: 0 0 320px; min-width: 200px; max-width: 640px; overflow-y: auto; padding-right: 4px; }

/* Drag-to-resize handle between the checklist and the preview pane. */
.doc-resize-handle { flex-shrink: 0; width: 10px; cursor: col-resize; position: relative; }
.doc-resize-handle::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: 2px;
  background: var(--border);
  border-radius: 1px;
  transition: background 0.1s ease;
}
.doc-resize-handle:hover::after,
.doc-resize-handle.dragging::after { background: var(--teal); }
.doc-preview-col {
  flex: 1;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f8fa;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.doc-preview-empty { margin: auto; color: var(--text-muted); font-size: 13px; text-align: center; padding: 20px; }
.doc-preview-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  background: white;
  position: sticky;
  top: 0;
  width: 100%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
}
.doc-preview-filename { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-preview-rename-btn,
.doc-preview-rename-save,
.doc-preview-rename-cancel {
  flex-shrink: 0;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--navy);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.doc-preview-rename-btn:hover { border-color: var(--teal); color: var(--teal); }
.doc-preview-rename-input {
  flex: 1;
  min-width: 0;
  padding: 3px 7px;
  border: 1px solid var(--teal);
  border-radius: 5px;
  font-size: 12px;
  font-family: inherit;
}
.doc-preview-content { width: 100%; flex: 1; min-height: 0; }
.doc-preview-frame { width: 100%; height: 100%; border: none; display: block; }
.doc-preview-image { max-width: 100%; display: block; margin: 12px auto; }
.doc-preview-text { white-space: pre-wrap; padding: 12px; font-size: 12px; margin: 0; }
.doc-preview-table { overflow: auto; padding: 0 12px 12px; }
.doc-preview-table table { border-collapse: collapse; font-size: 12px; }
.doc-preview-table td,
.doc-preview-table th { border: 1px solid var(--border); padding: 3px 7px; white-space: nowrap; }
.doc-preview-doc { padding: 16px 20px; background: white; line-height: 1.6; font-size: 13px; }

/* Client Notes / Comms activity timeline */
.activity-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.activity-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: none; }
.activity-row-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.activity-type-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg-alt, #eef2f5);
  color: var(--navy);
  flex-shrink: 0;
}
.activity-date { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.activity-contact { font-size: 12px; color: var(--teal); font-weight: 600; margin-left: auto; }
.activity-summary { font-size: 13px; color: var(--text); }
.activity-detail { font-size: 12px; color: var(--text-muted); margin-top: 3px; white-space: pre-wrap; }

.eval-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.eval-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
}
.eval-row:last-child { border-bottom: none; }
.eval-row:hover { color: var(--teal); }
.eval-date { color: var(--text-muted); font-size: 12px; width: 90px; flex-shrink: 0; }
.eval-type { font-weight: 600; flex: 1; }
.eval-by { color: var(--text-muted); font-size: 12px; }

/* Login / forced password-change gate */
#auth-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
#auth-screen[hidden] { display: none; }
.auth-box { width: 320px; padding: 32px; text-align: center; }
.auth-box img { display: block; margin: 0 auto 20px; max-width: 200px; }
.auth-box input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.auth-box button[type="submit"] {
  width: 100%;
  padding: 9px;
  border: none;
  border-radius: 6px;
  background: var(--teal);
  color: white;
  font-weight: 600;
  cursor: pointer;
}
.auth-box button[type="submit"]:hover { background: var(--navy); }
.auth-note { font-size: 13px; color: var(--text-muted); margin: 0 0 12px; }
.pw-field { position: relative; }
.pw-field input { padding-right: 34px; }
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  opacity: 0.5;
  padding: 4px;
}
.pw-toggle:hover { opacity: 0.9; }
.pw-toggle.active { opacity: 1; }
.auth-msg { min-height: 18px; margin-top: 10px; font-size: 13px; }
.auth-msg.error { color: #b00020; }
.auth-msg.ok { color: #1a7a3a; }
#forgot-password-link { display: inline-block; margin-top: 14px; font-size: 12px; color: var(--text-muted); }

.new-user-form { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; }
.new-user-form[hidden] { display: none; }
