/* ═══════════════════════════════════════════════════════════════
   DALUNA TPV — TEMA CLARO ACCESIBLE
   Alta legibilidad · Texto grande · Contraste AA+ · Marca malva+dorado
   Diseñado para personas con vista cansada: fondo claro, letra oscura,
   estados con color + etiqueta de texto (nunca solo color).
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* ── Superficies claras ── */
  --bg:         #f1ebe2;   /* crema cálida de fondo */
  --bg-2:       #e7ddd0;
  --surface:    #ffffff;   /* tarjetas: blanco puro para máxima lectura */
  --surface-2:  #faf6f0;
  --surface-3:  #f0e8dd;

  /* ── Tinta (texto) — todo AA+ sobre superficies claras ── */
  --ink:        #201a1b;   /* casi negro cálido */
  --ink-soft:   #3f3436;
  --ink-mute:   #6a5c5e;   /* contraste ~5:1 sobre blanco */
  --line:       rgba(32,26,27,.12);
  --line-2:     rgba(32,26,27,.20);
  --line-3:     rgba(32,26,27,.30);

  /* ── Marca ── */
  --malva:      #8a6a72;
  --malva-deep: #664a51;
  --malva-soft: #efe3e6;
  --gold:       #a87f4a;   /* dorado oscurecido para contraste sobre blanco */
  --gold-bright:#c9a77c;
  --gold-soft:  #f4ead7;

  /* ── Estados de mesa/pedido — colores AA sobre claro ── */
  --libre:      #2f8558;   --libre-bg:   #e4f2ea;   --libre-soft: #d6ecdf;
  --abierta:    #a86e1f;   --abierta-bg: #f8edd6;   --abierta-soft:#f6e8cf;
  --cobrar:     #b5382f;   --cobrar-bg:  #fbe6e3;   --cobrar-soft:#f7d9d5;
  --info:       #2f6bb0;   --info-bg:    #e2edf8;

  /* ── Tipografía ── */
  --f-serif: 'Fraunces', 'Playfair Display', Georgia, serif;
  --f-sans:  'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Escala GRANDE por defecto (base 17px). Se agranda con [data-size]. */
  --fs-xs:   .82rem;   /* 14px — solo etiquetas mayúsculas */
  --fs-sm:   .95rem;   /* 16px */
  --fs-base: 1rem;     /* 17px — cuerpo mínimo legible */
  --fs-md:   1.24rem;  /* 21px */
  --fs-lg:   1.6rem;   /* 27px */
  --fs-xl:   2.1rem;   /* 36px */
  --fs-2xl:  2.8rem;   /* 48px */

  /* Zona táctil generosa */
  --touch:   54px;

  /* Espaciado base 4px */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem;
  --sp-5: 1.5rem; --sp-6: 2rem; --sp-7: 3rem;

  --r-sm: 10px; --r: 16px; --r-lg: 22px; --r-xl: 30px; --r-pill: 999px;

  --hh: 64px;   /* header más alto = más aire */

  --shadow-sm:  0 1px 2px rgba(32,26,27,.05), 0 2px 8px -4px rgba(32,26,27,.10);
  --shadow:     0 2px 6px rgba(32,26,27,.06), 0 12px 28px -12px rgba(32,26,27,.18);
  --shadow-lg:  0 6px 16px rgba(32,26,27,.08), 0 28px 56px -24px rgba(32,26,27,.26);
  --glow-gold:  0 0 0 4px rgba(201,167,124,.25);

  --ease:      cubic-bezier(0.19, 1, 0.22, 1);
  --ease-soft: cubic-bezier(0.25, 1, 0.5, 1);
}

/* Tamaños de letra accesibles — escalan TODA la interfaz (rem) */
html[data-size="normal"] { font-size: 17px; }
html[data-size="grande"] { font-size: 19.5px; }
html[data-size="enorme"] { font-size: 22px; }

