/* Palette taken from the Marco's catering mock-up: deep red, forest green, cream.
   Contrast checked against white and cream backgrounds for WCAG AA body text. */
:root {
  --red: #c41230;
  --red-dark: #9c0e26;
  --red-wash: #fdf2f4;
  --green: #00733c;
  --green-dark: #005c30;
  --green-wash: #f0faf4;
  --cream: #fbf5ec;
  --cream-line: #ece2d2;

  --ink: #231f20;
  --muted: #5c5350;
  --line: var(--cream-line);
  --bg: var(--cream);
  --accent: var(--red);
  --error: #b3122b;
  --focus: #1d4ed8;
  --amber: #92400e;
  --amber-wash: #fffbeb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 8px;
  top: 8px;
  background: #fff;
  padding: 8px 12px;
  z-index: 10;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 3px solid var(--red);
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--red);
  letter-spacing: -0.01em;
  font-size: 1.05rem;
}
/* The logo file is opaque white, so it only sits correctly on the white header.
   Displayed at its natural aspect ratio and never recoloured (trademark guidelines). */
.brand-logo {
  width: 40px;
  height: 40px;
  display: block;
  border-radius: 6px;
}
.brand-text { white-space: nowrap; }
.site-header nav { display: flex; align-items: center; gap: 16px; }
.site-header nav a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.94rem;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.site-header nav a:hover { color: var(--red); border-bottom-color: var(--red); }
.who { color: var(--muted); font-size: 0.9rem; }
form.inline { display: inline; margin: 0; }

main { max-width: 1320px; margin: 0 auto; padding: 24px 20px 48px; }

h1 { font-size: 1.55rem; margin: 0 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0; }
.lede, .desc, .hint, .empty { color: var(--muted); }
.hint { font-size: 0.9rem; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(35, 31, 32, 0.04);
}
.card.narrow { max-width: 420px; margin: 40px auto; }

.item-list { list-style: none; padding: 0; margin: 20px 0 0; }
.item-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.price { font-weight: 700; white-space: nowrap; }
.delta { color: var(--muted); font-size: 0.85rem; }

