:root {
  --fg: #2b1d12; --bg: #fbf6ef; --card: #ffffff; --muted: #7a6a5c; --line: #eadfd2;
  --accent: #b45309; --accent-fg: #ffffff; --accent-soft: #fdecd6;
  --ready: #15803d; --ready-soft: #dcfce7; --pending: #b45309; --pending-soft: #fef3c7;
  --done: #6b7280; --done-soft: #f1f1f1; --error: #b91c1c; --error-soft: #fee2e2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #f3ebe2; --bg: #17120e; --card: #221b15; --muted: #b3a393; --line: #3a2f25;
    --accent: #f59e0b; --accent-fg: #1c1208; --accent-soft: #3a2a14;
    --ready: #4ade80; --ready-soft: #14321f; --pending: #fbbf24; --pending-soft: #3a2e10;
    --done: #a1a1aa; --done-soft: #2a2a2a; --error: #fca5a5; --error-soft: #3b1515;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 17px/1.5 system-ui, -apple-system, sans-serif; color: var(--fg); background: var(--bg); }
.container { max-width: 720px; margin: 0 auto; padding: 16px 14px 48px; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 1; padding: 12px 0; background: var(--bg);
}
.date { margin: 0; color: var(--muted); font-size: 0.9rem; }
.total {
  display: flex; flex-direction: column; align-items: flex-end;
  background: var(--accent); color: var(--accent-fg); border-radius: 14px; padding: 8px 16px;
}
.total-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.9; }
.total-amount { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.item-counts {
  list-style: none; margin: 0 0 16px; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px;
}
.item-counts li { background: var(--accent-soft); border-radius: 999px; padding: 2px 12px; font-size: 0.9rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.new-order { margin-bottom: 24px; }
.error { background: var(--error-soft); color: var(--error); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; }

.field { display: block; border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
.field > span, .field > legend { display: block; font-weight: 600; margin-bottom: 6px; padding: 0; }
input[type="text"], input[type="number"] {
  width: 100%; min-height: 52px; padding: 10px 14px; font: inherit; font-size: 1.1rem;
  color: var(--fg); background: var(--bg); border: 2px solid var(--line); border-radius: 12px;
}
input:focus { outline: none; border-color: var(--accent); }

.menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.menu-item input { position: absolute; opacity: 0; pointer-events: none; }
.menu-item span {
  display: flex; flex-direction: column; justify-content: center; min-height: 64px; padding: 8px 12px;
  border: 2px solid var(--line); border-radius: 12px; background: var(--bg); cursor: pointer;
}
.menu-item small { color: var(--muted); font-size: 0.95rem; }
.menu-item input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.menu-item input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.row { display: flex; gap: 12px; align-items: flex-end; }
.qty { flex: 0 0 110px; margin-bottom: 0; }

.btn {
  min-height: 52px; padding: 10px 20px; font: inherit; font-weight: 700; font-size: 1.05rem;
  border: 0; border-radius: 12px; cursor: pointer; touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn-primary { flex: 1; background: var(--accent); color: var(--accent-fg); }
.btn-ready { background: var(--ready); color: var(--card); }
.btn-picked { background: var(--done); color: var(--card); }
.btn-clear { width: 100%; background: transparent; color: var(--done); border: 2px solid var(--line); }

.counts { display: block; font-size: 0.85rem; font-weight: 400; color: var(--muted); }
.clear-picked { margin: 0 0 12px; }
.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.order { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.order form { margin: 0; flex-shrink: 0; }
.order .btn { min-width: 128px; }
.order-main { min-width: 0; }
.order-who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.customer { font-size: 1.15rem; overflow-wrap: anywhere; }
.order-what { margin-top: 2px; }
.order-time { color: var(--muted); font-size: 0.9rem; }
.status-pending { border-left: 6px solid var(--pending); }
.status-ready { border-left: 6px solid var(--ready); }
.status-picked_up { opacity: 0.6; }

.badge { font-size: 0.75rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; text-transform: uppercase; }
.badge-pending { background: var(--pending-soft); color: var(--pending); }
.badge-ready { background: var(--ready-soft); color: var(--ready); }
.badge-picked_up { background: var(--done-soft); color: var(--done); }

.history { width: 100%; border-collapse: separate; border-spacing: 0; padding: 4px 16px; }
.history th, .history td { padding: 12px 0; text-align: right; border-bottom: 1px solid var(--line); }
.history th[scope="row"], .history thead th:first-child { text-align: left; font-weight: 600; }
.history thead th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.history td { padding-left: 12px; font-variant-numeric: tabular-nums; }
.history tfoot th, .history tfoot td { border-bottom: 0; font-weight: 700; }
.history-empty { color: var(--muted); }

.empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* Phones and tablets: two big tabs above the content. Desktop: fixed left sidebar (below). */
.sidenav { display: flex; gap: 8px; max-width: 720px; margin: 0 auto; padding: 12px 14px 0; }
.sidenav a {
  flex: 1; display: flex; align-items: center; justify-content: center; min-height: 52px; padding: 8px 16px;
  border: 2px solid var(--line); border-radius: 12px; background: var(--card);
  color: var(--fg); font-weight: 700; text-decoration: none; touch-action: manipulation;
}
.sidenav a:hover { border-color: var(--accent); }
.sidenav a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sidenav a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

@media (min-width: 900px) {
  body { padding-left: 200px; }
  .sidenav {
    position: fixed; top: 0; bottom: 0; left: 0; width: 200px; max-width: none; margin: 0;
    flex-direction: column; gap: 4px; padding: 28px 12px;
    background: var(--card); border-right: 1px solid var(--line);
  }
  .sidenav a { flex: 0 0 auto; justify-content: flex-start; min-height: 48px; border: 0; background: none; }
  .sidenav a:hover { background: var(--accent-soft); }
  .sidenav a[aria-current="page"] { background: var(--accent); color: var(--accent-fg); }
}

@media (max-width: 420px) {
  .order { flex-direction: column; align-items: stretch; }
  .order .btn { width: 100%; }
}