/* Tema oscuro opcional (para quien lo prefiera de noche) */
html[data-theme="dark"] {
  --bg:        #1e1719;  --bg-2: #271e21;
  --surface:   #2c2225;  --surface-2: #352a2d;
  --surface-3: #413438;
  --ink:       #f7f0ec;  --ink-soft: rgba(247,240,236,.9); --ink-mute: rgba(247,240,236,.68);
  --line: rgba(247,240,236,.14); --line-2: rgba(247,240,236,.24); --line-3: rgba(247,240,236,.36);
  --malva-soft: #3a2d31; --gold: #d3b184; --gold-soft: #3a3026;
  --libre-bg:#1f3b2c; --abierta-bg:#3a2e1a; --cobrar-bg:#3a201e; --info-bg:#1e2e42;
  --malva: #c0adb0;
  color-scheme: dark;
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  font-family: var(--f-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: var(--fs-base);
  line-height: 1.5;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
input, button, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
.serif { font-family: var(--f-serif); font-weight: 400; }

/* Foco visible siempre (accesibilidad) */
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ─── APP SHELL + VIEWS ─── */
#app { position: relative; height: 100dvh; overflow: hidden; }
.view {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transform: translateY(12px) scale(.995);
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.view.active { opacity: 1; pointer-events: all; transform: none; }

/* ─── HEADER ─── */
.tpv-header {
  height: var(--hh); flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-4);
  box-shadow: var(--shadow-sm);
  z-index: 20;
  position: relative;
}
.header-brand {
  font-family: var(--f-serif);
  font-size: var(--fs-md);
  font-weight: 400;
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: var(--sp-3);
}
.header-brand .brand-logo {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.header-chip {
  font-family: var(--f-sans);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--gold-soft);
  padding: .28em .7em;
  border-radius: var(--r-pill);
  flex-shrink: 0;
}

/* Botón icono genérico */
.btn-icon {
  width: var(--touch); height: var(--touch);
  min-width: var(--touch);
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background .18s, color .18s, border-color .18s, transform .12s;
}
.btn-icon svg { width: 24px; height: 24px; }
.btn-icon:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }
.btn-icon:active { transform: scale(.92); }

/* ═══ BOTÓN ÚNICO DE CUENTA ═══ */
.account-btn {
  display: flex; align-items: center; gap: var(--sp-2);
  height: var(--touch);
  padding: 0 var(--sp-2) 0 var(--sp-3);
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  transition: background .18s, border-color .18s, box-shadow .18s, transform .12s;
  flex-shrink: 0;
}
.account-btn:hover { background: var(--surface-2); border-color: var(--gold); box-shadow: var(--shadow-sm); }
.account-btn:active { transform: scale(.97); }
.account-btn .acc-name {
  font-size: var(--fs-sm); font-weight: 600;
  max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.account-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--malva), var(--malva-deep));
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--f-serif); font-size: var(--fs-md); font-weight: 400;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.15);
}
.account-btn .acc-caret { width: 18px; height: 18px; color: var(--ink-mute); }

/* Menú desplegable de cuenta */
.account-menu {
  position: fixed;
  top: calc(var(--hh) + 8px);
  right: 12px;
  width: min(340px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  opacity: 0; transform: translateY(-8px) scale(.98);
  pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.account-menu.open { opacity: 1; transform: none; pointer-events: all; }
.account-menu-head {
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  background: linear-gradient(135deg, var(--malva-soft), var(--surface-2));
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--sp-3);
}
.account-menu-head .account-avatar { width: 52px; height: 52px; font-size: var(--fs-lg); }
.account-menu-head .am-name { font-family: var(--f-serif); font-size: var(--fs-md); line-height: 1.1; }
.account-menu-head .am-role { font-size: var(--fs-sm); color: var(--ink-mute); margin-top: 2px; }
.account-menu-list { padding: var(--sp-2); }
.am-item {
  width: 100%;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  min-height: var(--touch);
  border: none; background: transparent;
  border-radius: var(--r);
  color: var(--ink);
  font-size: var(--fs-base); font-weight: 500;
  text-align: left;
  text-decoration: none;
  transition: background .15s, transform .1s;
}
.am-item:hover { background: var(--surface-2); }
.am-item:active { transform: scale(.98); }
.am-item .am-ico {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--surface-3);
  display: grid; place-items: center;
  flex-shrink: 0; color: var(--malva-deep);
}
.am-item .am-ico svg { width: 22px; height: 22px; }
.am-item .am-label { flex: 1; }
.am-item .am-arrow { color: var(--ink-mute); width: 18px; height: 18px; }
.am-item.danger { color: var(--cobrar); }
.am-item.danger .am-ico { background: var(--cobrar-bg); color: var(--cobrar); }
.am-sep { height: 1px; background: var(--line); margin: var(--sp-2) var(--sp-3); }
.am-badge {
  font-size: var(--fs-xs); font-weight: 700;
  background: var(--gold-soft); color: var(--gold);
  padding: .2em .6em; border-radius: var(--r-pill);
}

/* Backdrop del menú */
.menu-backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: transparent;
  opacity: 0; pointer-events: none;
}
.menu-backdrop.open { pointer-events: all; }

