:root {
  color-scheme: light;
  --navy: #111c2b;
  --navy-soft: #1b2b41;
  --green: #3f7132;
  --green-bright: #c8f28b;
  --green-surface: #eaf5e5;
  --background: #f8f9f7;
  --surface: #ffffff;
  --text: #172033;
  --text-secondary: #6e7787;
  --border: #e4e7e2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px max(24px, calc((100vw - 880px) / 2));
  background: var(--navy);
  color: white;
}

.brand {
  display: block;
  min-width: 0;
  text-decoration: none;
}

.brand img {
  display: block;
  width: clamp(165px, 21vw, 218px);
  max-width: 100%;
  height: auto;
}

.page-shell {
  width: min(880px, calc(100% - 32px));
  min-height: calc(100vh - 150px);
  margin: 32px auto;
}

.stats-card,
.breakdown-card,
.category-card,
.state-card {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 12px 36px rgb(17 28 43 / 7%);
}

.pack-heading { padding: clamp(10px, 2vw, 20px) clamp(4px, 2vw, 12px) 4px; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1 { margin: 0; color: var(--navy); font-size: clamp(34px, 7vw, 56px); line-height: 1.05; }
.pack-description { max-width: 680px; margin: 16px 0 0; color: var(--text-secondary); line-height: 1.6; }
.pack-total {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 18px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--green-surface);
  color: var(--green);
}
.pack-total span { font-size: 12px; font-weight: 750; }
.pack-total strong { color: var(--navy); font-size: 18px; font-weight: 900; }

.stats-card { margin-top: 22px; overflow: hidden; }
.stats-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  cursor: pointer;
  list-style: none;
}
.stats-card-heading::-webkit-details-marker { display: none; }
.stats-card-heading h2 { font-size: 18px; }
.stats-heading-end { display: flex; align-items: center; gap: 10px; }
.stats-total { color: var(--green); font-size: 13px; font-weight: 800; }
.stats-card[open] > summary .expand-icon { transform: rotate(180deg); }
.stats-card-content { border-top: 1px solid var(--border); padding: 0 20px 20px; }

.donut-wrap {
  position: relative;
  width: min(250px, 78vw);
  margin: 18px auto 22px;
  aspect-ratio: 1;
}

.donut-chart { display: block; width: 100%; height: 100%; }
.donut-empty { fill: none; stroke: var(--border); stroke-width: 48; }
.donut-segment {
  cursor: pointer;
  transition: opacity .18s ease, filter .18s ease;
}
.donut-segment:hover,
.donut-segment:focus-visible {
  filter: brightness(1.08);
  opacity: .82;
  outline: none;
}
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-weight { color: var(--text); font-size: 22px; font-weight: 900; }
.donut-percent { margin-top: 3px; color: var(--text-secondary); font-size: 14px; font-weight: 700; }

