/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── CSS Variables ── */
:root {
  --orange: #f7951d;
  --orange-hover: #e8880f;
  --navy: #1A3A5C;
  --deep: #0e2640;
  --darker: #091a2e;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(247, 149, 29, 0.4);
  --text-primary: #f1f0ee;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --radius: 0.75rem;
  --risk-flagged: #f7951d;
  --risk-high: #ef4444;
  --risk-medium: #f59e0b;
  --risk-low: #22c55e;
}

/* ── Base ── */
html { scroll-behavior: smooth; }

body {
  font-family: 'Source Sans 3', sans-serif;
  background: var(--darker);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

.heading {
  font-family: 'Barlow Condensed', sans-serif;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--darker); }
::-webkit-scrollbar-thumb { background: var(--orange); border-radius: 3px; }

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 2rem;
  background: var(--deep);
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--orange);
  border: 1px solid var(--orange);
  border-radius: 4px;
  padding: 0.2em 0.6em;
  white-space: nowrap;
}

.powered-by {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--orange);
  color: var(--darker);
}

.btn-primary:hover {
  background: var(--orange-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.btn-sm {
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
}

/* ── Sections ── */
.section {
  display: none;
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 2rem;
}

.section.active {
  display: block;
}

/* ── Upload Zone ── */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem 2rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.upload-zone .upload-icon {
  font-size: 3rem;
  color: var(--orange);
}

.upload-zone h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.upload-zone p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ── Redaction Preview ── */
.redaction-summary {
  margin-bottom: 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.redaction-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  line-height: 1.7;
  max-height: 50vh;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* Redact items - readable text with visual indicators */
.redact-item {
  padding: 0.1em 0.3em;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.redact-item.redacted {
  background: rgba(239, 68, 68, 0.2);
  color: var(--risk-high);
  text-decoration: line-through;
  text-decoration-color: rgba(239, 68, 68, 0.6);
}
.redact-item.redacted:hover {
  background: rgba(239, 68, 68, 0.35);
}

.redact-item.unredacted {
  background: rgba(34, 197, 94, 0.1);
  color: var(--text-primary);
}
.redact-item.unredacted:hover {
  background: rgba(34, 197, 94, 0.25);
}

.redact-item.manual-redacted {
  background: rgba(247, 149, 29, 0.2);
  color: var(--orange);
  text-decoration: line-through;
  text-decoration-color: rgba(247, 149, 29, 0.6);
}
.redact-item.manual-redacted:hover {
  background: rgba(247, 149, 29, 0.4);
}

/* Filter checkboxes */
.redaction-filters {
  margin-bottom: 1rem;
}

.filter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: border-color 0.2s, background 0.2s;
}

.filter-checkbox:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.filter-checkbox input[type="checkbox"] {
  accent-color: var(--orange);
  cursor: pointer;
}

.filter-label {
  font-weight: 600;
}

.filter-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--darker);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

/* ── Custom Terms ── */
.custom-terms-section {
  margin-bottom: 1rem;
}

.custom-terms-section .form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.custom-terms-input-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.custom-term-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.85rem;
  outline: none;
}
.custom-term-input:focus {
  border-color: var(--border-hover);
}

.custom-terms-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.custom-term-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  background: rgba(247, 149, 29, 0.15);
  border: 1px solid rgba(247, 149, 29, 0.3);
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--orange);
}

.custom-term-tag .remove-term {
  cursor: pointer;
  font-size: 0.9rem;
  opacity: 0.7;
  font-family: 'Material Symbols Outlined';
}
.custom-term-tag .remove-term:hover {
  opacity: 1;
}

.redaction-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

/* ── Loader ── */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 4rem 2rem;
  text-align: center;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-align: left;
  margin-top: 0.5rem;
}

.loading-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  transition: color 0.3s;
}

.loading-step.active {
  color: var(--text-primary);
}

.loading-step.done {
  color: var(--risk-low);
}

.step-icon {
  font-size: 1.1rem;
  transition: color 0.3s;
}

.step-icon.pending {
  color: var(--text-muted);
}

.loading-step.active .step-icon {
  color: var(--orange);
  animation: pulse 1s ease-in-out infinite;
}

