/* Mediterráneo fresco: sunny sand and white, olive green for anything you can press,
   terracotta for prices and the warm accents, a touch of sea blue for focus and info. */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

:root {
  /* Surfaces */
  --bg: #fbf7f0;
  --bg-deep: #f4ecdf;
  --card-bg: #ffffff;
  --border: #e7dece;
  --line: #f0e9dd;

  /* Text — every pair below clears WCAG AA on white and on the sand background. */
  --text: #2b2a24;
  --text-muted: #6b6558;

  /* Olive: buttons, active chips, headings. White on --accent is 5.9:1. */
  --accent: #556b2f;
  --accent-hover: #46591f;
  --accent-dark: #3f4f1c;
  --accent-soft: #eef2df;
  --accent-softer: #f6f8ee;

  /* Terracotta: prices and warm badges. 5.9:1 on white. */
  --terracotta: #a9461f;
  --terracotta-soft: #fdeee3;
  --terracotta-ink: #8a3a17;

  /* Sea: focus rings and small info touches. */
  --sea: #2f6a87;
  --sea-soft: #eaf3f7;

  --danger: #b3261e;
  --danger-soft: #fdecea;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(74, 58, 30, 0.06), 0 1px 3px rgba(74, 58, 30, 0.05);
  --shadow: 0 1px 2px rgba(74, 58, 30, 0.05), 0 4px 14px rgba(74, 58, 30, 0.07);
  --shadow-lg: 0 2px 6px rgba(74, 58, 30, 0.08), 0 12px 32px rgba(74, 58, 30, 0.14);
  --focus: 0 0 0 3px var(--card-bg), 0 0 0 5px var(--sea);

  --font: 'Nunito', ui-rounded, 'SF Pro Rounded', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, 'Helvetica Neue', Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: var(--font);
  line-height: 1.45;
  background: var(--bg);
  background-image: radial-gradient(120% 320px at 50% -80px, #fff3d9 0%, rgba(255, 243, 217, 0) 70%);
  background-repeat: no-repeat;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

button {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* One focus ring for the whole app: sea blue, offset by a white halo so it reads on olive,
   terracotta and white alike. Keyboard only — a tap does not leave a ring behind. */
:focus-visible {
  outline: 3px solid var(--sea);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

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

header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--accent-dark);
}

/* Three little dots under the name: olive, terracotta, sea. */
header h1::after {
  content: '';
  display: block;
  width: 2.6rem;
  height: 0.4rem;
  margin: 0.55rem auto 0;
  background:
    radial-gradient(circle, var(--accent) 0.2rem, transparent 0.21rem) 0 50% / 0.9rem 0.4rem no-repeat,
    radial-gradient(circle, var(--terracotta) 0.2rem, transparent 0.21rem) 50% 50% / 0.9rem 0.4rem no-repeat,
    radial-gradient(circle, var(--sea) 0.2rem, transparent 0.21rem) 100% 50% / 0.9rem 0.4rem no-repeat;
}

.subtitle {
  color: var(--text-muted);
  margin: 0.45rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.subtitle:first-letter {
  text-transform: uppercase;
}

.main-nav {
  display: inline-flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.9rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
  font-size: 0.92rem;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0 1rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.main-nav a:hover {
  color: var(--accent-dark);
  background: var(--accent-softer);
}

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

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

.card {
  background: var(--card-bg);
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin-top: 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent-dark);
}

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

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

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

/* 16px text so iOS does not zoom into the field, and 44px tall to hit with a thumb. */
input,
textarea {
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  font-size: 1rem;
  font-weight: 400;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder,
textarea::placeholder {
  color: #9a9283;
}

input:hover,
textarea:hover {
  border-color: #d6cab5;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input:focus-visible,
textarea:focus-visible {
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.4;
}

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

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

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

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

.notice {
  margin: 0;
  padding: 1.1rem 1.2rem;
  border: none;
  border-left: 4px solid var(--terracotta);
  border-radius: var(--radius);
  background: var(--terracotta-soft);
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.sides-section {
  margin-top: 1.25rem;
  border-top: 1.5px dashed var(--border);
  padding-top: 0.9rem;
}

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

.sides-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-muted);
}

#add-side,
#add-time {
  min-height: 2.75rem;
  background: var(--accent-soft);
  border: none;
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  transition: background-color 0.15s;
}

#add-side:hover,
#add-time:hover {
  background: #e3ead0;
}

.side-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  background: var(--accent-softer);
  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. Three fields abreast on 390px leaves each one
   too narrow to read what you typed. */
@media (max-width: 719px) {
  .side-row .side-description {
    flex: 1 1 100%;
  }
}

.remove-side {
  width: 2.75rem;
  height: 2.75rem;
  flex: none;
  background: var(--danger-soft);
  border: none;
  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.5rem;
}

button.primary {
  flex: 1;
  min-height: 3rem;
  padding: 0.7rem 1.25rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 999px;
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(85, 107, 47, 0.28);
  transition: background-color 0.15s, transform 0.1s var(--ease);
}

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

button.primary:active {
  transform: scale(0.98);
}

button.secondary {
  min-height: 3rem;
  padding: 0.7rem 1.25rem;
  background: var(--card-bg);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

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

/* Weighted so that no component rule that sets its own display can bring a hidden
   element back. */
.hidden {
  display: none !important;
}

.edit-item {
  min-height: 2.75rem;
  padding: 0 0.5rem;
  background: none;
  border: none;
  border-radius: 999px;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
}

.edit-item:hover {
  background: var(--accent-soft);
}

.empty-state {
  color: var(--text-muted);
  font-style: italic;
}

.menu-hint {
  margin: 1rem 0 0;
  padding: 0.75rem 0.9rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--sea-soft);
  color: var(--text);
  font-size: 0.88rem;
}

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

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

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

/* The name keeps a readable width; when the price and the two buttons do not fit beside
   it, they drop to their own line on the right instead of squeezing it to a word a line. */
.dish-item-header > :first-child {
  flex: 1 1 9rem;
  min-width: 0;
}

.dish-item-header > :last-child {
  margin-left: auto;
  margin-right: -0.4rem;
}

.dish-title {
  font-weight: 800;
  font-size: 1.02rem;
  line-height: 1.3;
  color: var(--text);
}

.dish-extra {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
}

.dish-price {
  font-weight: 800;
  color: var(--terracotta);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.delete-dish {
  min-height: 2.75rem;
  padding: 0 0.5rem;
  background: none;
  border: none;
  border-radius: 999px;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
}

.delete-dish:hover {
  background: var(--danger-soft);
}

.side-item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.88rem;
  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.5rem;
  background: var(--card-bg);
  transition: background-color 0.15s, border-color 0.15s;
}

.daily-dish,
.daily-line {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  flex: 1;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.98rem;
  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.5rem;
}

/* Lifted out of the flow and following the finger. */
.daily-dish-group.dragging {
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius);
  background: var(--card-bg);
}

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

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

.daily-group-label {
  margin: 0 0 0.1rem;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* 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.5rem;
  background: none;
  border: none;
  border-radius: 999px;
  padding: 0.15rem 0.4rem 0.15rem 0;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.daily-combos-toggle-active {
  color: var(--accent-dark);
  font-weight: 800;
}

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

.daily-combos-count {
  color: var(--terracotta);
  font-weight: 800;
}

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

/* This rule comes after .hidden, so it has to re-assert the hide with more weight. */
.daily-combos.hidden {
  display: none;
}

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

.daily-dish-holder:has(.daily-dish-chosen) {
  border-color: var(--accent);
  background: var(--accent-softer);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
}

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

.daily-dish-mark {
  visibility: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
}

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

button.primary:disabled {
  background: var(--border);
  color: var(--text-muted);
  box-shadow: none;
  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 reuses the order line's layout — name on the left, price on the right,
   allergens and ingredients wrapping onto their own line below — but it is read-only, so
   none of the pointer, selection or quantity behaviour comes with it. */
.carta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: flex-start;
  gap: 0.5rem 0.75rem;
}

.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: 800;
  color: var(--accent);
}

.order-line-remove {
  position: absolute;
  top: -0.55rem;
  right: -0.55rem;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-size: 0.8rem;
  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: 1.5px dashed var(--border);
  padding-top: 0.9rem;
}

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

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

.time-option {
  min-height: 2.75rem;
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 999px;
  background: var(--accent-softer);
  box-shadow: inset 0 0 0 1.5px var(--border);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.time-option.selected {
  background: var(--accent);
  box-shadow: none;
  color: white;
  font-weight: 800;
}

.drop-point-slug {
  color: var(--text-muted);
  font-size: 0.85rem;
  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.8rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px 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.15rem;
}

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

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

/* A batch nobody has to cook any more steps back visually without disappearing. */
.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.25rem;
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
}

/* Done is an achievement, not a dead control: the line keeps its full contrast and
   picks up the same chosen look the daily menu uses. */
.kitchen-line-done {
  border-color: var(--accent);
  background: var(--accent-softer);
}

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

.kitchen-undo {
  position: absolute;
  top: -0.55rem;
  right: -0.55rem;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--text-muted);
  color: white;
  font-size: 0.9rem;
  /* The arrow glyph sits high in its own box, so the badge centres it as a flex item
     instead of trusting the line box. */
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
}

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

