:root {
  --lw-ink: #17363d;
  --lw-ink-soft: #36545a;
  --lw-muted: #60716f;
  --lw-canvas: #f7f7f2;
  --lw-surface: #ffffff;
  --lw-surface-subtle: #f1f4ef;
  --lw-rule: #cad6d2;
  --lw-rule-strong: #9eb0ac;
  --lw-accent: #173f47;
  --lw-accent-soft: #e6f0ed;
  --lw-highlight: #c8f04c;
  --lw-positive: #19764d;
  --lw-warning: #9a5a00;
  --lw-danger: #a4263c;
  --lw-focus: #9ccc22;
  --lw-space-1: 4px;
  --lw-space-2: 8px;
  --lw-space-3: 12px;
  --lw-space-4: 16px;
  --lw-space-5: 20px;
  --lw-space-6: 24px;
  --lw-space-8: 32px;
  --lw-radius-sm: 5px;
  --lw-radius-md: 8px;
  --lw-radius-lg: 12px;
  --lw-shadow-sm: 0 1px 2px rgba(23, 54, 61, 0.05);
  --lw-shadow-md: 0 10px 28px rgba(23, 54, 61, 0.08);
  --lw-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --lw-ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --lw-duration-press: 120ms;
  --lw-duration-fast: 160ms;
  --lw-duration-standard: 220ms;

  /* Compatibility aliases while legacy page rules migrate incrementally. */
  --ink: var(--lw-ink);
  --muted: var(--lw-muted);
  --line: var(--lw-rule);
  --panel: var(--lw-surface);
  --soft: var(--lw-surface-subtle);
  --accent: var(--lw-accent);
  --shadow: var(--lw-shadow-md);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --lw-ink: #edf5f3;
  --lw-ink-soft: #c4d7d3;
  --lw-muted: #a8bfba;
  --lw-canvas: #101b1e;
  --lw-surface: #18282c;
  --lw-surface-subtle: #21363a;
  --lw-rule: #3d5a5e;
  --lw-rule-strong: #668184;
  --lw-accent: #8fd3c5;
  --lw-accent-soft: #23483f;
  --lw-highlight: #c8f04c;
  --lw-positive: #72d5a2;
  --lw-warning: #f3c969;
  --lw-danger: #ff9baa;
  --lw-focus: #d7ff69;
  --ink: var(--lw-ink);
  --muted: var(--lw-muted);
  --line: var(--lw-rule);
  --panel: var(--lw-surface);
  --soft: var(--lw-surface-subtle);
  --accent: var(--lw-accent);
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  --paper: var(--lw-canvas);
  --paper-deep: var(--lw-surface-subtle);
  --eucalyptus: var(--lw-accent-soft);
  --rule: var(--lw-rule);
}

