@font-face {
  font-family: "Forma DJR Micro";
  src: url("fonts/forma-djr-micro-font-family/FormaDJRMicro-Regular-Testing.25c91cf6487c.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Forma DJR Micro";
  src: url("fonts/forma-djr-micro-font-family/FormaDJRMicro-Medium-Testing.ef59f1263144.otf") format("opentype");
  font-weight: 500 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Forma DJR Micro";
  src: url("fonts/forma-djr-micro-font-family/FormaDJRMicro-Bold-Testing.8b55428de181.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --surface: #f7f7f7;
  --surface-pressed: #e8e8e8;
  --ink: #1a1a1a;
  --ink-elevated: #292929;
  --muted: #3d3d3d;
  --mute: #3d3d3d;
  --line: #e8e8e8;
  --line-strong: #c2c2c2;
  --primary: #024ad8;
  --primary-bright: #296ef9;
  --primary-deep: #0e3191;
  --chart-budgeted: #356373;
  --chart-spent: #024ad8;
  --chart-success: var(--success);
  --chart-warning: var(--warning-ink);
  --chart-risk: var(--error);
  --chart-grid: var(--line);
  --chart-axis: var(--graphite, #636363);
  --success: #16856b;
  --success-soft: #dff5ed;
  --success-ink: #17664f;
  --error: #b3262b;
  --error-soft: #f9d4d2;
  --warning-soft: #fff1d6;
  --warning-ink: #7a4d00;
  --sidebar: #1a1a1a;
  --sidebar-muted: #c2c2c2;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  font-family: "Forma DJR Micro", Arial, ui-sans-serif, system-ui, sans-serif;
  font-kerning: normal;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { min-width: 0; margin: 0; background: var(--bg); line-height: 1.5; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
button, input, select { font: inherit; }
button, .button { touch-action: manipulation; }
button, a { -webkit-tap-highlight-color: rgb(0 0 0 / 0.14); }

.shell { width: min(100% - 4rem, 1440px); margin-inline: auto; }
.app-body { display: grid; grid-template-columns: 17rem minmax(0, 1fr); min-height: 100dvh; }
.app-sidebar { position: sticky; top: 0; display: flex; flex-direction: column; gap: var(--space-xl); height: 100dvh; padding: var(--space-lg); background: var(--sidebar); color: var(--surface); }
.app-content { min-width: 0; }
.app-body .app-content .shell { width: min(100% - 4rem, 1280px); }
.sidebar-brand { gap: var(--space-sm); min-height: 3rem; color: var(--surface); }
.sidebar-brand > span:last-child { display: grid; gap: 0.125rem; line-height: 1.1; }
.sidebar-brand strong { font-size: 1rem; }
.sidebar-brand small { color: var(--sidebar-muted); font-size: 0.75rem; font-weight: 500; }
.brand-mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px; background: var(--primary); color: var(--surface); font-size: 0.875rem; font-weight: 700; }
.sidebar-nav { display: grid; gap: var(--space-xs); }
.mobile-menu-toggle { display: none; }
.mobile-nav-dialog { width: min(calc(100vw - 2rem), 20rem); max-width: calc(100vw - 1rem); height: 100dvh; max-height: 100dvh; margin: 0; padding: var(--space-lg); border: 0; background: var(--sidebar); color: var(--surface); }
.mobile-nav-dialog[open] { display: flex; flex-direction: column; }
.mobile-nav-dialog::backdrop { background: rgb(26 26 26 / 0.48); }
.mobile-nav-header { display: flex; align-items: center; justify-content: space-between; min-height: 2.75rem; margin-bottom: var(--space-lg); }
.mobile-nav-header strong { font-size: 1.125rem; }
.mobile-nav-close, .mobile-nav-account button { min-height: 2.75rem; border: 0; background: transparent; color: var(--surface); cursor: pointer; font: inherit; }
.mobile-nav-close { width: 2.75rem; font-size: 1.5rem; line-height: 1; }
.mobile-nav-links { display: grid; gap: var(--space-xs); }
.mobile-nav-links a { display: flex; align-items: center; min-height: 2.75rem; padding-inline: var(--space-sm); border-radius: 8px; color: var(--sidebar-muted); font-weight: 500; text-decoration: none; }
.mobile-nav-links a[aria-current="page"] { background: rgb(255 255 255 / 0.1); color: var(--surface); }
.mobile-nav-account { display: grid; gap: var(--space-xs); margin-top: auto; padding-top: var(--space-lg); }
.mobile-nav-account a, .mobile-nav-account button { display: flex; align-items: center; padding-inline: var(--space-sm); color: var(--sidebar-muted); font-size: 0.875rem; font-weight: 500; text-decoration: none; }
.mobile-nav-account a { min-height: 2.75rem; }
.sidebar-section { margin: 0 0 var(--space-xs); color: var(--sidebar-muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.sidebar-nav > .sidebar-link, .sidebar-button { display: flex; align-items: center; min-height: 2.75rem; padding-inline: var(--space-sm); border-radius: 8px; font-weight: 500; text-decoration: none; }
.sidebar-nav > .sidebar-link { color: var(--sidebar-muted); }
.sidebar-nav > .sidebar-link:hover, .sidebar-nav > .sidebar-link[aria-current="page"] { background: rgb(255 255 255 / 0.1); color: var(--surface); }
.sidebar-button { justify-content: center; margin-top: var(--space-sm); border-color: var(--primary-bright); background: var(--primary); color: var(--surface); }
.sidebar-button:hover { background: var(--primary-bright); }
.sidebar-account { display: grid; grid-template-columns: 2.25rem minmax(0, 1fr); gap: var(--space-sm); align-items: center; margin-top: auto; padding: var(--space-sm); border-radius: 12px; background: rgb(255 255 255 / 0.08); color: var(--surface); font-size: 0.875rem; }
.sidebar-account > div { min-width: 0; }
.sidebar-account strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-avatar { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%; background: var(--primary-bright); color: var(--surface); font-size: 0.875rem; font-weight: 700; }
.site-header { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line); background: var(--surface); }
.header-content, .page-heading, .action-row, .project-topline, .metric-line, .dashboard-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.header-content { min-height: 4rem; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; min-height: 2.75rem; font-size: 1rem; font-weight: 700; text-decoration: none; }
.skip-link { position: fixed; top: 0.5rem; left: 0.5rem; z-index: 1; padding: 0.5rem 0.75rem; border-radius: 4px; background: var(--ink); color: var(--bg); transform: translateY(-150%); }
.skip-link:focus-visible { transform: translateY(0); }
nav { display: flex; align-items: center; gap: var(--space-md); }
nav form { margin: 0; }
nav > a:not(.button) { display: inline-flex; align-items: center; min-height: 2.75rem; font-weight: 500; text-decoration: none; }
nav > a:not(.button):hover { text-decoration: underline; }

main { padding-block: var(--space-xl); }
.flash-messages { display: grid; gap: var(--space-xs); margin-bottom: var(--space-lg); }
.flash-message { margin: 0; padding: var(--space-sm) var(--space-md); border: 1px solid var(--success); border-radius: 8px; background: var(--success-soft); color: var(--success-ink); font-weight: 500; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { max-width: 20ch; font-size: 2.75rem; font-weight: 500; line-height: 1.1; }
h2 { font-size: 2rem; font-weight: 500; line-height: 1.2; }
h3 { font-size: 1.25rem; font-weight: 500; line-height: 1.3; }
.page-heading { justify-content: space-between; align-items: end; margin-bottom: var(--space-xl); }
.page-kicker { margin: 0 0 0.5rem; color: var(--mute); font-size: 0.875rem; font-weight: 500; line-height: 1.15; }
.page-summary { max-width: 65ch; margin: 0.75rem 0 0; color: var(--muted); font-size: 1.125rem; line-height: 1.5; }

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--primary);
  border-radius: 4px;
  background: var(--primary);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.4;
  text-decoration: none;
  text-transform: none;
  transition: background-color 180ms ease-out, color 180ms ease-out;
}
.button:hover { background: var(--primary-deep); }
.button:active { background: var(--primary-deep); }
.button-small { min-height: 2.75rem; padding: 0.75rem 1rem; font-size: 0.875rem; }
.button-secondary { background: var(--bg); color: var(--primary); }
.button-secondary:hover { background: var(--surface); }
.button-inverted { border-color: var(--primary-bright); background: var(--primary-bright); color: var(--bg); }
.button-inverted:hover { background: var(--bg); color: var(--ink); }

.dashboard-toolbar {
  justify-content: space-between;
  align-items: end;
  min-height: 0;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.dashboard-toolbar .page-summary { color: var(--muted); }
.dashboard-toolbar .page-summary { max-width: 58ch; }
.overview-section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-md); }
.overview-section-heading h2 { font-size: 1.5rem; line-height: 1.2; }
.overview-section-heading span { color: var(--muted); font-size: 0.875rem; }
.overview-priority { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md); margin-bottom: var(--space-xl); }
.priority-metric { display: grid; align-content: center; gap: var(--space-xs); min-width: 0; min-height: 7rem; padding: var(--space-md); border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
.priority-metric span { color: var(--muted); font-size: 0.875rem; font-weight: 600; }
.priority-metric strong { font-size: 1.5rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.priority-risk { border-color: var(--error); color: var(--error); }
.priority-risk span, .priority-risk small { color: currentColor; }
.priority-safe { border-color: var(--success); color: var(--success); }
.priority-safe span, .priority-safe small { color: currentColor; }
.overview-subheading { margin: 0 0 var(--space-md); font-size: 1.125rem; }

.portfolio-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md); margin-bottom: var(--space-lg); }
.portfolio-summary > div { display: grid; align-content: center; gap: var(--space-xs); min-height: 7rem; padding: var(--space-md); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.portfolio-summary span { color: var(--muted); font-size: 0.875rem; }
.portfolio-summary strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.portfolio-progress meter { display: block; height: 0.5rem; margin-top: var(--space-xs); }
.portfolio-alert { border-color: var(--error) !important; color: var(--error); }
.portfolio-balance { border-color: var(--success) !important; color: var(--success); }
.portfolio-alert span, .portfolio-balance span { color: currentColor; }
.dashboard-projects { margin-top: 0; }
.attention-callout { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-sm); align-items: center; margin: var(--space-md) 0; padding: var(--space-sm) var(--space-md); border: 1px solid var(--error); border-radius: 8px; color: var(--ink); text-decoration: none; }
.attention-callout > * { min-width: 0; overflow-wrap: anywhere; }
.attention-callout span { color: var(--error); font-size: 0.875rem; font-weight: 600; }
.attention-callout strong { font-variant-numeric: tabular-nums; }
.attention-callout span:last-child { text-align: right; }
.attention-callout:hover { background: var(--error-soft); }
.dashboard-projects table { min-width: 48rem; }
.project-name { text-decoration: none; }
.project-name:hover { text-decoration: underline; }
.progress-value { display: block; font-weight: 600; white-space: nowrap; }
.progress-meter { display: block; height: 0.5rem; margin-top: var(--space-xs); }
.progress-empty { color: var(--muted); }
.risk-amount { display: block; margin-top: 0.25rem; color: var(--error); font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-scroll-hint { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.detail-stat strong, .stage-values { color: var(--ink); font-variant-numeric: tabular-nums; }
meter {
  --meter-fill: var(--chart-success);
  width: 100%;
  height: 0.75rem;
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: var(--surface-pressed);
  accent-color: var(--chart-success);
  color: var(--meter-fill);
}
meter::-webkit-meter-bar { border: 0; border-radius: inherit; background: var(--surface-pressed); }
meter::-webkit-meter-optimum-value, meter::-webkit-meter-suboptimum-value, meter::-webkit-meter-even-less-good-value { border-radius: inherit; background: var(--meter-fill); }
meter::-moz-meter-bar { border-radius: inherit; background: var(--meter-fill); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: var(--space-md); }
.detail-stat { min-width: 0; padding: var(--space-lg); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.detail-stat p { margin: 0 0 var(--space-xs); color: var(--muted); font-size: 0.875rem; }
.detail-stat strong { font-size: 1.5rem; }
.detail-note { display: block; margin-top: var(--space-xs); color: var(--muted); font-size: 0.875rem; line-height: 1.4; }
.detail-stat-risk { outline: 2px solid var(--error); outline-offset: 2px; }
.balance-negative { color: var(--error); text-decoration: underline 2px currentColor; text-underline-offset: 0.2em; }
.risk-label { display: inline-flex; width: fit-content; margin-top: var(--space-sm); padding: 0.25rem 0.5rem; border-radius: 3px; background: var(--error); color: var(--bg); font-size: 0.75rem; font-weight: 500; }
.budget-charts { display: grid; gap: var(--space-lg); margin-top: var(--space-xl); padding-top: var(--space-xl); border-top: 1px solid var(--line); }
.chart-heading { display: flex; align-items: end; justify-content: space-between; gap: var(--space-lg); }
.chart-heading p { margin: var(--space-xs) 0 0; color: var(--muted); }
.chart-total { color: var(--muted); font-size: 0.875rem; font-weight: 600; line-height: 1.4; font-variant-numeric: tabular-nums; text-align: right; }
.priority-note { width: fit-content; margin: 0; padding: var(--space-sm) var(--space-md); border-radius: 8px; background: var(--error-soft); color: var(--error); font-size: 0.875rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.chart-panel { min-width: 0; margin: 0; padding: var(--space-lg); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.chart-panel figcaption { font-size: 1rem; font-weight: 600; line-height: 1.4; }
.chart-canvas { position: relative; height: 20rem; margin-top: var(--space-md); }
.data-panel { margin-top: var(--space-lg); padding: var(--space-lg); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: var(--space-md); }
.section-heading p { margin: var(--space-xs) 0 0; color: var(--muted); }
.financing-contract { padding: 0; }
.financing-contract summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); padding: var(--space-lg); cursor: pointer; list-style: none; }
.financing-contract summary::-webkit-details-marker { display: none; }
.financing-contract-value { display: grid; gap: var(--space-xs); min-width: 0; }
.financing-contract-value > span { color: var(--muted); font-size: 0.875rem; }
.financing-contract-value strong { font-size: 1.5rem; }
.financing-edit-action { display: grid; place-items: center; flex: 0 0 auto; width: 2.75rem; height: 2.75rem; border-radius: 4px; color: var(--primary); }
.financing-edit-action img { width: 1.125rem; height: 1.125rem; }
.financing-contract summary:hover .financing-edit-action { background: var(--surface-pressed); color: var(--primary-deep); }
.financing-contract summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.financing-edit-form { display: grid; gap: var(--space-md); padding: var(--space-lg); border-top: 1px solid var(--line); }
.financing-edit-note { color: var(--muted); font-size: 0.875rem; line-height: 1.4; }
.financing-progress { --meter-fill: var(--primary); display: block; height: 0.5rem; margin-top: var(--space-sm); accent-color: var(--primary); }
.financing-releases .section-heading { margin-bottom: var(--space-lg); }
.financing-releases table { min-width: 20rem; table-layout: fixed; }
.financing-releases td { white-space: nowrap; }
.data-panel h3, .data-panel h2 { margin-bottom: var(--space-md); }
.table-scroll { overflow-x: auto; }
.data-panel table { width: 100%; min-width: 34rem; border-collapse: collapse; font-variant-numeric: tabular-nums; text-align: left; }
.data-panel th, .data-panel td { padding: var(--space-sm) var(--space-md); border-top: 1px solid var(--line); }
.data-panel th { overflow-wrap: anywhere; }
.data-panel th:not(:first-child), .data-panel td { text-align: right; }
.expense-panel { margin-top: var(--space-lg); }
.expense-panel-heading { display: flex; align-items: end; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-md); }
.expense-panel-heading h2, .expense-panel-heading p { margin: 0; }
.expense-panel-heading p { margin-top: var(--space-xs); color: var(--muted); font-size: 0.875rem; }
.expense-table { min-width: 42rem !important; }
.expense-table th, .expense-table td { text-align: left !important; vertical-align: middle; }
.expense-table th:last-child, .expense-table td:last-child { text-align: right !important; white-space: nowrap; }
.expense-table td:nth-child(2) { max-width: 34ch; overflow-wrap: anywhere; }
.expense-empty { display: grid; gap: var(--space-xs); padding: var(--space-lg) var(--space-md); }
.expense-empty h3, .expense-empty p { margin: 0; }
.expense-empty p { max-width: 48ch; color: var(--muted); }
.stage-panel { margin-top: var(--space-lg); }
.stage-panel-heading, .stage-chart-heading { display: flex; align-items: end; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-md); }
.stage-panel-heading h2, .stage-panel-heading p, .stage-chart-heading h2, .stage-chart-heading p { margin: 0; }
.stage-panel-heading p, .stage-chart-heading p { margin-top: var(--space-xs); color: var(--muted); font-size: 0.875rem; }
.stage-filters { display: grid; grid-template-columns: minmax(12rem, 1.4fr) minmax(10rem, 0.8fr) auto auto; gap: var(--space-sm); align-items: end; margin-bottom: var(--space-md); padding: var(--space-md); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.stage-filters label { display: grid; gap: 0.375rem; min-width: 0; font-size: 0.875rem; font-weight: 500; }
.stage-filters input, .stage-filters select { width: 100%; min-width: 0; min-height: 2.75rem; padding: 0.625rem 0.75rem; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--bg); color: var(--ink); }
.stage-filters input:focus-visible, .stage-filters select:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.stage-filter-reset { display: inline-flex; align-items: center; min-height: 2.75rem; color: var(--primary); font-size: 0.875rem; font-weight: 500; }
.stage-table { min-width: 48rem !important; }
.stage-table th, .stage-table td { vertical-align: middle; }
.stage-table th:not(:first-child), .stage-table td { text-align: left !important; }
.stage-table .stage-budget { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stage-status { display: inline-flex; align-items: center; min-height: 1.75rem; padding: 0.25rem 0.625rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.stage-status-pending { background: var(--surface-pressed); color: var(--muted); }
.stage-status-progress { background: var(--warning-soft); color: var(--warning-ink); }
.stage-status-completed { background: var(--success-soft); color: var(--success-ink); }
.stage-action { display: inline-flex; align-items: center; justify-content: center; min-width: 2.75rem; min-height: 2.75rem; padding: 0.5rem 0.625rem; border-radius: 4px; color: var(--primary); text-decoration: none; }
.stage-action:hover { background: var(--surface-pressed); color: var(--primary-deep); }
.stage-action:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.stage-action-icon { width: 1.125rem; height: 1.125rem; flex: 0 0 auto; }
.stage-action-label { display: none; }
.stage-empty { display: grid; gap: var(--space-xs); padding: var(--space-lg) var(--space-md); }
.stage-empty h3, .stage-empty p { margin: 0; }
.stage-empty p { max-width: 48ch; color: var(--muted); }
.stage-chart-section { margin-top: var(--space-xl); }
.stage-chart-section .chart-panel { margin-top: var(--space-md); }
.stage-load-more-wrap { display: flex; justify-content: center; margin-top: var(--space-md); }
.stage-load-more { min-height: 2.75rem; padding: 0.5rem 0; border: 0; background: transparent; color: var(--primary); cursor: pointer; font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 0.2em; }
.stage-load-more:hover { color: var(--primary-deep); }
.stage-load-more:disabled { color: var(--muted); cursor: wait; }
.budget-row-over th, .budget-row-over td { border-color: var(--error); }
.chart-script-note { margin: var(--space-md) 0 0; color: var(--muted); }
.chart-fallback { display: grid; gap: var(--space-xs); margin-bottom: var(--space-md); color: var(--muted); font-size: 0.875rem; }
.chart-fallback strong { color: var(--ink); }
.chart-fallback p { margin: 0; }
.chart-error { margin-top: var(--space-md); padding: var(--space-sm) var(--space-md); border: 1px solid var(--error); border-radius: 8px; background: var(--error-soft); color: var(--error); font-size: 0.875rem; }
.chart-error .button { margin-top: var(--space-sm); }
.chart-empty-state { margin-top: var(--space-lg); padding: var(--space-lg); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.chart-empty-state p { margin: var(--space-xs) 0 var(--space-lg); color: var(--muted); }
.action-row { flex-wrap: wrap; margin-top: var(--space-lg); }
.bill-page-heading { margin-bottom: var(--space-lg); }
.bill-page-heading .button { flex: 0 0 auto; }
.bill-filters { display: grid; gap: var(--space-md); margin-bottom: var(--space-lg); padding: var(--space-lg); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stage-filters { grid-template-columns: none; }
.bill-filter-heading, .bill-panel-heading { display: flex; align-items: end; justify-content: space-between; gap: var(--space-md); }
.bill-filter-heading h2, .bill-panel-heading h2 { margin: 0; font-size: 1.125rem; }
.bill-filter-heading p, .bill-panel-heading p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.875rem; }
.bill-filter-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: var(--space-sm); align-items: end; }
.bill-filter-fields label { display: grid; gap: 0.375rem; min-width: 0; font-size: 0.875rem; font-weight: 500; }
.bill-filter-fields input, .bill-filter-fields select { width: 100%; min-width: 0; min-height: 2.75rem; padding: 0.625rem 0.75rem; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--bg); color: var(--ink); }
.bill-filter-fields input:focus-visible, .bill-filter-fields select:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.bill-filter-reset { color: var(--primary); font-size: 0.875rem; font-weight: 500; }
.bill-panel { margin-top: 0; }
.bill-panel-heading h2 { white-space: nowrap; }
.bill-table { min-width: 60rem !important; }
.bill-table th:first-child { min-width: 18rem; }
.bill-table th:last-child, .bill-table td:last-child { width: 11rem; }
.bill-table thead th { white-space: nowrap; }
.bill-table th, .bill-table td { text-align: left !important; }
.bill-table th, .bill-table td { vertical-align: middle; }
.bill-table .bill-title { display: block; max-width: 30ch; font-weight: 500; }
.bill-category, .bill-date { color: var(--muted); font-size: 0.875rem; }
.bill-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bill-status { display: inline-flex; align-items: center; min-height: 1.75rem; padding: 0.25rem 0.625rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.bill-status-open { background: var(--warning-soft); color: var(--warning-ink); }
.bill-status-paid { background: var(--success-soft); color: var(--success-ink); }
.bill-files, .bill-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.bill-actions { min-width: 0; align-items: center; }
.bill-files { min-width: 8rem; }
.bill-file-link, .bill-action-link { color: var(--primary); font-size: 0.8125rem; font-weight: 500; white-space: nowrap; }
.bill-action-link, .bill-action-button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs); }
.bill-action-link { min-height: 2.25rem; padding: 0.5rem 0.625rem; border-radius: 4px; text-decoration: none; }
.bill-action-link:not(.bill-danger-button):hover { background: var(--surface-pressed); color: var(--primary-deep); }
.bill-action-icon { width: 1.125rem; height: 1.125rem; flex: 0 0 auto; }
.bill-action-label { display: none; }
.bill-receipt-input { display: inline-flex; align-items: center; gap: 0.375rem; color: var(--muted); font-size: 0.75rem; }
.bill-receipt-input input { max-width: 11rem; font-size: 0.75rem; }
.bill-action-button, .bill-danger-button { min-height: 2.25rem; padding: 0.5rem 0.625rem; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--ink); cursor: pointer; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.bill-action-button:hover { border-color: transparent; background: var(--surface-pressed); color: var(--primary); }
.bill-danger-button { border-color: transparent; color: var(--error); }
.bill-danger-button:hover { background: var(--error-soft); }
.bill-empty { display: grid; justify-items: start; gap: var(--space-sm); padding: var(--space-xl) var(--space-md); }
.bill-empty-mark { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 8px; background: #c9e0fc; color: var(--primary); font-size: 1.5rem; }
.bill-empty h3, .bill-empty p { margin: 0; }
.bill-empty p { max-width: 48ch; color: var(--muted); line-height: 1.5; }
.pending-table { min-width: 0 !important; table-layout: fixed; }
.pending-table th:first-child { width: 20%; min-width: 12rem; }
.pending-table th:nth-child(2) { width: 12%; }
.pending-table th:nth-child(3) { width: 11%; }
.pending-table th:nth-child(4) { width: 20%; min-width: 0; }
.pending-table th:nth-child(5) { width: 14%; }
.pending-table th:nth-child(6) { width: 18%; }
.pending-table th:last-child, .pending-table td:last-child { width: 5rem; }
.pending-description { max-width: 30ch; overflow-wrap: anywhere; line-height: 1.4; }
.pending-description p { margin: 0; }
.pending-file-list, .pending-status-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); }
.pending-file-entry { display: grid; gap: 0.125rem; min-width: 0; }
.pending-file-entry > span:last-child { display: inline-flex; align-items: center; flex-wrap: wrap; gap: var(--space-xs); }
.pending-file-supplier { color: var(--ink); font-size: 0.875rem; font-weight: 600; overflow-wrap: anywhere; }
.pending-status-form { margin-top: var(--space-xs); }
.pending-status-form select { min-height: 2rem; max-width: 9rem; padding: 0.25rem 0.5rem; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--bg); color: var(--ink); }
.pending-status-submit, .pending-file-remove { min-height: 2rem; padding: 0.25rem 0.5rem; border: 0; background: transparent; color: var(--primary); cursor: pointer; font: inherit; font-size: 0.75rem; font-weight: 600; }
.pending-status-submit:hover, .pending-file-remove:hover { color: var(--primary-deep); text-decoration: underline; }
.pending-file-remove { color: var(--error); font-size: 1rem; line-height: 1; }
.bill-dialog { width: min(calc(100vw - 2rem), 28rem); max-width: calc(100vw - 1rem); max-height: calc(100dvh - 2rem); overflow-y: auto; padding: var(--space-md); border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); color: var(--ink); }
.bill-dialog::backdrop { background: rgb(26 26 26 / 0.48); }
.bill-dialog form { display: block; min-width: 0; padding: 0; }
.bill-dialog form > * + * { margin-top: var(--space-lg); }
.bill-dialog-heading { position: relative; display: block; padding-right: var(--space-xl); }
.bill-dialog-heading h2 { min-width: 0; font-size: 1.25rem; line-height: 1.2; overflow-wrap: anywhere; }
.bill-dialog-context { margin: var(--space-xs) 0 0; color: var(--muted); line-height: 1.5; }
.bill-dialog-intro { margin: 0; color: var(--muted); line-height: 1.5; }
.bill-dialog-close { position: absolute; top: calc(var(--space-xs) * -1); right: calc(var(--space-xs) * -1); min-width: 2.75rem; min-height: 2.75rem; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.5rem; line-height: 1; }
.bill-dialog-close:hover { color: var(--ink); }
.bill-dialog-file { display: grid; gap: var(--space-sm); margin: var(--space-xs) 0; padding: var(--space-xs); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-weight: 500; line-height: 1.4; }
.bill-dialog-file-label { font-weight: 600; }
.bill-dialog-file-help { color: var(--muted); font-size: 0.875rem; font-weight: 400; }
.bill-dialog-file input { width: 100%; margin-top: var(--space-xs); padding: var(--space-sm); border: 1px solid var(--line-strong); border-radius: 4px; background: var(--bg); font-size: 0.875rem; }
.bill-dialog-file input::file-selector-button { margin-inline-end: var(--space-sm); padding: 0.5rem 0.75rem; border: 0; border-radius: 4px; background: var(--primary); color: var(--bg); cursor: pointer; font: inherit; font-weight: 600; }
.bill-dialog-file input::file-selector-button:hover { background: var(--primary-deep); }
.bill-dialog-file input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.bill-dialog-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: var(--space-sm); }
.confirm-dialog { width: min(100% - 2rem, 28rem); padding: 0; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); color: var(--ink); }
.confirm-dialog::backdrop { background: rgb(26 26 26 / 0.48); }
.confirm-dialog-form { display: grid; gap: var(--space-lg); padding: var(--space-xl); }
.confirm-dialog h2 { font-size: 1.25rem; }
.confirm-dialog p { margin: 0.5rem 0 0; color: var(--muted); line-height: 1.5; }
.confirm-dialog-actions { display: flex; justify-content: end; gap: var(--space-sm); }
.confirm-danger { border-color: var(--error); background: var(--error); }
.confirm-danger:hover { border-color: var(--error); background: #8f2024; }
.access-note { width: fit-content; margin: var(--space-lg) 0 0; padding: var(--space-sm) var(--space-md); border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 0.875rem; }
.data-recency { margin: 1rem 0 0; color: var(--muted); font-size: 0.875rem; }

.form-shell { width: min(100%, 42rem); }
.expense-form-shell { width: min(100%, 52rem); }
.back-link { display: inline-flex; align-items: center; min-height: 2.75rem; color: var(--muted); font-size: 0.875rem; font-weight: 500; }
.back-link:hover { color: var(--ink); }
.form-header { margin-top: var(--space-lg); }
.form-header .page-summary { max-width: 52ch; }
.form-card, .expense-form { display: grid; gap: var(--space-md); margin-top: var(--space-lg); padding: var(--space-lg); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.expense-form { gap: var(--space-lg); }
.expense-form-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-field, .expense-field { display: grid; gap: 0.5rem; min-width: 0; margin: 0; }
.expense-field-wide { grid-column: 1 / -1; }
.form-shell label, .expense-field label { font-weight: 500; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.form-card input, .form-card select, .form-card textarea, .expense-form input, .expense-form select, .expense-form textarea, .financing-edit-form input {
  width: 100%;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink);
}
.currency-field { display: flex; align-items: stretch; border-radius: 4px; background: var(--bg); }
.currency-prefix { display: inline-flex; align-items: center; padding-inline: 1rem; border-start-start-radius: 4px; border-end-start-radius: 4px; border: 1px solid var(--line-strong); border-inline-end: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.currency-field input { border-start-start-radius: 0; border-end-start-radius: 0; }
.form-card input:focus-visible, .form-card select:focus-visible, .form-card textarea:focus-visible, .expense-form input:focus-visible, .expense-form select:focus-visible, .expense-form textarea:focus-visible, .financing-edit-form input:focus-visible, a:focus-visible, button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.form-card .errorlist, .expense-form .errorlist { margin: 0; padding-left: 1.2rem; color: var(--ink); }
.form-errors, .field-errors { margin: 0; color: var(--ink); }
.field-help { color: var(--muted); font-size: 0.875rem; line-height: 1.4; }
.quote-upload-fieldset { display: grid; gap: var(--space-sm); min-width: 0; margin: 0; padding: 0; border: 0; }
.quote-upload-fieldset legend { padding: 0; font-weight: 600; }
.quote-upload-list { display: grid; gap: var(--space-sm); }
.quote-upload-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm); min-width: 0; padding: var(--space-sm); border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.quote-upload-row input[type="file"] { padding: var(--space-sm); }
.form-card .ck-editor-container, .form-card .ck-editor { width: 100%; max-width: 100%; min-width: 0; }

@media (max-width: 1024px) {
  .pending-table-scroll { overflow: visible; }
  .pending-table { display: block; }
  .pending-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .pending-table tbody { display: grid; gap: var(--space-md); }
  .pending-table tr { display: grid; gap: 0; padding: var(--space-md); border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
  .pending-table th, .pending-table td { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: var(--space-sm); align-items: start; width: auto !important; min-width: 0 !important; padding: var(--space-sm) 0; border-top: 1px solid var(--line); text-align: left !important; }
  .pending-table tr > th { display: block; padding-top: 0; border-top: 0; }
  .pending-table td::before { content: attr(data-label); color: var(--muted); font-size: 0.75rem; font-weight: 600; }
  .pending-table td:last-child { padding-bottom: 0; }
  .pending-table .pending-description { max-width: none; }
  .pending-table .pending-status-form { margin-top: 0; }
  .pending-table .pending-file-list { display: grid; align-items: start; }
  .pending-table .bill-actions { justify-content: flex-start; }
  .pending-table .bill-action-link { min-width: 2.75rem; min-height: 2.75rem; }
  .pending-table .bill-action-label { display: inline; }
}

.empty-state { max-width: 36rem; padding: var(--space-lg); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.empty-state p { color: var(--muted); line-height: 1.5; }
.account-action { min-height: 1.5rem; padding: 0; border: 0; background: transparent; color: var(--sidebar-muted); cursor: pointer; font-size: 0.75rem; font-weight: 500; }
.account-action:hover { color: var(--surface); text-decoration: underline; }
.account-name { display: block; overflow: hidden; color: var(--surface); text-overflow: ellipsis; text-decoration: none; white-space: nowrap; }
.account-name:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .shell { width: min(100% - 2rem, 1366px); }
  .app-body { display: block; }
  .app-sidebar { position: static; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--space-xs) var(--space-md); width: 100%; height: auto; padding: max(var(--space-sm), env(safe-area-inset-top)) max(var(--space-md), env(safe-area-inset-right)) var(--space-sm) max(var(--space-md), env(safe-area-inset-left)); }
  .app-sidebar .brand { min-height: 2.75rem; }
  .sidebar-brand small, .sidebar-section { display: none; }
  .mobile-menu-toggle { display: grid; place-content: center; gap: 0.25rem; width: 2.75rem; height: 2.75rem; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--surface); cursor: pointer; }
  .mobile-menu-toggle span { display: block; width: 1.125rem; height: 2px; background: currentColor; }
  .sidebar-nav, .app-sidebar .sidebar-account { display: none; }
  .app-content { padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); }
  .app-body .app-content .shell { width: min(100% - 2rem, 1280px); }
  .header-content, .page-heading, .project-topline, .dashboard-toolbar { align-items: stretch; flex-direction: column; }
  .header-content { padding-block: 1rem; }
  nav { justify-content: space-between; }
  main { padding-block: var(--space-lg); }
  h1 { font-size: 2rem; line-height: 1.22; }
  .dashboard-toolbar .button, .page-heading .button, .action-row .button { width: 100%; }
  .detail-stat, .empty-state { padding: var(--space-md); }
  .portfolio-summary, .overview-priority { grid-template-columns: 1fr; }
  .attention-callout { grid-template-columns: 1fr; gap: var(--space-xs); }
  .attention-callout span:last-child { text-align: left; }
  .dashboard-projects table { min-width: 0; }
  .dashboard-projects th:nth-child(3), .dashboard-projects td:nth-child(3), .dashboard-projects th:nth-child(4), .dashboard-projects td:nth-child(4) { display: none; }
  .table-scroll-hint { display: block; margin: var(--space-sm) 0 0; color: var(--muted); font-size: 0.875rem; }
  .detail-grid { grid-template-columns: 1fr; }
  .overview-section-heading { align-items: flex-start; flex-direction: column; gap: 0.25rem; }
  .chart-heading { flex-direction: column; gap: 0.5rem; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .section-heading .button { width: 100%; }
  .chart-total { text-align: left; }
  .chart-panel { padding: var(--space-md); }
  .chart-canvas { height: 18rem; }
  .chart-empty-state .button { width: 100%; }
  .bill-page-heading .button { width: 100%; }
  .bill-filter-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bill-filter-fields .button { width: 100%; grid-column: 1 / -1; }
  .bill-action-label { display: inline; }
  .bill-receipt-input { align-items: flex-start; flex-direction: column; }
  .bill-receipt-input input { max-width: 100%; }
  .bill-dialog-actions { align-items: stretch; flex-direction: column; }
  .bill-dialog-actions .button { width: 100%; }
  .bill-dialog { padding: var(--space-md); }
  .bill-dialog form > * + * { margin-top: var(--space-md); }
  .bill-dialog-file { padding: var(--space-xs); }
  .pending-status-form select { max-width: 100%; }
  .stage-filters { grid-template-columns: 1fr; align-items: stretch; }
  .stage-filters .button, .stage-filter-reset { width: 100%; justify-content: center; }
  .stage-action-label { display: inline; }
  .expense-form-fields { grid-template-columns: 1fr; }
  .expense-field-wide { grid-column: auto; }
  .quote-upload-row { grid-template-columns: 1fr; }
  .form-actions .button { width: 100%; }
  .responsive-card-table { display: block; min-width: 0 !important; }
  .responsive-card-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .responsive-card-table tbody { display: grid; gap: var(--space-md); }
  .responsive-card-table tr { display: grid; gap: 0; padding: var(--space-md); border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
  .responsive-card-table th, .responsive-card-table td { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: var(--space-sm); align-items: start; width: auto !important; min-width: 0 !important; padding: var(--space-sm) 0; border-top: 1px solid var(--line); text-align: left !important; }
  .responsive-card-table tr > th { display: block; padding-top: 0; border-top: 0; }
  .responsive-card-table td::before { content: attr(data-label); color: var(--muted); font-size: 0.75rem; font-weight: 600; }
  .responsive-card-table td:last-child { padding-bottom: 0; }
  .stage-table .stage-budget { text-align: left !important; }
  .stage-table .stage-status, .stage-table .stage-action { justify-self: start; }
}

@media (max-width: 420px) {
  .app-sidebar { gap: var(--space-xs); padding-inline: max(var(--space-sm), env(safe-area-inset-right)) max(var(--space-sm), env(safe-area-inset-left)); }
  .sidebar-brand > span:last-child, .sidebar-account .account-avatar { display: none; }
  .sidebar-nav { justify-content: end; }
  .sidebar-button { padding-inline: var(--space-sm); }
  .bill-filter-fields { grid-template-columns: 1fr; }
  .bill-filter-fields .button { grid-column: auto; }
  .bill-filter-heading, .bill-panel-heading { align-items: flex-start; flex-direction: column; }
  .account-action { min-height: 2.75rem; padding-inline: var(--space-xs); white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