/* ─── BOTÓN PRIMARIO ─── */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  width: 100%;
  min-height: var(--touch);
  background: var(--gold);
  color: #fff;
  border: none; border-radius: var(--r);
  padding: var(--sp-3) var(--sp-5);
  font-size: var(--fs-md); font-weight: 700;
  letter-spacing: .01em;
  transition: background .2s, transform .1s, box-shadow .2s;
  box-shadow: 0 4px 16px -4px rgba(168,127,74,.5);
}
.btn-primary:hover { background: var(--malva-deep); box-shadow: 0 6px 22px -4px rgba(102,74,81,.5); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .4; box-shadow: none; transform: none; cursor: default; }
.btn-primary svg { width: 22px; height: 22px; }

/* ─── LOADING ─── */
#view-loading { align-items: center; justify-content: center; }
.loading-screen { display: flex; flex-direction: column; align-items: center; gap: var(--sp-6); }
.loading-logo { display: flex; align-items: center; gap: var(--sp-3); }
.loading-brand { font-family: var(--f-serif); font-size: var(--fs-xl); }
.loading-chip {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--gold); align-self: center;
}
.spinner { animation: spin .9s linear infinite; width: 34px; height: 34px; color: var(--malva); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ SELECTOR DE ROL ═══ */
.roles-body {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: var(--sp-6) var(--sp-5); overflow-y: auto; gap: var(--sp-6);
}
.roles-title { text-align: center; }
.roles-title h1 {
  font-family: var(--f-serif); font-weight: 300;
  font-size: var(--fs-xl); letter-spacing: -.02em; margin-bottom: var(--sp-2);
}
.roles-title p { color: var(--ink-mute); font-size: var(--fs-md); }
.roles-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-5); width: 100%; max-width: 920px;
}
.role-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-6) var(--sp-5);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-4);
  text-align: center;
  transition: border-color .25s, transform .22s var(--ease), box-shadow .25s, background .2s;
  position: relative; overflow: hidden;
}
.role-card::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 0%, var(--gold-soft), transparent 70%);
  opacity: 0; transition: opacity .3s;
}
.role-card:hover {
  border-color: var(--gold); transform: translateY(-6px); box-shadow: var(--shadow-lg);
}
.role-card:hover::after { opacity: 1; }
.role-card:active { transform: translateY(-2px) scale(.99); }
.role-icon {
  width: 88px; height: 88px; color: var(--gold);
  position: relative; z-index: 1;
  transition: transform .3s var(--ease);
}
.role-card:hover .role-icon { transform: scale(1.08); }
.role-icon svg { width: 100%; height: 100%; }
.role-label { font-family: var(--f-serif); font-size: var(--fs-lg); position: relative; z-index: 1; }
.role-sub { font-size: var(--fs-base); color: var(--ink-mute); position: relative; z-index: 1; }

/* ═══ MESAS ═══ */
.mesa-legend {
  display: flex; align-items: center; gap: var(--sp-3);
  font-size: var(--fs-sm); color: var(--ink-soft); flex-wrap: wrap;
  margin-left: auto;
}
.mesa-legend .leg { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot-libre { background: var(--libre); }
.dot-abierta { background: var(--abierta); }
.dot-cobrar { background: var(--cobrar); }

.mesas-scroll { flex: 1; overflow: auto; padding: var(--sp-5); }
#floor-plan {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--sp-4);
  max-width: 1100px; margin: 0 auto;
}
.mesa-card {
  min-height: 128px;
  border-radius: var(--r);
  border: 2px solid var(--line);
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; position: relative; overflow: hidden;
  transition: border-color .22s, box-shadow .22s, transform .16s var(--ease);
  box-shadow: var(--shadow-sm);
}
.mesa-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.mesa-card:active { transform: translateY(-1px) scale(.99); }
.mesa-card .mesa-top-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 6px;
}
.mesa-nombre { font-family: var(--f-serif); font-size: var(--fs-lg); margin-top: 4px; }
.mesa-status {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: .25em .7em; border-radius: var(--r-pill);
}
.mesa-info { font-size: var(--fs-sm); color: var(--ink-mute); }

.mesa-card.libre .mesa-top-bar { background: var(--libre); }
.mesa-card.libre .mesa-status { background: var(--libre-bg); color: var(--libre); }
.mesa-card.libre:hover { border-color: var(--libre); }

.mesa-card.abierta .mesa-top-bar { background: var(--abierta); }
.mesa-card.abierta .mesa-status { background: var(--abierta-bg); color: var(--abierta); }
.mesa-card.abierta:hover { border-color: var(--abierta); }

