/* Micaela — "Letra grande y clara".
   Written for a clientele that includes many older people: one highly legible typeface at a
   large size, near-black text on a light cream page (every text colour here clears WCAG AAA,
   7:1), one deep blue for everything you can press, and controls big enough that a shaky
   thumb lands on the one it meant. Nothing decorative, nothing thin, nothing pale. */
@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&display=swap');

:root {
  /* Surfaces */
  --bg: #fbf8f1;            /* very light cream page */
  --card-bg: #ffffff;
  --tint: #e9eef8;          /* chosen / selected background, pale blue */
  --warm-tint: #fbf1e3;     /* notices */

  /* Lines. --border is for controls (≥3:1 against white, so a field can be seen);
     --line is for quiet separators between rows. */
  --border: #7d766d;
  --line: #d8d1c4;

  /* Text — all ≥7:1 on white and on the cream page */
  --text: #16130f;          /* ~18:1 */
  --text-muted: #45403a;    /* ~10:1, still dark: secondary, never faint */

  /* The one action colour, and its pressed state */
  --accent: #0b3d91;        /* ~10:1 on white, white on it ~10:1 */
  --accent-hover: #082d6c;
  --on-accent: #ffffff;

  /* Allergens and destructive actions */
  --danger: #8a1c1c;        /* ~9:1 on white */
  --danger-tint: #fbeceb;

  --focus: #16130f;
  --radius: 14px;
  --radius-small: 10px;
  --tap: 3.25rem;           /* 65px at the carta's 20px base: big buttons */
  --tap-round: 2.75rem;     /* 55px stepper circles */

  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, Verdana,
    'Helvetica Neue', Arial, sans-serif;
}

/* The carta is read at 20px. The staff screens are used up close by people who know them,
   on a phone in a hurry, so they come down a step to fit their dense forms — still large. */
html {
  font-size: 125%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html:has(.main-nav) {
  font-size: 106.25%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  overflow-wrap: break-word;
}

/* One focus ring for everything: thick, dark, offset so it never blends into a blue button. */
:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}

button {
  font-family: inherit;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

header {
  padding: calc(1.5rem + env(safe-area-inset-top)) 1rem 1.25rem;
  text-align: center;
}

header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.subtitle {
  color: var(--text-muted);
  margin: 0.35rem 0 0;
  font-size: 1.05rem;
}

.main-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  margin-top: 1rem;
  font-size: 1rem;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 0.85rem;
  color: var(--text);
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: 999px;
  font-weight: 700;
}

.main-nav a:hover {
  border-color: var(--border);
}

.main-nav a.current {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1rem calc(3rem + env(safe-area-inset-bottom));
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--card-bg);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.card h2 {
  margin-top: 0;
  font-size: 1.35rem;
  line-height: 1.25;
}

/* On the carta the list does not need a box around it: each dish is its own card. */
.card:has(> #carta-lines) {
  background: none;
  border: none;
  padding: 0;
}

.field-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  flex: 2;
}

.field-small {
  flex: 1;
  min-width: 90px;
}

input,
textarea {
  min-height: 2.75rem;
  padding: 0.55rem 0.7rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--card-bg);
  font-size: 1rem;
  font-family: inherit;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text);
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

input:focus,
textarea:focus {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--accent);
}

.closed-message-field {
  margin-top: 1rem;
}

.field-help {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* A day with no service reads as such from across the room. */
.day-closed {
  border-color: var(--danger);
}

.day-closed textarea {
  border-color: var(--danger);
}

.notice {
  margin: 0;
  padding: 1rem 1.1rem;
  border: 2px solid var(--text);
  border-left-width: 8px;
  border-radius: var(--radius-small);
  background: var(--warm-tint);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.sides-section {
  margin-top: 1.25rem;
  border-top: 2px solid var(--line);
  padding-top: 1rem;
}

.sides-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sides-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
}

#add-side,
#add-time {
  min-height: 2.75rem;
  background: var(--card-bg);
  border: 2px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  padding: 0 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
}

#add-side:hover,
#add-time:hover {
  background: var(--tint);
}

.side-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  align-items: center;
}

/* A flex item will not shrink below the width its content wants unless it is told to,
   which is what pushed this row — and the card around it — off the side of a phone. */