/* 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.85rem;
  }

  /* 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;
  }

  /* The board is read from across the kitchen, so its cards spread over the whole
     width instead of leaving empty tracks like the lists the staff read up close. */
  .kitchen-group .dishes-list {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }

  header {
    padding-top: calc(2.5rem + env(safe-area-inset-top));
  }

  header h1 {
    font-size: 2.1rem;
  }
}

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

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

.day-picker button {
  flex: none;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.6rem;
  border: none;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 0.15s;
}

.day-picker button:hover {
  background: #e3ead0;
  color: var(--accent-dark);
}

/* A family's name, sitting above the dishes that belong to it. It spans the whole grid so
   the family below it starts on a fresh row instead of continuing mid-line. Olive with a
   terracotta dot so a family reads as a clear header, well apart from the dish cards under
   it — the first one keeps a smaller top gap so it does not float. */
.line-group-heading {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 1.6rem 0 0.15rem;
  padding: 0;
  border: none;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--accent-dark);
  letter-spacing: -0.005em;
}

.line-group-heading::before {
  content: '';
  flex: none;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--terracotta);
  box-shadow: 0 0 0 4px var(--terracotta-soft);
}

.line-group-heading::after {
  content: '';
  flex: 1;
  height: 2px;
  margin-left: 0.25rem;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-soft), rgba(238, 242, 223, 0));
}

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