.options { border: 0; border-top: 1px solid var(--line); margin: 16px 0 0; padding: 12px 0 0; }
.options legend { font-weight: 600; font-size: 0.9rem; padding: 0; }
.rule { font-weight: 400; color: var(--muted); }
.choices {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 8px 0 0;
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.choices li {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}

label { display: block; margin: 14px 0 4px; font-weight: 600; font-size: 0.9rem; }
input[type="email"], input[type="password"], input[type="text"] {
  width: 100%;
  padding: 10px;
  border: 1px solid #a8a29e;
  border-radius: 6px;
  font-size: 1rem;
}

button.primary {
  margin-top: 20px;
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--red);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
button.primary:hover { background: var(--red-dark); }

.link-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.error {
  color: var(--error);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 0 0 4px;
}

.site-footer {
  padding: 20px;
  text-align: center;
  color: #fff;
  font-size: 0.85rem;
  background: var(--red);
}
.site-footer p { margin: 0; opacity: 0.95; }

/* --- Order builder & summaries --- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

main { max-width: 1320px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 620px) { .grid-2 { grid-template-columns: 1fr; } }

select, input[type="date"], input[type="number"] {
  width: 100%;
  padding: 9px;
  border: 1px solid #a8a29e;
  border-radius: 6px;
  font-size: 1rem;
  background: #fff;
}

table { width: 100%; border-collapse: collapse; }
.line-table, .summary { margin-top: 12px; }
.line-table th, .summary th, .line-table td, .summary td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.line-table th, .summary thead th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.col-qty { width: 90px; }
.line-table .qty { width: 80px; }
.num { text-align: right; }
.summary tfoot th, .summary tfoot td { border-bottom: 0; padding-top: 12px; font-weight: 700; }
.total { font-size: 1.2rem; color: var(--red); }

@media (max-width: 620px) {
  .line-table thead { display: none; }
  .line-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .line-table td { border: 0; padding: 0; }
  .line-table .qty { width: 100%; }
}

button.secondary {
  margin-top: 16px;
  padding: 9px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--green);
  background: #fff;
  border: 2px solid var(--green);
  border-radius: 6px;
  cursor: pointer;
}
button.secondary:hover { background: var(--green-wash); }

.button-link {
  display: inline-block;
  padding: 10px 16px;
  background: var(--red);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
}
.button-link:hover { background: var(--red-dark); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
/* Colour is an accelerant, not the message: the status word is always rendered too. */
.badge-new { background: var(--red-wash); border-color: #f3c6cd; color: var(--red-dark); }
.badge-accepted { background: var(--green-wash); border-color: #b6e3c9; color: var(--green-dark); }
.badge-delivered { background: var(--green); border-color: var(--green); color: #fff; }
.badge-modification,
.badge-updated { background: var(--amber-wash); border-color: #fde68a; color: var(--amber); }
.badge-cancelled { background: #f5f3f1; border-color: #ddd6d1; color: var(--muted); }

.detail { display: grid; grid-template-columns: 180px 1fr; gap: 6px 16px; margin: 12px 0 0; }
.detail dt { color: var(--muted); font-size: 0.9rem; }
.detail dd { margin: 0; }
@media (max-width: 620px) { .detail { grid-template-columns: 1fr; } .detail dd { margin-bottom: 8px; } }

.history { list-style: none; padding: 0; margin: 12px 0 0; }
.history li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.95rem; }

.error ul { margin: 8px 0 0; padding-left: 20px; }

.notice {
  color: #14532d;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 10px 12px;
}

.check { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; }
.check input[type="checkbox"] { width: 18px; height: 18px; }
.inline-label { display: inline; margin: 0; font-weight: 400; }

.choice-table input[type="text"] { padding: 6px 8px; font-size: 0.95rem; }
.choice-table td, .choice-table th { padding: 6px 8px; }
.choice-table input[type="checkbox"] { width: 18px; height: 18px; }

.danger-row { margin: -8px 0 20px; text-align: right; }
.link-button.danger { color: var(--error); font-size: 0.85rem; }

.closed-window {
  color: #7c2d12;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 10px 12px;
}

/* --- Orders grid (replaces the spreadsheet's single-sheet view) --- */



.grid-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 16px;
}
.pager { display: flex; gap: 8px; flex-wrap: wrap; }
.pager-link {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  background: #fff;
  white-space: nowrap;
}
.pager-link:hover { border-color: var(--red); color: var(--red); }

.filter-form { display: flex; align-items: center; gap: 8px; }
.filter-form select { width: auto; min-width: 130px; }
button.secondary.compact { margin-top: 0; padding: 7px 12px; }

.totals { color: var(--muted); margin: 4px 0 12px; }

/* Horizontal scroll rather than squeezing: the grid is dense by design. */
.grid-scroll {
  overflow-x: visible;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(35, 31, 32, 0.04);
}

.order-grid { width: 100%; border-collapse: collapse; font-size: 0.9rem; table-layout: fixed; }
.order-grid th, .order-grid td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.order-grid thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--cream);
  border-bottom: 2px solid var(--red);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  white-space: nowrap;
}
.order-grid tbody tr:hover { background: var(--cream); }

.day-row th, .day-row td {
  background: #fdfaf5;
  border-top: 2px solid var(--cream-line);
  border-bottom: 1px solid var(--cream-line);
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
}
.day-row td { font-weight: 600; }

.nowrap { white-space: nowrap; }



.line-chip {
  display: inline-block;
  background: var(--cream);
  border: 1px solid var(--cream-line);
  border-radius: 4px;
  padding: 1px 7px;
  margin: 0 4px 3px 0;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* --- Entry block on the orders workspace (spreadsheet-style row entry) --- */

.entry { padding: 16px 18px; }
.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.entry-head h2 { font-size: 1.05rem; }

.entry-fields {
  display: grid;
  grid-template-columns: 165px 130px minmax(180px, 1fr) 140px minmax(180px, 1fr);
  gap: 0 12px;
  align-items: end;
}
.entry-fields label { margin-top: 10px; margin-bottom: 3px; font-size: 0.82rem; }
@media (max-width: 900px) {
  .entry-fields { grid-template-columns: 1fr 1fr; }
  .entry-fields .f-event, .entry-fields .f-notes { grid-column: span 2; }
}

.line-table.compact { margin-top: 10px; }
.line-table.compact th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.line-table.compact td, .line-table.compact th { padding: 4px 6px; }
.line-table.compact input, .line-table.compact select { padding: 6px 8px; font-size: 0.92rem; }

.inline-estimate {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--green-wash);
  border: 1px solid #b6e3c9;
  border-radius: 6px;
}
.inline-estimate .total { display: block; margin-top: 6px; }

.entry-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
button.primary.compact { width: auto; margin-top: 16px; padding: 10px 20px; }

/* The newly saved row: the list is ordered by delivery date, so the new row may not be at the
   top. Highlight it so the operator can see where it landed. */
.just-added > td { background: var(--green-wash) !important; }
.just-added > td:first-child { box-shadow: inset 3px 0 0 var(--green); }

/* --- Fixed column widths so the grid fits the viewport without a horizontal scrollbar --- */

.c-num { width: 46px; }
.c-time { width: 82px; }
.c-biz { width: 130px; }
.c-event { width: 18%; }
.c-lines { width: auto; }
.c-qty { width: 48px; }
.c-total { width: 88px; }
.c-status { width: 132px; }
.c-act { width: 52px; }

.order-grid td, .order-grid th { overflow-wrap: anywhere; }
.order-grid .c-event .sub {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
}
.order-grid .c-status .badge { margin: 0 2px 2px 0; }
.row-edit {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--red);
  text-decoration: none;
  white-space: nowrap;
}
.row-edit:hover { text-decoration: underline; }

/* Only fall back to scrolling on genuinely narrow screens. */
@media (max-width: 860px) {
  .grid-scroll { overflow-x: auto; }
  .order-grid { table-layout: auto; min-width: 780px; }
}

/* --- Inline edit row --- */

.editing-row > td {
  background: var(--amber-wash);
  box-shadow: inset 3px 0 0 var(--red);
  padding: 14px 16px;
}
.edit-form .entry-head h3 { font-size: 1rem; margin: 0; }
.edit-form .line-table.compact { max-width: 640px; }
.cancel-reason { max-width: 260px; display: inline-block; margin-right: 8px; }
.danger-row { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }

/* --- Administrator section: visually separated so it is never mistaken for routine work --- */

.admin-zone { border: 2px solid var(--red); }
.admin-zone h2 { color: var(--red-dark); }
.warn {
  color: var(--amber);
  background: var(--amber-wash);
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 10px 12px;
}

/* --- Per-business menu builder: one block per item, with its option groups --- */

.menu-item-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 12px 0;
  background: #fff;
}
.menu-item-block.excluded { background: #faf9f7; opacity: 0.72; }

.menu-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.menu-item-head .check { margin: 0; }
.item-name { font-weight: 700; font-size: 1rem; }
.item-price { display: flex; align-items: center; gap: 8px; }
.item-price label { margin: 0; font-size: 0.82rem; }
.item-price .qty { width: 92px; flex: 0 0 92px; text-align: right; }

.opt-group {
  border: 0;
  border-top: 1px dashed var(--line);
  margin: 10px 0 0;
  padding: 10px 0 0;
}
.opt-group legend { font-size: 0.82rem; font-weight: 700; color: var(--muted); padding: 0; }

.opt-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 6px 18px;
  padding: 6px 0 0;
  margin: 0;
}
.opt-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  min-width: 0; /* allow the row to shrink instead of overflowing its grid cell */
}
.opt-list label {
  margin: 0;
  font-weight: 400;
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.25;
}
.opt-list input[type="checkbox"] { width: 17px; height: 17px; flex: none; }

