/* OFT Law Design System — Discovery & Document Review Platform */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap');

:root {
  --oft-navy: #000043;
  --oft-navy-dark: #000030;
  --oft-navy-light: #0d1259;
  --oft-emerald: #15a387;
  --oft-emerald-dark: #0e7d67;
  --oft-emerald-light: #e8f7f4;
  --oft-emerald-subtle: #f0fbf9;
  --oft-gold: #c89d5c;
  --oft-red: #dc2626;
  --oft-red-light: #fef2f2;
  --oft-blue: #2563eb;
  --oft-blue-light: #eff6ff;

  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-dark: var(--oft-navy);
  --bg-dark-hover: var(--oft-navy-light);
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --primary: var(--oft-emerald);
  --primary-hover: var(--oft-emerald-dark);
  --primary-light: var(--oft-emerald-light);
  --hot: #dc2626;
  --hot-bg: #fef2f2;
  --reviewed: #15a387;
  --reviewed-bg: #e8f7f4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --highlight-bg: #fef08a;
  --highlight-active: #f97316;

  --font-serif: 'DM Serif Display', Georgia, serif;
  --font-sans: 'Open Sans', system-ui, -apple-system, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

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

body {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-main);
  background: var(--bg-app);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.serif-title {
  font-family: var(--font-serif);
  font-weight: 400;
  color: var(--oft-navy);
}

.hidden {
  display: none !important;
}

/* ─── Top OFT Law Navigation Bar ────────────────────────────────────── */
.topbar {
  height: 56px;
  background: var(--oft-navy);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 48, 0.22);
  flex-shrink: 0;
  z-index: 30;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-logo {
  height: 32px;
  width: auto;
}

.brand-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.22);
}

.brand-text-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 17px;
  letter-spacing: 0.03em;
  color: #ffffff;
  white-space: nowrap;
}

.brand-badge {
  background: var(--oft-emerald);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.06em;
}

.case-select {
  background: var(--oft-navy-light);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  padding: 5px 10px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  max-width: 240px;
}

.topbar-search {
  flex: 1;
  max-width: 640px;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--oft-navy-light);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  padding: 0 9px;
  transition: border-color 0.15s, background 0.15s;
}

.search-input-wrap:focus-within {
  border-color: var(--oft-emerald);
  background: var(--oft-navy-dark);
}

.search-icon {
  font-size: 13px;
  margin-right: 6px;
  opacity: 0.8;
}

#searchInput {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 7px 0;
  outline: none;
}

#searchInput::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.search-clear {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
}

.search-help-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 4px;
}

.popover {
  position: absolute;
  top: 44px;
  left: 0;
  width: 480px;
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 67, 0.2);
  padding: 12px;
  z-index: 100;
}

.popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  color: var(--oft-navy);
}

.syntax-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.syntax-list code {
  background: var(--oft-emerald-light);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  color: var(--oft-emerald-dark);
  font-weight: 700;
}

.user-pill {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
}

/* ─── Buttons & Badges ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 5px;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11.5px;
}

.btn-primary {
  background: var(--oft-emerald);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--oft-emerald-dark);
}

.btn-secondary {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: #fff;
}

.workspace .btn-secondary {
  background: var(--bg-subtle);
  color: var(--oft-navy);
  border-color: var(--border-strong);
}

.workspace .btn-secondary:hover:not(:disabled) {
  background: #e2e8f0;
}

.btn-outline-sm {
  background: var(--bg-surface);
  color: var(--oft-navy);
  border: 1px solid var(--border-strong);
}

.btn-outline-sm:hover:not(:disabled) {
  background: var(--oft-emerald-subtle);
  border-color: var(--oft-emerald);
  color: var(--oft-emerald-dark);
}

.btn-fullscreen {
  background: var(--oft-navy);
  color: #ffffff;
  border: 1px solid var(--oft-navy);
}

.btn-fullscreen:hover {
  background: var(--oft-navy-light);
}

.btn-ghost {
  background: transparent;
  color: inherit;
  border-color: rgba(255, 255, 255, 0.22);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}

.workspace .btn-ghost {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.workspace .btn-ghost:hover:not(:disabled) {
  background: var(--bg-subtle);
}

.icon-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.icon-btn-sm {
  background: transparent;
  border: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--oft-emerald);
  color: #fff;
}

.badge-muted {
  background: var(--bg-subtle);
  color: var(--oft-navy);
  border: 1px solid var(--border-strong);
}

.badge-conf {
  background: var(--oft-red-light);
  color: var(--oft-red);
  border: 1px solid #fecaca;
}

.doc-pos-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 2px 7px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

/* ─── Main 3-Pane Workspace ─────────────────────────────────────────── */
.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* 1. Left Facets Sidebar */
.sidebar {
  width: 245px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 10px 0;
}