.mesa-card.pendiente .mesa-top-bar { background: var(--info); }
.mesa-card.pendiente .mesa-status { background: var(--info-bg); color: var(--info); }
.mesa-card.pendiente { border-color: var(--info-bg); animation: pulsePend 2s ease-in-out infinite; }
.mesa-card.pendiente:hover { border-color: var(--info); animation: none; }
@keyframes pulsePend {
  0%,100% { box-shadow: var(--shadow-sm); }
  50% { box-shadow: 0 0 0 4px var(--info-bg), var(--shadow); }
}

.mesa-card.cobrar .mesa-top-bar { background: var(--cobrar); }
.mesa-card.cobrar .mesa-status { background: var(--cobrar-bg); color: var(--cobrar); }
.mesa-card.cobrar { border-color: var(--cobrar-soft); animation: pulseCobrar 2.2s ease-in-out infinite; }
.mesa-card.cobrar:hover { border-color: var(--cobrar); animation: none; }
@keyframes pulseCobrar {
  0%,100% { box-shadow: var(--shadow-sm); }
  50% { box-shadow: 0 0 0 4px var(--cobrar-bg), var(--shadow); }
}

/* ═══ COMANDA ═══ */
.comanda-layout {
  flex: 1; display: grid;
  grid-template-columns: clamp(150px, 18%, 220px) 1fr clamp(260px, 28%, 340px);
  min-height: 0; overflow: hidden;
}
.cat-nav {
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto; padding: var(--sp-2);
  display: flex; flex-direction: column; gap: 4px;
}
.cat-item {
  min-height: var(--touch);
  padding: var(--sp-3) var(--sp-3);
  font-size: var(--fs-base); font-weight: 600;
  color: var(--ink-soft);
  border: none; background: transparent;
  border-radius: var(--r-sm);
  text-align: left;
  display: flex; align-items: center; gap: var(--sp-2);
  transition: background .16s, color .16s;
  position: relative;
}
.cat-item .cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--ca, var(--malva)); }
.cat-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item:hover { background: var(--surface-2); color: var(--ink); }
.cat-item.active { background: var(--malva-soft); color: var(--malva-deep); font-weight: 700; }

.prod-area { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.prod-scroll {
  flex: 1; overflow-y: auto; padding: var(--sp-3);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-2); align-content: start;
}
.prod-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--ca, var(--malva));
  border-radius: var(--r-sm);
  padding: var(--sp-3) var(--sp-4);
  min-height: 82px;
  display: flex; flex-direction: row;
  align-items: center; justify-content: space-between;
  gap: var(--sp-3);
  text-align: left;
  transition: transform .12s var(--ease), box-shadow .15s;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.prod-card:hover { background: var(--surface-2); transform: translateX(2px); }
.prod-card:active { transform: scale(.98); }

/* Nombre: protagonista, 2 líneas máx + puntos suspensivos */
.prod-card-name {
  flex: 1; min-width: 0;
  font-size: var(--fs-base);
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Precio: pequeño, a la derecha, secundario */
.prod-card-price {
  flex-shrink: 0;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-mute);
  font-family: var(--f-sans);
}

.prod-card-dest { display: none; }
.prod-card .add-flash {
  position: absolute; inset: 0; border-radius: inherit;
  background: var(--gold); opacity: 0; pointer-events: none;
}
.prod-card.flash .add-flash { animation: flashAdd .4s var(--ease); }
@keyframes flashAdd { 0% { opacity: .3; } 100% { opacity: 0; } }