.side-row input {
  flex: 2;
  min-width: 0;
}

.side-row .field-small {
  flex: 1;
  min-width: 0;
}

/* On a phone the description takes the whole width and the unit, the price and the
   remove button share the line below it. */
@media (max-width: 719px) {
  .side-row .side-description {
    flex: 1 1 100%;
  }
}

.remove-side {
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  background: var(--card-bg);
  border: 2px solid var(--danger);
  border-radius: 50%;
  color: var(--danger);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.form-actions {
  margin-top: 1.25rem;
  display: flex;
  gap: 0.6rem;
}

button.primary {
  flex: 1;
  min-height: var(--tap);
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--on-accent);
  border: 2px solid var(--accent);
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button.secondary {
  min-height: var(--tap);
  padding: 0.6rem 1.25rem;
  background: var(--card-bg);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

button.secondary:hover {
  background: var(--bg);
}

/* Hidden means hidden, whatever display a component's own rule sets. */
.hidden {
  display: none !important;
}

.edit-item {
  min-height: 2.75rem;
  padding: 0 0.6rem;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.empty-state {
  color: var(--text-muted);
  font-size: 1.05rem;
}

.menu-hint {
  margin: 1rem 0 0;
  padding: 0.75rem 0.9rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius-small);
  background: var(--tint);
  color: var(--text);
  font-size: 0.95rem;
}

.dishes-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dish-item {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  background: var(--card-bg);
}

.dish-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
}

.dish-item-header > :first-child {
  flex: 1 1 10rem;
  min-width: 0;
}

.dish-title {
  font-weight: 700;
}

.dish-extra {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.9em;
}

.dish-price {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.delete-dish {
  min-height: 2.75rem;
  padding: 0 0.6rem;
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.side-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  padding-left: 0.75rem;
}

.time-row .time-value {
  flex: 1;
}

.daily-dishes {
  margin-top: 1rem;
}

/* The card is the wrapper, not the row: a button cannot hold a number field, so the box
   sits beside the row inside one border and reads as part of the same item. */
.daily-dish-holder {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--card-bg);
}

.daily-dish,
.daily-line {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  flex: 1;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.4;
  text-align: left;
}

/* One dish and its combinados, with a handle to drag the whole dish at once. */
.daily-dish-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Lifted out of the flow and following the finger. */
.daily-dish-group.dragging {
  box-shadow: 0 10px 28px rgba(22, 19, 15, 0.28);
  border-radius: var(--radius);
  background: var(--card-bg);
}

/* The gap the dragged dish will drop into. */
.daily-drag-placeholder {
  border: 3px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--tint);
}

