/* Micaela — "como una app nativa".
   The carta and the staff screens borrow the look of an iOS app, so anyone who has used a
   phone knows at a glance what is a list, what is a button and what is a sheet: the grouped
   grey background with white inset sections, hairline separators, a large title, the system
   font, system blue for actions, green for sending the order, red for anything destructive.
   Every colour is a token here, so dark mode is the same rules with other values. The blue,
   green and red are a shade deeper than Apple's stock ones where white text sits on them or
   they sit on white, so they pass WCAG AA. */

:root {
  color-scheme: light dark;

  --bg: #f2f2f7;               /* systemGroupedBackground */
  --card-bg: #ffffff;          /* secondarySystemGroupedBackground */
  --inset-bg: #f2f2f7;         /* a row sitting inside a white section (staff lists) */
  --material: rgba(242, 242, 247, 0.82);
  --material-bar: rgba(249, 249, 249, 0.86);
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --segment-on: #ffffff;
  --separator: rgba(60, 60, 67, 0.29);
  --border: #d1d1d6;
  --text: #000000;
  --text-secondary: #3a3a3c;
  --text-muted: #6c6c70;
  --accent: #0066d6;           /* blue as text or icon */
  --accent-fill: #0066d6;      /* blue behind white text */
  --accent-hover: #0055b3;
  --tint-bg: rgba(0, 122, 255, 0.1);
  --tint-bg-strong: rgba(0, 122, 255, 0.18);
  --send: #1a7f37;             /* WhatsApp send */
  --send-hover: #146c2e;
  --danger: #d70015;
  --danger-bg: #fdecec;
  --focus: rgba(0, 122, 255, 0.6);
  --grabber: rgba(60, 60, 67, 0.3);
  --overlay: rgba(0, 0, 0, 0.4);
  --shadow-segment: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --hairline: 0.5px;
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card-bg: #1c1c1e;
    --inset-bg: #2c2c2e;
    --material: rgba(0, 0, 0, 0.72);
    --material-bar: rgba(22, 22, 24, 0.82);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(118, 118, 128, 0.36);
    --segment-on: #636366;
    --separator: rgba(84, 84, 88, 0.65);
    --border: #38383a;
    --text: #ffffff;
    --text-secondary: #d1d1d6;
    --text-muted: #98989f;
    --accent: #0a84ff;
    --accent-fill: #0064d2;
    --accent-hover: #0a72e6;
    --tint-bg: rgba(10, 132, 255, 0.18);
    --tint-bg-strong: rgba(10, 132, 255, 0.28);
    --send: #1a7f37;
    --send-hover: #21913f;
    --danger: #ff6961;
    --danger-bg: rgba(255, 69, 58, 0.18);
    --focus: rgba(10, 132, 255, 0.75);
    --grabber: rgba(235, 235, 245, 0.3);
    --overlay: rgba(0, 0, 0, 0.55);
    --shadow-segment: 0 3px 8px rgba(0, 0, 0, 0.3);
  }
}

/* ---------------------------------------------------------------- base */

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI",
    Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* One focus ring for everything a keyboard can reach, in the system's blue. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- large title */

header {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(1.5rem + env(safe-area-inset-top)) 1rem 0.9rem;
  text-align: left;
}

header h1 {
  margin: 0;
  font-size: 2.125rem;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: 0.01em;
}

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

/* Staff navigation as a segmented control. */
.main-nav {
  display: flex;
  width: fit-content;
  max-width: 100%;
  gap: 2px;
  margin-top: 0.9rem;
  padding: 2px;
  border-radius: 9px;
  background: var(--fill);
  font-size: 0.875rem;
}

.main-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0 0.9rem;
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.main-nav a.current {
  background: var(--segment-on);
  box-shadow: var(--shadow-segment);
  font-weight: 600;
}

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

/* An inset-grouped section. */
.card {
  background: var(--card-bg);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 1rem;
}