/* Sidebar de pedido */
.order-sidebar {
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-head {
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-head h3 { font-family: var(--f-serif); font-size: var(--fs-md); font-weight: 400; }
.order-items { flex: 1; overflow-y: auto; overflow-x: hidden; padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); }

/* Panel "Ya enviado" — pedidos consolidados de la mesa (readonly) */
.ya-pedido {
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  max-height: 40%;
  overflow-y: auto;
}
.ya-pedido-hdr {
  padding: var(--sp-2) var(--sp-3);
  display: flex; justify-content: space-between; align-items: center;
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: sticky; top: 0;
  background: var(--surface-2);
  border-bottom: 1px dashed var(--line);
}
.ya-pedido-total { color: var(--gold); font-family: var(--f-serif); font-weight: 700; font-size: var(--fs-base); text-transform: none; letter-spacing: 0; }
.ya-pedido-list { padding: var(--sp-2) var(--sp-3); display: flex; flex-direction: column; gap: 4px; }
.ya-pedido-det {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--sp-2);
  align-items: baseline;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  padding: 3px 0;
}
.ya-pedido-qty  { font-weight: 700; color: var(--gold); font-family: var(--f-serif); min-width: 26px; }
.ya-pedido-name { overflow-wrap: break-word; }
.ya-pedido-name em { font-style: italic; color: var(--ink-mute); font-size: .9em; }
.ya-pedido-price { color: var(--ink-mute); font-variant-numeric: tabular-nums; }
.order-empty {
  color: var(--ink-mute); font-size: var(--fs-base); text-align: center;
  padding: var(--sp-7) var(--sp-4);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
}
.order-empty svg { width: 48px; height: 48px; opacity: .4; }
.oi {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--sp-3);
  display: flex; align-items: flex-start; gap: var(--sp-2);
  min-width: 0;
  animation: slideIn .2s var(--ease);
}
@keyframes slideIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
.oi-qtybox { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.oi-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1.5px solid var(--line-2); background: var(--surface);
  font-size: var(--fs-md); line-height: 1; color: var(--ink);
  display: grid; place-items: center;
  transition: background .12s, border-color .12s, transform .1s;
}
.oi-btn:active { transform: scale(.9); }
.oi-btn.minus:hover { border-color: var(--cobrar); color: var(--cobrar); background: var(--cobrar-bg); }
.oi-btn.plus:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.oi-qty { font-size: var(--fs-md); font-weight: 700; color: var(--malva-deep); min-width: 26px; text-align: center; }
.oi { align-items: flex-start; }
.oi-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.oi-name {
  min-width: 0; overflow-wrap: anywhere; word-break: normal; hyphens: none;
  font-size: var(--fs-base); font-weight: 600; line-height: 1.25;
  cursor: text; border-radius: 4px;
  transition: color .15s;
}
.oi-name:hover { color: var(--malva-deep); text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.oi-price { font-size: var(--fs-sm); color: var(--gold); font-weight: 700; }
.oi-nota {
  width: 100%;
  border: none; background: transparent;
  padding: 1px 0;
  font-size: var(--fs-sm); font-style: italic;
  color: var(--gold); font-weight: 600;
  line-height: 1.35;
}
.oi-nota::placeholder { color: var(--ink-mute); font-weight: 400; }
.oi-nota:focus { outline: none; box-shadow: inset 0 -1.5px 0 var(--gold); }
.oi-nota.empty:not(:focus) { display: none; }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.total-row { display: flex; align-items: baseline; justify-content: space-between; }
.total-label { font-size: var(--fs-sm); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-mute); }
.total-amount { font-family: var(--f-serif); font-size: var(--fs-xl); color: var(--malva-deep); white-space: nowrap; }

/* ═══ DISPLAY COCINA / BARRA (KDS) ═══ */
.display-badge {
  margin-left: auto;
  font-size: var(--fs-sm); font-weight: 700;
  background: var(--malva); color: #fff;
  padding: .3em .9em; border-radius: var(--r-pill);
}
.display-badge.urgente { background: var(--cobrar); animation: pulseCobrar 1.6s infinite; }
.display-body { flex: 1; display: flex; overflow: hidden; }
.display-col { flex: 1; display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--line); }
.display-col:last-child { border-right: none; }
.display-col-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft);
}
.col-count { background: var(--surface-3); color: var(--ink-soft); font-weight: 700; padding: 2px 11px; border-radius: var(--r-pill); font-size: var(--fs-sm); }
.col-pendientes .col-count { background: var(--malva); color: #fff; }
.display-list { flex: 1; overflow-y: auto; padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); }
.display-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--sp-7); gap: var(--sp-3); color: var(--ink-mute); text-align: center; }
.display-empty svg { width: 64px; height: 64px; opacity: .3; }
.display-empty p { font-size: var(--fs-base); }

.kds-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--line-2);
  border-radius: var(--r);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  animation: cardIn .25s var(--ease);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.kds-card.warn { border-left-color: var(--abierta); }
