:root {
  --turquoise: #37F6F0;
  --new: #E85C1C;
  --bg: #F6F0FA;
  --line: #EEE4F7;
  --accent: #6B3FA8;
  --accent-hover: #5C2E9E;
  --ink: #1A1224;
  --muted: #5A4A6A;
  --bg-card: #FFFFFF;
  --accent-ink: var(--bg-card);
  --shadow: 0 10px 30px rgb(26 18 36 / 8%);
  --radius: 18px;
  --tap: 48px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.45;
  min-height: 100dvh;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); }
header.app {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  background: var(--accent-hover);
  color: var(--accent-ink);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand img { height: 46px; width: auto; }
@media (min-width: 640px) {
  .brand img { height: 60px; }
}
header.app h1, header.app p { margin: 0; }
header.app h1 { font-size: 1.15rem; font-weight: 700; }
header.app .sub { font-size: 0.95rem; }
.muted { color: var(--muted); }
main { width: min(1100px, calc(100% - 1.5rem)); margin: 1rem auto 5rem; }
button, .btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  min-height: var(--tap);
  padding: 0.7rem 1.1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
}
.btn { display: inline-grid; place-items: center; text-align: center; text-decoration: none; }
button:not(:disabled):hover, .btn:hover { background: var(--accent-hover); }
button.secondary, .btn.secondary {
  background: var(--line);
  color: var(--ink);
}
button.secondary:hover, .btn.secondary:hover { background: var(--bg); }
button.ok { background: var(--accent-hover); color: var(--accent-ink); }
button.ok:not(:disabled):hover { background: var(--accent); }
:focus-visible { outline: 3px solid var(--accent-hover); outline-offset: 3px; }
header.app :focus-visible { outline-color: var(--turquoise); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
input, textarea, select {
  font: inherit;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  min-height: var(--tap);
  background: var(--bg-card);
}
textarea { min-height: 6rem; resize: vertical; }
label { display: block; font-weight: 650; margin: 0.8rem 0 0.35rem; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.error {
  background: var(--line);
  color: var(--ink);
  border-inline-start: 4px solid var(--new);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
}
.hint {
  background: var(--line);
  color: var(--ink);
  border-radius: 12px;
  padding: 0.7rem 1rem;
  margin: 0.6rem 0;
}
/* Buscador de la carta */
.search { margin: 0 0 1rem; }
.search input[type="search"] {
  font-size: 1.1rem;
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow: var(--shadow);
}
.empty-search {
  text-align: center;
  background: var(--bg-card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 1.15rem;
  font-weight: 650;
}

/* Carta */
.carta-banner { background: var(--accent-hover); }
.carta-banner img {
  width: 100%;
  height: max(120px, 29vw);
  object-fit: cover;
  object-position: center 30%;
}
.carta-header h1 {
  margin: 0;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-size: 1.6rem;
}
.menu {
  display: grid;
  gap: 1rem;
}
@media (min-width: 640px) {
  .menu { grid-template-columns: 1fr 1fr; }
}
.product {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 0.85rem;
  align-items: start;
}
.product img, .product .ph {
  width: 112px;
  height: 112px;
  object-fit: cover;
  border-radius: 16px;
  background: var(--line);
}
.product h3 { margin: 0 0 0.2rem; font-size: 1.15rem; }
.product .desc { margin: 0; color: var(--muted); font-size: 0.95rem; }
.price { font-weight: 800; margin: 0.35rem 0; }
.qty { display: flex; align-items: center; gap: 0.4rem; }
.qty button { min-width: var(--tap); padding: 0; font-size: 1.4rem; background: var(--line); color: var(--ink); }
.qty button:not(:disabled):hover { background: var(--bg); }
.cart {
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
  color: var(--ink);
  border-top: 1px solid var(--line);
  padding: 0.85rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.cart strong { font-size: 1.2rem; }
/* Estado */
.status-box { text-align: center; padding: 1.5rem 1rem; }
.status-box .num { font-size: 2.4rem; font-weight: 800; }
.ready-banner {
  display: none;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 20px;
  padding: 1.5rem 1rem;
  text-align: center;
  margin: 1rem 0;
}
.ready-banner.show { display: block; animation: pulse 1.2s ease-in-out 3; }
.ready-banner h2 { margin: 0 0 0.4rem; font-size: 2rem; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}
/* Barra */
body.barra main { width: min(1400px, calc(100% - 1.2rem)); }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.6rem 0 1rem; }
.cola {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 1rem;
}
.pedido {
  background: var(--bg-card);
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 1.1rem;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.pedido.nuevo { border-inline-start: 5px solid var(--new); }
.pedido.listo { background: var(--line); }
.pedido h2 { margin: 0; font-size: 2rem; }
.pedido ul { margin: 0; padding: 0; list-style: none; flex: 1; }
.pedido li { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.35rem 0; border-bottom: 1px solid var(--line); font-size: 1.08rem; }
.pedido.listo li { border-color: var(--bg-card); }
.pedido .total { font-size: 1.4rem; font-weight: 800; }
.pedido .actions { display: flex; flex-direction: column; gap: 0.5rem; }
.pedido .actions button { width: 100%; min-height: 52px; font-size: 1.1rem; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); font-size: 1.3rem; }
/* Admin */
.tables, .admin-products { display: grid; gap: 0.75rem; }
.table-row, .admin-product {
  display: grid;
  gap: 0.6rem;
  align-items: center;
}
@media (min-width: 440px) and (max-width: 799px) {
  .table-row { grid-template-columns: 1fr auto; }
  .table-row .qr-thumb { grid-column: 2; grid-row: 1 / span 4; }
}
@media (min-width: 800px) {
  .table-row { grid-template-columns: 90px 1fr auto auto auto; }
  .admin-product { grid-template-columns: 88px 1fr auto; }
}
.qr-thumb, .qr-enlarged {
  display: block;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-card);
  cursor: zoom-in;
}
.qr-thumb { width: 120px; }
.qr-thumb:not(:disabled):hover { border-color: var(--accent); }
.qr-thumb img, .qr-enlarged img { width: 100%; height: auto; aspect-ratio: 1; }
.qr-dialog {
  width: min(440px, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--ink);
  text-align: center;
}
.qr-dialog::backdrop { background: rgb(26 18 36 / 65%); }
.qr-dialog h2 { margin: 0 0 0.75rem; }
.qr-enlarged {
  width: min(400px, 100%, calc(100dvh - 10rem));
  margin: 0 auto 0.75rem;
  cursor: zoom-out;
}
.admin-product img, .admin-product .ph { width: 88px; height: 88px; object-fit: cover; border-radius: 14px; background: var(--line); }
.url { font-size: 0.85rem; word-break: break-all; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 0.7rem; font-weight: 700; }
.switch input { width: auto; min-height: 28px; height: 1.4rem; width: 1.4rem; }
.login { width: min(420px, calc(100% - 2rem)); margin: 3rem auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Confirmación del pedido */
.confirm-dialog {
  width: min(440px, calc(100% - 1.5rem));
  max-height: calc(100% - 1.5rem);
  padding: 1.1rem 1.1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.confirm-dialog::backdrop { background: rgb(26 18 36 / 55%); }
.confirm-dialog h2 { margin: 0 0 0.6rem; font-size: 1.35rem; }
.confirm-dialog .summary { list-style: none; margin: 0 0 0.6rem; padding: 0; }
.confirm-dialog .summary li {
  display: flex; justify-content: space-between; gap: 0.7rem;
  padding: 0.35rem 0; border-bottom: 1px solid var(--line);
}
.confirm-dialog .actions { display: flex; gap: 0.6rem; margin-top: 0.9rem; }
.confirm-dialog .actions button { flex: 1; }
.carta-header .welcome { margin: 0; padding: 0 1rem 0.2rem; text-align: center; color: var(--muted); }
.carta-header .mesa-label { margin: 0; padding: 0 1rem 0.75rem; text-align: center; font-weight: 700; }
.status-box .who { font-size: 1.15rem; font-weight: 700; margin: 0.2rem 0 0.4rem; }
.pedido .who { font-size: 1.15rem; font-weight: 700; margin: 0; color: var(--accent-hover); }
.pedido h2 { font-size: 1.55rem; }

/* Admin personalización e historial */
.brand-previews { display: grid; gap: 1rem; margin: 0.8rem 0; }
@media (min-width: 720px) {
  .brand-previews { grid-template-columns: 1fr 1fr; }
}
.brand-preview img, .brand-preview .ph {
  width: 100%; max-height: 140px; object-fit: contain; background: var(--accent-hover);
  border-radius: 12px; border: 1px solid var(--line);
}
.brand-preview .ph { min-height: 80px; }
.history-filters { display: grid; gap: 0.6rem; margin: 0.6rem 0 1rem; }
@media (min-width: 720px) {
  .history-filters { grid-template-columns: repeat(4, 1fr) auto; align-items: end; }
}
.history-summary { font-weight: 700; margin: 0 0 0.7rem; }
.history-wrap { overflow-x: auto; }
.history {
  width: 100%; border-collapse: collapse; font-size: 0.95rem;
}
.history th, .history td {
  text-align: left; padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.history th { font-size: 0.85rem; color: var(--muted); }
.pager { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.8rem; }

[hidden] { display: none !important; }
.section-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.section-chips button { overflow-wrap: anywhere; }
.section-chips button[aria-pressed="true"], .admin-nav a[aria-current="page"] {
  color: var(--accent-ink);
  background: var(--accent);
}
.menu-section { margin-bottom: 1.25rem; }
.menu-section > h2 { margin: 0 0 .6rem; font-size: 1.2rem; overflow-wrap: anywhere; }
.toolbar { align-items: center; }
.toolbar label { margin: 0; }
.toolbar label:has([type="range"]) { display: flex; align-items: center; gap: .35rem; }
.toolbar input[type="range"] { width: min(9rem, 32vw); padding: 0; }
.status-box .switch { justify-content: center; }
.ready-banner button { background: var(--bg-card); color: var(--accent-hover); }
.ready-banner button:not(:disabled):hover { background: var(--line); }

.admin-layout { display: grid; gap: 1rem; }
.admin-content { min-width: 0; }
.admin-content > section { scroll-margin-top: 7rem; }
.admin-nav { display: none; }
.admin-nav.open, .admin-nav a { display: block; }
.admin-nav a {
  padding: .75rem 1rem;
  font-weight: 700;
  border-radius: 12px;
  text-decoration: none;
}
.admin-nav a:not([aria-current]):hover { background: var(--line); }
.admin-content .history-filters { grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); }
.admin-content .table-row { grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); }
.admin-content .table-row .qr-thumb { grid-area: auto; }
.admin-content .admin-product { grid-template-columns: 88px minmax(0, 1fr); align-items: start; }
.admin-content .admin-product form { min-width: 0; }
#arbol details { margin: .45rem 0; }
#arbol summary {
  cursor: pointer;
  overflow-wrap: anywhere;
  background: var(--bg);
  border-radius: 12px;
  padding: .7rem;
  min-height: var(--tap);
}
.section-actions { padding: .6rem 0; }
.section-actions form .row { margin: .75rem 0 .35rem; }
.section-children { border-inline-start: 2px solid var(--line); padding-inline-start: .55rem; }
.section-children .section-children .section-children { border: 0; padding-inline-start: 0; }
@media (min-width: 760px) {
  .admin-layout { grid-template-columns: 10.5rem minmax(0, 1fr); align-items: start; }
  .admin-nav { display: block; position: sticky; top: 6.5rem; }
  #admin-menu { display: none; }
}
@media (max-width: 480px) {
  .admin-content .admin-product, .admin-content .history-filters, .admin-content .table-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

.language-picker {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  width: fit-content;
  margin: .35rem 0;
}
.language-picker select { width: auto; }
.order-lines li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .35rem 0;
  border-bottom: 1px solid var(--line);
}
.text-translations { margin: .75rem 0; }
.order-language { margin-inline-start: .3rem; font-weight: 600; }

#excel-carta {
  margin-block: 1rem;
}

.excel-table {
  max-height: 26rem;
  overflow: auto;
}

.excel-table table {
  border-collapse: collapse;
}

.excel-table th,
.excel-table td {
  padding: .45rem .65rem;
  border-bottom: 1px solid currentColor;
  min-width: 8rem;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.excel-table th:first-child {
  min-width: 3rem;
}

.excel-table td:nth-child(2) {
  min-width: 15rem;
}

.ticket-dialog { width: min(100% - 2rem, 28rem); }
.ticket-dialog iframe { display: block; width: 100%; height: min(53vh, 28rem); border: 1px solid #999; background: white; }
.ticket-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.75rem; }
.staff-toasts {
  position: fixed;
  z-index: 20;
  inset: auto max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) 0.75rem;
  display: grid;
  justify-items: end;
  gap: 0.5rem;
  pointer-events: none;
}
.staff-toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: min(100%, 27rem);
  padding: 0.35rem 0.45rem 0.35rem 0.85rem;
  overflow-wrap: anywhere;
  border: 1px solid #428568;
  border-inline-start-width: 5px;
  border-radius: 12px;
  background: #e1f8eb;
  color: #143e2a;
  box-shadow: 0 4px 18px rgb(50 23 80 / 20%);
  pointer-events: auto;
}
.staff-toast.is-error { background: #ffe9ea; color: #6c222c; border-color: #ac4c5b; }
.staff-toast button {
  flex: none;
  margin-inline-start: auto;
  min-width: 44px;
  padding: 0.25rem;
  background: var(--bg-card);
  color: var(--accent-hover);
  font-size: 1.35rem;
}
.staff-toast button:not(:disabled):hover { background: var(--line); }
#printer-form fieldset { min-width: 0; margin: 0 0 0.75rem; border: 1px solid var(--line); border-radius: 12px; }
#printer-form fieldset button { margin-top: 0.75rem; }

.admin-panel {
  margin-block: 0.65rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
}
.admin-panel > summary { cursor: pointer; font-weight: 700; padding: 0.35rem 0; }
.admin-panel > img { margin-top: 0.5rem; }
.carta-toolbar, #mover-productos { align-items: end; margin-block: 0.75rem; }
.carta-toolbar > label, #mover-productos > label { flex: 1 1 14rem; min-width: 0; margin: 0; }
.admin-menu-row { display: flex; align-items: center; gap: 0.65rem; justify-content: space-between; padding: 0.6rem; }
.product-select { display: flex; gap: 0.65rem; flex: 1; min-width: 0; margin: 0; padding-block: 0.55rem; }
.product-select input { flex: 0 0 auto; width: 1.25rem; height: 1.25rem; }
.product-select span { min-width: 0; overflow-wrap: anywhere; }
.product-select small { display: block; }
.staff-sheet {
  width: min(100% - 1rem, 36rem);
  max-height: calc(100dvh - 1rem);
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  color: inherit;
}
.staff-sheet::backdrop { background: rgb(26 18 36 / 55%); }
.staff-sheet h2 { margin-top: 0; }
.staff-sheet .sheet-actions { margin: 0.9rem 0; }
.staff-sheet .sheet-actions button { flex: 1 1 auto; }
.staff-sheet .editor-photo { display: block; width: 6rem; height: 6rem; object-fit: cover; border-radius: 0.5rem; }
.staff-sheet fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 0.65rem; margin: 0.75rem 0; padding: 0.65rem; }
.staff-sheet .option-editor { padding: 0.6rem; margin: 0.6rem 0; border-radius: 0.5rem; background: #f5f5f8; }
.option-limits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
@media (max-width: 600px) {
  .staff-sheet { margin: auto 0 0; width: 100%; border-radius: 1rem 1rem 0 0; }
}
.line-option { display: block; font-size: 0.86em; overflow-wrap: anywhere; }


#cola { grid-template-columns: minmax(0, 1fr); }
.cuenta { width: 100%; margin: 0; }
.cuenta-cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.cuenta-cabecera h2 { display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; margin: 0; }
.cuenta-cabecera h2 span { font-variant-numeric: tabular-nums; }
.pedido.entregado { border-style: dashed; }
#cobro { max-height: calc(100dvh - 2rem); overflow: auto; }
#cobro-aviso { border-inline-start: 4px solid var(--new); }
#cobro-aviso p { margin-top: 0; font-weight: 700; }
.history-charge { margin: 0.35rem 0 0; }