.card h2 {
  margin-top: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

/* ---------------------------------------------------------------- forms (staff) */

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

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

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

input,
textarea {
  min-height: 2.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--fill);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
}

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

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

input:focus,
textarea:focus {
  outline: 3px solid var(--focus);
  outline-offset: 0;
  background: var(--card-bg);
  border-color: var(--accent);
}

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

.field-help {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  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;
  border: none;
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  font-size: 1.0625rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.card .notice {
  background: var(--tint-bg);
}

.sides-section {
  margin-top: 1.25rem;
  border-top: var(--hairline) solid var(--separator);
  padding-top: 0.75rem;
}

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

.sides-header h3 {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

#add-side,
#add-time {
  min-height: 2.75rem;
  padding: 0 1rem;
  border: none;
  border-radius: 999px;
  background: var(--tint-bg);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.side-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: var(--hairline) solid var(--separator);
  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;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 1rem;
  cursor: pointer;
}

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

button.primary {
  flex: 1;
  min-height: 3.125rem;
  padding: 0.75rem 1rem;
  background: var(--accent-fill);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1.0625rem;
  font-weight: 600;
  cursor: pointer;
}

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

button.secondary {
  min-height: 3.125rem;
  padding: 0.75rem 1.1rem;
  background: var(--fill);
  color: var(--accent);
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1.0625rem;
  font-weight: 600;
  cursor: pointer;
}

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

/* Always wins: several components set their own display and used to beat it. */
.hidden {
  display: none !important;
}

.edit-item {
  min-height: 2.75rem;
  padding: 0 0.6rem;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9375rem;
}

.empty-state {
  margin: 0;
  padding: 0.5rem 0;
  color: var(--text-muted);
}

.menu-hint {
  margin: 1rem 0 0;
  padding: 0.75rem 0.9rem;
  border: none;
  border-radius: 10px;
  background: var(--tint-bg);
  color: var(--text);
  font-size: 0.875rem;
}

/* ---------------------------------------------------------------- lists */

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

.dish-item {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  background: var(--inset-bg);
}

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

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

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

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

.delete-dish {
  min-height: 2.75rem;
  padding: 0 0.6rem;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--danger);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9375rem;
}

.side-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.9375rem;
  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;
  min-height: 2.75rem;
  background: var(--inset-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;
  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.35rem;
}

/* Lifted out of the flow and following the finger. */
.daily-dish-group.dragging {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  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(--tint-bg);
}

.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.8125rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* 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(--accent);
  font-family: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
}

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

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

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

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

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

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

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

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

/* The iOS checkmark of a chosen row. */
.daily-dish-mark {
  visibility: hidden;
  color: var(--accent);
  font-weight: 700;
}

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

button.primary:disabled {
  background: var(--fill-strong);
  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;
}

.carta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

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

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

.order-line-amount {
  min-width: 1.6rem;
  text-align: right;
  font-weight: 600;
  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: #ffffff;
  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: var(--hairline) solid var(--separator);
  padding-top: 0.9rem;
}

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

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

.time-option {
  min-height: 2.75rem;
  padding: 0 1rem;
  border: none;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text);
  font-size: 0.9375rem;
  font-family: inherit;
  cursor: pointer;
}

.time-option.selected {
  background: var(--accent-fill);
  color: #ffffff;
  font-weight: 600;
}

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

.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: var(--hairline) solid var(--separator);
  font-size: 1.0625rem;
}

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

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

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

/* ---------------------------------------------------------------- kitchen / counter (kept) */

.kitchen-status {
  margin-left: 0.5rem;
  font-size: 0.8125rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--fill);
}

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

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

.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.25rem;
}

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

.kitchen-chip {
  font-size: 0.8125rem;
  color: var(--text-muted);
  background: var(--fill);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}

.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(--fill-strong);
}

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

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

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

.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: #ffffff;
  font-size: 0.9rem;
  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,
  header {
    max-width: 1080px;
  }

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

  #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));
  }
}

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

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

