/* ============================================================
   Sistema de Restaurante — CSS Principal
   Diseño profesional, responsivo, sin frameworks
   Paleta: neutros cálidos + acento terracota + dorado
   ============================================================ */

/* Tipografía de títulos (igual que el login) */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@600;700;800&family=Inter:wght@400;500;600;700&display=swap');

/* --- Variables de diseño --- */
:root {
  
  /* Tipografía */
  --font-display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* Colores base */
  --c-bg:          #fffaf5;
  --c-surface:     #ffffff;
  --c-surface-2:   #faf4ee;
  --c-border:      #efe6dc;
  --c-border-dark: #e0d5c8;

  /* Texto */
  --c-text-primary:   #1f1b18;
  --c-text-secondary: #57504a;
  --c-text-muted:     #8d857d;
  --c-text-inverse:   #faf9f7;

  /* Marca — terracota + dorado */
  --c-primary:       #c85a2e;
  --c-primary-dark:  #a84520;
  --c-primary-light: #f0a07c;
  --c-primary-bg:    #fdf0ea;
  --c-accent:        #d4a017;
  --c-accent-dark:   #b08010;

  /* Estados */
  --c-success:    #2e7d52;
  --c-success-bg: #e8f5ee;
  --c-warning:    #c47f00;
  --c-warning-bg: #fff8e1;
  --c-danger:     #c62828;
  --c-danger-bg:  #fdecea;
  --c-info:       #1565c0;
  --c-info-bg:    #e8f0fd;

  /* Estados de mesa */
  --c-libre:      #2e7d52;
  --c-ocupada:    #c85a2e;
  --c-reservada:  #1565c0;
  --c-manten:     #9c9690;

  /* Estados de pedido / comanda */
  --c-pendiente:      #c47f00;
  --c-en-cocina:      #1565c0;
  --c-listo:          #2e7d52;
  --c-entregado:      #5a5550;

  /* Espaciado */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 40px;

  /* Layout */
  --sidebar-w:    252px;
  --topbar-h:     64px;
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    18px;
  --radius-full:  999px;

  /* Sombras */
  --shadow-sm:  0 1px 2px rgba(90,50,20,.04), 0 4px 14px -6px rgba(90,50,20,.10);
  --shadow-md:  0 10px 30px -12px rgba(90,50,20,.22);
  --shadow-lg:  0 30px 60px -28px rgba(90,50,20,.35);

  /* Transiciones */
  --transition: 160ms ease;
}

/* ============================================================
   RESET Y BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-body);
  background: var(--c-bg);
  color: var(--c-text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

img { display: block; max-width: 100%; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-dark); }

/* ============================================================
   TIPOGRAFÍA
   ============================================================ */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--c-text-primary);
}
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h2 { font-size: clamp(1.2rem, 2.5vw, 1.6rem); }
h3 { font-size: 1.1rem; }
p  { margin-bottom: var(--sp-md); }
small { font-size: .8rem; color: var(--c-text-muted); }