.sidebar.collapsed {
  display: none;
}

.sidebar-section {
  padding: 6px 10px 10px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--oft-navy);
  margin-bottom: 6px;
}

.sidebar-header-row .sidebar-title {
  margin-bottom: 0;
}

.tag-mode-toggle {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.mode-btn {
  border: none;
  background: transparent;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  cursor: pointer;
  color: var(--text-muted);
}

.mode-btn.active {
  background: var(--oft-emerald);
  color: #fff;
}

.facet-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.facet-scroll {
  max-height: 190px;
  overflow-y: auto;
}

.facet-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 5px 8px;
  border-radius: 5px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--text-main);
  cursor: pointer;
  gap: 6px;
}

.facet-item:hover {
  background: var(--oft-emerald-subtle);
}

.facet-item.active {
  background: var(--oft-emerald-light);
  color: var(--oft-navy);
  font-weight: 700;
  border-left: 3px solid var(--oft-emerald);
}

.facet-label-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.facet-count {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* 2. Center Document List Pane */
.doclist-pane {
  width: 405px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.doclist-header {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doclist-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--oft-navy);
  font-size: 12.5px;
  cursor: pointer;
}

.sort-select {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 12px;
  color: var(--oft-navy);
  font-weight: 600;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--oft-emerald-light);
  color: var(--oft-navy);
  border: 1px solid rgba(21, 163, 135, 0.3);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}

.filter-pill button {
  border: none;
  background: none;
  color: var(--oft-emerald-dark);
  cursor: pointer;
  font-weight: 700;
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  background: var(--oft-emerald-light);
  border: 1px solid rgba(21, 163, 135, 0.35);
  padding: 5px 8px;
  border-radius: 6px;
}

.bulk-count {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--oft-navy);
  margin-right: auto;
}

.doclist-items {
  flex: 1;
  overflow-y: auto;
}

.doc-card {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.doc-card:hover {
  background: var(--oft-emerald-subtle);
}

.doc-card.selected {
  background: var(--oft-emerald-light);
  border-left: 4px solid var(--oft-emerald);
  padding-left: 6px;
}

.doc-card-check {
  margin-top: 3px;
}

.doc-card-body {
  flex: 1;
  min-width: 0;
}

.doc-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}

.doc-bates {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--oft-navy);
}

