:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-subtle: #f7f9fa;
  --surface-raised: #ffffff;
  --text: #17232e;
  --text-muted: #536473;
  --text-faint: #5f6e7a;
  --border: #d4dde4;
  --border-strong: #7d8b96;
  --navy-900: #0d263b;
  --navy-800: #12324d;
  --navy-700: #1b4668;
  --green-800: #135b43;
  --green-700: #176e51;
  --green-100: #e4f3ed;
  --blue-100: #e8f0f7;
  --amber-800: #6f4700;
  --amber-100: #fff0cc;
  --red-800: #8f241f;
  --red-100: #fce9e7;
  --violet-800: #573a78;
  --violet-100: #f0e9f8;
  --neutral-100: #edf1f4;
  --focus: #0b67b2;
  --focus-ring: 0 0 0 4px rgba(11, 103, 178, 0.24);
  --shadow-sm: 0 1px 2px rgba(13, 38, 59, 0.05);
  --shadow-md: 0 10px 25px rgba(13, 38, 59, 0.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --content-width: 1200px;
}

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

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg {
  display: block;
  max-width: 100%;
}

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

button,
select {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

a {
  color: var(--navy-700);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--navy-900);
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: var(--focus-ring);
}

::selection {
  background: #c9dff1;
  color: var(--navy-900);
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--navy-900);
  line-height: 1.22;
  letter-spacing: -0.018em;
}

h1 {
  margin-bottom: 0.65rem;
  font-size: clamp(1.9rem, 3.2vw, 2.65rem);
}

h2 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.17rem, 1.8vw, 1.4rem);
}

h3 {
  margin-bottom: 0.8rem;
  font-size: 1.08rem;
}

p {
  margin-bottom: 0.85rem;
}

p:last-child {
  margin-bottom: 0;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.75rem 1rem;
  transform: translateY(-150%);
  border-radius: var(--radius-sm);
  background: var(--navy-900);
  color: #fff;
  font-weight: 700;
  box-shadow: var(--shadow-md);
}

.skip-link:focus {
  transform: translateY(0);
  color: #fff;
}

/* Header and navigation */
.site-header {
  position: relative;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.header-inner,
.footer-inner,
.page {
  width: min(calc(100% - 2.5rem), var(--content-width));
  margin-inline: auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  min-height: 76px;
}

.brand {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.75rem;
  color: var(--navy-900);
  text-decoration: none;
}

.brand:hover {
  color: var(--navy-900);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  margin-top: 0.18rem;
  color: var(--text-muted);
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.main-nav ul {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-link {
  display: block;
  padding: 0.65rem 0.82rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 650;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--surface-subtle);
  color: var(--navy-900);
}

.nav-link[aria-current="page"] {
  background: var(--blue-100);
  color: var(--navy-800);
}

/* Page shell */
.page {
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  padding-block: 2rem 3.5rem;
}

.page:focus {
  outline: none;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  padding-block: 0.35rem 0.4rem;
}

.page-heading > div:first-child {
  max-width: 760px;
}

.page-heading .button {
  flex-shrink: 0;
}

.case-heading {
  align-items: flex-end;
}

.heading-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
}

.eyebrow {
  margin-bottom: 0.45rem;
  color: var(--green-800);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.lead {
  max-width: 72ch;
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 1.03rem;
}

.breadcrumb {
  margin-top: -0.45rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumb li + li::before {
  margin-right: 0.4rem;
  content: "/";
  color: var(--border-strong);
}

.breadcrumb a {
  color: var(--text-muted);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.section-heading h2 {
  margin-bottom: 0.15rem;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 0.93rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.dashboard-grid,
.detail-layout,
.form-layout {
  display: grid;
  align-items: start;
  gap: 1.4rem;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.62fr) minmax(310px, 0.78fr);
}

.detail-layout {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 370px);
}

.form-layout {
  grid-template-columns: minmax(0, 1fr) minmax(290px, 340px);
}

/* Buttons */
.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.66rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button:hover {
  text-decoration: none;
}

.button-primary {
  border-color: var(--navy-800);
  background: var(--navy-800);
  color: #fff;
}

.button-primary:hover {
  border-color: var(--navy-900);
  background: var(--navy-900);
  color: #fff;
}

.button-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--navy-800);
}

.button-secondary:hover {
  border-color: var(--navy-700);
  background: var(--surface-subtle);
  color: var(--navy-900);
}

.button-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--navy-700);
}