/* Scoped to beat `input[type="text"] { width: 100% }`, which outranks a bare class selector.
   Without this the surcharge boxes render full-width and overlap the next option's label. */
.opt-list .opt-delta {
  width: 68px;
  flex: 0 0 68px;
  padding: 4px 6px;
  font-size: 0.85rem;
  text-align: right;
}

/* Quick shop-status actions in the grid: text buttons, so the row stays light. */
.quick-status { display: block; margin-top: 3px; }
.quick-status .link-button { font-size: 0.8rem; font-weight: 700; }

/* Running estimate: prominent enough to be noticed while typing, plainly marked indicative. */
.live-estimate {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 0;
  padding: 10px 12px;
  background: var(--green-wash);
  border: 1px solid #b6e3c9;
  border-radius: 6px;
}
.live-label { font-weight: 700; font-size: 0.85rem; color: var(--green-dark); }
#live-estimate { font-weight: 700; font-size: 1.05rem; color: var(--ink); }

/* Status cell: a small caption above each badge says whose column it is. */
.badge-line { display: block; margin-bottom: 3px; white-space: nowrap; }
.badge-kind {
  display: inline-block;
  width: 40px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}

/* Second topping greyed out when a non-vegetarian topping is chosen (DESIGN D35). Purely a hint;
   the server enforces the limit. */
select.veg-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Inline POS order ID field on the grid's one-click Accept. Scoped so it beats the bare
   input[type="text"] { width: 100% } rule (DESIGN D29). */
.accept-inline input[type="text"] {
  width: 5rem;
  display: inline-block;
  margin-right: 0.25rem;
}