.day-picker button {
  flex: none;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0 0.75rem;
  border: none;
  border-radius: 10px;
  background: var(--fill);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.day-picker button:hover {
  background: var(--tint-bg-strong);
}

/* A family's name, in the style of an iOS prominent section header. It spans the whole grid
   so the family below it starts on a fresh row. */
.line-group-heading {
  margin: 1.6rem 0 0.5rem;
  padding: 0 0.25rem;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.005em;
  color: var(--text);
}

.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: 400;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

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

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

/* 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.25rem + env(safe-area-inset-bottom));
}

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

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

.form-actions::before,
.sticky-actions::before {
  content: '';
  display: block;
  border-top: var(--hairline) solid var(--separator);
  margin-bottom: 0.75rem;
}

/* .form-actions is a flex row; the line above the buttons takes a row of its own. */
.form-actions {
  flex-wrap: wrap;
}

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

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

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

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

.daily-dish-stock {
  width: 4rem;
  height: 2.25rem;
  min-height: 0;
  flex: none;
  padding: 0.25rem 0.5rem;
  font-size: 0.9375rem;
  text-align: right;
}

.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;
}

.order-line-sold-out {
  background: var(--fill);
  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.6rem;
}

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

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

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

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

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

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

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

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

.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-fill);
  color: #ffffff;
  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:
   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: baseline;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.allergen-tag {
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.35;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.order-line-ingredients {
  flex: 1 1 100%;
  font-size: 0.8125rem;
  line-height: 1.35;
  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.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

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

.allergen-chip {
  min-height: 2.75rem;
  padding: 0 0.8rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

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

.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.15rem 0.6rem;
  border: none;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  vertical-align: middle;
}

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

.chime-button-blocked {
  background: var(--tint-bg);
  color: var(--accent);
}

/* ---------------------------------------------------------------- carta: category bar */

/* A translucent bar, like a navigation bar's material, stuck to the top while the page
   scrolls underneath. Edge to edge: it reaches past main's gutter and puts it back inside. */
.carta-categories {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  margin: 0 -1rem;
  padding: 0.4rem 1rem;
  background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: var(--hairline) solid var(--separator);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

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

.carta-chip {
  position: relative;
  flex: 0 0 auto;
  min-height: 2.25rem;
  padding: 0 0.95rem;
  border: none;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s, color 0.2s;
}

/* The capsule looks 36px tall; the finger gets 44px. */
.carta-chip::after {
  content: '';
  position: absolute;
  inset: -0.25rem 0;
}

.carta-chip:focus-visible {
  outline-offset: -1px;
}

.carta-chip-on {
  background: var(--accent-fill);
  color: #ffffff;
  font-weight: 600;
}

#tag-input {
  width: 100%;
}

.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: flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  min-height: 2.75rem;
  cursor: grab;
  touch-action: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0 0.2rem;
  user-select: none;
}

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

/* ---------------------------------------------------------------- carta: grouped list */

/* On the carta the card is only a frame: each family is its own inset-grouped section. */
.card:has(> #carta-lines) {
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
}

#carta-lines {
  display: flex;
  flex-direction: column;
  gap: 0;
}

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

/* A row: name and price on the left, the stepper on the right, allergens and ingredients
   below across the full width. Hairlines between rows start at the text, as in Settings. */
.dish-item.carta-line {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'title step'
    'price step'
    'details details';
  align-items: center;
  gap: 0 0.75rem;
  min-height: 2.75rem;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 0;
  background: var(--card-bg);
}

.carta-line + .carta-line::before {
  content: '';
  position: absolute;
  top: 0;
  left: 1rem;
  right: 0;
  border-top: var(--hairline) solid var(--separator);
}

#carta-lines > .carta-line:first-child,
.line-group-heading + .carta-line {
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}