.kds-card.urgente { border-left-color: var(--cobrar); }
.kds-card.listo { opacity: .6; border-left-color: var(--libre); }
.kds-head {
  background: var(--surface-2);
  padding: var(--sp-2) var(--sp-3);
  display: flex; align-items: center; gap: var(--sp-3);
  border-bottom: 1px solid var(--line);
}
.kds-mesa { font-family: var(--f-serif); font-size: var(--fs-base); flex: 1; font-weight: 600; }
.kds-time { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-mute); }
.kds-time.warn { color: var(--abierta); }
.kds-time.urgente { color: var(--cobrar); }
.kds-body { padding: var(--sp-2) var(--sp-3); display: flex; flex-direction: column; }
.kds-det {
  display: flex; align-items: baseline; gap: var(--sp-2);
  padding: 5px 0; border-bottom: 1px solid var(--line);
  font-size: var(--fs-base);
}
.kds-det:last-child { border-bottom: none; }
.kds-det-qty { font-weight: 800; color: var(--gold); font-family: var(--f-serif); flex-shrink: 0; min-width: 26px; }
.kds-det-name { flex: 1; min-width: 0; overflow-wrap: break-word; }
/* Ítems del otro destino: legibles pero secundarios (contexto para saber qué más lleva la mesa) */
.kds-det-other {
  opacity: 0.6;
  color: #7a6e70;
}
.kds-det-other .kds-det-qty { color: #7a6e70; font-weight: 600; }

/* Ítems compartidos (destino 'ambos'): legibles como normales, con badge de +cocina/+barra */
.kds-det-shared { }

/* Ítems propios PUROS (los que TÚ preparas): destacados con acento dorado */
.kds-det-pure {
  border-left: 3px solid var(--gold);
  background: rgba(255, 231, 170, 0.25);
  padding-left: 8px;
  padding-right: 6px;
  margin-left: -6px;
  margin-right: -6px;
  border-radius: 4px;
  font-weight: 600;
}
.kds-det-pure .kds-det-qty { font-size: 1.15em; }
.kds-det-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 0.72em;
  font-weight: 600;
  font-family: var(--f-sans, 'Inter', sans-serif);
  color: #6a5c5e;
  background: #ece4d8;
  border-radius: 10px;
  vertical-align: baseline;
  letter-spacing: 0.02em;
}
.kds-det-nota { font-size: var(--fs-xs); color: var(--abierta); font-style: italic; padding-left: 26px; margin-top: -2px; }
.kds-foot { padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--line); }
.btn-listo {
  width: 100%; min-height: 44px;
  background: var(--libre);
  border: none;
  color: #fff;
  border-radius: var(--r);
  font-size: var(--fs-sm); font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  transition: background .15s, transform .1s;
  box-shadow: 0 2px 8px -2px rgba(47,133,88,.35);
}
.btn-listo svg { width: 18px; height: 18px; }
.btn-listo:hover { background: #236b43; }
.btn-listo:active { transform: scale(.98); }

/* Tabs display (móvil) */
.display-tabs { display: none; }

/* ═══ COBRAR ═══ */
.cobrar-wrap { flex: 1; overflow-y: auto; padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); max-width: 640px; margin: 0 auto; width: 100%; }
.cobrar-items { display: flex; flex-direction: column; gap: var(--sp-2); }
.cobrar-det {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}
.cobrar-det-qty { background: var(--surface-3); color: var(--gold); font-weight: 800; min-width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.cobrar-det-name { flex: 1; min-width: 0; overflow-wrap: break-word; font-size: var(--fs-base); }
.cobrar-det-price { font-size: var(--fs-base); font-weight: 700; color: var(--gold); }
.cobrar-summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-5); box-shadow: var(--shadow); }
.cobrar-total-row { display: flex; align-items: baseline; justify-content: space-between; }
.cobrar-total-row > span:first-child { font-size: var(--fs-md); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-mute); font-weight: 600; }
.cobrar-total { font-family: var(--f-serif); font-size: var(--fs-2xl); color: var(--malva-deep); }
.btn-cerrar { background: var(--cobrar); box-shadow: 0 4px 16px -4px rgba(181,56,47,.5); }
.btn-cerrar:hover { background: #97302a; }

/* ═══ MODAL ═══ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(32,26,27,.5);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: var(--surface); border-radius: var(--r-lg);
  width: 100%; max-width: 460px;
  max-height: 90dvh; overflow-y: auto;
  padding: var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-4);
  box-shadow: var(--shadow-lg);
  animation: modalUp .25s var(--ease);
}
@keyframes modalUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-title { font-family: var(--f-serif); font-size: var(--fs-lg); }
.modal-actions {
  display: flex;
  gap: var(--sp-3);
  position: sticky;
  bottom: calc(var(--sp-5) * -1);
  background: var(--surface);
  padding-top: var(--sp-3);
  margin-top: auto;
  z-index: 5;
}
.btn-cancel { flex: 1; min-height: var(--touch); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r); color: var(--ink-soft); font-size: var(--fs-base); font-weight: 600; transition: background .15s; }
.btn-cancel:hover { background: var(--surface-3); }
.modal-actions .btn-primary { flex: 1.4; }

/* Ajustes: control de tamaño / tema */
.settings-group { display: flex; flex-direction: column; gap: var(--sp-2); }
.settings-label { font-size: var(--fs-sm); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-mute); }
.seg {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
}
.seg button {
  flex: 1; min-height: 48px; border: none; background: transparent;
  border-radius: 12px; font-size: var(--fs-base); font-weight: 600; color: var(--ink-soft);
  transition: background .15s, color .15s;
}
.seg button.active { background: var(--malva); color: #fff; box-shadow: var(--shadow-sm); }
.seg button.sz-n { font-size: 15px; }
.seg button.sz-g { font-size: 19px; }
.seg button.sz-e { font-size: 23px; }

/* ═══ TOAST ═══ */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--surface);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r); font-size: var(--fs-base); font-weight: 600;
  box-shadow: var(--shadow-lg); z-index: 999;
  opacity: 0; pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
  display: flex; align-items: center; gap: var(--sp-2);
  max-width: calc(100vw - 48px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast .t-ico { color: var(--gold-bright); }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — móvil vertical + tablet horizontal
   ═══════════════════════════════════════════════════════════════ */

/* ── Tablet/móvil apilado (≤ 820px = móvil vertical + tablet portrait) ── */
@media (max-width: 820px) {

  /* Roles: lista en lugar de grid */
  .roles-grid { grid-template-columns: 1fr; max-width: 460px; }
  .role-card {
    display: grid;
    grid-template-columns: 60px 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    text-align: left;
    padding: var(--sp-4) var(--sp-5);
    gap: var(--sp-1) var(--sp-3);
  }
  .role-icon { width: 56px; height: 56px; flex-shrink: 0; grid-row: 1/3; }
  .role-label { grid-column: 2; grid-row: 1; align-self: end; }
  .role-sub   { grid-column: 2; grid-row: 2; align-self: start; }

  /* Comanda: 3 filas apiladas con alturas fijas/porcentuales */
  .comanda-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 50px 1fr 36vh;
  }

  /* Nav de categorías: franja horizontal compacta */
  .cat-nav {
    height: 50px; padding: 0 var(--sp-2);
    flex-direction: row; overflow-x: auto; overflow-y: hidden;
    border-right: none; border-bottom: 1px solid var(--line);
    gap: var(--sp-2); align-items: center;
    scrollbar-width: none;
  }
  .cat-nav::-webkit-scrollbar { display: none; }
  .cat-item {
    flex-shrink: 0; white-space: nowrap;
    min-height: 38px; padding: 0 var(--sp-3);
    font-size: var(--fs-sm);
  }
  .cat-text { font-size: var(--fs-sm); }

  /* Área de productos: ocupa el espacio 1fr */
  .prod-area { min-height: 0; overflow: hidden; }
  .prod-scroll {
    padding: var(--sp-2); gap: var(--sp-2);
    grid-template-columns: repeat(auto-fill, minmax(clamp(110px, 42%, 150px), 1fr));
  }
  .prod-card {
    padding: var(--sp-3);
    min-height: 95px;
    gap: var(--sp-1);
  }
  .prod-card-name { font-size: var(--fs-sm); }

  /* Sidebar de pedido: franja fija en la parte inferior */
  .order-sidebar {
    border-left: none; border-top: 1px solid var(--line);
    max-height: none; min-height: 0;
    overflow: hidden;
  }
  .sidebar-head { padding: var(--sp-2) var(--sp-3); }
  .sidebar-head h3 { font-size: var(--fs-base); }
  .order-items { padding: var(--sp-2); gap: var(--sp-1); }
  .oi { padding: var(--sp-2); }
  .oi-btn { width: 34px; height: 34px; }
  .sidebar-foot { padding: var(--sp-2) var(--sp-3); }
  .total-row { margin-bottom: var(--sp-1); }
  .btn-primary { min-height: 44px; font-size: var(--fs-sm); }

  /* KDS: tabs + columna única */
  .display-tabs {
    display: flex; border-bottom: 1px solid var(--line);
    background: var(--surface-2); flex-shrink: 0;
  }
  .dtab {
    flex: 1; min-height: 48px; border: none; background: transparent;
    border-bottom: 3px solid transparent;
    font-size: var(--fs-base); font-weight: 700; color: var(--ink-mute);
    display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  }
  .dtab.active { color: var(--ink); border-bottom-color: var(--gold); }
  .dtab-badge { background: var(--malva); color: #fff; font-size: var(--fs-xs); font-weight: 800; padding: 1px 8px; border-radius: var(--r-pill); }
  .display-body { flex-direction: column; }
  .display-col { border-right: none; }
  .display-col.hidden-mobile { display: none; }

  /* Mesas */
  #floor-plan { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: var(--sp-3); }
}

/* ── Móvil pequeño (≤ 520px) ── */
@media (max-width: 520px) {
  :root { --hh: 56px; }
  html[data-size="grande"] { font-size: 16px; }
  html[data-size="enorme"] { font-size: 18px; }
  .account-btn .acc-name { display: none; }
  .header-brand .header-chip { display: none; }
  .mesa-legend { display: none; }
  .comanda-layout { grid-template-rows: 46px 1fr 34vh; }
  .cat-nav { height: 46px; }
  .prod-scroll { grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); padding: var(--sp-2); }
  .prod-card { min-height: 90px; }
  .prod-card-name { font-size: var(--fs-sm); }
  #floor-plan { grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); }
  .mesas-scroll { padding: var(--sp-2); }
}