.classification-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); padding-top: 18px; }
.classification-item { display: grid; justify-items: center; gap: 5px; padding: 0 10px; text-align: center; }
.classification-item + .classification-item { border-left: 1px solid var(--border); }
.classification-icon { width: 23px; height: 23px; fill: currentColor; }
.classification-label { min-height: 26px; color: var(--text-secondary); font-size: 11px; font-weight: 700; }
.classification-item strong { color: var(--text); font-size: 14px; }
.classification-percent { font-size: 13px; font-weight: 800; }
.classification-base .classification-icon, .classification-base .classification-percent { color: var(--green); }
.classification-worn .classification-icon, .classification-worn .classification-percent { color: #2563eb; }
.classification-consumable .classification-icon, .classification-consumable .classification-percent { color: #d97706; }

.breakdown-card { margin-top: 18px; overflow: hidden; }
.breakdown-card > summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 19px 20px; cursor: pointer; list-style: none; }
.breakdown-card > summary::-webkit-details-marker, .category-header::-webkit-details-marker { display: none; }
.breakdown-card > summary strong { display: block; font-size: 17px; }
.breakdown-card > summary small { display: block; margin-top: 3px; color: var(--text-secondary); font-size: 12px; }
.expand-icon {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--green-surface);
  transition: transform .2s ease, background-color .2s ease;
}
.expand-icon::before {
  position: absolute;
  top: 9px;
  left: 10px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--green);
  border-bottom: 2px solid var(--green);
  content: '';
  transform: rotate(45deg);
}
summary:hover .expand-icon { background: #dcefd5; }
.breakdown-card[open] > summary .expand-icon, .category-card[open] > summary .expand-icon { transform: rotate(180deg); }
.breakdown-list { border-top: 1px solid var(--border); padding: 4px 18px 12px; }
.breakdown-row { padding: 12px 4px; }
.breakdown-values { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.breakdown-identity { display: flex; min-width: 0; align-items: center; gap: 10px; }
.breakdown-identity strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.breakdown-numbers { display: grid; flex: none; grid-template-columns: 78px 48px; gap: 8px; color: var(--text); font-size: 13px; font-weight: 700; text-align: right; }
.breakdown-track { height: 5px; margin: 9px 0 0 20px; overflow: hidden; border-radius: 20px; background: var(--border); }
.breakdown-track span { display: block; height: 100%; border-radius: inherit; }

.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 30px 4px 12px; }
.section-heading h2 { font-size: 20px; }
.section-heading span { color: var(--text-secondary); font-size: 13px; font-weight: 700; }
.category-list { display: grid; gap: 16px; margin-top: 20px; }
.category-card { overflow: hidden; }
.category-card.category-highlight {
  animation: category-flash 1.4s ease-out;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  list-style: none;
}

.category-card:not([open]) .category-header { border-bottom-color: transparent; }

.category-identity { display: flex; min-width: 0; align-items: center; gap: 11px; }
.category-dot { width: 12px; height: 12px; flex: none; border-radius: 50%; }
h2 { overflow: hidden; margin: 0; color: var(--navy); font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.category-weight { color: var(--text-secondary); font-size: 13px; font-weight: 750; }
.category-totals { display: flex; flex: none; align-items: center; gap: 10px; }
.item-list { margin: 0; padding: 0; list-style: none; }

.item-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 22px;
}

.item-list li + li { border-top: 1px solid var(--border); }
.item-name { display: block; font-weight: 700; }
.item-description {
  display: block;
  max-width: 620px;
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}
.item-metadata {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
}
.item-status {
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  border-radius: 9px;
}
.item-status svg { width: 18px; height: 18px; fill: currentColor; }
.item-status-worn { background: #eff6ff; color: #2563eb; }
.item-status-consumable { background: #fff7ed; color: #d97706; }
.item-quantity { color: var(--text-secondary); font-size: 13px; font-weight: 700; }
.item-weight { flex: none; color: var(--navy-soft); font-size: 13px; font-weight: 750; }

.state-card { padding: 64px 24px; text-align: center; }
.state-card h1 { margin-top: 16px; font-size: 28px; }
.state-card p { color: var(--text-secondary); }
.state-icon { display: grid; width: 54px; height: 54px; margin: auto; place-items: center; border-radius: 50%; background: #fff1ef; color: #c83b32; font-size: 28px; font-weight: 850; }
.spinner { width: 42px; height: 42px; margin: auto; border: 4px solid var(--green-surface); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
footer { padding: 0 16px 32px; color: var(--text-secondary); font-size: 13px; text-align: center; }
footer a { color: var(--green); font-weight: 750; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes category-flash {
  0%, 45% { border-color: var(--green); box-shadow: 0 0 0 5px rgb(63 113 50 / 22%); }
  100% { border-color: var(--border); box-shadow: 0 12px 36px rgb(17 28 43 / 7%); }
}

@media (max-width: 640px) {
  .site-header { min-height: 64px; padding: 10px 16px; }
  .brand { max-width: 100%; }
  .brand img { width: clamp(156px, 51vw, 180px); }
  .page-shell { width: min(100% - 24px, 880px); margin: 16px auto 28px; }
  .stats-card, .breakdown-card, .category-card, .state-card { border-radius: 18px; }
  .stats-card-heading { padding: 18px 14px; }
  .stats-card-content { padding: 0 14px 18px; }
  .category-header, .item-list li { padding-right: 16px; padding-left: 16px; }
  .breakdown-numbers { grid-template-columns: 68px 42px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .category-card.category-highlight { animation: none; border-color: var(--green); }
}