/* ============================================================
   LAYOUT PRINCIPAL (sidebar + main)
   ============================================================ */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  grid-row: 1 / -1;
  background: var(--c-text-primary);
  color: var(--c-text-inverse);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: var(--sp-lg) var(--sp-md);
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}
.sidebar-brand .brand-icon {
  width: 36px; height: 36px;
  background: var(--c-primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.sidebar-brand .brand-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}
.sidebar-brand .brand-sub {
  font-size: .7rem;
  opacity: .5;
}

.sidebar-nav { flex: 1; padding: var(--sp-sm) 0; }
.nav-section-title {
  padding: var(--sp-md) var(--sp-md) var(--sp-xs);
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .4;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 10px var(--sp-md);
  color: rgba(255,255,255,.65);
  font-size: .875rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.9);
}
.nav-item.active {
  background: rgba(200,90,46,.18);
  color: var(--c-primary-light);
  border-left-color: var(--c-primary);
}
.nav-item .nav-icon { width: 18px; font-size: 1rem; text-align: center; opacity: .8; }
.nav-badge {
  margin-left: auto;
  background: var(--c-primary);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

/* Topbar */
.topbar {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-lg);
  gap: var(--sp-md);
  height: var(--topbar-h);
  box-shadow: var(--shadow-sm);
}
.topbar-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-sm); }
.topbar-user {
  display: flex; align-items: center; gap: var(--sp-sm);
  font-size: .85rem; color: var(--c-text-secondary);
}
.avatar {
  width: 32px; height: 32px;
  background: var(--c-primary-bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .75rem;
  color: var(--c-primary);
}

/* Main content */
.main-content {
  padding: var(--sp-lg);
  overflow-y: auto;
  background: var(--c-bg);
}

/* ============================================================
   COMPONENTES — CARDS
   ============================================================ */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-md);
  padding-bottom: var(--sp-md);
  border-bottom: 1px solid var(--c-border);
}
.card-title { font-family: var(--font-display); font-size: 1rem; font-weight: 600; }

/* ============================================================
   COMPONENTES — BOTONES
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-xs);
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--transition);
  font-family: var(--font-body);
  line-height: 1;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

.btn-primary   { background: var(--c-primary);  color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); }

.btn-secondary { background: var(--c-surface); color: var(--c-text-primary); border-color: var(--c-border-dark); }
.btn-secondary:hover { background: var(--c-surface-2); }

.btn-success   { background: var(--c-success); color: #fff; }
.btn-success:hover { filter: brightness(.9); }

.btn-danger    { background: var(--c-danger);  color: #fff; }
.btn-danger:hover { filter: brightness(.9); }

.btn-ghost     { background: transparent; color: var(--c-text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--c-surface-2); }

.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ============================================================
   COMPONENTES — BADGES / ESTADO
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.badge-libre     { background: var(--c-success-bg); color: var(--c-success); }
.badge-ocupada   { background: var(--c-primary-bg); color: var(--c-primary); }
.badge-reservada { background: var(--c-info-bg);    color: var(--c-info); }
.badge-manten    { background: var(--c-surface-2);  color: var(--c-text-muted); }
.badge-pendiente { background: var(--c-warning-bg); color: var(--c-warning); }
.badge-en-cocina { background: var(--c-info-bg);    color: var(--c-info); }
.badge-listo     { background: var(--c-success-bg); color: var(--c-success); }
.badge-cerrado   { background: var(--c-surface-2);  color: var(--c-text-muted); }

/* ============================================================
   COMPONENTES — FORMULARIOS
   ============================================================ */
.form-group    { margin-bottom: var(--sp-md); }
.form-label    { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 6px; color: var(--c-text-secondary); }
.form-control  {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--c-border-dark);
  border-radius: var(--radius-md);
  font-size: .9rem; font-family: var(--font-body);
  background: var(--c-surface); color: var(--c-text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(200,90,46,.12); }
.form-control::placeholder { color: var(--c-text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ============================================================
   MÓDULO — MAPA DE MESAS
   ============================================================ */
.mesas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--sp-md);
}
.mesa-card {
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-md);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.mesa-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.mesa-card.libre     { border-color: var(--c-libre); }
.mesa-card.ocupada   { border-color: var(--c-ocupada); background: var(--c-primary-bg); }
.mesa-card.reservada { border-color: var(--c-reservada); background: var(--c-info-bg); }
.mesa-card .mesa-num { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; }
.mesa-card .mesa-cap { font-size: .75rem; color: var(--c-text-muted); margin-top: 2px; }
.mesa-card .mesa-salon { font-size: .7rem; color: var(--c-text-muted); }

/* ============================================================
   MÓDULO — KDS COCINA
   ============================================================ */
