:root {
  --primary: #173f35;
  --primary-2: #225f50;
  --accent: #efb366;
  --bg: #f5f6f2;
  --surface: #ffffff;
  --text: #17201d;
  --muted: #68736e;
  --danger: #b43d3d;
  --success: #217a55;
  --warning: #c4771b;
  --border: #dde3df;
  --shadow: 0 14px 40px rgba(16, 42, 35, .10);
  --radius: 20px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

.btn { border: 0; border-radius: 13px; padding: 12px 17px; font-weight: 750; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: .2s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(23,63,53,.18); }
.btn-accent { background: var(--accent); color: #2d2419; }
.btn-light { background: #eef2ef; color: var(--primary); }
.btn-danger { background: #fee9e9; color: var(--danger); }
.btn-success { background: #e3f5ec; color: var(--success); }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 11px; border-radius: 10px; font-size: .88rem; }

.card { background: var(--surface); border: 1px solid rgba(221,227,223,.8); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 13px; padding: 12px 14px; outline: none; transition: .2s; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary-2); box-shadow: 0 0 0 4px rgba(34,95,80,.10); }
.textarea { min-height: 90px; resize: vertical; }
.form-group { display: grid; gap: 7px; }
.form-group label { font-size: .9rem; font-weight: 750; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .full { grid-column: 1/-1; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left, rgba(239,179,102,.26), transparent 34%), linear-gradient(135deg, #edf3ef, #f8f4ec); }
.login-shell { width: min(930px, 100%); display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; background: #fff; border-radius: 30px; box-shadow: 0 30px 90px rgba(17,50,41,.18); }
.login-visual { padding: 48px; color: #fff; background: linear-gradient(150deg, rgba(23,63,53,.94), rgba(34,95,80,.92)), url('../assets/restaurant-pattern.svg'); background-size: cover; display: flex; flex-direction: column; justify-content: space-between; min-height: 600px; }
.login-visual h1 { font-size: clamp(2.2rem, 5vw, 4.3rem); line-height: 1; margin: 18px 0; }
.login-visual p { max-width: 460px; color: rgba(255,255,255,.82); font-size: 1.05rem; }
.brand-badge { display: inline-flex; align-items: center; gap: 10px; padding: 10px 14px; width: fit-content; border-radius: 99px; background: rgba(255,255,255,.12); backdrop-filter: blur(8px); font-weight: 800; }
.login-form { padding: 48px; display: grid; align-content: center; gap: 18px; }
.login-form h2 { margin: 0; font-size: 2rem; }
.role-links { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 6px; }
.role-link { padding: 10px; text-align: center; border-radius: 12px; background: #f2f5f3; color: var(--primary); font-weight: 750; font-size: .86rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar { background: var(--primary); color: #fff; padding: 22px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { display: flex; gap: 12px; align-items: center; padding: 8px 10px 22px; }
.logo-mark { width: 44px; height: 44px; border-radius: 14px; background: var(--accent); color: var(--primary); display: grid; place-items: center; font-weight: 950; }
.sidebar-brand strong { display: block; font-size: 1.05rem; }
.sidebar-brand span { color: rgba(255,255,255,.65); font-size: .8rem; }
.nav { display: grid; gap: 6px; }
.nav button, .nav a { border: 0; width: 100%; color: rgba(255,255,255,.78); background: transparent; border-radius: 12px; padding: 12px 14px; text-align: left; font-weight: 720; }
.nav button:hover, .nav button.active, .nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-footer { margin-top: auto; display: grid; gap: 10px; }
.user-chip { background: rgba(255,255,255,.09); border-radius: 14px; padding: 12px; }
.user-chip small { color: rgba(255,255,255,.65); }
.main { min-width: 0; }
.topbar { min-height: 74px; padding: 15px 28px; background: rgba(255,255,255,.88); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 1.35rem; margin: 0; }
.content { padding: 28px; }
.section { display: none; }
.section.active { display: block; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-head h2 { margin: 0; font-size: 1.7rem; }
.section-head p { margin: 5px 0 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 14px; margin-bottom: 22px; }
.stat { padding: 18px; }
.stat small { color: var(--muted); font-weight: 700; }
.stat strong { display: block; margin-top: 8px; font-size: 1.75rem; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3,minmax(0,1fr)); }
.table-wrap { overflow: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8faf8; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 999px; font-size: .78rem; font-weight: 800; background: #edf1ef; color: var(--muted); }
.badge.pending { background: #fff1d9; color: #936014; }
.badge.cooking { background: #e8efff; color: #325da8; }
.badge.ready { background: #e2f6eb; color: #18704a; }
.badge.delivered, .badge.billed { background: #e8f5e8; color: #39713b; }
.badge.cancelled { background: #fee8e8; color: #a13b3b; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; }
.thumb { width: 58px; height: 58px; object-fit: cover; border-radius: 12px; background: #eef1ef; }
.image-preview { width: 160px; aspect-ratio: 4/3; border-radius: 16px; object-fit: cover; background: #eef1ef; border: 1px dashed var(--border); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(12,28,23,.58); display: grid; place-items: center; padding: 20px; z-index: 100; }
.modal { width: min(760px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.modal-head { padding: 20px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.icon-btn { border: 0; background: #eef2ef; border-radius: 10px; width: 38px; height: 38px; }

.toast-wrap { position: fixed; right: 18px; top: 18px; z-index: 300; display: grid; gap: 10px; }
.toast { min-width: 280px; max-width: 420px; padding: 14px 16px; border-radius: 14px; background: #1f2d28; color: #fff; box-shadow: var(--shadow); animation: toast-in .25s ease; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } }

/* Menú del cliente */
.customer-page { min-height: 100vh; background: #f7f5ef; padding-bottom: 110px; }
.customer-hero { background: linear-gradient(155deg, var(--primary), var(--primary-2)); color: #fff; padding: 22px 18px 46px; border-radius: 0 0 34px 34px; }
.customer-hero-inner { max-width: 1180px; margin: auto; }
.customer-brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.customer-brand-info { display: flex; align-items: center; gap: 12px; }
.customer-logo { width: 54px; height: 54px; border-radius: 17px; object-fit: contain; background: #fff; padding: 6px; }
.table-pill { background: rgba(255,255,255,.13); padding: 9px 13px; border-radius: 99px; font-weight: 800; }
.customer-hero h1 { margin: 28px 0 8px; font-size: clamp(2rem,7vw,4rem); line-height: 1; }
.customer-hero p { color: rgba(255,255,255,.8); max-width: 700px; }
.customer-main { max-width: 1180px; margin: -22px auto 0; padding: 0 16px; }
.register-card { max-width: 650px; margin: auto; padding: 24px; }
.category-strip { position: sticky; top: 0; z-index: 20; background: rgba(247,245,239,.92); backdrop-filter: blur(12px); padding: 14px 0; display: flex; gap: 9px; overflow-x: auto; scrollbar-width: none; }
.category-chip { white-space: nowrap; border: 1px solid var(--border); background: #fff; color: var(--primary); border-radius: 999px; padding: 10px 14px; font-weight: 800; }
.category-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.menu-section { margin: 22px 0 34px; }
.menu-section-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 14px; }
.menu-section h2 { margin: 0; font-size: 1.7rem; }
.category-banner { min-height: 150px; border-radius: 22px; overflow: hidden; position: relative; display: flex; align-items: end; margin-bottom: 16px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.category-banner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.category-banner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(8,25,20,.84), rgba(8,25,20,.08)); }
.category-banner > div { position: relative; z-index: 1; padding: 20px; }
.category-banner small { color: rgba(255,255,255,.82); }
.product-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
.product-card { overflow: hidden; background: #fff; border: 1px solid rgba(221,227,223,.8); border-radius: 22px; box-shadow: 0 10px 30px rgba(19,52,43,.07); display: flex; flex-direction: column; }
.product-photo { width: 100%; aspect-ratio: 16/10; object-fit: cover; background: #e9ede9; }
.product-body { padding: 16px; display: grid; gap: 9px; flex: 1; }
.product-body h3 { margin: 0; font-size: 1.08rem; }
.product-description { color: var(--muted); font-size: .9rem; line-height: 1.45; min-height: 42px; }
.product-bottom { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.product-price { font-size: 1.2rem; font-weight: 900; color: var(--primary); }
.add-btn { width: 42px; height: 42px; padding: 0; border-radius: 14px; font-size: 1.35rem; }
.cart-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 40; width: min(720px, calc(100% - 24px)); background: var(--primary); color: #fff; border-radius: 20px; box-shadow: 0 18px 50px rgba(16,42,35,.32); padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.cart-count { min-width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; background: var(--accent); color: var(--primary); font-weight: 950; }
.cart-drawer { position: fixed; inset: 0; z-index: 80; background: rgba(10,25,20,.55); display: flex; justify-content: flex-end; }
.cart-panel { width: min(480px, 100%); height: 100%; background: #fff; padding: 20px; overflow: auto; }
.cart-item { display: grid; grid-template-columns: 70px 1fr auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cart-item img { width: 70px; height: 70px; object-fit: cover; border-radius: 13px; }
.qty { display: inline-flex; align-items: center; gap: 8px; }
.qty button { width: 28px; height: 28px; border-radius: 9px; border: 0; background: #edf1ef; }
.order-status { max-width: 760px; margin: 20px auto; padding: 20px; }
.timeline { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-top: 18px; }
.step { position: relative; text-align: center; color: var(--muted); font-size: .78rem; font-weight: 760; }
.step::before { content: ''; width: 14px; height: 14px; border-radius: 50%; background: #dbe1dd; display: block; margin: 0 auto 8px; }
.step.active { color: var(--primary); }
.step.active::before { background: var(--accent); box-shadow: 0 0 0 5px rgba(239,179,102,.2); }
.customer-actions { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 18px; }
.customer-action { min-height: 88px; border: 1px solid var(--border); border-radius: 16px; background: #fff; color: var(--primary); font-weight: 850; padding: 12px; }

/* Cocina y meseros */
.board-page { min-height: 100vh; background: #eef2ef; }
.board-header { position: sticky; top: 0; z-index: 30; padding: 16px 22px; background: var(--primary); color: #fff; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.16); }
.board-header h1 { margin: 0; font-size: 1.4rem; }
.board-content { padding: 20px; }
.board-columns { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; }
.board-column { background: rgba(255,255,255,.55); border-radius: 22px; padding: 14px; min-height: 70vh; }
.board-column h2 { margin: 3px 4px 14px; display: flex; justify-content: space-between; }
.order-card { background: #fff; border-radius: 18px; box-shadow: 0 10px 25px rgba(19,52,43,.08); margin-bottom: 12px; overflow: hidden; border: 1px solid var(--border); }
.order-card-head { padding: 14px; background: #f8faf8; display: flex; justify-content: space-between; gap: 10px; }
.order-card-body { padding: 14px; }
.order-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.order-line:last-child { border-bottom: 0; }
.order-card-foot { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.alert-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.alert-card { padding: 18px; border-left: 5px solid var(--accent); }
.session-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.session-card { padding: 18px; }
.session-total { font-size: 1.6rem; font-weight: 950; margin: 8px 0; }

.qr-sheet { padding: 20px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.qr-card { border: 2px solid #17201d; border-radius: 20px; padding: 20px; text-align: center; break-inside: avoid; background: #fff; }
.qr-card img { width: 260px; margin: 12px auto; }
.qr-card h2 { margin: 0; font-size: 2rem; }

@media (max-width: 1050px) {
  .stats { grid-template-columns: repeat(3,1fr); }
  .product-grid, .grid-3, .session-grid, .alert-grid { grid-template-columns: repeat(2,1fr); }
  .board-columns { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { min-height: 260px; padding: 28px; }
  .login-form { padding: 28px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: auto 10px 10px 10px; width: auto; height: auto; z-index: 50; border-radius: 18px; padding: 8px; flex-direction: row; }
  .sidebar-brand, .sidebar-footer { display: none; }
  .nav { width: 100%; display: flex; overflow-x: auto; }
  .nav button, .nav a { white-space: nowrap; text-align: center; padding: 10px 12px; }
  .content { padding: 18px 14px 90px; }
  .topbar { padding: 12px 16px; }
  .stats, .product-grid, .grid-2, .grid-3, .session-grid, .alert-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .customer-actions { grid-template-columns: 1fr; }
  .product-card { display: grid; grid-template-columns: 120px 1fr; }
  .product-photo { height: 100%; aspect-ratio: auto; }
  .product-description { min-height: auto; }
  .qr-sheet { grid-template-columns: 1fr; }
}
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .qr-sheet { padding: 0; }
  .qr-card { page-break-inside: avoid; }
}
.calc-box { background: rgba(239,179,102,.16); border: 1px solid rgba(239,179,102,.45); border-radius: 14px; padding: 12px 14px; color: var(--text); }
.alert-pulse { animation: alert-pulse 1.4s ease-in-out infinite alternate; }
@keyframes alert-pulse { from { box-shadow: 0 0 0 rgba(239,179,102,0); } to { box-shadow: 0 0 0 4px rgba(239,179,102,.18); } }
.badge.waiter_pending { background: #fff3cd; color: #7a4b00; }

/* Alertas visuales y sonoras */
.alert-popup-stack {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: grid;
  gap: 12px;
  width: min(520px, calc(100vw - 24px));
  pointer-events: none;
}
.alert-popup {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 42px 1fr 34px;
  gap: 12px;
  align-items: start;
  padding: 16px;
  border-radius: 18px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 18px 60px rgba(10, 25, 20, .22);
  border: 1px solid rgba(221,227,223,.95);
  border-left: 7px solid var(--accent);
  animation: popup-in .24s ease;
}
.alert-popup.success { border-left-color: var(--success); }
.alert-popup.error, .alert-popup.warning { border-left-color: var(--warning); }
.alert-popup-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(239,179,102,.18);
  color: var(--primary);
  font-weight: 950;
  font-size: 1.15rem;
}
.alert-popup.success .alert-popup-icon { background: rgba(33,122,85,.12); color: var(--success); }
.alert-popup.error .alert-popup-icon, .alert-popup.warning .alert-popup-icon { background: rgba(196,119,27,.14); color: var(--warning); }
.alert-popup-content strong { display: block; font-size: 1rem; margin-bottom: 3px; }
.alert-popup-content p { margin: 0; color: var(--muted); line-height: 1.35; }
.alert-popup-close {
  border: 0;
  background: #eef2ef;
  color: var(--primary);
  border-radius: 10px;
  width: 32px;
  height: 32px;
  font-size: 1.25rem;
}
.sound-unlock {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 850;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  background: var(--accent);
  color: #2d2419;
  font-weight: 900;
  box-shadow: 0 14px 40px rgba(16,42,35,.20);
}
.customer-closed-card {
  max-width: 720px;
  margin: 24px auto;
  padding: 24px;
  text-align: center;
}
.customer-closed-icon {
  width: 66px;
  height: 66px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  background: rgba(33,122,85,.12);
  color: var(--success);
  font-size: 2rem;
  font-weight: 950;
}
@keyframes popup-in {
  from { transform: translateY(-10px); opacity: 0; }
}
@media (max-width: 760px) {
  .alert-popup-stack { top: 10px; }
  .sound-unlock { left: 12px; right: 12px; bottom: 10px; width: calc(100% - 24px); }
}
.timeline { grid-template-columns: repeat(5, 1fr); }


.push-unlock {
  position: fixed;
  right: 16px;
  bottom: 76px;
  z-index: 9999;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  background: var(--primary, #173f35);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 14px 30px rgba(0,0,0,.22);
  cursor: pointer;
}
.push-unlock:disabled { opacity: .7; cursor: progress; }
@media (max-width: 720px) { .push-unlock { left: 14px; right: 14px; bottom: 70px; } }
