:root {
  --paper: #f1f4f9;
  --ink: #161c29;
  --navy: #1f3864;
  --steel: #5b6472;
  --line: #dfe5ee;
  --card: #ffffff;
  --bad: #b00020;
  --amber: #7a4b08;
  --amber-bg: #fff4e0;
  --amber-line: #f0d9a8;
  --potato: #c4a35a;
  --carrot: #c65d32;
  --innovative: #2a6f97;
  --ok: #1f6b4a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.45;
}

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--steel);
}

h1 { font-size: 1.45rem; font-weight: 650; letter-spacing: -0.02em; }
h2 { font-size: 0.95rem; font-weight: 650; margin-bottom: 10px; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 5;
}

#as-of { color: var(--steel); font-size: 0.92rem; margin-top: 2px; }

button {
  min-height: 44px;
  min-width: 44px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  background: var(--navy);
  color: #fff;
  cursor: pointer;
  padding: 0 16px;
}

button:active { transform: scale(0.98); }

.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

a.button .icon { width: 18px; height: 18px; margin-right: 6px; flex: none; }

a.button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  background: var(--paper);
  color: var(--navy);
  border: 1px solid var(--line);
}

button.secondary {
  width: auto;
  background: var(--paper);
  color: var(--navy);
  border: 1px solid var(--line);
}

#banner, #error {
  margin: 12px 16px 0;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
}

#banner {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber-line);
}

#error {
  background: #fde8e8;
  color: var(--bad);
  border: 1px solid #f3c1c1;
}

#board { padding: 12px 16px 32px; }

.kpi {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

@media (min-width: 720px) {
  .kpi { grid-template-columns: repeat(4, 1fr); }
}

.kpi button, .kpi .kpi-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 72px;
}

.kpi .num {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--navy);
}

.kpi .lbl {
  display: block;
  font-size: 0.8rem;
  color: var(--steel);
  margin-top: 2px;
}

.cards {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

@media (min-width: 720px) {
  .cards { grid-template-columns: 1fr 1fr; }
}

.section-head {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.section-head:first-child { margin-top: 0; }
.section-head h2 { margin: 0; }
.section-head span { font-size: 0.85rem; color: var(--steel); }
.section-empty { grid-column: 1 / -1; color: var(--steel); font-size: 0.9rem; }

.card {
  width: 100%;
  text-align: left;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  min-height: 120px;
}

.card .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
}

.card .dot.potato { background: var(--potato); }
.card .dot.carrot { background: var(--carrot); }
.card .dot.innovative { background: var(--innovative); }

.tabs {
  display: flex;
  gap: 8px;
  margin: 4px 0 10px;
  flex-wrap: wrap;
}

button.tab {
  width: auto;
  background: var(--paper);
  color: var(--navy);
  border: 1px solid var(--line);
}

button.tab[aria-pressed="true"] {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

button.chip {
  width: auto;
  flex: 0 0 auto;
  background: var(--paper);
  color: var(--navy);
  border: 1px solid var(--line);
  font-size: 0.9rem;
}

button.chip[aria-pressed="true"] {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.card h3 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.sku-card .lbl {
  color: var(--steel);
  font-size: 0.82rem;
  margin-bottom: 10px;
}

.sizes {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.size-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 1.05rem;
}

.size-row span { color: var(--steel); flex: 1; }
.size-row strong { color: var(--navy); font-size: 1.15rem; text-align: right; }
.size-row em {
  font-style: normal;
  color: var(--steel);
  font-size: 0.9rem;
  min-width: 6.5em;
  text-align: right;
}

.card .big {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--navy);
}

.card .meta {
  color: var(--steel);
  font-size: 0.92rem;
  margin-top: 6px;
}

.sub {
  color: var(--steel);
  font-size: 0.82rem;
}

#outside-note { margin-top: 10px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.age { display: flex; flex-direction: column; gap: 8px; }

.age-row { display: grid; grid-template-columns: 110px 1fr 90px; gap: 8px; align-items: center; }

.age-row .lab { font-size: 0.85rem; color: var(--steel); }
.age-row .val { font-size: 0.85rem; text-align: right; font-weight: 600; }

.bar {
  height: 12px;
  background: var(--paper);
  border-radius: 99px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--navy);
  border-radius: 99px;
}

.split {
  display: grid;
  gap: 12px;
}

@media (min-width: 720px) {
  .split { grid-template-columns: 1fr 1fr; }
}

.lot {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.lot:last-child { border-bottom: none; }

.lot .code { font-weight: 650; }
.lot .sub { color: var(--steel); font-size: 0.82rem; }
.lot .right { text-align: right; }

footer {
  color: var(--steel);
  font-size: 0.82rem;
  padding: 8px 2px 24px;
}

.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(22, 28, 41, 0.4); }

.drawer-sheet {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(420px, 100%);
  background: var(--card);
  padding: 16px;
  overflow-y: auto;
  box-shadow: -8px 0 24px rgba(22, 28, 41, 0.12);
}

.drawer-close { margin-bottom: 16px; }

.drawer-sheet dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.drawer-sheet dt { font-size: 0.78rem; color: var(--steel); text-transform: uppercase; letter-spacing: 0.06em; }
.drawer-sheet dd { font-size: 1.05rem; font-weight: 650; }

.status-pill {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--paper);
  color: var(--steel);
}

.status-pill.idle { background: var(--amber-bg); color: var(--amber); }
.status-pill.running { background: #e5f6ee; color: var(--ok); }

[hidden] { display: none !important; }

#login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

#login-form {
  width: min(360px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 18px;
}

#login-form .lead { color: var(--steel); margin: 8px 0 14px; }
#login-form input[type="password"],
#login-form input[type="email"] {
  width: 100%;
  min-height: 44px;
  font-size: 1rem;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 10px;
}
#login-form button { width: 100%; }
#login-form .err { color: var(--bad); min-height: 1.2em; margin-bottom: 8px; font-size: 0.92rem; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