.doc-badges {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.mini-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.mini-badge.native {
  background: #fef3c7;
  color: #b45309;
}

.mini-badge.hits {
  background: #fef08a;
  color: #854d0e;
}

.mini-badge.reviewed {
  background: var(--reviewed-bg);
  color: var(--oft-emerald-dark);
}

.mini-badge.hot {
  background: var(--hot-bg);
  color: var(--hot);
}

.doc-title {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.doc-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.doc-snippet {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-snippet mark,
.doc-text-content mark,
.native-table mark {
  background: var(--highlight-bg);
  color: #0f172a;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

.doc-text-content mark.active-hit {
  background: var(--highlight-active);
  color: #fff;
  outline: 2px solid var(--highlight-active);
}

.doc-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.tag-chip-sm {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  color: #fff;
}

.doclist-footer {
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-info {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* 3. Right Viewer & Coding Pane */
.viewer-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  min-width: 0;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 8px;
  padding: 24px;
  text-align: center;
}

.empty-icon {
  font-size: 40px;
}

.empty-state code {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
}

.active-viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.viewer-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.viewer-bates-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewer-bates {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--oft-navy);
}

.viewer-nav-btns {
  display: flex;
  gap: 4px;
  margin-left: 4px;
}

.viewer-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  max-width: 480px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: 7px;
  border: 1px solid var(--border);
}

.viewer-tab {
  border: none;
  background: transparent;
  padding: 5px 10px;
  border-radius: 5px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.viewer-tab.active {
  background: var(--oft-navy);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 67, 0.15);
}

.tab-badge {
  background: #fef08a;
  color: #854d0e;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10.5px;
}

.viewer-coding-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.coding-btn {
  padding: 5px 11px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-secondary);
  transition: all 0.12s;
}

.coding-btn:hover {
  border-color: var(--oft-navy);
  color: var(--oft-navy);
}

.coding-btn.active-hot {
  background: var(--hot);
  color: #fff;
  border-color: var(--hot);
}

.coding-btn.active-reviewed {
  background: var(--oft-emerald);
  color: #fff;
  border-color: var(--oft-emerald);
}

/* ─── Full-Screen / Zen Focus Review Mode ───────────────────────────── */
body.fullscreen-mode .topbar,
body.fullscreen-mode .sidebar,
body.fullscreen-mode .doclist-pane {
  display: none !important;
}

body.fullscreen-mode .viewer-pane {
  width: 100vw;
  height: 100vh;
}

body.fullscreen-mode .viewer-header {
  background: var(--oft-navy);
  color: #ffffff;
  border-bottom: 1px solid var(--oft-navy-light);
  padding: 10px 18px;
}

body.fullscreen-mode .viewer-bates {
  color: #ffffff;
  font-size: 15px;
}

body.fullscreen-mode .viewer-subtitle {
  color: rgba(255, 255, 255, 0.78);
  max-width: 650px;
}

body.fullscreen-mode .doc-pos-badge {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

body.fullscreen-mode .viewer-tabs {
  background: var(--oft-navy-light);
  border-color: rgba(255, 255, 255, 0.2);
}

body.fullscreen-mode .viewer-tab {
  color: rgba(255, 255, 255, 0.8);
}

body.fullscreen-mode .viewer-tab.active {
  background: var(--oft-emerald);
  color: #ffffff;
}

body.fullscreen-mode .btn-fullscreen {
  background: var(--oft-gold);
  border-color: var(--oft-gold);
  color: var(--oft-navy-dark);
  font-weight: 800;
}

/* ─── Email / Attachment Family Bar ─────────────────────────────────── */
.family-bar {
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
}

.family-bar-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #92400e;
  white-space: nowrap;
}

.family-members-list {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
}

.family-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 5px;
  background: #fff;
  border: 1px solid #fcd34d;
  font-size: 11.5px;
  color: #78350f;
  cursor: pointer;
  white-space: nowrap;
}

.family-pill.current {
  background: var(--oft-navy);
  color: #fff;
  border-color: var(--oft-navy);
  font-weight: 700;
}

/* ─── Coding Strip (Tags + Notes Toggle) ────────────────────────────── */
.coding-strip {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.tags-area {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.strip-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--oft-navy);
}

.doc-tags-list {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.doc-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  color: #fff;
}

.doc-tag-pill button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
}

.add-tag-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.tag-input {
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 12px;
  width: 150px;
}

.tag-input:focus {
  outline: none;
  border-color: var(--oft-emerald);
}