.loading-step.done .step-icon {
  color: var(--risk-low);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Stats Bar ── */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 0.75rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.stat-value {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

/* ── Dashboard Grid ── */
.dashboard {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 0;
  height: calc(100vh - 6.5rem);
}
.dashboard.no-docviewer { grid-template-columns: 1fr; }
.dashboard.no-docviewer .doc-viewer { display: none; }

.panel {
  background: var(--deep);
  border-right: 1px solid var(--border);
  padding: 1.25rem;
  overflow-y: auto;
}

.panel-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

/* ── Clause Navigator ── */
.clause-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.clause-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  padding: 0.75rem 0 0.35rem;
}

.clause-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.clause-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.clause-item.active {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-left: 3px solid var(--orange);
}

.risk-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.risk-dot.flagged { background: var(--risk-flagged); }
.risk-dot.high { background: var(--risk-high); }
.risk-dot.medium { background: var(--risk-medium); }
.risk-dot.low { background: var(--risk-low); }

/* ── Detail View ── */
.detail-view {
  background: var(--darker);
  border-right: none;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.75rem 1.25rem;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.tab:hover { color: var(--text-primary); }

.tab.active {
  color: var(--orange);
  border-bottom-color: var(--orange);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.clause-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.clause-card h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.original-text {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
  padding: 1rem;
  background: var(--darker);
  border-radius: 6px;
  margin-bottom: 0.75rem;
  border-left: 3px solid var(--border);
}

.explanation {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.replacement {
  position: relative;
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 1rem;
  background: rgba(34, 197, 94, 0.06);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 6px;
  color: var(--text-primary);
}

.replacement .copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.replacement .copy-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* ── Risk Badges ── */
.risk-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15em 0.6em;
  border-radius: 4px;
}

.risk-badge.flagged {
  background: rgba(247, 149, 29, 0.15);
  color: var(--risk-flagged);
}

.risk-badge.high {
  background: rgba(239, 68, 68, 0.15);
  color: var(--risk-high);
}

.risk-badge.medium {
  background: rgba(245, 158, 11, 0.15);
  color: var(--risk-medium);
}

.risk-badge.low {
  background: rgba(34, 197, 94, 0.15);
  color: var(--risk-low);
}

/* ── Chat Panel ── */
.chat-panel {
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 1rem;
}

.chat-bubble {
  max-width: 90%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.5;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--orange);
  color: var(--darker);
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--surface);
  color: var(--text-primary);
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  padding: 0.6rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: var(--border-hover);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 50vh;
  }

  .panel:last-child {
    border-left: none;
    border-bottom: none;
  }
}