@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.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* A plate that just arrived. The flash fades on its own, so a cook who looks up a few
   seconds later sees a normal board rather than a permanent badge to dismiss. */
@keyframes kitchen-arrived {
  from {
    background: #f7d9cc;
    border-color: var(--accent);
  }
  to {
    background: var(--card-bg);
    border-color: var(--border);
  }
}

.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 — which is what a page with several forms needs. */
.form-actions,
.sticky-actions {
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
}

.sticky-actions {
  /* The wrapper sticks as one piece; the footer and the buttons inside it would otherwise
     stick separately and sit on top of each other. */
  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: 1px solid var(--line);
  margin-bottom: 0.75rem;
}

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

.form-actions::before {
  flex: 1 1 100%;
  margin-bottom: 0.25rem;
}

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

/* The summary card's buttons are the end of a short card; a bar there would only add a
   line above two buttons nobody has to hunt for. */
#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.25rem;
  height: 2.75rem;
  min-height: 0;
  flex: none;
  padding: 0.25rem 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  text-align: right;
}

/* How many are left, under the name. Absolutely positioned so adding one never changes
   the height of the row, the same reason the amount has a fixed width. */
.order-line-left {
  position: absolute;
  left: 0.9rem;
  bottom: 0.1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

/* Nothing left: the row stays readable but stops being a control. */
.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);
}

/* The counter line: one tap sells one, so the whole row is the control and the two small
   buttons sit out of the way of a thumb aiming at it. */
.counter-line {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  padding-right: 2.6rem;
}

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

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

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

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

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

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

/* Sold more than there was: an order placed through the app is going to come up short,
   and nobody would find out until the round went out. */
.counter-line-short {
  border-color: var(--danger);
}

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

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

/* Allergens and ingredients under the name. Always there rather than behind a control:
   tapping the row adds to the order, and nobody with an allergy should have to open
   dishes one at a time to find out. */
.order-line-details {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.1rem;
  min-width: 0;
}

/* A soft warm pill: tinted, not alarming, and dark enough to read at a glance. */
.allergen-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem 0.15rem 0.45rem;
  border: none;
  border-radius: 999px;
  background: var(--terracotta-soft);
  color: var(--terracotta-ink);
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.allergen-tag::before {
  content: '';
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}