.family-tag-check {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ─── Viewer Body & In-DOM PDF.js Canvas Viewer ─────────────────────── */
.viewer-body {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.viewer-panel {
  flex: 1;
  display: none;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.viewer-panel.active {
  display: flex;
}

.pdf-toolbar {
  padding: 6px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.pdf-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pdf-page-indicator {
  font-size: 12px;
  font-weight: 600;
  color: var(--oft-navy);
}

.pdf-page-input {
  width: 48px;
  padding: 2px 5px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 12px;
  text-align: center;
  font-weight: 700;
}

.pdf-zoom-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 64px;
  text-align: center;
}

.pdf-canvas-container {
  flex: 1;
  overflow: auto;
  background: #475569;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  outline: none;
}

.pdf-page-wrapper {
  background: #ffffff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.32);
  border-radius: 2px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pdf-page-wrapper canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.pdf-page-number-tag {
  position: absolute;
  bottom: 8px;
  right: 10px;
  background: rgba(0, 0, 67, 0.72);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  pointer-events: none;
}

/* Text & Search Hits View */
.text-panel-toolbar {
  padding: 8px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.hit-nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hit-counter {
  font-size: 12px;
  font-weight: 600;
  color: var(--oft-navy);
}

.doc-text-content {
  flex: 1;
  overflow-y: auto;
  padding: 22px 30px;
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.bates-cite-link {
  color: var(--oft-emerald-dark);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  background: var(--oft-emerald-light);
  padding: 0 5px;
  border-radius: 3px;
}

.bates-cite-link:hover {
  background: #cceee6;
}

/* Native / Spreadsheet Preview */
.native-toolbar {
  padding: 6px 12px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.sheet-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.sheet-tab-btn {
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.sheet-tab-btn.active {
  background: var(--oft-navy);
  color: #fff;
  border-color: var(--oft-navy);
}

.native-preview-container {
  flex: 1;
  overflow: auto;
  background: var(--bg-surface);
  padding: 10px;
}

.native-table {
  border-collapse: collapse;
  font-size: 12px;
  width: max-content;
  min-width: 100%;
}

.native-table th,
.native-table td {
  border: 1px solid var(--border);
  padding: 5px 8px;
  text-align: left;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.native-table th {
  background: var(--oft-navy);
  color: #ffffff;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 2;
}

.native-table tr:nth-child(even) td {
  background: #f8fafc;
}

/* Metadata Table */
.meta-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  background: var(--bg-surface);
}

.meta-table {
  width: 100%;
  max-width: 820px;
  border-collapse: collapse;
}

.meta-table th,
.meta-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 12.5px;
}

.meta-table th {
  width: 190px;
  color: var(--oft-navy);
  font-weight: 700;
  background: var(--bg-subtle);
}

/* ─── Attorney Comments / Notes Drawer ──────────────────────────────── */
.comments-drawer {
  width: 290px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.comments-drawer.collapsed {
  display: none;
}

.comments-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--oft-navy);
}

.reviewed-by-label {
  font-size: 11px;
  color: var(--oft-emerald-dark);
  font-weight: 600;
}

.comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comment-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}

.comment-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.comment-author {
  font-weight: 700;
  color: var(--oft-navy);
}

.comment-body {
  font-size: 12.5px;
  white-space: pre-wrap;
  line-height: 1.4;
}

.comment-form {
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comment-form textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 12.5px;
  resize: vertical;
}

.comment-form textarea:focus {
  outline: none;
  border-color: var(--oft-emerald);
}

.comment-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.comment-author-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── Modals ────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 48, 0.58);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: var(--bg-surface);
  border-radius: 10px;
  width: 520px;
  max-width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 67, 0.25);
}

.modal-lg {
  width: 680px;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}

.modal-hint {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.45;
}

.pleadings-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pleading-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg-subtle);
}

.pleading-card-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--oft-navy);
  margin-bottom: 2px;
}

.pleading-card-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.form-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--oft-navy);
}

.form-row input {
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.ingest-status {
  margin-top: 12px;
  padding: 10px;
  border-radius: 6px;
  background: var(--oft-emerald-light);
  color: var(--oft-navy);
  font-weight: 600;
}

.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
}

.shortcuts-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

kbd {
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--oft-navy);
}

