/* ===========================================================================
 * Ordena2Go POS — global styles
 * Inter font + slate/indigo paleta + dark sidebar + light content area
 * Inspirado en Odoo POS / Toast / Square
 * ======================================================================== */

@import url('https://rsms.me/inter/inter.css');

:root {
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;

  /* Brand */
  --brand-50:  #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-300: #93c5fd;
  --brand-400: #60a5fa;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --brand-800: #1e40af;
  --brand-900: #1e3a8a;

  /* Slate (neutrals) */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* Estado */
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #0891b2;
  --info-bg: #cffafe;

  /* Layout */
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(15,23,42,.06);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 6px -1px rgba(15,23,42,.10), 0 2px 4px -2px rgba(15,23,42,.06);
  --shadow-lg: 0 10px 15px -3px rgba(15,23,42,.10), 0 4px 6px -4px rgba(15,23,42,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-feature-settings: 'cv02','cv03','cv04','cv11';
  background: var(--slate-100);
  color: var(--slate-900);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font-family: inherit; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* ============================ Login ====================================== */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 10% -20%, rgba(37,99,235,.18) 0, transparent 60%),
    radial-gradient(900px 500px at 90% 110%, rgba(99,102,241,.16) 0, transparent 60%),
    linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: 18px;
  padding: 32px;
  box-shadow: 0 30px 60px -10px rgba(2,6,23,.5), 0 18px 36px -18px rgba(2,6,23,.4);
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.login-brand .logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
  display: grid; place-items: center;
  color: white;
  box-shadow: var(--shadow-md);
}
.login-brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0;
}
.login-brand p { color: var(--slate-500); font-size: 13px; margin: 0; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label { font-size: 13px; font-weight: 500; color: var(--slate-700); }
.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--slate-300);
  border-radius: 10px;
  background: white;
  color: var(--slate-900);
  font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}
.input.lg { height: 52px; font-size: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .04s;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-600); color: white; }
.btn-primary:hover:not([disabled]) { background: var(--brand-700); }
.btn-secondary { background: var(--slate-100); color: var(--slate-800); border-color: var(--slate-200); }
.btn-secondary:hover:not([disabled]) { background: var(--slate-200); }
.btn-ghost { background: transparent; color: var(--slate-700); }
.btn-ghost:hover:not([disabled]) { background: var(--slate-100); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not([disabled]) { background: #b91c1c; }
.btn-block { width: 100%; }
.btn-lg { height: 52px; font-size: 16px; padding: 0 24px; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 40px; padding: 0; }

.error-banner {
  background: var(--danger-bg);
  color: #7f1d1d;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.error-banner.show { display: block; }

/* ============================ App shell ================================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns .2s ease;
}
/* En desktop, .sidebar-collapsed esconde la columna del sidebar */
.app.sidebar-collapsed { grid-template-columns: 0 1fr; }
.app.sidebar-collapsed .sidebar {
  overflow: hidden;
  visibility: hidden;
  border-right: none;
}
.sidebar {
  grid-row: 1 / 3;
  background: var(--slate-900);
  color: var(--slate-300);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--slate-800);
}
.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  color: white;
  font-weight: 600;
  font-size: 15px;
  border-bottom: 1px solid var(--slate-800);
}
.sidebar-brand .logo-mini {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: grid; place-items: center;
  color: white;
}
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-nav .nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--slate-500);
  padding: 12px 12px 6px;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--slate-300);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .12s, color .12s;
}
.sidebar-nav a:hover { background: var(--slate-800); color: white; }
.sidebar-nav a.active {
  background: var(--brand-600);
  color: white;
}
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--slate-800);
  font-size: 12px;
  color: var(--slate-400);
}