/* ── Settings Form ── */
.settings-container {
  max-width: 640px;
  margin: 2rem auto;
  padding: 0 2rem 3rem;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input,
.form-group select {
  padding: 0.6rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group select option {
  background: var(--deep);
  color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--border-hover);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 0.25rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 0.25rem;
}

.settings-section {
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.settings-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.settings-subheading {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Standards Callout (upload page) */
.standards-callout {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 520px;
  margin: 1.25rem auto 0;
  padding: 1rem 1.25rem;
  background: rgba(247, 149, 29, 0.06);
  border: 1px solid rgba(247, 149, 29, 0.2);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.standards-callout:hover {
  border-color: rgba(247, 149, 29, 0.5);
  background: rgba(247, 149, 29, 0.1);
}

.standards-callout > div {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* Standards Intro */
.standards-intro {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem;
  background: rgba(247, 149, 29, 0.06);
  border: 1px solid rgba(247, 149, 29, 0.2);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

/* Standards Link Card (on settings page) */
.standards-link-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.standards-link-card:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.standards-link-card > div:first-child {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.standards-link-card > span:last-child {
  margin-left: auto;
  flex-shrink: 0;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--orange);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Input with $ prefix */
.input-prefix {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.2s;
}

.input-prefix:focus-within {
  border-color: var(--border-hover);
}

.input-prefix span {
  padding: 0 0.5rem 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.input-prefix input {
  border: none !important;
  background: transparent !important;
  padding-left: 0 !important;
  flex: 1;
  min-width: 0;
}

.form-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ── Privacy Note ── */
.privacy-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Sub Requirement Cards ── */
.req-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
}

.req-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.req-card:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.req-card:has(input[type="checkbox"]:checked) {
  border-color: var(--orange);
  background: rgba(247, 149, 29, 0.06);
}

.req-card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.req-card-top input[type="checkbox"] {
  margin-top: 0.2rem;
  accent-color: var(--orange);
  width: auto;
  cursor: pointer;
  flex-shrink: 0;
}

.req-card-detail {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.req-card-detail input {
  font-size: 0.85rem;
}

/* ── Privacy Options ── */
.privacy-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.privacy-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.privacy-option:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.privacy-option:has(input:checked) {
  border-color: var(--orange);
  background: rgba(247, 149, 29, 0.06);
}

.privacy-option input[type="radio"] {
  margin-top: 0.2rem;
  accent-color: var(--orange);
  cursor: pointer;
}

.privacy-option-content {
  flex: 1;
}

.privacy-option-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

/* ── Overview Tab ── */
.overview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.overview-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.overview-card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.overview-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.overview-list li {
  position: relative;
  padding-left: 1.25rem;
  line-height: 1.6;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.overview-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
}

.overview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.overview-table th {
  text-align: left;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.overview-table td {
  padding: 0.6rem 0.75rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.overview-table tr:last-child td {
  border-bottom: none;
}

/* ── Decision Buttons ── */
.decision-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-accept {
  background: transparent;
  color: var(--risk-low);
  border: 1px solid rgba(34, 197, 94, 0.3);
  transition: all 0.3s ease;
}
.btn-accept:hover {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--risk-low);
}
.btn-accept.active {
  background: var(--risk-low);
  color: var(--darker);
  border-color: var(--risk-low);
  font-weight: 700;
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
}

.btn-reject {
  background: transparent;
  color: var(--risk-high);
  border: 1px solid rgba(239, 68, 68, 0.4);
  transition: all 0.3s ease;
}
.btn-reject:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--risk-high);
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-reject.active {
  background: var(--risk-high);
  color: white;
  border-color: var(--risk-high);
  font-weight: 700;
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

.btn-edit {
  background: transparent;
  color: var(--orange);
  border: 1px solid rgba(247, 149, 29, 0.3);
  transition: all 0.3s ease;
}
.btn-edit:hover {
  background: rgba(247, 149, 29, 0.15);
  border-color: var(--orange);
}
.btn-edit.active {
  background: var(--orange);
  color: var(--darker);
  border-color: var(--orange);
  font-weight: 700;
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(247, 149, 29, 0.4);
}

@keyframes decisionPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1.05); }
}

.btn-accept.just-clicked,
.btn-reject.just-clicked,
.btn-edit.just-clicked {
  animation: decisionPulse 0.3s ease;
}

/* ── Decision Icons in Clause Nav ── */
.decision-icon {
  font-family: 'Material Symbols Outlined';
  font-size: 1rem;
  flex-shrink: 0;
}
.decision-icon.accepted { color: var(--risk-low); }
.decision-icon.rejected { color: var(--text-muted); }
.decision-icon.edited { color: var(--orange); }

/* ── Edit Textarea ── */
.edit-textarea {
  width: 100%;
  min-height: 120px;
  padding: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
.edit-textarea:focus {
  border-color: var(--border-hover);
}

/* ── Export Button ── */
.btn-export {
  background: var(--orange);
  color: var(--darker);
  position: relative;
}
.btn-export:hover { background: var(--orange-hover); }
.btn-export:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-export:disabled:hover {
  background: var(--orange);
}

.export-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.2rem;
  height: 1.2rem;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--darker);
  color: var(--orange);
  border-radius: 50%;
  margin-left: 0.35rem;
}

/* ── Sidebar ── */
.sidebar { position: relative; display: flex; flex-direction: column; overflow: hidden; }
.sidebar-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; margin: -1.25rem -1.25rem 0; padding: 0 0.5rem; }
.sidebar-content { flex: 1; overflow-y: auto; padding-top: 1rem; }
.clause-detail-panel { position: absolute; inset: 0; background: var(--deep); overflow-y: auto; padding: 1.25rem; transform: translateX(-100%); transition: transform 0.25s ease; z-index: 3; }
.clause-detail-panel.visible { transform: translateX(0); }
.back-btn { display: inline-flex; align-items: center; gap: 0.3rem; background: none; border: none; color: var(--orange); font-family: 'Source Sans 3', sans-serif; font-size: 0.85rem; font-weight: 600; cursor: pointer; margin-bottom: 1rem; padding: 0.3rem 0; }

/* ── Document Viewer ── */
.doc-viewer { background: var(--darker); border-left: 1px solid var(--border); display: flex; flex-direction: column; border-right: none; }
.doc-viewer-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; flex-shrink: 0; }
.doc-viewer-header .panel-title { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0; }
.doc-viewer-legend { display: flex; gap: 0.75rem; font-size: 0.7rem; color: var(--text-muted); }
.legend-item { display: flex; align-items: center; gap: 0.3rem; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-dot.flagged { background: var(--risk-flagged); }
.legend-dot.high { background: var(--risk-high); }
.legend-dot.medium { background: var(--risk-medium); }
.legend-dot.low { background: var(--risk-low); }
.doc-viewer-content { flex: 1; overflow-y: auto; padding: 0.5rem; background: rgba(0,0,0,0.15); border-radius: 6px; }
.doc-page { margin-bottom: 1rem; background: white; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.doc-page canvas { display: block; width: 100%; height: auto; pointer-events: none; }
.doc-page-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); padding: 0.4rem 0.75rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.doc-page.active-page { outline: 2px solid var(--orange); outline-offset: 2px; }
@keyframes emphasisPulse { 0% { box-shadow: 0 0 0 4px rgba(247, 149, 29, 0.6); } 100% { box-shadow: 0 0 0 0 rgba(247, 149, 29, 0); } }
.doc-loading { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.9rem; }
.doc-rendered-text { background: white; color: #1a1a1a; padding: 2rem 2.5rem; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.3); font-size: 0.9rem; line-height: 1.8; }
.doc-line { padding: 2px 0; margin-bottom: 2px; }
.doc-heading { font-weight: 700; font-size: 1rem; margin-top: 1.25rem; margin-bottom: 0.5rem; color: #111; }
.doc-empty { height: 0.6rem; }

/* ── Back to Top Button ── */
.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  z-index: 99;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.back-to-top:hover { background: var(--orange); color: var(--darker); }
.back-to-top.hidden { opacity: 0; pointer-events: none; transform: translateY(10px); }

/* ── Multi-Select Dropdown ── */
.multi-select { position: relative; max-width: 320px; }
.multi-select-display {
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.multi-select-display::after { content: '\25BC'; font-size: 0.6rem; margin-left: 0.5rem; opacity: 0.5; }
.multi-select-display.has-values { color: var(--text-primary); }
.multi-select-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 2px;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.multi-select.open .multi-select-dropdown { display: block; }
.multi-select-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}
.multi-select-option:hover { background: rgba(247, 149, 29, 0.1); }

/* ── Chat FAB + Drawer ── */
.chat-fab { position: fixed; bottom: 1.5rem; right: 1.5rem; display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1.25rem; background: var(--orange); color: var(--darker); border: none; border-radius: 2rem; font-family: 'Source Sans 3', sans-serif; font-weight: 700; font-size: 0.9rem; cursor: pointer; z-index: 100; box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
.chat-fab.hidden { display: none; }
.chat-drawer { position: fixed; top: 0; right: 0; width: 380px; height: 100vh; background: var(--deep); border-left: 1px solid var(--border); display: flex; flex-direction: column; z-index: 200; transform: translateX(100%); transition: transform 0.3s ease; box-shadow: -4px 0 30px rgba(0,0,0,0.5); }
.chat-drawer.open { transform: translateX(0); }
.chat-drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.btn-icon { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0.25rem; border-radius: 4px; }
.chat-drawer .chat-messages { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; }
.chat-drawer .chat-form { padding: 0.75rem 1.25rem; border-top: 1px solid var(--border); flex-shrink: 0; }

/* ── Flag Clause Modal ── */
.flag-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  backdrop-filter: blur(2px);
}

.flag-modal {
  background: var(--deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 520px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  animation: flagModalIn 0.2s ease-out;
}

@keyframes flagModalIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.flag-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.flag-modal-header h3 {
  font-size: 1.1rem;
  color: var(--orange);
}

.flag-modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flag-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.flag-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.85rem;
  padding: 0.6rem 0.75rem;
  resize: vertical;
  line-height: 1.5;
}

.flag-textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 2px rgba(247, 149, 29, 0.15);
}

.flag-textarea[readonly] {
  opacity: 0.8;
  cursor: default;
}

.flag-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ── PDF Text Layer (for selection) ── */
.doc-text-layer {
  opacity: 1;
  line-height: 1;
  z-index: 2;
  pointer-events: all;
  user-select: none;
  cursor: text;
}

.doc-text-layer > span {
  position: absolute;
  white-space: pre;
  color: transparent;
  pointer-events: all;
  cursor: text;
  user-select: none;
}

/* ── Custom Selection Highlights ── */
.custom-selection-highlight {
  position: absolute;
  background: rgba(247, 149, 29, 0.3);
  border-radius: 2px;
  pointer-events: none;
  z-index: 3;
}

/* ── AI Clause Highlights (client-side overlays) ── */
.clause-highlight {
  position: absolute;
  background: rgba(247, 149, 29, 0.25);
  pointer-events: none;
  z-index: 3;
  transition: background 0.3s ease;
}
.clause-highlight.accepted {
  background: rgba(34, 197, 94, 0.25);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .dashboard { grid-template-columns: 1fr; height: auto; }
  .sidebar { max-height: 45vh; border-right: none; border-bottom: 1px solid var(--border); }
  .doc-viewer { min-height: 50vh; }
  .chat-drawer { width: 100%; }
}