/* ─── AI Hot Document Sweep & Issue Hunt Components ─────────────────── */
.btn-ai-topbar {
  background: linear-gradient(135deg, #1b998b 0%, #137a6f 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(27, 153, 139, 0.25);
}

.btn-ai-topbar:hover {
  background: linear-gradient(135deg, #20b0a0 0%, #15877b 100%);
}

.badge-ai {
  background: rgba(0, 0, 67, 0.35);
  color: #ffffff;
}

.facet-ai-item {
  border-left: 3px solid var(--oft-emerald);
}

.facet-count-ai {
  background: var(--oft-emerald-light) !important;
  color: var(--oft-emerald-dark) !important;
  font-weight: 700;
}

.mini-badge.ai-high {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
  font-weight: 700;
}

.mini-badge.ai-med {
  background: var(--oft-emerald-light);
  color: var(--oft-emerald-dark);
  border: 1px solid #99f6e4;
}

.doc-ai-rationale-preview {
  font-size: 11px;
  color: #4c1d95;
  background: #f5f3ff;
  border-left: 2.5px solid #7c3aed;
  padding: 3px 6px;
  margin-top: 4px;
  border-radius: 0 4px 4px 0;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ai-banner {
  background: linear-gradient(90deg, #f5f3ff 0%, #effcf9 100%);
  border-bottom: 1px solid #ddd6fe;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-banner-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ai-banner-left {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.ai-score-pill {
  background: #5b21b6;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 1px;
}

.ai-score-pill.score-critical {
  background: #b91c1c;
}

.ai-score-pill.score-med {
  background: var(--oft-emerald-dark);
}

.ai-banner-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.ai-rationale-text {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--oft-navy);
  line-height: 1.4;
}

.ai-quote-text {
  font-size: 11.5px;
  font-style: italic;
  color: #475569;
  border-left: 2px solid var(--oft-gold);
  padding-left: 7px;
}

.ai-suggested-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  margin-top: 2px;
}

.ai-sug-tag-pill {
  font-size: 10.5px;
  font-weight: 600;
  background: #ffffff;
  color: #5b21b6;
  border: 1px dashed #8b5cf6;
  padding: 1px 7px;
  border-radius: 999px;
  cursor: pointer;
}

.ai-sug-tag-pill:hover {
  background: #ede9fe;
}

.ai-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-ai-confirm {
  background: var(--oft-emerald);
  color: #ffffff;
  border: 1px solid var(--oft-emerald-dark);
  font-weight: 700;
}

.btn-ai-confirm:hover {
  background: var(--oft-emerald-dark);
}

.btn-ghost-dark {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}

.btn-ghost-dark:hover {
  background: rgba(15, 23, 42, 0.12);
}

.btn-ai-subtle {
  background: #f5f3ff;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
  font-weight: 700;
}

.btn-ai-subtle:hover {
  background: #ede9fe;
}

.ai-summary-box {
  background: #ffffff;
  border: 1px solid #c4b5fd;
  border-radius: 6px;
  padding: 8px 12px;
}

.ai-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #4c1d95;
  margin-bottom: 4px;
}

.ai-summary-content {
  font-size: 12.5px;
  color: var(--text-main);
  white-space: pre-wrap;
  line-height: 1.45;
}

/* AI Modal */
.ai-modal-tabs {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  gap: 3px;
}

.ai-modal-tab {
  border: none;
  background: transparent;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
}

.ai-modal-tab.active {
  background: var(--oft-navy);
  color: #ffffff;
}

.ai-preset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.ai-preset-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--oft-navy);
}

.ai-preset-chip {
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--oft-navy);
  cursor: pointer;
  transition: all 0.12s;
}

.ai-preset-chip:hover {
  background: var(--oft-emerald-light);
  border-color: var(--oft-emerald);
  color: var(--oft-emerald-dark);
}

.ai-ask-form {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.ai-ask-form input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
}

.ai-ask-form input:focus {
  outline: none;
  border-color: var(--oft-emerald);
}

.ai-ask-status {
  padding: 12px;
  border-radius: 6px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  color: #4c1d95;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 12px;
}

.ai-answer-card {
  background: #f8fafc;
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--oft-navy);
  border-radius: 7px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.ai-answer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: var(--oft-navy);
  font-size: 13px;
}

.ai-answer-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-main);
  white-space: pre-wrap;
}

.ai-matches-header {
  font-size: 12.5px;
  color: var(--oft-navy);
  margin-bottom: 8px;
}

.ai-matches-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-match-card {
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 10px 12px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.12s;
}

.ai-match-card:hover {
  border-color: var(--oft-emerald);
  background: #f8fafc;
}

.ai-match-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.ai-match-bates {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--oft-navy);
  font-size: 12.5px;
}

.ai-match-why {
  font-size: 12px;
  color: var(--text-main);
  font-weight: 600;
  margin-bottom: 3px;
}

.ai-match-quote {
  font-size: 11.5px;
  color: var(--text-muted);
  font-style: italic;
}

.ai-sweep-progress-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f5f3ff;
  border: 1px solid #c4b5fd;
}

.ai-progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: #4c1d95;
  margin-bottom: 6px;
}

.ai-progress-bar-track {
  height: 8px;
  background: #ddd6fe;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}

.ai-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--oft-emerald), #7c3aed);
  transition: width 0.3s ease;
}

.ai-progress-msg {
  font-size: 12px;
  color: var(--text-secondary);
}

.cli-code-box {
  background: #0f172a;
  color: #e2e8f0;
  padding: 10px 12px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  overflow-x: auto;
  line-height: 1.5;
}