.topbar {
  grid-column: 2;
  background: white;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar h1 {
  font-size: 16px; font-weight: 600; margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.breadcrumb {
  font-size: 13px; color: var(--slate-500);
  display: flex; align-items: center; gap: 6px;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar .user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  background: var(--slate-100);
}
.topbar .user .avatar {
  width: 28px; height: 28px;
  border-radius: 999px;
  background: var(--brand-600);
  color: white;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}
.topbar .user .info { line-height: 1.1; font-size: 12px; }
.topbar .user .info .name { font-weight: 600; color: var(--slate-900); }
.topbar .user .info .role { color: var(--slate-500); }

.outlet {
  grid-column: 2;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--slate-100);
  min-height: 0;
}

/* ============================ Generic UI ================================= */
.page { padding: 20px; max-width: 1400px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-head .subtitle { color: var(--slate-500); font-size: 13px; margin-top: 4px; }

.card { background: white; border-radius: 12px; box-shadow: var(--shadow-sm); border: 1px solid var(--slate-200); }
.card-pad { padding: 16px; }
.card-head { padding: 12px 16px; border-bottom: 1px solid var(--slate-200); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: white; border: 1px solid var(--slate-200); border-radius: 12px;
  padding: 14px 16px;
}
.kpi .label { color: var(--slate-500); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 700; color: var(--slate-900); margin-top: 4px; letter-spacing: -.02em; }
.kpi .delta { font-size: 12px; color: var(--success); margin-top: 4px; }
.kpi .delta.down { color: var(--danger); }

.badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-success { background: var(--success-bg); color: #065f46; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-danger  { background: var(--danger-bg); color: #7f1d1d; }
.badge-info    { background: var(--info-bg); color: #155e75; }
.badge-neutral { background: var(--slate-100); color: var(--slate-700); }

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; padding: 10px 12px; background: var(--slate-50); color: var(--slate-600); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--slate-200); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--slate-100); }
.tbl tr:hover td { background: var(--slate-50); }

.toast-stack { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast {
  background: var(--slate-900); color: white; padding: 10px 14px;
  border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px;
  display: flex; align-items: center; gap: 8px; min-width: 220px;
  animation: toast-in .18s ease-out;
}
.toast.success { background: #14532d; }
.toast.danger  { background: #7f1d1d; }
.toast.warning { background: #92400e; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: white; border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.modal.lg { max-width: 760px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--slate-200); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--slate-200); display: flex; justify-content: flex-end; gap: 8px; }

/* ============================ POS module ================================= */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}
.pos-catalog { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--slate-100); }
.pos-catalog-head {
  padding: 12px 16px;
  background: white;
  border-bottom: 1px solid var(--slate-200);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.pos-search {
  flex: 1; min-width: 180px;
  height: 40px;
  border: 1px solid var(--slate-300);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 14px;
  outline: none;
  background: var(--slate-50);
}
.pos-search:focus { background: white; border-color: var(--brand-500); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }
.pos-cats {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 8px 16px; background: white; border-bottom: 1px solid var(--slate-200);
}
.pos-cat-chip {
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
  background: var(--slate-100); color: var(--slate-700);
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
}
.pos-cat-chip.active { background: var(--brand-600); color: white; }
.pos-grid {
  flex: 1; overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  grid-auto-rows: min-content;
  align-content: start;
  align-items: start;
  gap: 12px;
  padding: 16px;
}
.pos-product {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 8px;
  transition: transform .08s, box-shadow .15s, border-color .15s;
  user-select: none;
}
.pos-product:hover { box-shadow: var(--shadow-md); border-color: var(--brand-300); }
.pos-product:active { transform: scale(.98); }
.pos-product .img {
  width: 100%; aspect-ratio: 1; border-radius: 10px;
  background: var(--slate-100) center/cover no-repeat;
}
.pos-product .name { font-size: 13px; font-weight: 600; color: var(--slate-900); line-height: 1.25; min-height: 2.5em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pos-product .price { font-size: 14px; font-weight: 700; color: var(--brand-700); }
.pos-product .stock { font-size: 11px; color: var(--slate-500); }
.pos-product.low-stock .stock { color: var(--warning); }
.pos-product.no-stock { opacity: .55; pointer-events: none; }

.pos-cart {
  display: flex; flex-direction: column;
  background: white;
  border-left: 1px solid var(--slate-200);
  min-height: 0;
  overflow: hidden;
}
.pos-cart-head { padding: 14px 16px; border-bottom: 1px solid var(--slate-200); }
.pos-cart-head .order-info { display: flex; align-items: center; justify-content: space-between; }
.pos-cart-head .order-info .num { font-weight: 700; font-size: 16px; }
.pos-cart-head .order-info .meta { font-size: 12px; color: var(--slate-500); }
.pos-cart-lines { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 0; }
.pos-line {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--slate-100);
}
.pos-line .info { flex: 1; min-width: 0; }
.pos-line .name { font-size: 13px; font-weight: 600; color: var(--slate-900); }
.pos-line .meta { font-size: 11px; color: var(--slate-500); margin-top: 2px; }
.pos-line .qty {
  display: flex; align-items: center; gap: 4px;
  background: var(--slate-100); border-radius: 8px; padding: 2px;
}
.pos-line .qty button {
  width: 26px; height: 26px; border: none; background: transparent;
  font-size: 16px; font-weight: 600; color: var(--slate-700); cursor: pointer; border-radius: 6px;
}
.pos-line .qty button:hover { background: white; }
.pos-line .qty span { min-width: 22px; text-align: center; font-weight: 600; font-size: 13px; }
.pos-line .total { font-weight: 700; font-size: 13px; color: var(--slate-900); min-width: 60px; text-align: right; }

.pos-totals {
  padding: 12px 16px;
  border-top: 1px solid var(--slate-200);
  background: var(--slate-50);
  font-size: 13px;
}
.pos-totals .row { display: flex; justify-content: space-between; padding: 3px 0; }
.pos-totals .row.total {
  margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--slate-200);
  font-size: 18px; font-weight: 700;
}
.pos-actions {
  padding: 12px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  border-top: 1px solid var(--slate-200);
}
.pos-pay-btn {
  grid-column: 1 / 3;
  height: 56px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
  color: white; font-weight: 700; font-size: 17px;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: var(--shadow-md);
}
.pos-pay-btn:hover { filter: brightness(1.08); }
.pos-pay-btn[disabled] { opacity: .5; cursor: not-allowed; filter: none; }

/* Pago modal */
.pay-methods { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.pay-method {
  padding: 14px;
  border: 2px solid var(--slate-200);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: white;
}
.pay-method.active { border-color: var(--brand-600); background: var(--brand-50); color: var(--brand-700); }
.pay-method svg { width: 22px; height: 22px; }

.amount-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.amount-pad button {
  height: 48px; border: 1px solid var(--slate-200);
  border-radius: 10px; background: white; font-size: 16px; font-weight: 600; cursor: pointer;
}
.amount-pad button:hover { background: var(--slate-50); border-color: var(--brand-300); }
.amount-pad button.danger { color: var(--danger); }

/* ============================ Customization modal ======================= */
.cust-section { margin-bottom: 18px; }
.cust-section .h {
  font-size: 12px; font-weight: 600; color: var(--slate-700);
  text-transform: uppercase; letter-spacing: .04em;
  margin: 0 0 8px;
}
.cust-section .h .hint { font-weight: 400; color: var(--slate-500); text-transform: none; letter-spacing: 0; margin-left: 6px; }
.opt-grid { display: grid; grid-template-columns: 1fr; gap: 6px; }
.opt-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  background: white;
  cursor: pointer;
  user-select: none;
  transition: background .12s, border-color .12s;
  font-size: 14px;
}
.opt-row:hover { background: var(--slate-50); }
.opt-row.selected { border-color: var(--brand-500); background: var(--brand-50); }
.opt-row.excluded { background: #fef2f2; border-color: #fecaca; color: var(--danger); text-decoration: line-through; }
.opt-row .left { display: flex; align-items: center; gap: 10px; }
.opt-row .check {
  width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid var(--slate-300); background: white;
  display: grid; place-items: center;
}
.opt-row.selected .check { background: var(--brand-600); border-color: var(--brand-600); color: white; }
.opt-row .price { font-size: 13px; font-weight: 600; color: var(--brand-700); }
.opt-row .ing-state { font-size: 11px; color: var(--success); font-weight: 600; }
.opt-row.excluded .ing-state { color: var(--danger); }
.cust-qty {
  display: flex; align-items: center; gap: 6px;
  background: var(--slate-100); padding: 4px; border-radius: 10px;
}
.cust-qty button {
  width: 32px; height: 32px; border: none; background: white;
  border-radius: 7px; font-size: 18px; font-weight: 600;
  cursor: pointer;
}
.cust-qty span { min-width: 30px; text-align: center; font-weight: 700; }

/* Empty state */
.empty {
  display: grid; place-items: center;
  height: 100%; padding: 40px;
  text-align: center; color: var(--slate-500);
  gap: 8px;
}
.empty svg { width: 48px; height: 48px; color: var(--slate-300); }

/* ============================ Tabs ======================================= */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--slate-200);
  margin-bottom: -1px;
}
.tabs .tab {
  background: transparent;
  border: none;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--slate-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tabs .tab:hover { color: var(--slate-800); }
.tabs .tab.active {
  color: var(--brand-600);
  border-bottom-color: var(--brand-600);
}

.subtabs {
  display: flex;
  gap: 4px;
  background: var(--slate-100);
  padding: 4px;
  border-radius: 10px;
  width: fit-content;
}
.subtabs .subtab {
  background: transparent;
  border: none;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-600);
  cursor: pointer;
  border-radius: 7px;
}
.subtabs .subtab.active {
  background: white;
  color: var(--slate-900);
  box-shadow: var(--shadow-xs);
}

/* Toolbar arriba de tablas */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar > .search {
  flex: 1; min-width: 220px; height: 38px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  padding: 0 12px 0 36px;
  background: white url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") 12px center no-repeat;
  outline: none; font-size: 14px;
}
.toolbar > .search:focus { border-color: var(--brand-500); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }
.toolbar select {
  height: 38px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  padding: 0 30px 0 12px;
  background: white;
  font-size: 14px;
  outline: none;
  cursor: pointer;
}

/* Tabla con foto + acciones inline */
.tbl-prod th, .tbl-prod td { padding: 8px 12px; font-size: 13px; vertical-align: middle; }
.tbl-prod .img-cell {
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--slate-100) center/cover no-repeat;
  display: inline-block;
}
.tbl-prod .actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Visibilidad chip selector */
.vis-pill {
  display: inline-flex;
  background: var(--slate-100);
  border-radius: 999px;
  padding: 2px;
  font-size: 11px;
  font-weight: 600;
  user-select: none;
}
.vis-pill button {
  background: transparent;
  border: none;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--slate-500);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .02em;
}
.vis-pill button.active {
  background: white;
  color: var(--brand-700);
  box-shadow: var(--shadow-xs);
}
.vis-pill button:disabled { opacity: .5; cursor: not-allowed; }