.button-ghost:hover {
  background: var(--blue-100);
  color: var(--navy-900);
}

.button-small {
  min-height: 36px;
  padding: 0.48rem 0.7rem;
  font-size: 0.82rem;
}

.button[aria-busy="true"] {
  cursor: progress;
}

.text-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 700;
}

/* Cards and metrics */
.card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.3rem 1rem;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  margin-bottom: 0.2rem;
  font-size: 1.13rem;
}

.card-header p {
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 0.89rem;
}

.card-body {
  padding: 1.25rem 1.3rem;
}

.card-body > :first-child {
  margin-top: 0;
}

.card-footnote {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  margin: 0;
  padding: 0.8rem 1.3rem;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 0.82rem;
}

.card-footnote a {
  font-weight: 700;
}

.card-callout {
  border-color: #b9d3c9;
  background: linear-gradient(145deg, #f7fbf9, #eef7f3);
}

.card-callout h2 {
  color: var(--green-800);
}

.card-sticky {
  position: sticky;
  top: 1rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.metric-grid-compact {
  gap: 0.8rem;
}

.metric-card {
  min-width: 0;
  padding: 1.05rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.metric-card::before {
  display: block;
  width: 26px;
  height: 3px;
  margin-bottom: 0.8rem;
  border-radius: 99px;
  background: var(--green-700);
  content: "";
}

.metric-label {
  margin-bottom: 0.22rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.metric-value {
  margin-bottom: 0.2rem;
  color: var(--navy-900);
  font-size: clamp(1.7rem, 3vw, 2.12rem);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.metric-value-small {
  font-size: clamp(1rem, 1.8vw, 1.28rem);
  letter-spacing: -0.02em;
}

.metric-note {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.8rem;
}

/* Badges, status and alerts */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.33rem;
  padding: 0.23rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 750;
  line-height: 1.35;
  white-space: nowrap;
}

.badge-neutral {
  background: var(--neutral-100);
  color: #354653;
}

.badge-success {
  background: var(--green-100);
  color: var(--green-800);
}

.badge-warning {
  background: var(--amber-100);
  color: var(--amber-800);
}

.badge-danger {
  background: var(--red-100);
  color: var(--red-800);
}

.badge-info {
  background: var(--blue-100);
  color: var(--navy-700);
}

.badge-critical {
  background: var(--violet-100);
  color: var(--violet-800);
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  min-height: 24px;
  margin-bottom: 0.55rem;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-top: -0.45rem;
  padding: 0.72rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.87rem;
}

.status-separator {
  color: var(--border-strong);
}

.status-dot {
  display: inline-block;
  flex-shrink: 0;
  width: 0.58rem;
  height: 0.58rem;
  border-radius: 50%;
}

.status-dot-neutral {
  background: #778692;
}

.status-dot-success {
  background: var(--green-700);
  box-shadow: 0 0 0 3px rgba(23, 110, 81, 0.14);
}

.status-dot-warning {
  background: #a76b00;
  box-shadow: 0 0 0 3px rgba(167, 107, 0, 0.16);
}

.status-dot-danger {
  background: #b9342e;
  box-shadow: 0 0 0 3px rgba(185, 52, 46, 0.14);
}

.alert {
  padding: 0.95rem 1.1rem;
  border: 1px solid;
  border-radius: var(--radius-sm);
  font-size: 0.93rem;
}

.alert:focus {
  outline: none;
}

.alert-error {
  border-color: #e5b7b3;
  background: var(--red-100);
  color: var(--red-800);
}

.alert-warning {
  border-color: #e1c47f;
  background: var(--amber-100);
  color: var(--amber-800);
}

.alert-info {
  border-color: #b9cee0;
  background: var(--blue-100);
  color: var(--navy-700);
}

.alert-title {
  margin-bottom: 0.5rem;
  color: inherit;
  font-size: 1rem;
}

.alert ul {
  margin: 0;
  padding-left: 1.25rem;
}

.alert a {
  color: inherit;
  font-weight: 700;
}

.status-dot + .status-dot {
  margin-left: 0.35rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
  text-align: left;
}

.data-table caption {
  padding: 0.8rem 0.95rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: left;
}

.data-table th,
.data-table td {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid #e4eaee;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.data-table thead th {
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #fafcfd;
}

.table-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table-action {
  text-align: right;
  white-space: nowrap;
}

.cell-primary {
  color: var(--navy-900);
  font-weight: 700;
}

.cell-secondary {
  margin-top: 0.16rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.cell-muted {
  color: var(--text-muted);
}

.table-wrap:focus-visible {
  outline-offset: 2px;
}

.calculation-result-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.calculation-result-header .section-subheading {
  margin-block: 0;
}

.calculation-result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem 0.75rem;
}

.calculation-download-status {
  flex-basis: 100%;
  min-height: 0;
  text-align: right;
}

.calculation-download-status:empty {
  display: none;
}

.calculation-result-body {
  display: grid;
  min-width: 0;
  gap: 0.9rem;
}

.calculation-subsection {
  min-width: 0;
  margin-top: 0.35rem;
}

.calculation-subsection h4 {
  margin-bottom: 0.55rem;
  color: var(--navy-900);
  font-size: 0.94rem;
}

.calculation-nested {
  min-width: 15rem;
}

.calculation-nested .table-wrap {
  margin-top: 0.15rem;
}

.calculation-nested .data-table {
  font-size: 0.82rem;
}

/* States */
.loading-message,
.empty-inline {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.loading-message::before {
  display: inline-block;
  width: 0.72rem;
  height: 0.72rem;
  margin-right: 0.48rem;
  border: 2px solid #b7c5cf;
  border-top-color: var(--navy-700);
  border-radius: 50%;
  content: "";
  animation: spin 900ms linear infinite;
  vertical-align: -0.05em;
}

.state-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 1.1rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
}

.state-panel h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.state-panel p {
  max-width: 68ch;
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.state-panel-error {
  border-color: #dca9a5;
  background: #fffafa;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Lists used by findings, services and documents */
.compact-list,
.finding-list,
.document-list,
.audit-list,
.source-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.service-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  padding-block: 0.7rem;
  border-bottom: 1px solid #e7ecef;
}

.service-row:first-child {
  padding-top: 0;
}

.service-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.service-name {
  margin: 0;
  color: var(--navy-900);
  font-size: 0.92rem;
  font-weight: 750;
}

.service-detail {
  margin: 0.12rem 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.finding-card {
  padding: 0.82rem 0.9rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.finding-card[data-severity="critical"] { border-left-color: var(--violet-800); }
.finding-card[data-severity="high"] { border-left-color: var(--red-800); }
.finding-card[data-severity="medium"] { border-left-color: #a76b00; }
.finding-card[data-severity="low"] { border-left-color: var(--green-700); }
.finding-card[data-severity="info"] { border-left-color: var(--navy-700); }

.finding-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
}

.finding-title {
  margin: 0;
  color: var(--navy-900);
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.35;
}

.finding-description {
  margin: 0.4rem 0 0;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.finding-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin-top: 0.55rem;
  color: var(--text-faint);
  font-size: 0.77rem;
}

.document-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.document-main {
  min-width: 0;
}

.document-name {
  display: block;
  overflow: hidden;
  color: var(--navy-900);
  font-size: 0.91rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.7rem;
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.document-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
}

/* Definition lists */
.definition-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.95rem 1.3rem;
  margin: 0;
}

.definition-grid > div {
  min-width: 0;
}

.definition-grid dt {
  margin-bottom: 0.12rem;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.definition-grid dd {
  margin: 0;
  color: var(--navy-900);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.definition-grid .span-2 {
  grid-column: 1 / -1;
}

.code-block {
  max-height: 17rem;
  margin: 0;
  overflow: auto;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f5f7f8;
  color: #263640;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.section-subheading {
  margin: 1.35rem 0 0.65rem;
  font-size: 1.02rem;
}

/* Confidence and provenance */
.confidence {
  display: inline-flex;
  min-width: 94px;
  align-items: center;
  gap: 0.42rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  white-space: nowrap;
}

.confidence-progress {
  width: 54px;
  height: 6px;
  overflow: hidden;
  appearance: none;
  border: 0;
  border-radius: 99px;
  background: #e0e6ea;
}

.confidence-progress::-webkit-progress-bar {
  width: 54px;
  height: 6px;
  border-radius: 99px;
  background: #e0e6ea;
}

.confidence-progress::-webkit-progress-value {
  border-radius: inherit;
  background: var(--green-700);
}

.confidence-progress::-moz-progress-bar {
  border-radius: inherit;
  background: var(--green-700);
}

.confidence[data-level="medium"] .confidence-progress::-webkit-progress-value { background: #b57608; }
.confidence[data-level="medium"] .confidence-progress::-moz-progress-bar { background: #b57608; }
.confidence[data-level="low"] .confidence-progress::-webkit-progress-value { background: var(--red-800); }
.confidence[data-level="low"] .confidence-progress::-moz-progress-bar { background: var(--red-800); }

.provenance {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.provenance::before {
  content: "↗";
  color: var(--text-faint);
}

/* Forms */
.form-card {
  overflow: visible;
}

.form-section {
  padding: 1.25rem 1.3rem;
  border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
  border-bottom: 0;
}

.fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.fieldset legend {
  margin-bottom: 0.35rem;
  padding: 0;
  color: var(--navy-900);
  font-size: 1.02rem;
  font-weight: 750;
}

.case-details {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
}

.case-details + .case-details {
  margin-top: 1rem;
}

.case-details legend {
  padding-inline: 0.35rem;
  font-size: 0.95rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-grid .span-2,
.calculation-form > .span-2 {
  grid-column: 1 / -1;
}

.form-grid-tight {
  gap: 0.8rem;
}

.calculation-form {
  display: grid;
  gap: 1rem;
}

.calculation-fieldset {
  min-width: 0;
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
}

.calculation-fieldset legend {
  padding-inline: 0.35rem;
  color: var(--navy-900);
  font-size: 0.92rem;
  font-weight: 750;
}

.calculation-fieldset > .field-hint {
  margin-top: 0.75rem;
}

.calculation-form > .field {
  grid-column: 1 / -1;
}

.calculation-form .form-actions .check-row {
  flex: 1 1 100%;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.35rem;
}

.field-full {
  grid-column: 1 / -1;
}

.field label,
.check-row label {
  color: var(--navy-900);
  font-size: 0.88rem;
  font-weight: 700;
}

.field input:not([type="radio"]):not([type="checkbox"]),
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.62rem 0.72rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.35;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

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

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: #788c9b;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--focus);
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.field input[aria-invalid="true"],
.field select[aria-invalid="true"],
.field textarea[aria-invalid="true"] {
  border-color: var(--red-800);
  background: #fffafa;
}

.code-input {
  font-family: var(--font-mono) !important;
  font-size: 0.83rem !important;
  tab-size: 2;
}

.field-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.field-error {
  margin: 0;
  color: var(--red-800);
  font-size: 0.82rem;
  font-weight: 650;
}

.required-mark {
  color: var(--red-800);
  font-weight: 800;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.55rem;
}

.choice-card {
  position: relative;
  display: block;
  min-width: 0;
  cursor: pointer;
}

.choice-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.choice-content {
  display: flex;
  min-height: 76px;
  flex-direction: column;
  justify-content: center;
  padding: 0.72rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.choice-card:hover .choice-content {
  border-color: var(--navy-700);
  background: #fbfdfe;
}

.choice-card input:checked + .choice-content {
  border-color: var(--navy-800);
  background: var(--blue-100);
  box-shadow: inset 0 0 0 1px var(--navy-800);
}

.choice-card input:focus-visible + .choice-content {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.choice-title {
  color: var(--navy-900);
  font-size: 0.93rem;
  font-weight: 800;
}

.choice-description {
  margin-top: 0.16rem;
  color: var(--text-muted);
  font-size: 0.77rem;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.68rem;
}

.check-row input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 auto;
  margin-top: 0.1rem;
  accent-color: var(--navy-800);
}

.check-row .field-hint {
  margin-top: 0.22rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 1.2rem 1.3rem;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
}

.form-actions-compact {
  padding: 0;
  border-top: 0;
  background: transparent;
}

.form-status {
  flex-basis: 100%;
  min-height: 1.25rem;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.form-status.is-error {
  color: var(--red-800);
  font-weight: 650;
}

.form-status.is-success {
  color: var(--green-800);
  font-weight: 650;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.upload-zone {
  padding: 1rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
}

.upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  text-align: center;
}

.upload-icon {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  margin-bottom: 0.15rem;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-100);
  color: var(--navy-700);
  font-size: 1.2rem;
  font-weight: 800;
}

.upload-title {
  color: var(--navy-900);
  font-size: 0.92rem;
  font-weight: 750;
}

.upload-hint {
  color: var(--text-muted);
  font-size: 0.79rem;
}

.upload-zone input[type="file"] {
  width: 100%;
  margin-top: 0.75rem;
  color: var(--text);
  font-size: 0.86rem;
}

.upload-zone input[type="file"]::file-selector-button {
  min-height: 38px;
  margin-right: 0.65rem;
  padding: 0.42rem 0.68rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--navy-800);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.upload-zone.is-dragging {
  border-color: var(--focus);
  background: var(--blue-100);
}

.prose {
  color: var(--text);
  font-size: 0.92rem;
}

.prose h2 {
  font-size: 1.08rem;
}

.step-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.68rem;
}

.step-number {
  display: grid;
  width: 1.6rem;
  height: 1.6rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--green-100);
  color: var(--green-800);
  font-size: 0.76rem;
  font-weight: 800;
}

.audit-controls .card-body {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(220px, 0.65fr);
  align-items: end;
  gap: 1.5rem;
}

.field-inline {
  max-width: 520px;
}

.audit-context {
  padding-left: 1.3rem;
  border-left: 1px solid var(--border);
}

.audit-context-value {
  margin-bottom: 0.18rem;
  color: var(--navy-900);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.audit-list {
  position: relative;
  gap: 0;
}

.audit-entry {
  position: relative;
  display: grid;
  grid-template-columns: 10.5rem minmax(0, 1fr);
  gap: 0.9rem;
  padding: 0.82rem 0 0.82rem 1.15rem;
  border-bottom: 1px solid #e8edf0;
}

.audit-entry::before {
  position: absolute;
  top: 1.13rem;
  left: 0;
  width: 0.46rem;
  height: 0.46rem;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--navy-700);
  box-shadow: 0 0 0 1px var(--border-strong);
  content: "";
}

.audit-entry:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.audit-time {
  color: var(--text-muted);
  font-size: 0.79rem;
  font-variant-numeric: tabular-nums;
}

.audit-action {
  margin: 0;
  color: var(--navy-900);
  font-size: 0.89rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.audit-actor {
  margin: 0.16rem 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.audit-details {
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

/* Rates */
.rate-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.rate-card {
  min-width: 0;
  padding: 1.05rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.rate-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.rate-name {
  margin: 0;
  color: var(--navy-900);
  font-size: 0.9rem;
  font-weight: 750;
}

.rate-period {
  margin: 0.14rem 0 0;
  color: var(--text-faint);
  font-size: 0.77rem;
}

.rate-value {
  margin: 0.8rem 0 0.2rem;
  color: var(--navy-900);
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.1;
}

.rate-value-unit {
  margin-left: 0.12rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: 0;
}

.rate-delta {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.rate-delta.is-up {
  color: var(--red-800);
}

.rate-delta.is-down {
  color: var(--green-800);
}

.rate-source {
  margin: 0.55rem 0 0;
  color: var(--text-faint);
  font-size: 0.78rem;
}

.source-list {
  gap: 0;
}

.source-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid #e8edf0;
}

.source-item:first-child {
  padding-top: 0;
}

.source-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.source-name {
  margin: 0;
  color: var(--navy-900);
  font-size: 0.89rem;
  font-weight: 750;
}

.source-link {
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.source-meta {
  margin: 0.12rem 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* Footer */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 2rem;
  padding-block: 1.25rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer-inner p {
  margin: 0;
}

/* Responsive layout */
@media (max-width: 1000px) {
  .dashboard-grid,
  .detail-layout,
  .form-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .card-sticky {
    position: static;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rate-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-layout > aside {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

@media (max-width: 760px) {
  .header-inner,
  .footer-inner,
  .page {
    width: min(calc(100% - 1.5rem), var(--content-width));
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding-block: 0.8rem;
  }

  .main-nav {
    width: 100%;
    overflow-x: auto;
  }

  .main-nav ul {
    width: max-content;
    gap: 0.15rem;
  }

  .nav-link {
    padding: 0.52rem 0.65rem;
    font-size: 0.86rem;
  }

  .page {
    gap: 1.25rem;
    padding-block: 1.25rem 2.5rem;
  }

  .page-heading {
    flex-direction: column;
    gap: 1rem;
  }

  .page-heading .button {
    width: 100%;
  }

  .heading-actions {
    width: 100%;
  }

  .heading-actions .button {
    flex: 1 1 140px;
    width: auto;
  }

  .metric-grid,
  .rate-grid,
  .form-layout > aside {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .choice-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .choice-content {
    min-height: auto;
  }

  .audit-controls .card-body {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .field-inline {
    max-width: none;
  }

  .audit-context {
    padding-top: 1rem;
    padding-left: 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .audit-entry {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.22rem;
  }

  .document-item {
    grid-template-columns: minmax(0, 1fr);
  }

  .document-actions {
    justify-content: flex-start;
  }

  .definition-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .definition-grid .span-2 {
    grid-column: auto;
  }

  .form-actions .button {
    flex: 1 1 150px;
  }

  .calculation-result-header {
    align-items: stretch;
    flex-direction: column;
  }

  .calculation-result-actions {
    justify-content: flex-start;
  }

  .calculation-result-actions .button {
    flex: 1 1 150px;
  }

  .calculation-download-status {
    text-align: left;
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 440px) {
  .brand-subtitle {
    font-size: 0.66rem;
  }

  .main-nav ul {
    flex-wrap: wrap;
  }

  .card-header,
  .card-body,
  .form-section,
  .form-actions {
    padding-inline: 1rem;
  }

  .status-strip {
    align-items: flex-start;
  }

  .status-separator {
    display: none;
  }

  .form-actions .button {
    width: 100%;
    flex-basis: 100%;
  }
}

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

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .button,
  .card,
  .metric-card,
  .choice-content,
  .badge,
  .alert,
  .state-panel {
    border: 1px solid CanvasText;
  }

  .confidence-progress,
  .status-dot,
  .metric-card::before,
  .audit-entry::before {
    background: CanvasText;
    forced-color-adjust: none;
  }
}

@media print {
  .site-header,
  .site-footer,
  .button,
  .upload-form,
  .calculation-form,
  .heading-actions {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .page {
    width: 100%;
    padding: 0;
  }

  .card,
  .metric-card {
    break-inside: avoid;
    box-shadow: none;
  }
}