html {
  color-scheme: light;
  background: var(--lw-canvas);
  text-rendering: optimizeLegibility;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .login,
html[data-theme="dark"] .onboarding {
  background: var(--lw-canvas);
  color: var(--lw-ink);
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] .reports,
html[data-theme="dark"] .upload-box,
html[data-theme="dark"] .lex-card,
html[data-theme="dark"] .card,
html[data-theme="dark"] .metric,
html[data-theme="dark"] .dashboard-card,
html[data-theme="dark"] .insight-card,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .onboarding-card,
html[data-theme="dark"] .project-header,
html[data-theme="dark"] .rule-basis-card,
html[data-theme="dark"] .toolbar {
  background: var(--lw-surface) !important;
  color: var(--lw-ink);
  border-color: var(--lw-rule);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .btn,
html[data-theme="dark"] .tab.active,
html[data-theme="dark"] .step.active {
  background-color: var(--lw-surface) !important;
  color: var(--lw-ink);
  border-color: var(--lw-rule-strong);
}

html[data-theme="dark"] th,
html[data-theme="dark"] .tabs,
html[data-theme="dark"] .auth-toggle,
html[data-theme="dark"] .empty,
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .low-volume-state,
html[data-theme="dark"] .lw-empty-state {
  background: var(--lw-surface-subtle) !important;
  color: var(--lw-ink);
}

html[data-theme="dark"] td,
html[data-theme="dark"] th,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .table-scroll {
  border-color: var(--lw-rule);
}

html[data-theme="dark"] .btn.primary {
  background: var(--lw-accent) !important;
  color: #10272b;
}

html[data-theme="dark"] .notice,
html[data-theme="dark"] .findings-summary,
html[data-theme="dark"] .readiness-panel,
html[data-theme="dark"] .term-definition {
  background: var(--lw-accent-soft) !important;
  color: var(--lw-ink);
  border-color: var(--lw-rule-strong);
}

html[data-theme="dark"] aside {
  background: #0c252b;
  color: var(--lw-ink);
  border-color: var(--lw-rule);
}

html[data-theme="dark"] .brand-name {
  color: var(--lw-ink);
}

html[data-theme="dark"] .avatar {
  background: #244b50;
  color: #fff;
}

html[data-theme="dark"] .role-guidance-block,
html[data-theme="dark"] .workflow-stage,
html[data-theme="dark"] .workflow-bar,
html[data-theme="dark"] .kpi-card,
html[data-theme="dark"] .decision-header,
html[data-theme="dark"] .disclosure,
html[data-theme="dark"] .takeaway-item,
html[data-theme="dark"] .next-action,
html[data-theme="dark"] .evidence-row,
html[data-theme="dark"] .example-card,
html[data-theme="dark"] .case-question,
html[data-theme="dark"] .detail-box,
html[data-theme="dark"] .law,
html[data-theme="dark"] .timing-matrix-wrap,
html[data-theme="dark"] .broad-heatmap-wrap,
html[data-theme="dark"] .review-detail-panel,
html[data-theme="dark"] .support-ticket-item,
html[data-theme="dark"] .toast,
html[data-theme="dark"] .matter-mobile-card,
html[data-theme="dark"] .user-menu-panel,
html[data-theme="dark"] .matter-actions-menu summary,
html[data-theme="dark"] .matter-actions-panel,
html[data-theme="dark"] .period-select,
html[data-theme="dark"] .output-row,
html[data-theme="dark"] .recent-tabs span,
html[data-theme="dark"] .matter-summary-strip,
html[data-theme="dark"] .review-minute-grid > div,
html[data-theme="dark"] .review-decision-footer,
html[data-theme="dark"] .activity-entry-body,
html[data-theme="dark"] .detail-section,
html[data-theme="dark"] .secondary-analysis-metrics,
html[data-theme="dark"] .review-mobile-card,
html[data-theme="dark"] .import-qa-decision-card,
html[data-theme="dark"] .donut > div,
html[data-theme="dark"] td {
  background: var(--lw-surface);
  color: var(--lw-ink);
  border-color: var(--lw-rule);
}

html[data-theme="dark"] .kpi-definition,
html[data-theme="dark"] .kpi-ratio,
html[data-theme="dark"] .status,
html[data-theme="dark"] .help,
html[data-theme="dark"] label {
  color: var(--lw-muted);
}

body {
  background: var(--lw-canvas);
  color: var(--lw-ink);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.btn,
[role="button"] {
  touch-action: manipulation;
}

.btn,
button:not(.project-item):not(.nav-item) {
  min-height: 36px;
  border-radius: var(--lw-radius-sm);
  transition:
    transform var(--lw-duration-press) var(--lw-ease-out),
    border-color var(--lw-duration-fast) var(--lw-ease-out),
    background-color var(--lw-duration-fast) var(--lw-ease-out),
    color var(--lw-duration-fast) var(--lw-ease-out),
    box-shadow var(--lw-duration-fast) var(--lw-ease-out);
}

.btn:disabled,
button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.56;
}

.btn:active:not(:disabled),
button:active:not(:disabled),
[role="button"]:active:not([aria-disabled="true"]) {
  transform: scale(0.98);
}

input,
select,
textarea {
  min-height: 38px;
  border-color: var(--lw-rule-strong);
  border-radius: var(--lw-radius-sm);
  background: var(--lw-surface);
  color: var(--lw-ink);
  transition:
    border-color var(--lw-duration-fast) var(--lw-ease-out),
    box-shadow var(--lw-duration-fast) var(--lw-ease-out);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--lw-focus);
  outline-offset: 2px;
}

.panel,
.reports,
.upload-box,
.lex-card,
.card,
.metric,
.dashboard-card,
.insight-card,
.rule-basis-card,
.admin-chip,
.toolbar {
  border-color: var(--lw-rule);
  border-radius: var(--lw-radius-md);
  box-shadow: var(--lw-shadow-sm);
}

.lex-card,
.panel,
.reports,
.upload-box {
  padding: var(--lw-space-4);
}

.section-title {
  gap: var(--lw-space-3);
  margin-bottom: var(--lw-space-3);
}

.section-title h2,
.section-title h3,
.section-title p {
  margin-block: 0;
}

.actions {
  gap: var(--lw-space-2);
}

.field {
  gap: var(--lw-space-2);
  margin-bottom: var(--lw-space-3);
}

.cards,
.metrics,
.dashboard-grid,
.insight-grid,
.module-metrics {
  gap: var(--lw-space-3);
}

.module-metric,
.metric,
.card {
  min-width: 0;
}

.module-metric > b,
.module-metric > strong,
.metric > b,
.metric > strong,
.card > b,
.card > strong {
  display: block;
  margin: 0 0 var(--lw-space-1);
  font-variant-numeric: tabular-nums;
}

.module-metric > span,
.metric > span,
.card > span {
  display: block;
  overflow-wrap: anywhere;
}

.pill,
.status-badge,
.header-badge,
.internal-badge,
.secure-badge {
  border-radius: 999px;
  white-space: nowrap;
}

.table-wrap,
.table-scroll,
.lw-scroll-region {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.presentation-timestamp {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

th,
td {
  padding: 9px 10px;
  vertical-align: top;
}

th {
  background: var(--lw-surface-subtle);
  color: var(--lw-ink);
}

.empty,
.empty-state,
.low-volume-state,
.lw-empty-state {
  border: 1px dashed var(--lw-rule-strong);
  border-radius: var(--lw-radius-md);
  background: var(--lw-surface-subtle);
  padding: var(--lw-space-5);
  color: var(--lw-muted);
}

.pay-code-treatment-menu {
  min-width: 156px;
}

.pay-code-treatment-menu > summary {
  cursor: pointer;
  color: var(--lw-ink-soft);
  font-size: 12px;
  font-weight: 750;
}

.pay-code-treatment-menu[open] > summary {
  margin-bottom: var(--lw-space-2);
}

.heatmap-cell.heatmap-mode-rate.population-small {
  /* De-emphasise only the rate-cell surface; values and population labels stay fully legible. */
  background: #fff9e9;
}

.heatmap-cell.heatmap-mode-rate.population-insufficient {
  background: #f5f6f3;
}

.notice,
.replacement-import-banner,
.role-guidance,
.first-run-guide {
  border-radius: var(--lw-radius-md);
}

.role-guidance {
  padding: 10px 12px;
}

.role-guidance .role-guidance-head {
  align-items: flex-start;
}

.role-guidance .role-guidance-summary {
  max-width: 72ch;
}

.role-guidance .role-guidance-summary h2 {
  font-size: 16px;
}

.role-guidance .role-guidance-summary p {
  margin-top: var(--lw-space-1);
}

.role-guidance > .role-guidance-grid {
  display: none;
}

.role-guidance .role-guidance-footer {
  margin-top: var(--lw-space-1);
}

.role-guidance .role-guidance-access {
  display: none;
}

.lw-page-head {
  gap: var(--lw-space-4);
  margin-bottom: var(--lw-space-4);
}

details.disclosure > summary,
.disclosure > summary {
  min-height: 40px;
  padding: 10px 12px;
  cursor: pointer;
}

.toast {
  transition:
    opacity var(--lw-duration-standard) var(--lw-ease-out),
    transform var(--lw-duration-standard) var(--lw-ease-out);
}

.login-card,
.onboarding-card {
  border-radius: var(--lw-radius-lg);
  box-shadow: var(--lw-shadow-md);
}

main > .topbar,
.admin-shell > main > .topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-block: var(--lw-space-2);
  background: color-mix(in srgb, var(--lw-canvas) 94%, transparent);
  backdrop-filter: blur(10px);
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled),
  button:hover:not(:disabled) {
    box-shadow: 0 3px 10px rgba(23, 54, 61, 0.1);
  }
}

@media (max-width: 700px) {
  main {
    padding-inline: var(--lw-space-3);
  }

  .lex-card,
  .panel,
  .reports,
  .upload-box {
    padding: var(--lw-space-3);
  }

  .actions > .btn,
  .actions > button {
    min-height: 40px;
  }

  .section-title {
    align-items: flex-start;
  }

  .support-board {
    grid-template-columns: 1fr;
    overflow-x: visible;
  }

  .support-column {
    min-height: 0;
  }

  .timeline-row {
    grid-template-columns: 14px minmax(0, 1fr);
    min-width: 0;
  }

  .timeline-row > b,
  .timeline-row > strong,
  .timeline-row > span,
  .timeline-row > button {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .timeline-row > :nth-child(n + 3) {
    grid-column: 2;
    justify-self: start;
    max-width: 100%;
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .btn,
  button,
  .toast,
  input,
  select,
  textarea {
    transition-duration: 80ms;
  }

  .btn:active:not(:disabled),
  button:active:not(:disabled),
  [role="button"]:active:not([aria-disabled="true"]) {
    transform: none;
  }
}