.carta-line:last-child,
.carta-line:has(+ .line-group-heading) {
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.carta-line > .order-line-title {
  grid-area: title;
  align-self: end;
  font-size: 1.0625rem;
  line-height: 1.3;
}

.carta-line .dish-extra {
  font-size: 0.875rem;
}

.carta-line > .dish-price {
  grid-area: price;
  align-self: start;
  margin-top: 0.1rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
}

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

.carta-line > .order-line-details {
  grid-area: details;
  margin-top: 0.45rem;
}

/* ---------------------------------------------------------------- stepper */

/* An iOS stepper: one grey rounded rectangle, minus and plus in the tint colour. Each half
   looks 36px tall and catches a 44px finger. */
.order-stepper {
  display: inline-flex;
  align-items: center;
  flex: none;
  height: 2.25rem;
  border-radius: 9px;
  background: var(--fill);
}

.order-stepper:has(> .order-add:only-child) {
  background: none;
}

.order-stepper button {
  position: relative;
  width: 2.75rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: 9px;
  background: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 1.375rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.15s;
}

.order-stepper button::after {
  content: '';
  position: absolute;
  inset: -0.25rem 0;
}

.order-stepper button:active {
  background: var(--fill-strong);
}

.order-stepper .order-add {
  width: 2.75rem;
  background: var(--tint-bg);
  font-weight: 600;
}

.order-stepper .order-add:active {
  background: var(--tint-bg-strong);
}

.order-quantity {
  min-width: 1.5rem;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ---------------------------------------------------------------- bottom bar */

/* 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.6rem calc(1rem + env(safe-area-inset-right)) calc(0.6rem + env(safe-area-inset-bottom))
    calc(1rem + env(safe-area-inset-left));
  background: var(--material-bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: var(--hairline) solid var(--separator);
  animation: bar-in 0.3s var(--ease-sheet);
}

.order-bar-button,
.order-send {
  display: block;
  width: 100%;
  max-width: 32rem;
  min-height: 3.125rem;
  margin: 0 auto;
  padding: 0.8rem 1rem;
  border: none;
  border-radius: 14px;
  background: var(--accent-fill);
  color: #ffffff;
  font-family: inherit;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.15s;
}

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

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

/* ---------------------------------------------------------------- sheet */

.order-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--overlay);
  animation: fade-in 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.4rem calc(1rem + env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom))
    calc(1rem + env(safe-area-inset-left));
  border-radius: 14px 14px 0 0;
  background: var(--bg);
  box-shadow: 0 -2px 24px rgba(0, 0, 0, 0.15);
  animation: sheet-up 0.4s var(--ease-sheet);
}

/* The grabber pill. */
.order-sheet::before {
  content: '';
  display: block;
  width: 36px;
  height: 5px;
  margin: 0 auto 0.6rem;
  border-radius: 3px;
  background: var(--grabber);
}

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

.order-sheet-head h2 {
  margin: 0;
  padding-left: 0.25rem;
  font-size: 1.375rem;
  font-weight: 700;
}

/* The round grey close button of an iOS sheet, inside a 44px target. */
.order-close {
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  margin-right: -0.4rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: radial-gradient(circle, var(--fill-strong) 0 15px, transparent 15.5px);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.order-sheet .order-items {
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--card-bg);
}

.order-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.25rem;
  padding: 0.55rem 0.75rem 0.55rem 1rem;
  border-bottom: none;
}

.order-item + .order-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 1rem;
  right: 0;
  border-top: var(--hairline) solid var(--separator);
}

.order-item-name {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  font-weight: 500;
}

