:root {
  --bg: #f7f8f5;
  --paper: #fffefa;
  --ink: #101616;
  --muted: #5f6865;
  --line: #d9dfd8;
  --teal: #0d6f65;
  --teal-dark: #084b46;
  --coral: #c94f3c;
  --gold: #b98521;
  --blue: #2f5f9f;
  --shadow: 0 18px 45px rgba(16, 22, 22, 0.09);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(13, 111, 101, 0.05), transparent 42%),
    radial-gradient(circle at 86% 8%, rgba(201, 79, 60, 0.09), transparent 24rem),
    var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  line-height: 1.58;
}

a {
  color: var(--teal-dark);
  text-underline-offset: 0.2em;
}

code {
  padding: 0.12rem 0.32rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #eef3ef;
  font-size: 0.92em;
}

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 20;
  transform: translateY(-160%);
  padding: 0.65rem 0.9rem;
  background: var(--ink);
  color: white;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 19.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  padding: 1.3rem;
  background: #101616;
  color: white;
  border-right: 5px solid var(--teal);
}

.brand {
  display: grid;
  grid-template-columns: 2.8rem 1fr;
  gap: 0.75rem;
  align-items: center;
  color: white;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  font-family: Georgia, serif;
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.sidebar-note span,
.sidebar-note small,
nav small {
  color: rgba(255, 255, 255, 0.62);
}

nav {
  display: grid;
  gap: 0.35rem;
}

nav a {
  display: block;
  padding: 0.72rem 0.78rem;
  border: 1px solid transparent;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
}

nav a span,
nav a small {
  display: block;
}

nav a.is-active,
nav a:hover,
nav a:focus-visible {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.sidebar-note {
  margin-top: auto;
  display: grid;
  gap: 0.45rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.content {
  width: min(100% - 22rem, 74rem);
  margin-left: 19.5rem;
  padding: 3.4rem clamp(1.2rem, 4vw, 4rem) 5rem;
}

.page-header {
  max-width: 58rem;
  margin-bottom: 2rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--coral);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0;
  line-height: 1.12;
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 5vw, 4.9rem);
}

h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.55rem, 2.6vw, 2.3rem);
}

h3 {
  margin: 1.5rem 0 0.65rem;
  font-size: 1.28rem;
}

.intro {
  max-width: 48rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.15rem;
}

.summary-band,
.report-section,
.inventory-tools {
  margin: 0 0 1.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.88);
  box-shadow: var(--shadow);
}

.summary-band {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(17rem, 0.85fr);
  gap: 1rem;
  align-items: stretch;
  padding: 1.1rem;
}

.summary-band > div,
.callout {
  padding: 1.1rem;
}

.summary-band h2,
.summary-band p,
.callout p {
  margin-top: 0;
}

.callout {
  border-left: 5px solid var(--coral);
  background: #fff7f2;
  border-radius: 6px;
}

.callout strong {
  display: block;
  margin-bottom: 0.45rem;
}

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

.metric {
  min-height: 8.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.95rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.metric span,
.metric small {
  color: var(--muted);
}

.metric strong {
  font-family: Georgia, serif;
  font-size: 1.75rem;
  line-height: 1;
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.8rem;
  margin: 1.2rem 0;
}

.route-card {
  min-height: 12rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
}

.route-card:hover,
.route-card:focus-visible {
  border-color: var(--teal);
  box-shadow: var(--shadow);
}

.route-card span {
  width: 2rem;
  color: var(--coral);
  font-weight: 800;
}

.route-card strong {
  font-size: 1.05rem;
}

.route-card p {
  margin: 0;
  color: var(--muted);
}

.report-section {
  padding: clamp(1rem, 3vw, 1.6rem);
}

.report-section + .report-section {
  margin-top: 1.2rem;
}

.table-frame {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 0.94rem;
}

th,
td {
  padding: 0.72rem 0.78rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3ef;
  color: #24302e;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

ul,
ol {
  padding-left: 1.25rem;
}

li + li {
  margin-top: 0.35rem;
}

.inventory-tools {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(16rem, 1fr) minmax(13rem, 0.5fr) minmax(12rem, 0.4fr) auto;
  gap: 0.8rem;
  align-items: end;
  padding: 1rem;
}

.inventory-tools label,
.inventory-tools span {
  display: grid;
  gap: 0.28rem;
}

.inventory-tools span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 2.7rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.58rem 0.7rem;
  background: white;
  color: var(--ink);
  font: inherit;
}

output {
  min-width: 7rem;
  padding: 0.7rem 0.8rem;
  border-radius: 7px;
  background: #eef3ef;
  font-weight: 800;
  text-align: center;
}

.inventory-frame {
  max-height: 72vh;
}

.status {
  display: inline-block;
  white-space: nowrap;
  border-radius: 999px;
  padding: 0.22rem 0.52rem;
  font-size: 0.82rem;
  font-weight: 800;
}

.status.is-ok {
  background: #e4f3eb;
  color: #135b38;
}

.status.is-derived {
  background: #fff0df;
  color: #8a3f0e;
}

@media (max-width: 1100px) {
  .sidebar {
    position: static;
    width: auto;
    border-right: 0;
    border-bottom: 5px solid var(--teal);
  }

  .content {
    width: 100%;
    margin-left: 0;
  }

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

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

@media (max-width: 760px) {
  .content {
    padding: 1.5rem 1rem 3rem;
  }

  .summary-band,
  .inventory-tools {
    grid-template-columns: 1fr;
  }

  nav,
  .metric-grid,
  .flow-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2.4rem;
  }
}

@media print {
  body {
    background: white;
  }

  .sidebar,
  .skip-link,
  .inventory-tools,
  script {
    display: none !important;
  }

  .content {
    width: auto;
    margin: 0;
    padding: 0;
  }

  .report-section,
  .summary-band,
  .metric,
  .route-card {
    box-shadow: none;
    break-inside: avoid;
  }
}