.kds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-md);
}
.kds-card {
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.kds-card-header {
  padding: 10px var(--sp-md);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700;
}
.kds-card-header.urgente { background: var(--c-danger-bg); color: var(--c-danger); }
.kds-card-header.normal  { background: var(--c-primary-bg); color: var(--c-primary); }
.kds-card-header.listo   { background: var(--c-success-bg); color: var(--c-success); }
.kds-timer { font-size: .8rem; font-weight: 600; font-family: var(--font-mono); }

.kds-items { padding: var(--sp-sm) var(--sp-md); }
.kds-item {
  display: flex; align-items: center; gap: var(--sp-sm);
  padding: 6px 0;
  border-bottom: 1px solid var(--c-border);
  font-size: .875rem;
}
.kds-item:last-child { border-bottom: none; }
.kds-item .kds-qty {
  width: 28px; height: 28px;
  background: var(--c-primary); color: #fff;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.kds-item .kds-nota { font-size: .75rem; color: var(--c-text-muted); display: block; }
.kds-item.listo .kds-qty { background: var(--c-success); }
.kds-item.listo .kds-nombre { text-decoration: line-through; color: var(--c-text-muted); }

.kds-actions { padding: var(--sp-sm) var(--sp-md); border-top: 1px solid var(--c-border); }

/* ============================================================
   MÓDULO — CARTA PÚBLICA (CLIENTES)
   ============================================================ */
.carta-layout {
  max-width: 860px;
  margin: 0 auto;
  padding: var(--sp-md);
}
.carta-header {
  text-align: center;
  padding: var(--sp-xl) var(--sp-md) var(--sp-lg);
}
.carta-logo { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; margin: 0 auto var(--sp-md); }
.carta-empresa { font-family: var(--font-display); font-size: 2rem; font-weight: 700; }
.carta-mesa-info { color: var(--c-text-muted); font-size: .9rem; }

.carta-categorias {
  display: flex; gap: var(--sp-sm); overflow-x: auto;
  padding: var(--sp-md) 0;
  scrollbar-width: none;
}
.carta-categorias::-webkit-scrollbar { display: none; }
.cat-tab {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: .85rem; font-weight: 600;
  border: 1.5px solid var(--c-border-dark);
  background: var(--c-surface);
  color: var(--c-text-secondary);
  cursor: pointer; white-space: nowrap;
  transition: all var(--transition);
}
.cat-tab.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }

.productos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-md);
  padding: var(--sp-md) 0;
}
.producto-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
}
.producto-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--c-primary); }
.producto-card .prod-img {
  width: 100%; height: 160px;
  object-fit: cover;
  background: var(--c-surface-2);
}
.producto-card .prod-img-placeholder {
  width: 100%; height: 160px;
  background: linear-gradient(135deg, var(--c-surface-2) 0%, var(--c-border) 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; color: var(--c-border-dark);
}
.producto-card .prod-body { padding: var(--sp-md); }
.producto-card .prod-nombre { font-weight: 700; font-size: .95rem; margin-bottom: 4px; }
.producto-card .prod-desc { font-size: .8rem; color: var(--c-text-muted); margin-bottom: var(--sp-sm); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.producto-card .prod-footer { display: flex; align-items: center; justify-content: space-between; }
.producto-card .prod-precio { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; color: var(--c-primary); }
.destacado-badge {
  position: absolute; top: var(--sp-sm); right: var(--sp-sm);
  background: var(--c-accent); color: #fff;
  font-size: .65rem; font-weight: 700; padding: 3px 8px;
  border-radius: var(--radius-full); text-transform: uppercase;
}

/* ============================================================
   CHAT IA — Flotante en la carta
   ============================================================ */
.ia-fab {
  position: fixed; bottom: var(--sp-lg); right: var(--sp-lg);
  width: 54px; height: 54px;
  background: var(--c-text-primary); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  cursor: pointer; z-index: 1000;
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition), background var(--transition);
}
.ia-fab:hover { transform: scale(1.08); background: var(--c-primary); }

.ia-chat {
  position: fixed; bottom: 84px; right: var(--sp-lg);
  width: min(380px, calc(100vw - 2 * var(--sp-lg)));
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  max-height: 520px;
  z-index: 999;
  overflow: hidden;
  transform: translateY(10px) scale(.97);
  opacity: 0; pointer-events: none;
  transition: all 200ms ease;
}
.ia-chat.open { transform: translateY(0) scale(1); opacity: 1; pointer-events: all; }

.ia-chat-header {
  padding: var(--sp-md);
  background: var(--c-text-primary);
  color: var(--c-text-inverse);
  display: flex; align-items: center; gap: var(--sp-sm);
  font-weight: 600; font-size: .9rem;
}
.ia-chat-header .ia-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80; animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.ia-chat-messages {
  flex: 1; overflow-y: auto; padding: var(--sp-md);
  display: flex; flex-direction: column; gap: var(--sp-sm);
}
.ia-msg { padding: 8px 12px; border-radius: var(--radius-md); font-size: .85rem; max-width: 85%; }
.ia-msg.user { background: var(--c-primary); color: #fff; align-self: flex-end; border-radius: var(--radius-md) var(--radius-md) 4px var(--radius-md); }
.ia-msg.bot  { background: var(--c-surface-2); color: var(--c-text-primary); align-self: flex-start; border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 4px; }
.ia-msg.loading { opacity: .6; font-style: italic; }

.ia-chat-input {
  display: flex; gap: var(--sp-xs); padding: var(--sp-sm);
  border-top: 1px solid var(--c-border);
}
.ia-input { flex: 1; padding: 8px 12px; border: 1.5px solid var(--c-border-dark); border-radius: var(--radius-full); font-size: .85rem; background: var(--c-bg); }
.ia-input:focus { outline: none; border-color: var(--c-primary); }
.ia-send { background: var(--c-primary); color: #fff; border: none; border-radius: 50%; width: 36px; height: 36px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background var(--transition); }
.ia-send:hover { background: var(--c-primary-dark); }

/* Pedido flotante (carrito) */
.carrito-panel {
  position: sticky;
  bottom: 88px;
  margin: var(--sp-md) 0 0;
  width: 100%;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 20px;
  box-shadow: 0 16px 44px rgba(18,28,45,.16);
  z-index: 30;
  display: none;
  overflow: hidden;
}
.carrito-panel.visible {
  display: block;
}
.carrito-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
  padding: var(--sp-md) var(--sp-lg);
  background: linear-gradient(135deg, rgba(202,106,73,.1) 0%, rgba(255,255,255,1) 100%);
  border-bottom: 1px solid var(--c-border);
}
.carrito-panel-title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; }
.carrito-panel-sub { font-size: .8rem; color: var(--c-text-muted); margin-top: 2px; }
.carrito-toggle {
  border: none;
  background: var(--c-text-primary);
  color: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
}
.carrito-detalle {
  display: none;
}
.carrito-detalle.open { display: block; }
.carrito-vacio {
  padding: var(--sp-md) var(--sp-lg) var(--sp-lg);
  color: var(--c-text-muted);
  font-size: .9rem;
}
.carrito-items {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  max-height: 340px;
  overflow-y: auto;
  padding: var(--sp-md) var(--sp-lg);
}
.carrito-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--c-border);
}
.carrito-item:last-child { border-bottom: none; }
.carrito-item-img {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--c-surface-2);
}
.carrito-item-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--c-text-muted);
}
.carrito-item-main { flex: 1; min-width: 0; }
.carrito-item-top,
.carrito-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.carrito-item-top {
  align-items: flex-start;
}
.carrito-item-top span {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--c-primary);
}
.carrito-item-top strong {
  font-size: .92rem;
  line-height: 1.3;
  flex: 1;
  white-space: normal;
  overflow: visible;
  text-overflow: initial;
}
.carrito-item-bottom {
  margin-top: 8px;
  color: var(--c-text-muted);
  font-size: .8rem;
}
.carrito-qty {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--c-surface-2);
  border-radius: 999px;
  padding: 4px 8px;
}
.carrito-qty button {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: var(--c-primary);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.carrito-totales {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
  padding: var(--sp-md) var(--sp-lg) var(--sp-lg);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-2);
}
.carrito-totales div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .8rem;
  color: var(--c-text-muted);
}
.carrito-totales strong {
  color: var(--c-text-primary);
  font-size: 1rem;
}
.carrito-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--c-text-primary);
  color: var(--c-text-inverse);
  padding: var(--sp-md) var(--sp-lg);
  display: flex; align-items: center; justify-content: space-between;
  transform: translateY(100%); transition: transform 300ms ease;
  z-index: 998;
}
.carrito-bar.visible { transform: translateY(0); }
.carrito-info { display: flex; align-items: center; gap: var(--sp-sm); }
.carrito-count { background: var(--c-primary); width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; }