.order-item-name small {
  display: block;
  margin-top: 0.1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.order-total {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.order-sheet .order-total {
  margin: 0.75rem 0 0;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  background: var(--card-bg);
  font-size: 1.0625rem;
}

.order-total span:last-child {
  color: var(--text);
}

/* An iOS grouped-section header. */
.order-field-label {
  display: block;
  margin: 1.25rem 0 0.4rem;
  padding: 0 1rem;
  font-size: 0.8125rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

/* The pickup times as a segmented control. */
.order-times {
  display: flex;
  gap: 2px;
  margin-bottom: 1.25rem;
  padding: 2px;
  border-radius: 10px;
  background: var(--fill-strong);
}

.order-time {
  flex: 1;
  min-height: 2.75rem;
  padding: 0 0.5rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
}

.order-time-on {
  background: var(--segment-on);
  box-shadow: var(--shadow-segment);
  color: var(--text);
  font-weight: 700;
}

.order-error {
  margin: 0 0 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.9375rem;
  font-weight: 500;
}

/* Sending opens WhatsApp, so it wears WhatsApp's green. */
.order-send {
  background: var(--send);
}

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

.order-hint {
  margin: 0.75rem 0 0;
  padding: 0 1rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
  text-align: center;
}

/* ---------------------------------------------------------------- today's order */

.order-summary {
  margin-bottom: 0;
  border: none;
  padding: 1rem 1rem 1rem;
}

.order-summary h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
}

/* A green tick, like a delivered-state badge. */
.order-summary h2::before {
  content: '✓';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--send);
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 700;
}

.order-summary-line {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.order-summary-line + .order-summary-line {
  border-top: var(--hairline) solid var(--separator);
}

.order-summary-line span:last-child {
  color: var(--text-secondary);
  white-space: nowrap;
}

.order-summary .order-total {
  border-top: var(--hairline) solid var(--separator);
  margin-top: 0;
  font-size: 1.0625rem;
}

.order-summary-time {
  margin: 0 0 0.9rem;
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  background: var(--tint-bg);
  font-weight: 600;
  color: var(--accent);
}

.order-summary-edit,
.order-discard {
  display: block;
  width: 100%;
  min-height: 3.125rem;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 14px;
  background: var(--tint-bg);
  color: var(--accent);
  font-family: inherit;
  font-size: 1.0625rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.15s;
}

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

/* Throwing away the changes is destructive, so it is red, as in an iOS action sheet. */
.order-discard {
  max-width: 32rem;
  margin: 0.6rem auto 0;
  background: var(--card-bg);
  color: var(--danger);
}

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

.order-cancel-note {
  margin: 0 0 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 500;
}

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

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

/* Dark sheets are lifted a step, with their groups one step higher still. */
@media (prefers-color-scheme: dark) {
  .order-sheet {
    background: var(--card-bg);
  }

  .order-sheet .order-items,
  .order-sheet .order-total {
    background: var(--inset-bg);
  }

  .order-sheet .order-times {
    background: var(--fill);
  }
}

/* ---------------------------------------------------------------- carta at desktop width */

@media (min-width: 720px) {
  body:has(#carta-lines) header,
  body:has(#carta-lines) main {
    max-width: 720px;
  }

  body:has(#carta-lines) header {
    padding-top: calc(2.5rem + env(safe-area-inset-top));
  }

  header h1 {
    font-size: 2.5rem;
  }

  .order-sheet {
    bottom: 1rem;
    border-radius: 14px;
    max-height: calc(100vh - 2rem);
  }
}

/* ---------------------------------------------------------------- motion */

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

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

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

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

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

/* ---------------------------------------------------------------- staff refinements */

/* Staff titles are long ("Micaela — Menú del día"): a smaller large title keeps them on
   one or two lines. */
body:has(.main-nav) header h1 {
  font-size: 1.75rem;
}

/* The name keeps at least a readable width; the price and actions drop below it when the
   row is too narrow for both. */
.dish-item-header {
  flex-wrap: wrap;
}

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

.dish-item-header .edit-item,
.dish-item-header .delete-dish {
  padding: 0 0.4rem;
  font-size: 0.875rem;
}

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

body:has(#carta-lines) main {
  gap: 1rem;
}

@media (min-width: 720px) {
  .carta-categories {
    margin: 0;
    padding: 0.4rem 0;
  }
}