/* Tarjeta de categoria expandible */
.cat-card { background: white; border: 1px solid var(--slate-200); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.cat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; cursor: pointer; user-select: none;
  background: var(--slate-50);
  border-bottom: 1px solid var(--slate-200);
}
.cat-head:hover { background: var(--slate-100); }
.cat-head.collapsed { border-bottom-color: transparent; }
.cat-head .name { flex: 1; font-weight: 600; font-size: 14px; }
.cat-head .meta { color: var(--slate-500); font-size: 12px; }
.cat-head .chevron { transition: transform .15s; }
.cat-head.collapsed .chevron { transform: rotate(-90deg); }
.cat-body { padding: 8px 12px 12px; }
.cat-body.hidden { display: none; }

.sub-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
}
.sub-row:hover { background: var(--slate-50); }
.sub-row .label { flex: 1; font-size: 13px; }
.sub-row .meta { color: var(--slate-500); font-size: 12px; }
.sub-row .actions { display: flex; gap: 2px; }

/* ============================ Charts ==================================== */
.bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 90px;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  font-size: 13px;
}
.bar-row .bar-label { color: var(--slate-600); font-weight: 500; }
.bar-row .bar-track { background: var(--slate-100); border-radius: 6px; height: 24px; position: relative; }
.bar-row .bar-fill  {
  background: linear-gradient(90deg, var(--brand-500), var(--brand-700));
  height: 100%; border-radius: 6px;
  min-width: 2px;
  transition: width .25s ease;
}
.bar-row .bar-value { text-align: right; font-weight: 600; color: var(--slate-900); font-variant-numeric: tabular-nums; }