/* ── Móvil muy pequeño (≤ 360px) ── */
@media (max-width: 360px) {
  .prod-card { min-height: 80px; }
  .mesas-scroll { padding: var(--sp-2); }
}

/* ── Teléfono horizontal: restaura 3 columnas ── */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --hh: 48px; }
  .comanda-layout {
    grid-template-columns: clamp(120px, 16vw, 160px) 1fr clamp(200px, 25vw, 260px);
    grid-template-rows: 1fr;
  }
  .cat-nav {
    height: auto; flex-direction: column;
    overflow-y: auto; overflow-x: hidden;
    border-right: 1px solid var(--line); border-bottom: none;
    padding: var(--sp-2);
  }
  .cat-item { flex-shrink: 1; white-space: normal; min-height: 40px; }
  .order-sidebar {
    border-top: none; border-left: 1px solid var(--line);
    max-height: none; min-height: 0;
  }
  .display-tabs { display: none; }
  .display-body { flex-direction: row; }
  .display-col { border-right: 1px solid var(--line); display: flex; }
  .display-col.hidden-mobile { display: flex; }
  .roles-grid { grid-template-columns: repeat(3, 1fr); max-width: none; }
  .role-card { padding: var(--sp-3); gap: var(--sp-3); display: flex; flex-direction: column; text-align: center; }
  .role-icon { width: 44px; height: 44px; }
}

