

/* ============================================================
   Base
   ============================================================ */

*,*::before,*::after { box-sizing: border-box; }

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--text);
  background: var(--surface-alt);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================================
   Page header
   ============================================================ */

.page-header {
  flex-shrink: 0;
  background: var(--brand-primary);
  color: var(--text-on-primary);
  padding: var(--space-lg) var(--space-xl);
  font-family: var(--font-headline);
}

.page-header h1 {
  margin: 0 0 var(--space-xs);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-header .subtitle {
  margin: 0;
  font-size: var(--font-size-sm);
  opacity: 0.75;
  font-weight: 400;
}

/* ============================================================
   Controls bar
   ============================================================ */

.controls {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-md) var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.controls-section {
  margin-bottom: var(--space-md);
}

.controls-section:last-child {
  margin-bottom: 0;
}

.controls-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
  display: block;
}

.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  border: 0px solid var(--border);
  border-radius: var(--radius-null);
  background: var(--brand-light-background);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.toggle-btn.active:hover,
.toggle-btn:hover {
  background: var(--brand-accent-1-tint);
  border-color: var(--brand-accent-1);
  color: var(--text);
}

.toggle-btn.active {
  background: var(--brand-primary);
  color: var(--text-on-primary);
  border-color: var(--brand-primary);
}

.toggle-btn.bulk-toggle {
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  font-weight: 600;
  border: 1px solid var(--brand-primary);
  padding: var(--space-xs) var(--space-sm);
}

.toggle-btn.bulk-toggle:hover {
  color: var(--brand-primary);
  background: transparent;
}

.toggle-btn .toggle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.15s ease;
}

.toggle-btn.active .toggle-dot {
  background: var(--text-on-primary);
}

/* ============================================================
   Export button
   ============================================================ */

.controls-actions {
  margin-bottom: 0;
}

.export-btn {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-md);
  background: var(--brand-accent-2);
  color: var(--text-on-primary);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-null);
  cursor: pointer;
  transition: all 0.15s ease;
}

.export-btn:hover {
  background: var(--brand-accent-3-tint);
  border-color: var(--brand-accent-3);
  color: var(--text);
}

/* ============================================================
   Health warning banner
   ============================================================ */

.health-warning {
  flex-shrink: 0;
  background: var(--warn-solid);
  border: 2px solid var(--warn-text);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: 20px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--warn-text);
  line-height: var(--line-height);
  text-align: center;
}

/* ============================================================
   Table wrapper
   ============================================================ */

.table-wrapper {
  padding: var(--space-lg) var(--space-xl);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.table-scroll {
  overflow: auto;
  flex: 1;
  min-height: 0;
}

/* ============================================================
   Comparison table
   ============================================================ */

.comparison-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border-radius: var(--radius-null);
  box-shadow: var(--shadow-md);
  table-layout: fixed;
}

.comparison-table th,
.comparison-table td {
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
}

.comparison-table th:last-child,
.comparison-table td:last-child {
  border-right: none;
}

.comparison-table tr:last-child td {
  border-bottom: none;
}

/* ---- Header row ---- */

.comparison-table thead th {
  background: var(--brand-primary);
  color: var(--text-on-primary);
  font-weight: 600;
  font-size: var(--font-size-sm);
  font-family: var(--font-headline);
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

.comparison-table thead th:first-child {
  border-top-left-radius: var(--radius-null);
}

.comparison-table thead th:last-child {
  border-top-right-radius: var(--radius-null);
}

.comparison-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--radius-null);
}

.comparison-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--radius-null);
}

.comparison-table thead th.corner-cell {
  background: var(--brand-primary);
  z-index: 12;
  position: sticky;
  left: 0;
  width: 160px;
  min-width: 160px;
  max-width: 160px;
}

a.inst-link {
  color: var(--text-on-primary);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

a.inst-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* ---- Theme label column ---- */

.comparison-table .theme-cell {
  background: var(--surface);
  font-weight: 600;
  width: 160px;
  min-width: 160px;
  max-width: 160px;
  position: sticky;
  left: 0;
  z-index: 5;
}

.theme-cell .theme-name {
  color: var(--brand-primary);
  font-size: var(--font-size-base);
}

.theme-cell .theme-element {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  font-weight: 400;
  margin-top: 2px;
  display: block;
}

/* ---- Data cells ---- */

.comparison-table .data-cell {
  min-width: 150px;
  font-size: var(--font-size-sm);
  position: relative;
}

.comparison-table tbody tr:nth-child(even) .data-cell {
  background: var(--surface-hover);
}
.comparison-table tbody tr:nth-child(even) .theme-cell {
  background: var(--surface-hover);
}

/* ---- Rule entry ---- */

.rule-entry {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-light);
}

.rule-entry:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.rule-number {
  font-family: var(--font-headline);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--brand-primary);
  margin-bottom: var(--space-xs);
  display: block;
}

.rule-summary {
  color: var(--text);
  line-height: var(--line-height);
  margin-bottom: var(--space-sm);
}

/* ---- Source locator ---- */

.source-locator {
  display: inline-block;
  background: var(--brand-accent-light);
  color: var(--brand-accent);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-null);
  border: 1px solid rgba(192, 144, 44, 0.25);
  line-height: 1.4;
  word-break: break-word;
}

.source-link {
  display: inline-block;
  margin-top: var(--space-xs);
  font-size: var(--font-size-xs);
  color: var(--brand-primary-light);
  text-decoration: none;
}

.source-link:hover {
  text-decoration: underline;
}

/* ---- Status badges ---- */

.status-badge {
  display: inline-block;
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 2px var(--space-sm);
  border-radius: 999px;
  text-transform: capitalize;
  margin-bottom: var(--space-sm);
}

.status-badge.addressed {
  background: var(--status-addressed-bg);
  color: var(--status-addressed);
}

.status-badge.partially_addressed {
  background: var(--status-partial-bg);
  color: var(--status-partial);
}

.status-badge.not_addressed {
  background: var(--status-not-addressed-bg);
  color: var(--status-not-addressed);
}

/* ---- Not addressed cell ---- */

.not-addressed-msg {
  color: var(--text-muted);
  font-style: italic;
  font-size: var(--font-size-sm);
}

/* ============================================================
   Clickable rule summary
   ============================================================ */

.rule-clickable {
  cursor: pointer;
  transition: color 0.15s ease;
}

.rule-clickable:hover {
  color: var(--brand-accent-1);
}

/* ============================================================
   Modal overlay
   ============================================================ */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
}

.modal-overlay.active {
  display: block;
}

.modal-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border-radius: var(--radius-null);
  box-shadow: var(--shadow-lg);
  width: 640px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  z-index: 10000;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-headline);
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--brand-primary);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.modal-copy {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
  transition: all 0.15s ease;
}

.modal-copy:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 var(--space-xs);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  font-size: var(--font-size-sm);
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
}

/* ============================================================
   Empty state
   ============================================================ */

.empty-state {
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================================
   Footer
   ============================================================ */

.page-footer {
  flex-shrink: 0;
  padding: var(--space-md) var(--space-md);
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  text-align: center;
  border-top: 1px solid var(--border-light);
  background: var(--surface);
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  .page-header,
  .controls,
  .table-wrapper {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }

  .comparison-table .theme-cell {
    min-width: 120px;
    width: 120px;
  }

  .comparison-table .data-cell {
    min-width: 180px;
  }
}
