/* ------------------------------------------------------------------ tokens */
:root {
  --ground: #eef2ee;
  --surface: #ffffff;
  --surface-2: #f6f8f6;
  --ink: #16201b;
  --ink-2: #4a5850;
  --ink-3: #7a877f;
  --line: #d8e0da;
  --accent: #1d7a4b;
  --accent-ink: #ffffff;
  --accent-soft: #d6ecdf;
  --accent-tint: #eef7f1;
  --warn: #9a5b00;
  --warn-soft: #fbefd9;
  --bad: #b3362c;
  --bad-soft: #f9e1de;
  --ticket: #fffefa;
  --scroll-thumb: #9cc7ae;
  --scroll-thumb-hover: #1d7a4b;
  --shadow: 0 1px 2px rgba(22, 32, 27, 0.06), 0 6px 20px rgba(22, 32, 27, 0.06);
  --radius: 10px;
  --font-display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  --font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --ground: #0e1310;
    --surface: #161d19;
    --surface-2: #1b241f;
    --ink: #e5ede8;
    --ink-2: #aebbb3;
    --ink-3: #7d8b83;
    --line: #2a352f;
    --accent: #52c285;
    --accent-ink: #08140d;
    --accent-soft: #1f3b2c;
    --accent-tint: #172a20;
    --warn: #f0b75a;
    --warn-soft: #3a2c14;
    --bad: #f08a80;
    --bad-soft: #3d1d1a;
    --ticket: #1a221e;
    --scroll-thumb: #2f5b43;
    --scroll-thumb-hover: #52c285;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --ground: #0e1310;
  --surface: #161d19;
  --surface-2: #1b241f;
  --ink: #e5ede8;
  --ink-2: #aebbb3;
  --ink-3: #7d8b83;
  --line: #2a352f;
  --accent: #52c285;
  --accent-ink: #08140d;
  --accent-soft: #1f3b2c;
  --accent-tint: #172a20;
  --warn: #f0b75a;
  --warn-soft: #3a2c14;
  --bad: #f08a80;
  --bad-soft: #3d1d1a;
  --ticket: #1a221e;
  --scroll-thumb: #2f5b43;
  --scroll-thumb-hover: #52c285;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ scrollbars (color del tema) */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 10px;
  border: 2px solid var(--surface);
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}
*::-webkit-scrollbar-corner {
  background: transparent;
}

