:root {
  --bg: #f6f1e9; --panel: #fffdf9; --ink: #221b14; --muted: #6d6156; --line: #e7ddcf; --soft: #f2ebe0;
  --accent: #8f4a10; --accent-ink: #ffffff; --accent-soft: #f6e7d6;
  --ok: #2f7d32; --ok-soft: #e7f3e5; --warn: #9a5b06; --warn-soft: #fcf0dc; --bad: #b3261e; --bad-soft: #fbe9e7; --info: #3b5ba5; --info-soft: #e9eef9;
  --radius: 10px; --shadow: 0 1px 2px rgba(34, 27, 20, .06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110d; --panel: #1d1914; --ink: #efe7db; --muted: #a99c8b; --line: #362e25; --soft: #191510;
    --accent: #f0a35a; --accent-ink: #2a1604; --accent-soft: #3a2614;
    --ok: #7bd389; --ok-soft: #15261a; --warn: #f5c062; --warn-soft: #2c2210; --bad: #ff8a80; --bad-soft: #2e1514; --info: #9db7f5; --info-soft: #172036;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
.boot { padding: 40px 16px; color: var(--muted); }

/* header and tabs */
.top { position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1160px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; letter-spacing: -.01em; margin-right: auto; }
.brand small { font-weight: 500; color: var(--muted); margin-left: 6px; font-size: 13px; }
.tabs { max-width: 1160px; margin: 0 auto; padding: 0 16px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 9px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
main { max-width: 1160px; margin: 0 auto; padding: 18px 16px 120px; }
h1 { font-size: 20px; margin: 4px 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 4px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
.lead { color: var(--muted); margin: 0 0 16px; max-width: 780px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.banner { border-radius: 8px; padding: 9px 12px; font-size: 14px; margin: 0 0 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner.demo { background: var(--info-soft); color: var(--info); }
.banner.test { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }

/* cards and grids */
.grid { display: grid; gap: 12px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.g6 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 12px; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; margin-right: auto; }
.kpi { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.kpi small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.section { margin-top: 22px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stack > * + * { margin-top: 8px; }
.spacer { flex: 1; }

/* pills, chips and dots */
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.status { display: inline-block; border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; background: var(--soft); color: var(--muted); }
.status.approved { background: var(--info-soft); color: var(--info); }
.status.creating { background: var(--warn-soft); color: var(--warn); }
.status.created { background: var(--ok-soft); color: var(--ok); }
.status.skipped, .status.replaced { text-decoration: line-through; }

/* key-value lines */
.lines { list-style: none; padding: 0; margin: 0; }
.lines li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.lines li:last-child { border-bottom: 0; }
.lines .v { margin-left: auto; color: var(--muted); font-size: 13px; text-align: right; }

/* buttons and fields */
button, .btn { font: inherit; font-weight: 600; font-size: 14px; border-radius: 8px; padding: 8px 14px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; }
button:hover, .btn:hover { border-color: var(--muted); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 4px 6px; color: var(--accent); min-height: 0; }
button.small { min-height: 30px; padding: 3px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
label .hint { font-weight: 400; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 15px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 38px; }
textarea { font-family: var(--mono); font-size: 13px; min-height: 120px; }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
input.qty { width: 84px; min-height: 32px; padding: 4px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 12px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { flex: 1; }
.mono { font-family: var(--mono); font-size: 13px; }
.errors { color: var(--bad); font-size: 13px; margin: 8px 0 0; }
.note { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.note.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.note.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.steps { margin: 6px 0 0; padding-left: 20px; font-size: 14px; }
.steps li { margin: 4px 0; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; margin: 0; cursor: pointer; }
.progress { height: 8px; border-radius: 6px; background: var(--soft); overflow: hidden; margin: 8px 0 4px; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width .3s; }

/* production lines */
.linecard { border-left: 4px solid var(--line); }
.linecard.approved { border-left-color: var(--info); }
.linecard.creating { border-left-color: var(--warn); }
.linecard.created { border-left-color: var(--ok); }
.linecard.skipped, .linecard.replaced { opacity: .65; }
.linecard .meta { color: var(--muted); font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.neg { color: var(--bad); }
.mo { font-family: var(--mono); font-size: 12px; color: var(--ok); }
.mo.would { color: var(--muted); }
.mo.err { color: var(--bad); font-family: inherit; }

/* pour sheets */
.pots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.pot { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--soft); }
.pot b { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.pot .w { font-size: 18px; font-weight: 700; }
.pot .o { font-size: 14px; }

/* season: last year week by week */
.bars { display: grid; gap: 6px; margin-top: 10px; }
.bar { display: grid; grid-template-columns: 92px 1fr 56px; gap: 10px; align-items: center; font-size: 13px; }
.bar .track { height: 14px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.bar .fill { display: block; height: 100%; background: var(--accent-soft); border-right: 2px solid var(--accent); }
.bar.peak .fill { background: var(--accent); }
.bar .v { text-align: right; font-variant-numeric: tabular-nums; }
details.card > summary { cursor: pointer; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
details.card[open] > summary { margin-bottom: 10px; }

/* retailers */
.retailer { border-left: 4px solid var(--line); }
.retailer.due { border-left-color: var(--warn); }
.retailer.lapsed, .retailer.hold { border-left-color: var(--bad); }
.retailer.soon { border-left-color: var(--info); }
.retailer.nudged { border-left-color: var(--ok); }
textarea.msg { font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; margin-top: 8px; }

/* order desk */
.order { border-left: 4px solid var(--line); }
.order.high { border-left-color: var(--bad); }
.order.medium { border-left-color: var(--warn); }
.issues { list-style: none; padding: 0; margin: 6px 0 0; font-size: 14px; }
.issues li { padding: 3px 0; display: flex; gap: 8px; align-items: baseline; }
.issues .lvl { flex: none; font-size: 11px; font-weight: 700; text-transform: uppercase; border-radius: 4px; padding: 0 6px; }
.lvl.high { background: var(--bad-soft); color: var(--bad); } .lvl.medium { background: var(--warn-soft); color: var(--warn); } .lvl.info { background: var(--soft); color: var(--muted); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; background: var(--soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.short td { background: var(--warn-soft); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.filters button { min-height: 30px; padding: 3px 10px; font-size: 13px; font-weight: 500; }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
pre.summary { white-space: pre-wrap; font: 13px/1.55 var(--mono); margin: 0; }

/* sign-in */
.signin { max-width: 380px; margin: 10vh auto; padding: 0 16px; }
.signin .card { padding: 22px; }
.signin h1 { margin-bottom: 6px; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; max-width: calc(100% - 32px); }
#toast div { background: var(--ink); color: var(--panel); padding: 10px 14px; border-radius: 8px; font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); margin-top: 6px; }
#toast div.bad { background: var(--bad); color: #fff; }

@media (max-width: 640px) {
  main { padding-top: 14px; }
  .kpi { font-size: 20px; }
  th, td { padding: 6px 8px; }
  td:first-child { min-width: 170px; } /* the table scrolls inside its box; rows stay one or two lines */
}
@media print {
  .top, .no-print, #toast, .banner { display: none !important; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; border-color: #bbb; }
  .pot { background: #fff; border-color: #999; }
}