/* ═══════════════════════════════════════════════════════════════
   SUBFAMILIAS Y PICKER DE VARIANTES
   ═══════════════════════════════════════════════════════════════ */

/* Cabecera de subfamilia — ocupa toda la fila del grid */
.prod-subfamily-hdr {
  grid-column: 1 / -1;
  font-family: var(--f-serif);
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--ink-soft);
  padding: var(--sp-4) var(--sp-2) var(--sp-1);
  border-bottom: 2px solid var(--line-2);
  letter-spacing: .01em;
}

/* Indicador de variantes en tarjeta */
.prod-variants-hint {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: auto;
}
.prod-card.has-variants { border-style: dashed; }

/* Subtítulo del picker */
.picker-sub {
  font-size: var(--fs-sm);
  color: var(--ink-mute);
  margin-top: calc(var(--sp-2) * -1);
}

/* Rejilla de variantes */
.variant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--sp-2);
}

/* Botón de variante */
.variant-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  text-align: left;
  transition: background .14s, border-color .14s, transform .1s;
  min-height: 52px;
}
.variant-btn:hover  { background: var(--surface-3); border-color: var(--gold); transform: translateY(-2px); }
.variant-btn:active { transform: scale(.97); }
.variant-btn.selected {
  background: var(--gold-soft);
  border-color: var(--gold);
  border-width: 2px;
}
.var-check {
  font-size: 11px; font-weight: 900; color: var(--gold);
  opacity: 0; transition: opacity .15s;
  align-self: flex-end;
  margin-top: auto;
}
.variant-btn.selected .var-check { opacity: 1; }
.var-name  { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); line-height: 1.2; }
.var-price { font-size: var(--fs-base); font-weight: 700; color: var(--gold); font-family: var(--f-serif); }
.variant-btn.selected .var-name  { color: var(--malva-deep); font-weight: 700; }

/* Etiqueta del bloque "Opciones" en el combo café */
.cafe-opts-title {
  font-size: var(--fs-sm);
  color: var(--ink-mute);
  font-weight: 600;
  margin: var(--sp-3) 0 var(--sp-2);
}
/* Botón deshabilitado (cuando se elige "Sin café" las opciones se apagan) */
.variant-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* Picker modal: ancho para que quepan las 3 secciones del combo café */
.modal-card:has(.variant-grid) { max-width: 780px; }
@media (max-width: 600px) {
  .variant-grid { grid-template-columns: repeat(2, 1fr); max-height: 44dvh; }
  .variant-btn { min-height: 56px; padding: var(--sp-2) var(--sp-2); }
  .var-name  { font-size: .85rem; }
  .var-price { font-size: .9rem; }
}
