:root {
  --brand: #e8461e; --brand-dark: #c23812; --teal: #1f5a5a; --teal-soft: #e3eeee;
  --bg: #f5f4f1; --card: #fff; --ink: #1e2422; --muted: #6b7471; --line: #e4e2dd;
  --ok: #1d7a46; --ok-bg: #e2f3e8; --warn: #9a6200; --warn-bg: #fdf0d5; --bad: #b3261e; --bad-bg: #fbe4e1; --info-bg: #e5eef8;
  --r: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--teal); }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px 32px; }
main.wide { max-width: 1400px; }
h2 { font-size: 1.05rem; margin: 22px 2px 8px; color: var(--teal); }
h3 { font-size: .95rem; margin: 18px 2px 6px; color: var(--teal); }
small { display: block; color: var(--muted); font-size: .82rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.bad-text { color: var(--bad); font-weight: 600; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 12px; background: var(--teal); color: #fff; }
.top .brand img { height: 34px; width: 44px; object-fit: contain; background: #fff; border-radius: 8px; padding: 2px; display: block; }
.top .back { color: #fff; text-decoration: none; font-size: 2rem; line-height: 1; width: 44px; height: 44px; display: grid; place-items: center; margin-left: -8px; }
.top-title { flex: 1; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu summary { list-style: none; cursor: pointer; font-size: 1.4rem; width: 44px; height: 44px; display: grid; place-items: center; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 8px; top: 52px; background: #fff; color: var(--ink); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18); min-width: 220px; padding: 6px; }
.menu-pop a, .menu-pop button { display: block; width: 100%; text-align: left; padding: 12px; border: 0; background: none; font: inherit; color: var(--ink); text-decoration: none; border-radius: 8px; }
.menu-pop a:active, .menu-pop button:active { background: var(--bg); }
.menu-who { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-weight: 600; }

/* building blocks */
.card { display: block; background: var(--card); border-radius: var(--r); padding: 14px; margin: 10px 0; box-shadow: 0 1px 2px rgba(0,0,0,.05); border: 1px solid var(--line); color: inherit; text-decoration: none; }
.card.list { padding: 0; overflow: hidden; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; min-height: 56px; }
.list-row:first-child { border-top: 0; }
.list-row .right, .list-row .qty { text-align: right; flex-shrink: 0; }
.qty { font-weight: 700; font-size: 1.05rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 18px; border-radius: 12px; border: 0; background: var(--brand); color: #fff; font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; }
.btn:active { background: var(--brand-dark); }
.btn.ghost { background: #fff; color: var(--teal); border: 1.5px solid var(--teal); }
.btn.big { width: 100%; min-height: 54px; font-size: 1.05rem; }
.btn[disabled] { opacity: .45; }
.small-btn { min-height: 40px; padding: 0 14px; font-size: .92rem; }
.wide-btn { width: 100%; margin-top: 14px; }
.link-btn { background: none; border: 0; color: var(--bad); font: inherit; font-size: .82rem; padding: 4px 0; }
form.inline { display: inline; }
.chip { display: inline-block; font-size: .75rem; font-weight: 650; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); } .chip.info { background: var(--info-bg); color: #24507e; }
.chip.muted { background: #eceae5; color: var(--muted); }
.alert { padding: 12px 14px; border-radius: 12px; margin: 10px 0; }
.alert.ok { background: var(--ok-bg); color: #13502e; } .alert.bad { background: var(--bad-bg); color: #7a1a14; }
.alert.warn { background: var(--warn-bg); color: #6b4500; } .alert.info { background: var(--info-bg); color: #1d3f63; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }
.hello { font-weight: 650; margin: 6px 2px 0; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.actions .btn { padding: 0 10px; font-size: .92rem; text-align: center; }
.actions .btn:only-child { grid-column: 1 / -1; }

/* forms */
.form label { display: block; font-size: .88rem; font-weight: 600; color: var(--muted); margin: 10px 0; }
.form input, .form select, .form textarea, .site-filter select { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 16px; color: var(--ink); padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--teal); border-color: var(--teal); }
.form label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; }
.form label.check input { width: 22px; height: 22px; margin: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two label { margin: 6px 0; }
.site-filter { margin: 10px 0; }
.tabs { display: flex; gap: 4px; background: #e9e7e2; padding: 4px; border-radius: 12px; margin: 10px 0; overflow-x: auto; }
.tabs a { flex: 1; text-align: center; padding: 10px 8px; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; font-size: .92rem; }
.tabs a.on { background: #fff; color: var(--teal); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg { display: flex; gap: 6px; margin: 10px 0; }
.seg a, .seg button { flex: 1; text-align: center; padding: 10px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; font: inherit; font-weight: 600; font-size: .92rem; }
.seg .on { border-color: var(--teal); background: var(--teal); color: #fff; }
details.edit { display: block; padding: 0; }
details.edit summary { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; cursor: pointer; list-style: none; min-height: 52px; }
details.edit summary::-webkit-details-marker { display: none; }
details.edit form { padding: 0 14px 14px; }
details.extra summary { font-weight: 650; color: var(--teal); cursor: pointer; }

/* login */
body.plain { background: linear-gradient(180deg, #fff 0, var(--bg) 320px); }
body.plain .top { display: none; }
.login { text-align: center; padding-top: 18px; }
.login-logo { width: 120px; }
.login h1 { margin: 6px 0 2px; font-size: 1.5rem; color: var(--teal); }
.login form { text-align: left; }

/* cycle cards */
.card.cycle { position: relative; }
.card.cycle .btn { margin-top: 12px; width: 100%; }
.due { margin-top: 6px; }
.progress { height: 8px; background: #ecebe6; border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.progress span { display: block; height: 100%; background: var(--ok); }
.stat-row { display: flex; gap: 10px; margin: 12px 0; }
.stat { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; }
.stat b { font-size: 1.6rem; display: block; color: var(--teal); }
.stat span { color: var(--muted); font-size: .85rem; }

/* order form */
body.with-bar main { padding-bottom: 96px; }
.order-head .small-btn { margin-top: 10px; }
.tools { position: sticky; top: 54px; z-index: 10; background: var(--bg); padding: 10px 0 6px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.tools input[type=search] { width: 100%; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; }
.sections { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.sections::-webkit-scrollbar { display: none; }
.sections button { flex-shrink: 0; border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 99px; padding: 7px 13px; font: inherit; font-size: .88rem; font-weight: 600; }
.sections button.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.sec h3 { scroll-margin-top: 170px; }
.item { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 8px 12px; margin: 6px 0; }
.item.has { border-color: var(--brand); background: #fff7f4; box-shadow: inset 4px 0 0 var(--brand); }
.iname { min-width: 0; }
.iname b { font-weight: 600; display: block; }
.unit { font-weight: 600; color: var(--teal); }
.stepper { display: flex; align-items: center; flex-shrink: 0; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--teal-soft); color: var(--teal); font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stepper button.plus { background: var(--teal); color: #fff; }
.stepper input { width: 52px; height: 44px; text-align: center; font: inherit; font-size: 17px; font-weight: 700; border: 0; background: transparent; }
.item:not(.has) .stepper .minus { visibility: hidden; }
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
.bar .btn { flex: 1; max-width: 360px; margin-left: auto; }
.send { margin-top: 10px; }

/* chef delivery check */
.help .small-btn { margin-top: 10px; }
.sline { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.sline:first-child { border-top: 0; }
.sline.received { background: #f1faf4; } .sline.short { background: #fdf1ef; } .sline.pending { background: #fff8e8; }
.sctl { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sctl .tick { width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--ok); background: #fff; color: var(--ok); font-size: 1.2rem; font-weight: 700; }
.sline.received .tick { background: var(--ok); color: #fff; }
.sval { width: 58px; height: 44px; text-align: center; font: inherit; font-size: 17px; font-weight: 700; border: 1.5px solid var(--line); border-radius: 10px; }
.later { display: flex; flex-direction: column; align-items: center; font-size: .72rem; color: var(--muted); }
.later input { width: 22px; height: 22px; margin: 0; }
.manage { margin-top: 24px; }

/* consolidated table */
.matrix-wrap { overflow: auto; max-height: 70vh; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
.matrix { border-collapse: separate; border-spacing: 0; font-size: .88rem; }
.matrix th, .matrix td { padding: 7px 8px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; white-space: nowrap; background: #fff; }
.matrix thead th { position: sticky; top: 0; z-index: 2; background: var(--teal-soft); color: var(--teal); }
.matrix .sticky { position: sticky; left: 0; z-index: 1; text-align: left; min-width: 150px; max-width: 190px; white-space: normal; }
.matrix thead .sticky { z-index: 3; }
.matrix .tot { font-weight: 700; background: #fff7f4; }
.matrix .secrow td { background: #fce9e2; font-weight: 700; color: var(--brand-dark); }
.matrix small { font-size: .72rem; }

@media (min-width: 720px) {
  .actions { grid-template-columns: repeat(4, 1fr); }
}
/* Desktop and tablet: wider pages, items in two or three columns */
@media (min-width: 900px) {
  main { max-width: 860px; }
  body.with-bar main { max-width: 1180px; }
  .sec { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
  .sec h3 { grid-column: 1 / -1; }
  .tools { margin: 0; padding-left: 0; padding-right: 0; }
  .bar { padding-left: max(16px, calc(50% - 574px)); padding-right: max(16px, calc(50% - 574px)); }
  .login { max-width: 440px; margin: 0 auto; padding-top: 48px; }
  .stepper button:hover { filter: brightness(1.1); }
  .btn:hover { filter: brightness(1.06); }
  a.list-row:hover, a.card.cycle:hover { background: #fbfaf8; }
}
@media (min-width: 1300px) {
  .sec { grid-template-columns: 1fr 1fr 1fr; }
}