/* ------------------------------------------------------------------ base */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
html {
  background: var(--ground);
}
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3 {
  font-family: var(--font-display);
  margin: 0;
  text-wrap: balance;
  letter-spacing: -0.01em;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ------------------------------------------------------------------ shell */
.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding-inline: 16px;
  padding-block: 0 16px;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-block: 14px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.brand h1 {
  font-size: 22px;
  font-weight: 700;
}
.brand .mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 700 14px/1 var(--font-mono);
  align-self: center;
}
.theme-toggle {
  margin-left: auto;
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
  display: inline-grid;
  place-items: center;
}
.credits {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 12.5px;
  color: var(--ink-3);
  text-align: center;
}
.credits p {
  margin: 0;
}
.credits a,
.credits .link-btn {
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.credits a:hover,
.credits .link-btn:hover {
  color: var(--accent);
}
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.copied {
  margin-left: 6px;
  color: var(--accent);
  font-weight: 600;
}
.brand p {
  margin: 0;
  color: var(--ink-3);
  font-size: 13.5px;
}

.layout {
  flex: 1;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(250px, 300px) minmax(340px, 1fr) minmax(360px, 1.1fr);
  min-height: 0;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.panel-head {
  padding: 14px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  font-size: 17px;
}
.panel-body {
  padding: 14px 16px;
  overflow: auto;
  min-height: 0;
}
@media (min-width: 1100px) {
  .app {
    height: 100%;
  }
  .layout {
    overflow: hidden;
  }
  .panel {
    max-height: 100%;
  }
}
@media (max-width: 1099px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .panel-setup {
    grid-column: 1 / -1;
  }
  .panel-menu .panel-body {
    max-height: 75vh;
  }
}
@media (max-width: 760px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ------------------------------------------------------------------ setup panel */
.setup {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
@media (max-width: 1099px) and (min-width: 761px) {
  .setup {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
  }
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.control {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
}
.control:hover {
  border-color: var(--ink-3);
}
select.control {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
    linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
  cursor: pointer;
}
.resto-meta {
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  gap: 6px 12px;
  flex-wrap: wrap;
}
.resto-meta .star {
  color: var(--accent);
  font-weight: 700;
}

.add-person {
  display: flex;
  gap: 8px;
}
.btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  color: var(--accent-ink);
  filter: brightness(1.08);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  padding: 4px 6px;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 13px;
}
.people {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.person-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-tint);
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  padding: 3px 4px 3px 11px;
  font-size: 14px;
  font-weight: 500;
}
.person-chip button {
  border: 0;
  background: transparent;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--ink-3);
  font-size: 15px;
  line-height: 1;
}
.person-chip button:hover {
  background: var(--bad-soft);
  color: var(--bad);
}
.people-count {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
/* Que "Vaciar" no haga la fila más alta que las etiquetas de las otras columnas. */
.people-count .btn-ghost {
  padding: 0 2px;
  line-height: 1;
  font-size: 12.5px;
}
.budget-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.money-input {
  position: relative;
}
.money-input input {
  padding-left: 50px;
  padding-right: 26px;
  font-family: var(--font-mono);
}
.money-input .pre {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: text;
}
.money-input span {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
}
.hint {
  font-size: 12.5px;
  color: var(--ink-3);
  margin: 0;
}

/* ------------------------------------------------------------------ menu panel */
.menu-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.check-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.menu-tools .spacer {
  flex: 1;
}
.search {
  flex: 1 1 160px;
  min-width: 0;
  padding: 7px 10px;
}
input[type='checkbox'] {
  accent-color: var(--accent);
  width: 17px;
  height: 17px;
  margin: 0;
  cursor: pointer;
  flex: none;
}
.cat {
  margin-bottom: 14px;
}
.cat-head {
  position: sticky;
  top: -14px;
  z-index: 1;
  background: var(--surface);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-block: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}
.cat-head h3 {
  font-size: 14px;
  font-weight: 700;
}
.cat-head .count {
  font-size: 12px;
  color: var(--ink-3);
}
.dish {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: start;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
}
.dish:hover {
  background: var(--surface-2);
}
.dish.checked {
  background: var(--accent-tint);
}
.dish input {
  margin-top: 2px;
}
.dish-name {
  font-weight: 600;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.dish-desc {
  grid-column: 2 / 4;
  font-size: 12.5px;
  color: var(--ink-3);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dish-price {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
  text-align: right;
}
.dish-meta {
  grid-column: 2 / 4;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: center;
  font-size: 12px;
  color: var(--ink-2);
}
.dish-meta .sep {
  color: var(--line);
}
.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag-rec {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.tag-good {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}
.tag-mid {
  background: var(--warn-soft);
  border-color: transparent;
  color: var(--warn);
}
.tag-bad {
  background: var(--bad-soft);
  border-color: transparent;
  color: var(--bad);
}
.empty {
  color: var(--ink-3);
  text-align: center;
  padding: 30px 10px;
}

/* ------------------------------------------------------------------ plan panel */
.plan-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.status {
  font-size: 12.5px;
  color: var(--ink-3);
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.stat {
  background: var(--surface-2);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.stat b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(14px, 1.3vw, 17px);
  white-space: nowrap;
}
.stat span {
  font-size: 11.5px;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}
@media (max-width: 440px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.plan-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.alerts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.alert {
  background: var(--warn-soft);
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  border-left: 3px solid var(--warn);
}
.alert.error {
  background: var(--bad-soft);
  border-left-color: var(--bad);
}
.fill-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.fill-chips button {
  border: 1px dashed var(--warn);
  background: transparent;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12.5px;
  cursor: pointer;
}
.fill-chips button:hover {
  background: var(--surface);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.section-title h3 {
  font-size: 15px;
}
.order-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.order-table td {
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
  vertical-align: top;
}
.order-table td.qty {
  width: 38px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
}
.order-table td.amt {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-left: 10px;
}
.order-table .unit {
  color: var(--ink-3);
  font-size: 12px;
}

/* Tickets por persona */
.tickets {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ticket {
  background: var(--ticket);
  border: 1px solid var(--line);
  border-bottom: 2px dashed var(--line);
  border-radius: 6px 6px 2px 2px;
  padding: 10px 11px 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.ticket-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 2px 8px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 6px;
}
.ticket-head .label {
  grid-column: 1 / -1;
}
.ticket-total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
}
.ticket-total small {
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
}
.ticket-total.low .num,
.ticket-total.low small {
  color: var(--warn);
}
.ticket-head h4 {
  margin: 0;
  font: 700 15px/1.2 var(--font-display);
  overflow-wrap: anywhere;
}
.ticket-head .num {
  font-weight: 700;
  font-size: 15px;
}
.ticket ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.ticket li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 6px;
}
.ticket li .q {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
}
.ticket li .a {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.meter {
  margin-top: auto;
  height: 5px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  background: var(--accent);
}
.meter.low i {
  background: var(--warn);
}
.meter-caption {
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  justify-content: space-between;
}
.howto {
  font-size: 12.5px;
  color: var(--ink-3);
  margin: 0;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--surface);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  z-index: 10;
}
@media (prefers-reduced-motion: no-preference) {
  .dish,
  .btn {
    transition: background-color 0.12s, border-color 0.12s, color 0.12s;
  }
  .plan-body.busy {
    opacity: 0.55;
    transition: opacity 0.15s;
  }
}