/* ============================================================
   MÉTRICAS / DASHBOARD
   ============================================================ */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--sp-md);
  margin-bottom: var(--sp-lg);
}
.metric-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-md);
  display: flex; flex-direction: column; gap: 6px;
}
.metric-label { font-size: .75rem; font-weight: 600; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.metric-value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; }
.metric-sub   { font-size: .75rem; color: var(--c-text-muted); }
.metric-up    { color: var(--c-success); }
.metric-down  { color: var(--c-danger); }

/* ============================================================
   TABLAS
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th { text-align: left; padding: 10px var(--sp-md); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-muted); border-bottom: 1.5px solid var(--c-border); }
tbody td { padding: 12px var(--sp-md); border-bottom: 1px solid var(--c-border); vertical-align: middle; }
tbody tr:hover { background: var(--c-surface-2); }
tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   LOGIN / REGISTRO EMPRESA
   ============================================================ */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--c-surface-2); padding: var(--sp-md); }
.auth-card { background: var(--c-surface); border-radius: var(--radius-lg); padding: var(--sp-xl); width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.auth-logo { text-align: center; margin-bottom: var(--sp-lg); }
.auth-logo .logo-icon { font-size: 2.5rem; margin-bottom: var(--sp-sm); }
.auth-logo h1 { font-size: 1.4rem; }
.auth-logo p { font-size: .85rem; color: var(--c-text-muted); }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
  }
  .sidebar { display: none; }
  .sidebar.open {
    display: flex;
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
    z-index: 2000;
  }
  .main-content { padding: var(--sp-md); }
  .mesas-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .kds-grid   { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .carrito-panel {
    bottom: 78px;
    border-radius: 16px;
  }
  .carrito-panel-header,
  .carrito-totales,
  .carrito-items,
  .carrito-vacio { padding-left: var(--sp-md); padding-right: var(--sp-md); }
  .carrito-totales {
    flex-direction: column;
    align-items: flex-start;
  }
  .carrito-bar { padding: var(--sp-sm) var(--sp-md); }
}