.donut-wrap {
  display: flex; align-items: center; gap: 18px;
  padding: 8px 0;
}
.donut-svg { width: 140px; height: 140px; flex-shrink: 0; }
.donut-svg circle.bg { fill: none; stroke: var(--slate-100); stroke-width: 18; }
.donut-svg circle.seg { fill: none; stroke-width: 18; stroke-linecap: butt; transition: stroke-dasharray .25s; }
.donut-center { position: relative; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.donut-legend .item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.donut-legend .swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.donut-legend .name { flex: 1; color: var(--slate-700); }
.donut-legend .value { font-weight: 600; color: var(--slate-900); }

/* Spinner */
.spin {
  width: 18px; height: 18px;
  border: 2px solid var(--slate-300);
  border-top-color: var(--brand-600);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Botón menú: visible siempre. En desktop colapsa la columna del sidebar.
   En mobile abre el sidebar como overlay. */
#btn-menu { display: inline-flex; }

/* Backdrop oscuro detrás del sidebar mobile abierto */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(2px);
  z-index: 49;
  opacity: 0; pointer-events: none;
  transition: opacity .18s;
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

/* Mobile */
@media (max-width: 900px) {
  .app { grid-template-columns: 0 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 50;
    box-shadow: 6px 0 24px -8px rgba(2,6,23,.4);
  }
  .sidebar.open { transform: translateX(0); visibility: visible; }
  /* En mobile, .sidebar-collapsed no aplica — siempre 0 1fr y overlay con .open */
  .app, .app.sidebar-collapsed { grid-template-columns: 0 1fr; }
  .pos-layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .pos-cart { border-left: none; border-top: 1px solid var(--slate-200); max-height: 50vh; }
}

/* ── Topbar compacto en móvil ────────────────────────────────────────────
   Reduce padding, achica el page-title y trunca el nombre del negocio. */
@media (max-width: 640px) {
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar h1 { font-size: 14px; max-width: 38vw; }
  .topbar-right { gap: 4px; }
  .topbar .user { padding: 4px 8px 4px 4px; gap: 6px; }
  .topbar .user .avatar { width: 24px; height: 24px; font-size: 11px; }
  .topbar .user .info .name {
    max-width: 28vw;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #btn-cajero-mode span { display: none; }
  #btn-cajero-mode { padding: 6px 8px; }
  /* Chip de conexión: oculta el texto (En línea/Sincronizando…/Sin conexión).
     Su ancho variable empujaba toda la topbar al cambiar de estado. En móvil
     basta el punto de color + el badge de pendientes (ancho constante). */
  #net-chip .net-txt { display: none; }
  #net-chip { padding: 6px 8px; }
}

/* ── Forms de Productos (manual + IA) en móvil ───────────────────────────
   Colapsa los grids inline a una sola columna y centra la foto-preview. */
@media (max-width: 640px) {
  .modal-backdrop { padding: 8px; }
  .modal-body { padding: 14px; }
  .prod-form-mobile > div,
  .prod-form-mobile div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  .prod-form-mobile #img-preview {
    width: 160px !important;
    height: 160px !important;
    margin: 0 auto;
  }
  .prod-form-mobile #ai-analyze-box,
  .prod-form-mobile #ai-product-box {
    height: 160px !important;
  }
}
