:root {
  color-scheme: light;
  --background: #f4f6f1;
  --surface: #fff;
  --ink: #182b24;
  --muted: #53665e;
  --line: #dce4dc;
  --forest: #173d32;
  --forest-dark: #0d2c23;
  --lime: #dafaaf;
  --tint: #f1f6ee;
  --warning: #805018;
  --warning-bg: #faf0dc;
  --danger: #a2352f;
  --danger-bg: #fbecea;
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  font-size: 100%;
  color: var(--ink);
  background: var(--background);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 1rem; }
body { margin: 0; line-height: 1.5; }
h1, h2, p, dl, dd, ul { margin: 0; }
h1, h2 { line-height: 1.15; letter-spacing: -.045em; }
a { color: inherit; }
input, button, select { font: inherit; }
button, summary, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid #48825f; outline-offset: 3px; }
[hidden] { display: none !important; }

.shell { width: min(100% - 3rem, 78rem); margin-inline: auto; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { min-height: 4.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; font-weight: 750; letter-spacing: -.035em; }
.brand img { flex: none; }
.topbar nav { display: flex; gap: 1.6rem; }
.topbar nav a { color: var(--muted); font-size: .9375rem; font-weight: 650; text-decoration: none; }
.topbar nav a:hover, .footer a:hover { color: var(--forest); text-decoration: underline; }
.skip-link { position: absolute; z-index: 2; top: .4rem; left: .4rem; transform: translateY(-150%); padding: .65rem 1rem; background: var(--surface); }
.skip-link:focus { transform: none; }
.visually-hidden { position: absolute; overflow: hidden; clip-path: inset(50%); width: 1px; height: 1px; white-space: nowrap; }

.intro { padding-block: clamp(2.25rem, 6vw, 4rem) 1.65rem; }
.intro h1 { font-size: clamp(2.45rem, 6vw, 4.6rem); margin-block: .45rem .55rem; }
.intro p:not(.eyebrow) { color: var(--muted); }
.eyebrow { color: var(--forest); font-size: .875rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.notice { margin-top: .8rem; padding: .65rem 1rem; border-radius: .5rem; background: var(--warning-bg); }
.metrics { display: grid; gap: .9rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric, .panel { border: 1px solid var(--line); border-radius: .85rem; background: var(--surface); }
.metric { display: flex; flex-direction: column; align-items: flex-start; padding: 1.05rem 1.2rem; }
.metric dt { font-size: .9375rem; font-weight: 650; }
.metric dd { margin-block: .2rem .3rem; max-width: 100%; overflow-wrap: anywhere; font-size: clamp(1.5rem, 3vw, 2.4rem); font-weight: 750; line-height: 1.2; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.metric p { color: var(--muted); font-size: .875rem; }
.metric:first-child { color: #fff; background: var(--forest); border-color: var(--forest); }
.metric:first-child dd { color: var(--lime); }
.metric:first-child p { color: #d3e4d9; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: .9rem; margin-block: .9rem; align-items: stretch; }
.panel { min-width: 0; padding: 1.2rem; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.panel-header h2, dialog h2 { font-size: clamp(1.25rem, 3vw, 1.65rem); }
.panel-header p, dialog p { margin-top: .25rem; color: var(--muted); font-size: .9375rem; }
.forecast-key { flex: none; border-radius: .35rem; background: var(--warning-bg); color: var(--warning); padding: .25rem .5rem; font-size: .8125rem; font-weight: 650; }
.forecast-list { display: grid; gap: .68rem; padding: 0; list-style: none; }
.forecast-row { display: grid; grid-template-columns: minmax(5rem, 1fr) minmax(4rem, 1.2fr) 3.7rem; align-items: center; gap: .65rem; font-size: .875rem; }
.forecast-row strong { font-weight: 650; overflow-wrap: anywhere; }
.forecast-row span:last-child { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.bar { display: block; height: .55rem; overflow: hidden; border-radius: 1rem; background: var(--tint); }
.bar > span { display: block; width: var(--runway); height: 100%; border-radius: inherit; background: #639674; }
.bar.risk > span { background: #c68b4e; }
.empty { color: var(--muted); }

.button, .chip { min-height: 2.65rem; border: 1px solid var(--line); border-radius: .46rem; background: var(--surface); color: var(--ink); padding: .45rem .8rem; font-size: .875rem; font-weight: 680; white-space: nowrap; }
.button:hover:not(:disabled), .chip:hover { border-color: #839b89; background: var(--tint); }
.button-small { min-height: 2.3rem; padding: .3rem .65rem; }
.button-primary { border-color: var(--forest); background: var(--forest); color: #fff; }
.button-primary:hover:not(:disabled) { border-color: var(--forest-dark); background: var(--forest-dark); }
.presets, .actions, .dialog-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { min-height: 2rem; padding: .2rem .55rem; border-radius: 1rem; background: var(--tint); }
.command-form { display: flex; gap: .45rem; margin-block: .75rem; }
.command-form input, .filters input { flex: 1; width: 0; }
input, select { min-width: 0; min-height: 2.65rem; padding: .48rem .65rem; border: 1px solid #cbd8cf; border-radius: .45rem; color: var(--ink); background: var(--surface); }
input::placeholder { color: #627268; }
select { appearance: none; padding-right: 2rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 1.05rem) 50%, calc(100% - .75rem) 50%; background-size: .3rem .3rem; background-repeat: no-repeat; }
.command-result { min-height: 3rem; max-height: 12rem; overflow: auto; padding: .55rem .65rem; border-radius: .4rem; background: var(--tint); color: #334b3e; font-size: .9375rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.command-help { margin-top: .65rem; color: var(--muted); font-size: .875rem; }
.command-help summary { font-weight: 650; }
.command-help ul { padding: .45rem 0 .2rem 1.2rem; }

.filters { display: flex; gap: .5rem; margin-bottom: .75rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 47rem; border-collapse: collapse; text-align: left; font-size: .9375rem; }
thead { background: var(--tint); }
th { font-size: .875rem; font-weight: 700; }
td, th { padding: .62rem .6rem; vertical-align: middle; }
td { border-bottom: 1px solid var(--line); }
td:first-child { width: 30%; overflow-wrap: anywhere; }
td strong { display: block; }
.muted { color: var(--muted); font-size: .875rem; }
.status { display: inline-block; border-radius: .3rem; padding: .13rem .33rem; font-size: .8125rem; white-space: nowrap; }
.status.warning { color: var(--warning); background: var(--warning-bg); }
.status.danger { color: var(--danger); background: var(--danger-bg); }
.row-button { border: 0; padding: .4rem .25rem; margin-right: .3rem; background: transparent; color: var(--forest); font-size: .875rem; font-weight: 650; white-space: nowrap; }
.row-button:hover { text-decoration: underline; }
.row-button.delete { color: var(--danger); }
.inventory-message { padding-top: .55rem; color: var(--muted); overflow-wrap: anywhere; }
.inventory-message:empty { padding: 0; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: .75rem; padding-top: .75rem; font-size: .875rem; }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1.5rem; padding-block: 1.3rem 1.75rem; color: var(--muted); font-size: .875rem; }

dialog { width: min(100% - 2rem, 36rem); max-height: calc(100% - 2rem); padding: 1.2rem; border: 1px solid var(--line); border-radius: .85rem; color: var(--ink); }
dialog::backdrop { background: rgb(12 33 24 / .6); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem .8rem; margin-block: .8rem; }
.field-grid label { display: grid; gap: .2rem; font-size: .875rem; font-weight: 650; }
.field-grid label span { display: inline; }
.dialog-actions { justify-content: flex-end; margin-top: .75rem; }
.form-error { color: var(--danger); }

@media (max-width: 54rem) {
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 37rem) {
  .shell { width: min(100% - 1.5rem, 78rem); }
  .topbar-inner { flex-wrap: wrap; gap: .5rem; padding-block: .55rem; }
  .topbar nav { order: 1; flex-basis: 100%; gap: 1.15rem; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric, .panel { padding: .8rem; }
  .inventory-heading { flex-wrap: wrap; }
  .filters { flex-wrap: wrap; }
  .filters input { min-width: 100%; }
  .forecast-key { font-size: .75rem; }
}

@media (max-width: 22rem) {
  .field-grid { grid-template-columns: 1fr; }
  .forecast-key { display: none; }
}