.order-line-ingredients {
  flex: 1 1 100%;
  margin-top: 0.15rem;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

/* The order line has to wrap now that a second row hangs under the name. */
.order-line {
  flex-wrap: wrap;
}

/* The multiselect in Gestión: a chip has the shape of the tag it becomes on the carta,
   so what is marked is what will be seen. */
.allergen-field {
  margin-top: 1rem;
}

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

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

.allergen-chip {
  min-height: 2.5rem;
  padding: 0.3rem 0.85rem;
  border: none;
  border-radius: 999px;
  background: var(--card-bg);
  box-shadow: inset 0 0 0 1.5px var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.allergen-chip:hover {
  background: var(--bg);
}

.allergen-chip-on,
.allergen-chip-on:hover {
  background: var(--terracotta-soft);
  box-shadow: inset 0 0 0 1.5px #f1c9b1;
  color: var(--terracotta-ink);
  font-weight: 800;
}

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

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

/* A side carries its own, so its row grows a second and third line on a phone. */
.side-row .side-ingredients,
.side-row .allergen-chips {
  flex: 1 1 100%;
  min-width: 0;
}

/* Says whether this screen will make a sound when an order comes in, and fixes it when
   the browser is holding the sound back until somebody touches the page. */
.chime-button {
  margin-left: 0.4rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  vertical-align: middle;
}

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

/* Not an error, but it does need a tap, so it asks for one rather than sitting quiet. */
.chime-button-blocked {
  border-color: var(--accent);
  color: var(--accent);
}

/* Carta: the category filter bar. Chips scroll horizontally and stick to the top so the
   categories stay reachable while the list scrolls. It bleeds to the screen edges so the
   chips slide out from under the edge instead of being cut by the page gutter. */
.carta-categories {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  margin: 0 -1rem -0.5rem;
  padding: 0.6rem 1rem 0.7rem;
  padding-top: calc(0.6rem + env(safe-area-inset-top));
  background: rgba(251, 247, 240, 0.92);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-padding-inline: 1rem;
}

.carta-categories::-webkit-scrollbar {
  display: none;
}

.carta-chip {
  flex: 0 0 auto;
  min-height: 2.75rem;
  padding: 0.4rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: var(--card-bg);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.carta-chip:hover {
  background: var(--accent-softer);
}

.carta-chip-on,
.carta-chip-on:hover {
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(85, 107, 47, 0.3);
  color: #fff;
  font-weight: 800;
}

/* 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.4rem;
}

.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: #a39a89;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.2rem 0.3rem;
  border-radius: var(--radius-sm);
  user-select: none;
}

.drag-handle:hover {
  color: var(--accent);
  background: var(--accent-softer);
}

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

/* The carta scrolls as a normal page — so pull-to-refresh keeps working — with the category
   bar stuck to the top, reachable however far down the dishes you are. A soft shadow under
   it marks where the fixed part ends and the list begins. */
.carta-categories {
  border-bottom: none;
  box-shadow: 0 6px 12px -10px rgba(74, 58, 30, 0.35);
}

/* On the carta the list itself is the page: the dishes are the cards, so the box around
   them steps back and lets the sand show between them. */
.card:has(> #carta-lines) {
  padding: 0;
  background: none;
  box-shadow: none;
  border-radius: 0;
}

#carta-lines {
  gap: 0.65rem;
}

#carta-lines > .empty-state {
  text-align: center;
  padding: 2rem 0;
}

.carta-line.dish-item {
  padding: 0.95rem 0.85rem 0.95rem 1.1rem;
  border: none;
  box-shadow: var(--shadow);
}

.carta-line .order-line-title {
  align-self: center;
}

.carta-line .dish-price {
  font-size: 1.02rem;
}

/* 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.15rem;
  flex: none;
}

.carta-line .order-stepper:has(.order-minus) {
  padding: 0.15rem;
  border-radius: 999px;
  background: var(--accent-soft);
}

.order-stepper button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--card-bg);
  color: var(--accent-dark);
  font-family: inherit;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.12s var(--ease);
}

.order-stepper .order-minus {
  box-shadow: var(--shadow-sm);
}

.order-stepper .order-add,
.order-stepper .order-plus {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(85, 107, 47, 0.35);
}

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

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

.order-quantity {
  min-width: 1.6rem;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-dark);
  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(7rem + env(safe-area-inset-bottom));
}

.order-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 0.75rem calc(1rem + env(safe-area-inset-right)) calc(0.85rem + env(safe-area-inset-bottom))
    calc(1rem + env(safe-area-inset-left));
  background: linear-gradient(to top, var(--bg) 35%, rgba(251, 247, 240, 0));
  animation: order-rise 0.3s var(--ease);
}

.order-bar-button,
.order-send {
  display: block;
  width: 100%;
  max-width: 32rem;
  min-height: 3.5rem;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(63, 79, 28, 0.25), 0 10px 28px rgba(63, 79, 28, 0.22);
  transition: background-color 0.15s, transform 0.12s var(--ease);
}

/* The bar carries a basket in a white bubble on the left and a chevron on the right, so it
   reads as "your order, tap to see it" before the text is read. */
.order-bar-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 1.25rem 0.5rem 0.5rem;
}

.order-bar-button::before {
  content: '';
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  margin-right: auto;
  border-radius: 50%;
  background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a9461f' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8h14l-1.2 11.1a2 2 0 0 1-2 1.9H8.2a2 2 0 0 1-2-1.9L5 8z'/%3E%3Cpath d='M9 8V6.5a3 3 0 0 1 6 0V8'/%3E%3C/svg%3E")
    center / 1.35rem no-repeat;
}