@media (max-width: 480px) {
  .productos-grid { grid-template-columns: 1fr; }
  .metrics-grid   { grid-template-columns: 1fr 1fr; }
  .ia-chat { right: var(--sp-sm); left: var(--sp-sm); width: auto; }
  .carrito-bar {
    gap: 10px;
    align-items: flex-start;
    flex-direction: column;
  }
  .carrito-bar > div:last-child {
    width: 100%;
    justify-content: space-between;
  }
  .carrito-item {
    align-items: flex-start;
  }
  .carrito-item-bottom {
    align-items: flex-start;
    flex-direction: column;
  }
  .carrito-panel-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .carrito-toggle {
    width: 100%;
  }
}

/* ============================================================
   UTILIDADES
   ============================================================ */
.flex    { display: flex; }
.flex-col{ flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm  { gap: var(--sp-sm); }
.gap-md  { gap: var(--sp-md); }
.mt-sm   { margin-top: var(--sp-sm); }
.mt-md   { margin-top: var(--sp-md); }
.mt-lg   { margin-top: var(--sp-lg); }
.mb-md   { margin-bottom: var(--sp-md); }
.text-muted   { color: var(--c-text-muted); }
.text-center  { text-align: center; }
.text-sm      { font-size: .85rem; }
.font-bold    { font-weight: 700; }
.hidden       { display: none !important; }
.w-full       { width: 100%; }
.divider { border: none; border-top: 1px solid var(--c-border); margin: var(--sp-md) 0; }


.mesa-card.hide {
  display: none !important;
}


/* ============================================================
   TEMA VISUAL 2026 — alineado con la pantalla de acceso
   Fondo claro y cálido, terracota como color principal.
   ============================================================ */
h1, h2, h3, h4 { letter-spacing: -.02em; font-weight: 800; }

/* Sidebar (fondo café espresso, alto contraste) */
.sidebar {
  background:
    radial-gradient(420px 260px at 0% 0%, rgba(224,120,74,.22), transparent 70%),
    linear-gradient(180deg, #2b1b14 0%, #1f140f 100%);
  color: #fff;
  border-right: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand { border-bottom: 1px solid rgba(255,255,255,.08); padding: 20px 16px; gap: 12px; }
.sidebar-brand .brand-icon {
  width: 42px; height: 42px; border-radius: 12px; flex: none; color: #fff;
  background: linear-gradient(140deg, #e8875a, var(--c-primary) 60%, #a84520);
  box-shadow: 0 8px 18px -8px rgba(224,120,74,.8);
}
.sidebar-brand .brand-name { font-size: 1rem; font-weight: 800; letter-spacing: -.01em; color: #fff; }
.sidebar-brand .brand-sub { opacity: 1; color: #d9c7ba; font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.nav-section-title { opacity: 1; color: #d9c7ba; }
.nav-item { color: #f1e6de; font-weight: 500; border-left: 0; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active {
  background: linear-gradient(135deg, #e07a48 0%, #c85a2e 60%, #a84520 100%);
  color: #fff; font-weight: 600;
  box-shadow: 0 8px 18px -10px rgba(224,120,74,.9);
}
.nav-item .nav-icon { opacity: 1; color: #f0b48f; }
.nav-item.active .nav-icon { color: #fff; }

/* Topbar */
.topbar {
  background: var(--c-topbar, rgba(255,255,255,.85));
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  box-shadow: none; position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1.2rem; font-weight: 800; letter-spacing: -.02em; }
.avatar { width: 36px; height: 36px; background: linear-gradient(140deg, #e07a48, var(--c-primary)); color: #fff; box-shadow: 0 6px 14px -8px rgba(200,90,46,.8); }

/* Contenido */
.main-content {
  padding: 28px;
  background:
    radial-gradient(900px 420px at 100% 0%, rgba(226,167,46,.07), transparent 60%),
    var(--c-bg);
}

/* Cards */
.card { border-color: var(--c-border); box-shadow: var(--shadow-sm); }
.card-header { border-bottom-color: var(--c-border); }
.card-title { font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em; }

/* Métricas */
.metric-card {
  position: relative; overflow: hidden; padding: 20px; gap: 8px;
  border-color: var(--c-border); box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}
.metric-card::before {
  content: ''; position: absolute; left: 0; top: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--c-primary), #e2a72e);
}
.metric-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.metric-value { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; }

/* Botones */
.btn { border-radius: 12px; padding: 10px 18px; }
.btn-primary {
  background: linear-gradient(135deg, #d8683a 0%, var(--c-primary) 50%, var(--c-primary-dark) 100%);
  box-shadow: 0 10px 20px -12px rgba(200,90,46,.8), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-primary:hover { background: linear-gradient(135deg, #d8683a 0%, var(--c-primary) 50%, var(--c-primary-dark) 100%); filter: brightness(1.05); color: #fff; transform: translateY(-1px); }
.btn-secondary { background: var(--c-surface); border-color: var(--c-border-dark); }
.btn-secondary:hover { background: var(--c-surface-2); border-color: var(--c-primary-light); }
.btn-sm { padding: 6px 12px; border-radius: 10px; }
.btn-lg { padding: 13px 28px; }

/* Formularios */
.form-label { color: var(--c-label, #3b3530); font-size: .82rem; }
.form-control {
  border-radius: 12px; padding: 11px 14px; background: var(--c-input, #fcfaf8); border-color: var(--c-border-dark);
}
.form-control:hover { border-color: #d6c9ba; }
.form-control:focus { background: var(--c-surface); border-color: var(--c-primary); box-shadow: 0 0 0 4px rgba(200,90,46,.13); }

/* Tablas */
thead th { background: var(--c-surface-2); border-bottom: 1px solid var(--c-border); }
thead th:first-child { border-radius: 10px 0 0 10px; }
thead th:last-child { border-radius: 0 10px 10px 0; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--c-row-hover, #fff6ee); }

/* Mesas */
.mesa-card { border-radius: 16px; transition: transform var(--transition), box-shadow var(--transition); }
.mesa-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.mesa-card .mesa-num { font-weight: 800; letter-spacing: -.02em; }

/* Badges */
.badge { letter-spacing: .03em; font-weight: 700; }

@media (max-width: 768px) {
  .main-content { padding: var(--sp-md); }
  .sidebar.open { box-shadow: 0 0 0 100vmax rgba(31,27,24,.35); }
  .metric-card { padding: 16px; }
  .metric-value { font-size: 1.45rem; }
  .card { padding: var(--sp-md); }
  .dash-2col { grid-template-columns: 1fr !important; }
}


/* ============================================================
   MODO OSCURO — se activa con <html data-theme="dark">
   ============================================================ */
.theme-toggle {
  width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; cursor: pointer;
  border: 1px solid var(--c-border-dark); background: var(--c-surface); color: var(--c-text-secondary);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.theme-toggle:hover { color: var(--c-primary); border-color: var(--c-primary-light); }
.theme-toggle .ic-sol { display: none; }
html[data-theme="dark"] .theme-toggle .ic-luna { display: none; }
html[data-theme="dark"] .theme-toggle .ic-sol { display: block; }

html[data-theme="dark"] {
  color-scheme: dark;
  --c-bg:          #14100e;
  --c-surface:     #1e1815;
  --c-surface-2:   #28201b;
  --c-border:      #362c25;
  --c-border-dark: #4a3d33;
  --c-text-primary:   #f6efe9;
  --c-text-secondary: #d3c6bb;
  --c-text-muted:     #a3968b;
  --c-text-inverse:   #1f1b18;
  --c-primary:       #e8804f;
  --c-primary-dark:  #c85a2e;
  --c-primary-light: #f4a985;
  --c-primary-bg:    rgba(232,128,79,.16);
  --c-accent:        #e9b23c;
  --c-success:    #5ccf8f;  --c-success-bg: rgba(92,207,143,.14);
  --c-warning:    #eeb54a;  --c-warning-bg: rgba(238,181,74,.14);
  --c-danger:     #f27468;  --c-danger-bg:  rgba(242,116,104,.15);
  --c-info:       #78b0f5;  --c-info-bg:    rgba(120,176,245,.15);
  --c-libre: #5ccf8f; --c-ocupada: #e8804f; --c-reservada: #78b0f5; --c-manten: #a3968b;
  --c-pendiente: #eeb54a; --c-en-cocina: #78b0f5; --c-listo: #5ccf8f; --c-entregado: #a3968b;
  --c-topbar: rgba(24,19,17,.85);
  --c-input: #1a1512;
  --c-row-hover: rgba(232,128,79,.07);
  --c-label: #e2d6cc;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px -8px rgba(0,0,0,.5);
  --shadow-md: 0 14px 34px -14px rgba(0,0,0,.7);
  --shadow-lg: 0 30px 60px -24px rgba(0,0,0,.8);
}
html[data-theme="dark"] .main-content {
  background: radial-gradient(900px 420px at 100% 0%, rgba(232,128,79,.08), transparent 60%), var(--c-bg);
}
html[data-theme="dark"] .sidebar { background: radial-gradient(420px 260px at 0% 0%, rgba(232,128,79,.18), transparent 70%), linear-gradient(180deg, #1c1310 0%, #120c0a 100%); }
html[data-theme="dark"] .card,
html[data-theme="dark"] .metric-card { background: var(--c-surface); }
html[data-theme="dark"] .form-control:hover { border-color: #5b4b3f; }
html[data-theme="dark"] .form-control::placeholder { color: #85786e; }
/* Fondos blancos fijos dentro de los módulos */
html[data-theme="dark"] .main-content [style*="background:#fff"],
html[data-theme="dark"] .main-content [style*="background: #fff"],
html[data-theme="dark"] .main-content [style*="background:white"] { background: var(--c-surface) !important; }
html[data-theme="dark"] .swal2-popup { background: var(--c-surface); color: var(--c-text-primary); }

/* Modo oscuro: paneles con fondo claro fijo en Tienda, Pedidos, Compras y Productos */
html[data-theme="dark"] .pos-hero {
  background: radial-gradient(600px 300px at 100% 0%, rgba(232,128,79,.2), transparent 65%), linear-gradient(135deg, #261d18 0%, #1c1613 100%) !important;
  border-color: var(--c-border) !important;
}
html[data-theme="dark"] .pos-title { color: var(--c-text-primary); }
html[data-theme="dark"] .pos-eyebrow,
html[data-theme="dark"] .pos-meta-pill,
html[data-theme="dark"] .pos-cat-count { background: rgba(255,255,255,.06); border-color: var(--c-border); color: var(--c-text-secondary); }
html[data-theme="dark"] .pos-cat,
html[data-theme="dark"] .pos-card,
html[data-theme="dark"] .pos-cart-card,
html[data-theme="dark"] .pos-empty,
html[data-theme="dark"] .pedido-card,
html[data-theme="dark"] .pedido-cart-card,
html[data-theme="dark"] .pedido-cart-header,
html[data-theme="dark"] .pedido-cart-close,
html[data-theme="dark"] .compra-item-row,
html[data-theme="dark"] .prod-panel-box { background: var(--c-surface); border-color: var(--c-border); color: var(--c-text-primary); }
html[data-theme="dark"] .pos-cat { color: var(--c-text-secondary); }
html[data-theme="dark"] .pos-card-name { color: var(--c-text-primary); }
html[data-theme="dark"] .pos-card-media { background: var(--c-surface-2); }
html[data-theme="dark"] .pos-guard { background: var(--c-warning-bg); border-color: rgba(238,181,74,.25); }
html[data-theme="dark"] .pos-item,
html[data-theme="dark"] .pedido-item { background: var(--c-surface-2); border-color: var(--c-border); }
html[data-theme="dark"] .pos-totals,
html[data-theme="dark"] .pedido-totals { background: var(--c-surface-2); border-color: var(--c-border); }
html[data-theme="dark"] .pos-totals *,
html[data-theme="dark"] .pedido-totals * { color: inherit; }
html[data-theme="dark"] .pos-qty button,
html[data-theme="dark"] .pedido-qty button,
html[data-theme="dark"] .pos-search input,
html[data-theme="dark"] .pedido-search input,
html[data-theme="dark"] .select2-container--default .select2-selection--single { background: var(--c-input); color: var(--c-text-primary); border-color: var(--c-border-dark); }
html[data-theme="dark"] .select2-dropdown { background: var(--c-surface); color: var(--c-text-primary); border-color: var(--c-border-dark); }
html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--c-text-primary); }