.daily-dish-lines {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.daily-group-label {
  margin: 0 0 0.1rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

/* Combinados collapse under a toggle so a dish is one short, easy-to-drag row. */
.daily-combos-toggle {
  align-self: flex-start;
  min-height: 2.75rem;
  background: none;
  border: none;
  padding: 0 0.25rem;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.daily-combos-toggle-active {
  color: var(--accent);
}

.daily-combos-caret {
  display: inline-block;
  width: 1em;
}

.daily-combos-count {
  color: var(--accent);
  font-weight: 700;
}

.daily-combos {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--line);
}

.daily-combos.hidden {
  display: none !important;
}

.daily-dish-holder:active {
  background: var(--bg);
}

.daily-dish-holder:has(.daily-dish-chosen) {
  border-color: var(--accent);
  background: var(--tint);
}

.daily-dish-title {
  flex: 1;
}

.daily-dish-mark {
  visibility: hidden;
  color: var(--accent);
  font-weight: 700;
  font-size: 1.2rem;
}

.daily-dish-chosen .daily-dish-mark {
  visibility: visible;
}

button.primary:disabled {
  background: var(--line);
  border-color: var(--line);
  color: var(--text-muted);
  cursor: default;
}

.order-line {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.order-line-title {
  flex: 1;
  min-width: 0;
}

/* The carta row. A grid so the bigger type never squeezes anything: the name gets the
   whole width to wrap over as many lines as it needs, allergens and ingredients sit under
   it, and the price and the buttons share a row of their own at the bottom — the price on
   the left where the eye lands after reading, the control on the right under the thumb. */
.carta-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'title   title'
    'details details'
    'price   stepper';
  align-items: center;
  gap: 0.6rem 1rem;
  padding: 1rem 1.1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--card-bg);
}

.carta-line:not(:has(.order-line-details)) {
  grid-template-areas:
    'title   title'
    'price   stepper';
}

.carta-line .order-line-title {
  grid-area: title;
  font-size: 1.15rem;   /* 23px */
  line-height: 1.35;
}

.carta-line .dish-title {
  font-weight: 700;
}

.carta-line .dish-extra {
  font-size: 0.85em;
  color: var(--text-muted);
}

.carta-line .dish-price {
  grid-area: price;
  font-size: 1.3rem;    /* 26px */
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.carta-line .order-stepper {
  grid-area: stepper;
  justify-self: end;
}

.carta-line .order-line-details {
  grid-area: details;
  margin-top: 0;
}

/* A line already in the order says so with its border, so it can be found again at a glance. */
.carta-line:has(.order-quantity) {
  border-color: var(--accent);
  box-shadow: inset 6px 0 0 var(--accent);
}

.order-line-chosen {
  border-color: var(--accent);
}

.order-line:active {
  background: var(--bg);
}

.order-line-amount {
  min-width: 1.6rem;
  text-align: right;
  font-weight: 700;
  color: var(--accent);
}

.order-line-remove {
  position: absolute;
  top: -0.6rem;
  right: -0.6rem;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

.order-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-top: 1.25rem;
  border-top: 2px solid var(--line);
  padding-top: 1rem;
}

.time-options-label {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.time-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.time-option {
  min-height: 2.75rem;
  padding: 0 1rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.time-option.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.order-total {
  margin: 0;
  font-weight: 700;
}

.order-summary {
  margin-top: 1rem;
}

.order-summary .side-item {
  margin-top: 0.5rem;
  font-size: 1rem;
  color: var(--text);
  padding-left: 0;
}

.order-summary-total {
  display: flex;
  justify-content: space-between;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 2px solid var(--line);
  font-size: 1.1rem;
}

.drop-point-slug {
  color: var(--text-muted);
  font-size: 0.95rem;
  text-decoration: none;
}

.drop-point-slug:hover {
  color: var(--accent);
}

.time-option.closed {
  color: var(--text-muted);
  background: var(--bg);
  text-decoration: line-through;
  cursor: not-allowed;
}

.kitchen-status {
  margin-left: 0.5rem;
  font-size: 0.9rem;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  border: 2px solid var(--border);
}

.kitchen-status-live {
  color: var(--accent);
  border-color: var(--accent);
}

.kitchen-status-down {
  color: var(--danger);
  border-color: var(--danger);
}

.kitchen-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.kitchen-group-header h2 {
  margin: 0;
  font-size: 1.35rem;
}

.kitchen-group-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kitchen-chip {
  font-size: 0.9rem;
  color: var(--text-muted);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
}

.kitchen-group-ready {
  border-color: var(--accent);
}

.kitchen-group-ready .kitchen-group-count {
  color: var(--accent);
}

.kitchen-line {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.kitchen-line:active {
  background: var(--bg);
}

.kitchen-line-title {
  flex: 1;
}

.kitchen-count {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.kitchen-line-done {
  border-color: var(--accent);
  background: var(--tint);
}

.kitchen-line-done .kitchen-count {
  font-size: 1.5rem;
}

.kitchen-undo {
  position: absolute;
  top: -0.6rem;
  right: -0.6rem;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--text-muted);
  color: #fff;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
}

.kitchen-undo.hidden {
  display: none !important;
}

/* Desktop only: the phone layout below 720px stays exactly as it is. */
@media (min-width: 720px) {
  main {
    max-width: 1080px;
  }

  .dishes-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    column-gap: 0.9rem;
    row-gap: 0.9rem;
  }

  /* Rows of one-line items look ragged when a long name wraps, so every card in
     these two lists takes the height of the tallest one. */
  #daily-dishes,
  #order-lines,
  .kitchen-group .dishes-list {
    grid-auto-rows: 1fr;
  }

  .kitchen-group .dishes-list {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }

  /* The carta's cards are bigger, so fewer and wider columns read better. */
  #carta-lines {
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    align-items: stretch;
  }

  /* With the price row at the foot, cards of different heights still line their
     buttons up along the bottom. */
  .carta-line {
    grid-template-rows: auto 1fr auto;
    align-items: start;
  }

  .carta-line:not(:has(.order-line-details)) {
    grid-template-rows: 1fr auto;
  }

  .carta-line .dish-price,
  .carta-line .order-stepper {
    align-self: end;
  }
}

.day-picker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.day-picker input {
  flex: 1 1 6rem;
  min-width: 0;
}

.day-picker button {
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.day-picker button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* A family's name, above the dishes that belong to it: large, dark, sentence case and
   underlined with a thick bar — a header you cannot miss, without shouting in capitals. */
.line-group-heading {
  margin: 1.75rem 0 0.25rem;
  padding-bottom: 0.35rem;
  border-bottom: 4px solid var(--accent);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

.line-group-heading:first-child {
  margin-top: 0.25rem;
}

/* The staff lists are denser; their family headings come down to match. */
html:has(.main-nav) .line-group-heading {
  font-size: 1.15rem;
  border-bottom-width: 3px;
}

@media (min-width: 720px) {
  .line-group-heading {
    grid-column: 1 / -1;
  }
}

/* A dish with no price is a group; the list says so where the price would be. */
.dish-group-tag {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.9rem;
}

@keyframes kitchen-arrived {
  from {
    background: var(--tint);
    border-color: var(--accent);
  }
  to {
    background: var(--card-bg);
    border-color: var(--line);
  }
}

.kitchen-line-new {
  animation: kitchen-arrived 2.5s ease-out;
}

/* The list above these can run to ninety lines, so the action stays on screen instead of
   waiting at the bottom of it. Sticky rather than fixed: the bar keeps its place in the
   flow, so it never covers the last row, and it stops sticking at the end of its own card. */
.form-actions,
.sticky-actions {
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
  padding-bottom: calc(0.4rem + env(safe-area-inset-bottom));
}

.sticky-actions {
  padding-top: 0.1rem;
}

.sticky-actions .form-actions {
  position: static;
  padding-bottom: 0;
}

/* A line scrolling underneath must not read through the bar. */
.form-actions::before,
.sticky-actions::before {
  content: '';
  display: block;
  border-top: 2px solid var(--line);
  margin-bottom: 0.75rem;
}

/* .form-actions is a flex row, so its rule has to take a whole line of its own. */
.form-actions::before {
  flex: 1 1 100%;
  margin-bottom: 0;
}

.form-actions {
  flex-wrap: wrap;
}

.sticky-actions .form-actions::before {
  content: none;
}

#summary-card .form-actions {
  position: static;
}

#summary-card .form-actions::before {
  content: none;
}

/* Small and fixed: stretched to the row's height it dwarfed everything next to a name
   that wrapped over four lines. */
.daily-dish-stock {
  width: 4.5rem;
  height: 2.75rem;
  flex: none;
  padding: 0.25rem 0.4rem;
  font-size: 1rem;
  text-align: right;
}

/* How many are left, under the name. */
.order-line-left {
  position: absolute;
  left: 0.9rem;
  bottom: 0.1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.order-line:has(.order-line-left:not(:empty)) {
  padding-bottom: 1.5rem;
}

.order-line-sold-out {
  background: var(--bg);
  cursor: not-allowed;
}

.order-line-sold-out .dish-title,
.order-line-sold-out .dish-price {
  color: var(--text-muted);
}

.order-line-sold-out .order-line-left {
  color: var(--danger);
}

.counter-line {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  padding-right: 2.8rem;
}

.counter-line:active {
  background: var(--bg);
}

.counter-line-title {
  flex: 1;
  min-width: 0;
}

.counter-breakdown {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.counter-count {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.counter-line-empty {
  background: var(--bg);
}

.counter-line-empty .counter-count {
  color: var(--text-muted);
}

.counter-line-short {
  border-color: var(--danger);
}

.counter-short {
  color: var(--danger);
  font-weight: 700;
}

.counter-add {
  position: absolute;
  bottom: -0.6rem;
  right: -0.6rem;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
}

/* Allergens and ingredients under the name, always visible. */
.order-line-details {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

/* A plain bordered label, sentence case, at a size that can be read without glasses. */
.allergen-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.55rem;
  border: 2px solid var(--danger);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--danger);
  font-size: 0.85rem;   /* 17px on the carta */
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}

.order-line-ingredients {
  flex: 1 1 100%;
  font-size: 0.9rem;    /* 18px on the carta */
  line-height: 1.45;
  color: var(--text-muted);
}

.order-line {
  flex-wrap: wrap;
}

/* The multiselect in Gestión: a chip has the shape of the tag it becomes on the carta. */
.allergen-field {
  margin-top: 1rem;
}

.allergen-label {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.allergen-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.allergen-chip {
  min-height: 2.5rem;
  padding: 0 0.75rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.allergen-chip-on {
  border-color: var(--danger);
  background: var(--danger-tint);
  color: var(--danger);
  font-weight: 700;
}

.details-field {
  margin-top: 0.75rem;
}

.side-row .side-ingredients,
.side-row .allergen-chips {
  flex: 1 1 100%;
  min-width: 0;
}

.chime-button {
  margin-left: 0.4rem;
  padding: 0.1rem 0.6rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  vertical-align: middle;
}

.chime-button-muted {
  color: var(--text-muted);
}

.chime-button-blocked {
  border-color: var(--accent);
  color: var(--accent);
}

/* Carta: the category bar. Big chips in one row that scrolls sideways, stuck to the top
   so the families stay one tap away however far down the list you are. It runs edge to
   edge on a phone and carries a solid line under it, so the fixed part reads as fixed. */
.carta-categories {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 -1rem;
  padding: 0.65rem 1rem;
  background: var(--bg);
  border-bottom: 2px solid var(--line);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.carta-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 3rem;     /* 60px */
  padding: 0 1.15rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}

.carta-chip:hover {
  border-color: var(--accent);
}

.carta-chip-on,
.carta-chip-on:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

/* The chip bar clips its own overflow, so the ring goes inside the chip there. */
.carta-chip:focus-visible {
  outline-offset: -6px;
  outline-color: var(--on-accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.carta-chip:not(.carta-chip-on):focus-visible {
  outline-color: var(--focus);
}

/* Gestión: the single free-text category field on the dish form. */
#tag-input {
  width: 100%;
}

/* Menú del día: the per-day ordering list. */
.daily-order {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.daily-order-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* The grab handle: touch-action none so dragging it never scrolls the page. */
.drag-handle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  min-height: 2.75rem;
  cursor: grab;
  touch-action: none;
  color: var(--text-muted);
  font-size: 1.35rem;
  line-height: 1;
  padding: 0.2rem;
  user-select: none;
}

.daily-order-row.dragging {
  opacity: 0.6;
  border-color: var(--accent);
  cursor: grabbing;
}

/* Carta: ordering over WhatsApp (order.js). A stepper on each line, a bar fixed to the
   bottom once something is in the order, and a sheet that slides up with the summary. */
.order-stepper {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.order-stepper button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-round);
  height: var(--tap-round);
  padding: 0;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: var(--card-bg);
  color: var(--accent);
  font-family: inherit;
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.order-stepper .order-add,
.order-stepper .order-plus {
  background: var(--accent);
  color: var(--on-accent);
}

.order-stepper button:hover {
  background: var(--tint);
}

.order-stepper .order-add:hover,
.order-stepper .order-plus:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.order-stepper button:active {
  transform: scale(0.95);
}

/* Nothing in the order yet: the first tap is a labelled button, not a bare symbol. */
.order-stepper .order-add {
  width: auto;
  min-width: var(--tap-round);
  gap: 0.4rem;
  padding: 0 1.2rem 0 0.95rem;
  border-radius: 999px;
}

.order-stepper .order-add::after {
  content: 'Añadir';
  font-size: 1.05rem;
  line-height: 1;
}

.order-quantity {
  min-width: 1.6rem;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Leave room under the last line so the bar never covers it. */
body:has(.order-bar:not(.hidden)) main {
  padding-bottom: calc(7.5rem + env(safe-area-inset-bottom));
}

/* A solid strip across the bottom rather than a floating button, so it is plainly part of
   the page and nothing scrolls visibly behind it. */
.order-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 0.75rem max(1rem, env(safe-area-inset-right)) calc(0.75rem + env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
  background: var(--card-bg);
  border-top: 2px solid var(--line);
  box-shadow: 0 -6px 18px rgba(22, 19, 15, 0.1);
  animation: rise-in 0.22s ease-out;
}

.order-bar-button,
.order-send {
  display: block;
  width: 100%;
  max-width: 32rem;
  min-height: var(--tap);
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
  touch-action: manipulation;
}

.order-bar-button:hover,
.order-send:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.order-bar-button:focus-visible,
.order-send:focus-visible {
  outline-offset: 4px;
}

.order-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(22, 19, 15, 0.55);
  animation: fade-in 0.2s ease-out;
}

.order-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  max-width: 36rem;
  max-height: 90vh;
  max-height: 90dvh;
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.25rem max(1.25rem, env(safe-area-inset-right)) calc(1.25rem + env(safe-area-inset-bottom))
    max(1.25rem, env(safe-area-inset-left));
  border-radius: 1.25rem 1.25rem 0 0;
  background: var(--card-bg);
  box-shadow: 0 -8px 30px rgba(22, 19, 15, 0.25);
  animation: sheet-up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes rise-in {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.order-sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-bottom: 0.75rem;
  margin-bottom: 0.25rem;
  border-bottom: 2px solid var(--line);
}

.order-sheet-head h2 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.25;
}

.order-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-round);
  height: var(--tap-round);
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--card-bg);
  color: var(--text);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.order-close:hover {
  background: var(--bg);
}

.order-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem 0.9rem;
  padding: 0.9rem 0;
  border-bottom: 2px solid var(--line);
}

.order-item-name {
  flex: 1 1 6rem;
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
}

.order-item-name small {
  display: block;
  margin-top: 0.15rem;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 400;
}

.order-item .order-stepper {
  margin-left: auto;
}

.order-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.9rem 0;
  font-size: 1.3rem;
  font-weight: 700;
}

.order-field {
  margin-top: 0.25rem;
}

.order-field-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.order-times {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.order-time {
  flex: 1 1 5rem;
  min-height: var(--tap);
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  touch-action: manipulation;
}

.order-time:hover {
  border-color: var(--accent);
}

.order-time-on,
.order-time-on:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: inset 0 0 0 2px var(--card-bg);
}

.order-error {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 2px solid var(--danger);
  border-left-width: 8px;
  border-radius: var(--radius-small);
  background: var(--danger-tint);
  color: var(--danger);
  font-weight: 700;
}

.order-hint {
  margin: 0.9rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
}

/* The order sent today from this browser, above the carta. */
.order-summary {
  margin-bottom: 0;
  border: 3px solid var(--accent);
  background: var(--card-bg);
}

.order-summary h2 {
  margin: 0 0 0.6rem;
  font-size: 1.4rem;
}

.order-summary-line {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0;
  font-size: 1.05rem;
  border-bottom: 1px solid var(--line);
}

.order-summary-line > :last-child {
  white-space: nowrap;
  font-weight: 700;
}

.order-summary .order-total {
  border-top: none;
  margin-top: 0.1rem;
}

.order-summary-time {
  margin: 0 0 1rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-small);
  background: var(--tint);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.order-summary-edit,
.order-discard {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 1.25rem;
  border: 3px solid var(--accent);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--accent);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.order-summary-edit:hover {
  background: var(--tint);
}

.order-discard {
  max-width: 32rem;
  margin: 0.75rem auto 0;
  border-width: 2px;
  border-color: var(--border);
  color: var(--text);
}

.order-discard:hover {
  background: var(--bg);
}

.order-cancel-note {
  margin: 1rem 0 0.25rem;
  padding: 0.75rem 0.9rem;
  border: 2px solid var(--danger);
  border-radius: var(--radius-small);
  background: var(--danger-tint);
  color: var(--danger);
  font-weight: 700;
}

.order-items-cancelled .order-item-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.order-items-cancelled {
  margin-bottom: 1rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .kitchen-line-new {
    animation: none;
    border-color: var(--accent);
  }

  .order-stepper button:active {
    transform: none;
  }
}