.order-bar-button::after {
  content: '';
  flex: none;
  width: 0.6rem;
  height: 0.6rem;
  margin-left: auto;
  border-top: 2.5px solid currentColor;
  border-right: 2.5px solid currentColor;
  transform: rotate(-45deg) translate(-0.1rem, 0.1rem);
}

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

.order-bar-button:active,
.order-send:active {
  transform: scale(0.98);
}

.order-bar-button:focus-visible,
.order-send:focus-visible {
  box-shadow: var(--focus), 0 10px 28px rgba(63, 79, 28, 0.22);
}

.order-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(43, 42, 36, 0.42);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: order-fade 0.25s ease-out;
}

.order-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  max-width: 36rem;
  max-height: 88vh;
  max-height: 88dvh;
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.6rem calc(1.25rem + env(safe-area-inset-right)) calc(1.25rem + env(safe-area-inset-bottom))
    calc(1.25rem + env(safe-area-inset-left));
  border-radius: 24px 24px 0 0;
  background: var(--card-bg);
  box-shadow: 0 -8px 40px rgba(43, 42, 36, 0.22);
  animation: order-rise 0.32s var(--ease);
}

/* The grab bar on top of the sheet: decoration, but it says "this came up from below". */
.order-sheet::before {
  content: '';
  display: block;
  width: 2.75rem;
  height: 0.3rem;
  margin: 0 auto 0.7rem;
  border-radius: 999px;
  background: var(--border);
}

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

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

.order-sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.order-sheet-head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent-dark);
}

.order-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--bg-deep);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s;
}

.order-close:hover {
  background: #ebe0cd;
}

.order-items {
  margin: 0 -0.25rem;
}

.order-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.25rem;
  border-bottom: 1px solid var(--line);
}

.order-item-name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  line-height: 1.3;
}

.order-item-name small {
  display: block;
  margin-top: 0.15rem;
  color: var(--terracotta);
  font-size: 0.88rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.order-item .order-stepper:has(.order-minus) {
  padding: 0.15rem;
  border-radius: 999px;
  background: var(--accent-soft);
}

.order-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0;
  padding: 0.9rem 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.order-total span:last-child {
  color: var(--terracotta);
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

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

.order-times {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}

.order-time {
  flex: 1;
  min-height: 3rem;
  padding: 0.6rem;
  border: none;
  border-radius: 14px;
  background: var(--accent-softer);
  box-shadow: inset 0 0 0 1.5px var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.order-time:hover {
  background: var(--accent-soft);
}

.order-time-on,
.order-time-on:hover {
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(85, 107, 47, 0.3);
  color: #fff;
  font-weight: 800;
}

.order-error {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 700;
}

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

/* The order sent today from this browser, above the carta: a soft olive card with a tick. */
.order-summary {
  margin: 0 0 0.25rem;
  border: none;
  background: linear-gradient(160deg, var(--accent-softer), var(--card-bg) 60%);
  box-shadow: 0 0 0 1.5px var(--accent-soft), var(--shadow);
}

.order-summary h2 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 0.6rem;
  font-size: 1.2rem;
}

.order-summary h2::before {
  content: '';
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E")
    center / 1rem no-repeat;
}

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

.order-summary-line {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0;
}

.order-summary-line span:last-child {
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.order-summary-total {
  display: flex;
  justify-content: space-between;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--border);
  font-size: 1.05rem;
}

.order-summary .order-total {
  border-top: 1.5px dashed var(--border);
  margin-top: 0.4rem;
}

/* The pickup time as a small sea-blue badge: information, not an action. */
.order-summary-time {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.9rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: var(--sea-soft);
  color: var(--sea);
  font-weight: 800;
}

.order-summary-time::before {
  content: '';
  width: 1rem;
  height: 1rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232f6a87' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.order-summary-edit,
.order-discard {
  display: block;
  width: 100%;
  min-height: 3rem;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 999px;
  background: var(--card-bg);
  box-shadow: inset 0 0 0 2px var(--accent);
  color: var(--accent-dark);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 0.15s;
}

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

.order-summary-edit:focus-visible,
.order-discard:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent), var(--focus);
}

.order-discard {
  max-width: 32rem;
  margin: 0.6rem auto 0;
  background: none;
  box-shadow: none;
  color: var(--text-muted);
  font-weight: 700;
}

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

.order-cancel-note {
  margin: 0.75rem 0 0.5rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  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;
}

/* Motion is decoration here: anyone who asked for less gets none. */
@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);
  }
}
