  :root {
    --v1: #D9480F;
    --v2: #FD7E14;
    --bg: #f3f0ec;
    --card: #ffffff;
    --text: #1a1a1a;
    --muted: #666;
    --border: #d4d6dc;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-card-hover: 0 4px 12px rgba(15, 23, 42, 0.10), 0 2px 4px rgba(15, 23, 42, 0.06);
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
  }
  button {
    cursor: pointer;
    border: none;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.15s;
  }
  input, select, textarea {
    font-family: inherit;
    font-size: 14px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 100%;
    background: white;
  }
  input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--v2);
  }
  /* ───── LOGIN ───── */
  #login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--v1), var(--v2));
    padding: 20px;
  }
  .login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  }
  .login-brand {
    text-align: center;
    margin-bottom: 30px;
  }
  .login-brand h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--v1), var(--v2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  .login-brand p {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
  }
  .login-card label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    margin-top: 14px;
  }
  .login-card button {
    width: 100%;
    background: linear-gradient(135deg, var(--v1), var(--v2));
    color: white;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    margin-top: 24px;
  }
  .login-card button:hover { opacity: 0.9; }
  .login-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 13px;
    display: none;
  }
  /* ───── APP ───── */
  #app { display: none; min-height: 100vh; }
  .layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
  }
  .sidebar {
    background: linear-gradient(180deg, var(--v1), var(--v2));
    color: white;
    padding: 20px 20px 16px 20px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: hidden;
  }
  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    margin-bottom: 16px;
    flex-shrink: 0;
  }
  .sidebar-brand .emoji { font-size: 28px; }
  .sidebar-brand .info h2 { font-size: 16px; font-weight: 600; }
  .sidebar-brand .info small { font-size: 11px; opacity: 0.8; }
  .sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    margin-right: -8px;
    padding-right: 8px;
    min-height: 0;
  }
  .sidebar-nav::-webkit-scrollbar { width: 6px; }
  .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
  .nav-btn {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 4px;
    opacity: 0.85;
  }
  .nav-btn:hover { background: rgba(255,255,255,0.1); opacity: 1; }
  .nav-btn.active { background: rgba(255,255,255,0.2); opacity: 1; font-weight: 600; }
  .sidebar-footer {
    flex-shrink: 0;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.15);
  }
  .sidebar-footer .user-info {
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    font-size: 12px;
    margin-bottom: 8px;
  }
  .credito-sigma { margin-top: 10px; text-align: center; font-size: 10.5px; line-height: 1.3; opacity: 0.8; letter-spacing: 0.01em; }
  .credito-login { margin-top: 16px; opacity: 1; color: var(--muted, #6b7280); }
  .logout-btn {
    width: 100%;
    background: rgba(0,0,0,0.3);
    color: white;
    padding: 8px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    border: none;
    font-family: inherit;
  }
  .logout-btn:hover { background: rgba(0,0,0,0.5); }
  .main { padding: 24px; overflow-x: auto; }
  .page-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
  }
  .card {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    transition: box-shadow 0.18s ease;
  }
  .card:hover { box-shadow: var(--shadow-card-hover); }

  /* Inputs más prolijos */
  input, select, textarea {
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
  input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--v2);
    box-shadow: 0 0 0 3px rgba(107, 63, 160, 0.15);
  }

  /* Filas de tabla con hover */
  tbody tr { transition: background 0.12s ease; }
  tbody tr:hover { background: rgba(107, 63, 160, 0.04); }

  /* Botones con transición */
  button { transition: transform 0.06s ease, box-shadow 0.15s ease, opacity 0.15s ease; }
  button:active:not(:disabled) { transform: scale(0.98); }
  .row { display: flex; gap: 12px; flex-wrap: wrap; }
  .row > * { flex: 1; min-width: 180px; }
  .label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 500; }

  /* Nueva Venta */
  .pos-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 16px;
  }
  .tipo-cbte-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }
  .tipo-cbte-tab {
    flex: 1;
    min-width: 120px;
    padding: 12px;
    background: var(--bg);
    border: 2px solid transparent;
    border-radius: 10px;
    font-weight: 600;
    color: var(--muted);
  }
  .tipo-cbte-tab.active {
    background: white;
    border-color: var(--v2);
    color: var(--v1);
  }
  .rubros-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }
  .rubro-btn {
    padding: 10px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    text-align: center;
  }
  .rubro-btn.active { background: var(--v2); color: white; border-color: var(--v2); }
  .item-row {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 8px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 6px;
  }
  .item-row .item-name { font-size: 13px; font-weight: 500; }
  .item-row .item-qty-price { font-size: 12px; color: var(--muted); }
  .item-row .item-total { font-weight: 600; text-align: right; }
  .btn-remove {
    background: transparent;
    color: var(--danger);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
  }
  .resumen-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
  }
  .resumen-total {
    font-size: 22px;
    font-weight: 700;
    border-top: 2px solid var(--border);
    padding-top: 12px;
    margin-top: 8px;
  }
  .btn-primary {
    background: linear-gradient(135deg, var(--v1), var(--v2));
    color: white;
    padding: 14px;
    border-radius: 10px;
    font-weight: 600;
    width: 100%;
    font-size: 15px;
    margin-top: 12px;
  }
  .btn-primary:hover { opacity: 0.9; }
  .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
  .btn-secondary {
    background: var(--bg);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
  }
  .pago-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 8px;
  }
  .pago-btn {
    padding: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    text-align: center;
  }
  .pago-btn.active { background: var(--success); color: white; border-color: var(--success); }

  /* Tabla facturas */
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  th, td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  th { background: var(--bg); font-weight: 600; color: var(--muted); font-size: 12px; }
  tr.nc { background: #fef2f2; color: var(--danger); }
  tr.nc td { color: var(--danger); }
  .badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
  }
  .badge-A { background: #dbeafe; color: #1e40af; }
  .badge-B { background: #d1fae5; color: #065f46; }
  .badge-T { background: #fef3c7; color: #92400e; }
  .badge-NCA { background: #fee2e2; color: #991b1b; }
  .badge-NCB { background: #fee2e2; color: #991b1b; }
  .icon-btn {
    background: transparent;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 16px;
  }
  .icon-btn:hover { background: var(--bg); }

  /* Modal */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
  }
  .modal-overlay.active { display: flex; }
  .modal {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    max-height: 85dvh; /* dynamic viewport - corrige iOS Safari */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* scroll suave en iOS */
    overscroll-behavior: contain;
    padding-bottom: 80px; /* espacio extra para que botones sticky no tapen contenido */
  }
  /* Modal ancho (para listados como Historial de cajas) */
  .modal-overlay.active .modal.modal-wide {
    max-width: min(960px, 95vw);
    width: 95vw;
  }
  .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
  }
  .modal-close { background: transparent; font-size: 24px; padding: 0 8px; }

  /* Toast */
  #toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--text);
    color: white;
    padding: 14px 20px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 1000;
    display: none;
    max-width: 360px;
  }
  #toast.success { background: var(--success); }
  #toast.error { background: var(--danger); }

  /* Loading */
  .spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ═══ TOUR GUIADO ═══ */
  .tour-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.7);
    z-index: 9998; display: none; pointer-events: auto;
    animation: tour-fade 0.25s ease-out;
  }
  .tour-overlay.active { display: block; }
  @keyframes tour-fade { from { opacity: 0; } to { opacity: 1; } }

  .tour-spotlight {
    position: fixed; border-radius: 12px; pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.65), 0 0 30px 5px rgba(255,255,255,.4);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid #fff; z-index: 9999;
  }

  .tour-tooltip {
    position: fixed; background: white; border-radius: 14px;
    padding: 22px; max-width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    z-index: 10000; transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border-top: 4px solid #FD7E14;
  }
  .tour-tooltip h3 {
    margin: 0 0 10px 0; font-size: 17px; font-weight: 700;
    color: #D9480F !important; display: flex; align-items: center; gap: 8px;
  }
  .tour-tooltip p {
    margin: 0 0 14px 0; font-size: 13.5px; line-height: 1.55; color: #374151 !important;
  }
  .tour-tooltip .tour-roles {
    background: linear-gradient(135deg, #f9fafb, #fff);
    border: 1px solid #e5e7eb; border-radius: 8px;
    padding: 10px 12px; margin: 10px 0; font-size: 12.5px; line-height: 1.5;
    color: #374151;
  }
  .tour-tooltip .tour-roles strong { color: #FD7E14 !important; }
  .tour-controls {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 12px; padding-top: 12px; border-top: 1px solid #f1f5f9;
  }
  .tour-progress {
    font-size: 12px; color: #64748b; font-weight: 600;
  }
  .tour-progress-dots { display: inline-flex; gap: 4px; margin-left: 8px; }
  .tour-progress-dots span {
    width: 7px; height: 7px; border-radius: 50%; background: #cbd5e1;
  }
  .tour-progress-dots span.active { background: #FD7E14; }
  .tour-buttons { display: flex; gap: 8px; }
  .tour-btn {
    padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
    cursor: pointer; border: none; font-family: inherit;
  }
  .tour-btn-skip { background: transparent; color: #64748b; }
  .tour-btn-skip:hover { color: #1f2937; }
  .tour-btn-back { background: #f1f5f9; color: #1f2937; }
  .tour-btn-back:hover { background: #e2e8f0; }
  .tour-btn-next {
    background: linear-gradient(135deg, #FD7E14, #FF922B) !important;
    color: white !important; box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  }
  .tour-btn-next:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.15); filter: brightness(1.1); }


  /* Mi Negocio */
  .negocio-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  @media (max-width: 900px) {
    .negocio-grid { grid-template-columns: 1fr; }
  }
  .emoji-pick {
    width: 38px;
    height: 38px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
  }
  .emoji-pick:hover { background: white; transform: scale(1.05); }
  .logo-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
  }
  .logo-tab {
    flex: 1;
    padding: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
  }
  .logo-tab.active {
    background: white;
    border-color: var(--v2);
    color: var(--v1);
    font-weight: 600;
  }
  .palette-btn {
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  }
  .palette-btn:hover { transform: translateY(-1px); }

  /* KPI cards */
  .kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
  }
  .kpi-card { padding: 12px; }
  .kpi-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
  .kpi-value { font-size: 16px; font-weight: 700; color: var(--v1); line-height: 1.2; word-break: break-word; }
  .kpi-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
  .delta {
    font-weight: 600;
    display: inline-block;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 10px;
  }
  .delta.up { color: #065f46; background: #d1fae5; }
  .delta.down { color: #991b1b; background: #fee2e2; }
  .delta.neutral { color: var(--muted); background: var(--bg); }

  .reportes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
  }
  .reportes-grid > .card { min-width: 0; }
  .reportes-grid canvas { width: 100% !important; height: 160px !important; display: block; }
  @media (max-width: 900px) {
    .reportes-grid { grid-template-columns: 1fr; }
  }
  .rubros-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  @media (max-width: 768px) {
    .rubros-layout { flex-direction: column; }
    .rubros-layout > div { width: 100% !important; flex: 1 !important; }
  }
  .rubro-bar-row {
    margin-bottom: 10px;
  }
  .rubro-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 4px;
  }
  .rubro-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
  }
  .rubro-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--v1), var(--v2));
  }

  /* Impresión del reporte */
  @media print {
    @page { size: A4 portrait; margin: 8mm; }
    body.printing-report > * { display: none !important; visibility: hidden !important; }
    body.printing-report #print-area { display: none !important; }
    body.printing-report #print-report-area {
      display: block !important;
      visibility: visible !important;
      position: static !important;
      width: 100% !important;
      padding: 0 !important;
      background: white !important;
      color: #000 !important;
    }
    body.printing-report #print-report-area * {
      visibility: visible !important;
      color: #000 !important;
    }
    body.printing-report #print-report-area .card {
      box-shadow: none !important;
      border: 1px solid #ddd !important;
      page-break-inside: avoid;
      margin-bottom: 8px !important;
    }
    body.printing-report #print-report-area canvas,
    body.printing-report #print-report-area img {
      max-width: 100% !important;
    }
    body.printing-report #print-report-area .reportes-grid {
      display: grid !important;
      grid-template-columns: 1fr 1fr !important;
      gap: 8px !important;
    }
    body.printing-report #print-report-area .kpi-grid {
      display: grid !important;
      grid-template-columns: repeat(5, 1fr) !important;
      gap: 6px !important;
    }
    body.printing-report #print-report-area .kpi-value { font-size: 13px !important; }
    body.printing-report #print-report-area .rubros-layout {
      display: flex !important;
      gap: 16px !important;
    }
  }
  #print-report-area { display: none; }

  /* Atajos de teclado */
  .kbd-hint, kbd {
    background: var(--bg);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-family: ui-monospace, monospace;
    font-size: 11px;
    font-weight: 600;
  }

  /* Impresión: solo imprime el contenido del ticket */
  @media print {
    body:not(.printing-report) html, body:not(.printing-report) {
      margin: 0 !important;
      padding: 0 !important;
      height: auto !important;
      background: white !important;
    }
    body:not(.printing-report) * { visibility: hidden !important; }
    body:not(.printing-report) #print-area, body:not(.printing-report) #print-area * { visibility: visible !important; }
    body:not(.printing-report) #print-area {
      display: block !important;
      position: absolute !important;
      left: 0 !important;
      top: 0 !important;
      width: 50mm !important;
      padding: 2mm 4mm 2mm 2mm !important;
      margin: 0 !important;
      font-family: 'Courier New', 'Courier', monospace !important;
      font-size: 11pt !important;
      font-weight: bold !important;
      line-height: 1.3 !important;
      letter-spacing: 0 !important;
      color: #000 !important;
      background: white !important;
      text-transform: uppercase !important;
      page-break-inside: avoid !important;
      page-break-after: avoid !important;
      -webkit-print-color-adjust: exact !important;
      print-color-adjust: exact !important;
    }
    body:not(.printing-report) #print-area h2 {
      font-size: 13pt !important;
      font-weight: bold !important;
      margin: 2px 0 !important;
      text-align: center !important;
      text-transform: uppercase !important;
    }
    body:not(.printing-report) #print-area .ticket-line {
      border-top: 1px dashed #000 !important;
      margin: 2mm 0 !important;
    }
    body:not(.printing-report) #print-area table {
      width: 100% !important;
      font-size: 11pt !important;
      font-weight: bold !important;
      border-collapse: collapse !important;
    }
    body:not(.printing-report) #print-area th,
    body:not(.printing-report) #print-area td {
      padding: 1px 0 !important;
      word-wrap: break-word !important;
      overflow-wrap: break-word !important;
    }
    body:not(.printing-report) #print-area .ticket-total {
      font-size: 16pt !important;
      font-weight: bold !important;
    }
    body:not(.printing-report) #print-area img {
      max-width: 100% !important;
    }
    body:not(.printing-report) #print-area > * { page-break-inside: avoid !important; }
    .modal-overlay, #toast { display: none !important; }
  }
  /* Tamaño de página solo cuando NO es reporte */
  @media print {
    body:not(.printing-report) {
      /* Para que aplique a hojas de ticket */
    }
  }
  #print-area { display: none; }

  /* ── Queluz · Productos: tabla en computadora, tarjetas en tablet y celular ── */
  #page-stock .prod-filtros { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(120px, 1fr)); gap: 10px; align-items: end; }
  #page-stock .prod-filtros label { display: block; margin-bottom: 4px; }
  #page-stock .prod-filtros input, #page-stock .prod-filtros select { height: 40px; margin: 0; padding: 0 12px; }
  #prod-cards { display: none; }
  #prod-tabla-wrap { overflow: visible !important; }
  #tabla-productos { table-layout: fixed; border-collapse: collapse; }
  #tabla-productos td { vertical-align: middle; white-space: normal; overflow: visible; text-overflow: clip; }
  #tabla-productos td.td-nombre strong { font-size: 13px; }
  .prod-cod { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; font-size: 13px; overflow-wrap: anywhere; word-break: break-all; }
  .prod-stock { display: inline-block; min-width: 64px; text-align: center; padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; white-space: nowrap; }
  .prod-stock.sin { background: #fdecec; color: #b42318; }
  .prod-stock.bajo { background: #fff4e0; color: #b54708; }
  .prod-stock.ok { background: #e7f6ec; color: #067647; }
  .prod-precio { font-weight: 800; font-size: 14px; white-space: nowrap; }
  .prod-sub { font-size: 11px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
  .prod-acciones { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
  .prod-acciones .btn-editar { margin: 0 !important; width: auto !important; padding: 6px 12px !important; font-size: 13px !important; white-space: nowrap; }
  .prod-mas { position: relative; }
  .prod-mas > summary { list-style: none; cursor: pointer; padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); font-weight: 700; line-height: 1; user-select: none; }
  .prod-mas > summary::-webkit-details-marker { display: none; }
  .prod-mas[open] > summary { border-color: var(--v2); color: var(--v1); }
  .prod-mas .prod-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 50; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(15,23,42,.14); min-width: 240px; padding: 6px; }
  .prod-mas .prod-menu button { display: block; width: 100% !important; margin: 0 !important; text-align: left; white-space: nowrap; padding: 9px 10px !important; background: none; border: 0; border-radius: 6px; font-size: 13px !important; color: var(--text); }
  .prod-mas .prod-menu button:hover { background: var(--bg); }
  .prod-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; box-shadow: var(--shadow-card); }
  .prod-card .pc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .prod-card .pc-nombre { font-weight: 700; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
  .prod-card .pc-meta { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
  .prod-card .pc-pie { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; margin-top: 4px; }
  .prod-card .pc-precio .prod-precio { font-size: 16px; color: var(--v1); }
  .prod-pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
  .prod-pager button { margin: 0 !important; width: auto !important; padding: 8px 14px !important; }
  .prod-pager button:disabled { opacity: .45; cursor: default; }
  @media (max-width: 1180px) {
    #prod-tabla-wrap { display: none; }
    #prod-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    #page-stock .prod-filtros { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    #page-stock .prod-filtros .pf-buscar { grid-column: 1 / -1; }
  }
  @media (max-width: 640px) {
    #prod-cards { grid-template-columns: 1fr; }
    #page-stock .prod-toolbar { display: grid !important; grid-template-columns: 1fr 1fr; width: 100%; }
    #page-stock .prod-toolbar button { width: 100% !important; font-size: 13px; }
    #page-stock .prod-toolbar .btn-primary { grid-column: 1 / -1; }
  }

  /* ── Reportes agrupados (Queluz) ── */
  .rep-agrup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
  @media (max-width: 1100px) { .rep-agrup-grid { grid-template-columns: 1fr; } }
  .rep-agrup-card { min-width: 0; margin: 0 !important; }
  .rep-agrup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
  .rep-agrup-head h3 { font-size: 15px; margin: 0; }
  .rep-agrup-resumen { font-size: 12px; color: var(--muted); margin-top: 3px; }
  .rep-agrup-head button { margin: 0 !important; width: auto !important; padding: 6px 10px !important; font-size: 12px !important; white-space: nowrap; }
  .rep-agrup-body { display: grid; grid-template-columns: minmax(320px, 1.5fr) minmax(230px, 0.8fr); gap: 24px; align-items: start; }
  .rep-agrup-lista { min-width: 0; max-width: 640px; }
  .rep-agrup-panel { display: flex; flex-direction: column; gap: 12px; align-items: center; }
  .rep-agrup-pista { width: 100%; font-size: 11px; color: var(--muted); text-align: center; line-height: 1.45; }
  .rep-evol { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px 6px; margin-bottom: 16px; }
  .rep-evol-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
  .rep-evol-head strong { font-size: 13px; }
  .rep-evol-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
  .rep-evol-head button { margin: 0 !important; width: auto !important; padding: 5px 10px !important; font-size: 11px !important; white-space: nowrap; }
  #rep-evol-canvas { display: block; width: 100%; }
  @media (max-width: 900px) { .rep-agrup-body { grid-template-columns: 1fr; } .rep-agrup-lista { max-width: none; } }
  .rep-agrup-donut { flex: 0 0 auto; display: flex; justify-content: center; }
  @media (max-width: 640px) { .rep-agrup-body { flex-direction: column-reverse; align-items: stretch; } .rep-agrup-donut { flex-basis: auto; } }
  .rep-fila { padding: 8px 0; border-bottom: 1px solid var(--border); }
  .rep-fila:last-child { border-bottom: 0; }
  .rep-fila-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
  .rep-nombre { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
  .rep-nombre i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
  .rep-fila-top strong { white-space: nowrap; }
  .rep-barra { height: 6px; background: #f1f3f5; border-radius: 4px; margin: 5px 0 3px; overflow: hidden; }
  .rep-barra > div { height: 100%; border-radius: 4px; }
  .rep-fila-sub { font-size: 11px; color: var(--muted); }
  .rep-ver-todos { margin: 10px 0 0 !important; width: 100% !important; padding: 7px !important; font-size: 12px !important; }

  /* ── Ticket para compartir: sin tablas, inmune a las reglas generales de la app ── */
  .tk-share { box-sizing: border-box; background: #ffffff; color: #1f2937; font-family: Arial, Helvetica, sans-serif; padding: 24px 22px 20px; line-height: 1.35; text-transform: none; letter-spacing: 0; }
  .tk-share * { box-sizing: border-box; }
  .tk-cabecera { text-align: center; }
  .tk-logo { width: 78px; height: 78px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto 10px; }
  .tk-negocio { font-size: 21px; font-weight: 800; color: #D9480F; letter-spacing: 0.3px; }
  .tk-sub { font-size: 12px; color: #6b7280; margin-top: 2px; }
  .tk-datos { font-size: 11px; color: #6b7280; margin-top: 7px; line-height: 1.5; }
  .tk-banda { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 16px 0 12px; padding: 10px 14px; background: #D9480F; color: #ffffff; border-radius: 10px; }
  .tk-banda-etq { font-size: 10px; letter-spacing: 1px; opacity: 0.9; }
  .tk-banda-val { font-size: 17px; font-weight: 800; white-space: nowrap; }
  .tk-bloque { margin-bottom: 12px; }
  .tk-fila { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 0; border-bottom: 1px solid #eef0f3; font-size: 12px; }
  .tk-fila:last-child { border-bottom: 0; }
  .tk-etq { color: #6b7280; flex: 0 0 auto; }
  .tk-val { font-weight: 700; text-align: right; min-width: 0; overflow-wrap: anywhere; }
  .tk-fila-chica { color: #4b5563; border-bottom: 0; padding: 3px 0; }
  .tk-detalle-cab { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; border-bottom: 2px solid #D9480F; padding: 0 2px 5px; font-size: 12px; font-weight: 800; color: #D9480F; letter-spacing: 0.8px; }
  .tk-detalle-cant { font-size: 11px; font-weight: 400; color: #6b7280; letter-spacing: 0; }
  .tk-item { padding: 9px 10px; border-bottom: 1px solid #eef0f3; page-break-inside: avoid; break-inside: avoid; }
  .tk-alt { background: #fafafa; }
  .tk-item-nombre { font-size: 13px; font-weight: 700; line-height: 1.3; color: #111827; overflow-wrap: anywhere; }
  .tk-item-linea { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 4px; }
  .tk-item-det { font-size: 12px; color: #4b5563; min-width: 0; overflow-wrap: anywhere; }
  .tk-item-total { font-size: 13px; font-weight: 800; color: #111827; white-space: nowrap; flex: 0 0 auto; }
  .tk-total { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; padding: 12px 14px; background: #fff4ec; border: 1px solid #fbd5b5; border-radius: 10px; }
  .tk-total-etq { font-size: 15px; font-weight: 800; color: #111827; }
  .tk-total-val { font-size: 24px; font-weight: 800; color: #D9480F; white-space: nowrap; }
  .tk-pie { margin-top: 16px; padding-top: 12px; border-top: 1px dashed #d1d5db; text-align: center; }
  .tk-pie-leyenda { font-size: 10px; color: #9ca3af; letter-spacing: 0.8px; }
  .tk-pie-gracias { font-size: 13px; font-weight: 700; color: #374151; margin-top: 6px; }
  /* Modal del ticket */
  .tk-vista { display: flex; justify-content: center; background: #f3f0ec; padding: 14px; border-radius: 10px; }
  .tk-vista-papel { width: 100%; max-width: 420px; box-shadow: 0 2px 12px rgba(0,0,0,.08); border-radius: 8px; overflow: hidden; }
  .tk-acciones { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
  .tk-acciones button { margin: 0 !important; width: 100% !important; padding: 11px 8px !important; font-weight: 700; white-space: nowrap; }
  .tk-btn-wa { background: #25D366 !important; border-color: #25D366 !important; color: #ffffff !important; }
  .tk-panel-wa { margin-top: 12px; padding: 12px; border: 1px solid #b7ebc9; background: #f0fbf4; border-radius: 10px; }
  .tk-panel-wa label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
  .tk-panel-wa-fila { display: flex; gap: 8px; }
  .tk-panel-wa-fila input { flex: 1; min-width: 0; margin: 0; height: 42px; }
  .tk-panel-wa-fila button { margin: 0 !important; width: auto !important; padding: 0 14px !important; height: 42px; white-space: nowrap; font-weight: 700; }
  .tk-panel-wa-ayuda { font-size: 11px; color: var(--muted); margin-top: 6px; }
  @media (max-width: 520px) {
    .tk-acciones { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tk-panel-wa-fila { flex-direction: column; }
    .tk-panel-wa-fila button { width: 100% !important; }
  }

  /* Menú lateral compacto en pantallas bajas: que Caja y Compras no queden tapadas */
  @media (min-width: 769px) and (max-height: 780px) {
    .sidebar { padding-top: 14px !important; padding-bottom: 10px !important; }
    .sidebar-brand { padding-bottom: 10px !important; margin-bottom: 8px !important; }
    .sidebar .nav-btn { padding: 7px 12px !important; margin-bottom: 2px !important; font-size: 13px; }
    .sidebar-footer { padding-top: 8px !important; margin-top: 4px !important; }
    .sidebar-footer .user-info { padding: 6px 10px !important; }
    .sidebar-footer .logout-btn { padding-top: 6px !important; padding-bottom: 6px !important; }
  }

  /* Caja: selector del administrador */
  .caja-selector { padding: 12px 14px !important; margin-bottom: 14px; }
  .caja-selector-fila { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .caja-selector-fila select { flex: 1; min-width: 220px; margin: 0; height: 40px; }
  .caja-aviso-lectura { margin-top: 10px; padding: 8px 12px; background: #fff4e0; color: #8a4b00; border: 1px solid #f7d49b; border-radius: 8px; font-size: 13px; }

  /* Historial: detalle de una caja */
  .hc-cab { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-bottom: 12px; }
  .hc-cab h3 { text-align: center; }
  .hc-cab button { margin: 0 !important; width: auto !important; padding: 7px 12px !important; }
  .hc-datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin-bottom: 10px; }
  .hc-dato { background: var(--bg); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
  .hc-dato span { color: var(--muted); }
  .hc-dato b { font-size: 14px; }
  .hc-fp { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; margin-bottom: 10px; }
  .hc-movs { max-height: 50vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
  .hc-movs th, .hc-movs td { padding: 7px 8px; }
  .hc-movs thead th { position: sticky; top: 0; }

  /* Comprobante A4 (descarga e impresión en A4) */
  .a4-doc { width: 703px; box-sizing: border-box; background: #fff; color: #1f2937; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 1.4; }
  .a4-doc * { box-sizing: border-box; }
  .a4-doc th, .a4-doc td { white-space: normal !important; overflow: visible !important; text-overflow: clip !important; }
  .a4-cab { display: flex; justify-content: space-between; align-items: stretch; gap: 16px; border: 1.5px solid #D9480F; border-radius: 10px; padding: 16px 18px; }
  .a4-emisor { display: flex; gap: 14px; align-items: center; min-width: 0; }
  .a4-logo { width: 66px; height: 66px; border-radius: 50%; flex: 0 0 auto; }
  .a4-negocio { font-size: 20px; font-weight: 800; color: #D9480F; }
  .a4-sub { font-size: 12px; color: #6b7280; margin: 1px 0 4px; }
  .a4-linea { font-size: 11.5px; color: #374151; }
  .a4-comp { text-align: right; border-left: 1px dashed #f0b58f; padding-left: 18px; display: flex; flex-direction: column; justify-content: center; gap: 3px; flex: 0 0 auto; }
  .a4-comp-tipo { font-size: 22px; font-weight: 800; color: #111827; letter-spacing: 1px; }
  .a4-comp-nro { font-size: 15px; font-weight: 700; color: #D9480F; }
  .a4-cliente { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr; gap: 10px; margin: 12px 0; padding: 10px 14px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; }
  .a4-cliente div { display: flex; flex-direction: column; min-width: 0; }
  .a4-cliente span { font-size: 10px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.5px; }
  .a4-cliente b { font-size: 12.5px; overflow-wrap: anywhere; }
  .a4-items { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .a4-items thead th { background: #fff4ec; color: #9a3412; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; text-align: left; padding: 8px 8px; border-bottom: 2px solid #D9480F; }
  .a4-items tbody td { padding: 7px 8px; border-bottom: 1px solid #e5e7eb; vertical-align: top; font-size: 12px; }
  .a4-items tbody tr:nth-child(even) td { background: #fcfcfd; }
  .a4-items tr { page-break-inside: avoid; break-inside: avoid; }
  .a4-cod { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px !important; overflow-wrap: anywhere; }
  .a4-desc { overflow-wrap: anywhere; }
  .a4-num { text-align: right !important; white-space: nowrap !important; }
  .a4-fuerte { font-weight: 700; }
  .a4-dto { color: #b42318; }
  .a4-pie-tabla { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-top: 12px; page-break-inside: avoid; break-inside: avoid; }
  .a4-resumen-cant { font-size: 11px; color: #6b7280; padding-top: 6px; }
  .a4-totales { width: 280px; flex: 0 0 auto; }
  .a4-tot-fila { display: flex; justify-content: space-between; gap: 12px; padding: 4px 2px; font-size: 12px; }
  .a4-tot-fila.a4-total { margin: 4px 0; padding: 10px 12px; background: #D9480F; color: #fff; border-radius: 8px; font-size: 17px; font-weight: 800; }
  .a4-tot-fila.a4-chica { font-size: 11px; color: #4b5563; }
  .a4-leyenda { margin-top: 18px; padding-top: 10px; border-top: 1px dashed #d1d5db; text-align: center; font-size: 10.5px; color: #6b7280; letter-spacing: 0.5px; }
  @media print { .a4-doc { width: 100% !important; } }

  .a4-salto { page-break-before: always; break-before: page; }
  .a4-continua { font-size: 11px; color: #6b7280; padding: 0 2px 8px; margin-bottom: 8px; border-bottom: 1px solid #f0b58f; }

  /* Reportes: barra de filtros fija y resumen de período */
  .rep-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 14px; border-bottom: 1px solid var(--border); }
  .rep-tab { background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
             font: inherit; font-size: 13px; padding: 8px 12px; cursor: pointer; border-radius: 6px 6px 0 0; }
  .rep-tab:hover { color: var(--text); background: rgba(0,0,0,0.03); }
  .rep-tab.activo { color: var(--v1); border-bottom-color: var(--v1); font-weight: 600; }
  .rep-fila { cursor: pointer; border-radius: 6px; padding: 2px 4px; }
  .rep-fila.activa { background: rgba(217,72,15,0.10); box-shadow: inset 3px 0 0 var(--v1); }
  #rep-donut { cursor: pointer; }
  .rep-fila:hover, .rep-fila:focus-visible { background: rgba(217,72,15,0.06); outline: none; }
  #rep-tooltip { position: fixed; z-index: 9999; pointer-events: none; display: none; max-width: 260px;
                 background: #1f2937; color: #fff; border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.45;
                 box-shadow: 0 8px 24px rgba(0,0,0,.25); }
  #rep-tooltip b { color: #fff; }
  /* Aviso de versión nueva */
  .aviso-version { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 100000;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
    background: #1f2937; color: #fff; border-radius: 12px; padding: 12px 16px; font-size: 13px;
    box-shadow: 0 10px 30px rgba(0,0,0,.3); max-width: calc(100vw - 24px); }
  .aviso-version b { color: #fff; }
  .aviso-version button { margin: 0 !important; width: auto !important; border: 0; border-radius: 999px;
    cursor: pointer; font: inherit; font-size: 12px; padding: 7px 14px; }
  .aviso-version .av-ok { background: var(--v2); color: #fff; font-weight: 600; }
  .aviso-version .av-no { background: rgba(255,255,255,.16); color: #fff; }
  #rep-tooltip .tt-dato { color: #d1d5db; }
  .rep-topbar { position: sticky; top: 0; z-index: 30; padding: 12px 14px; margin-bottom: 16px; }
  .rep-topbar-fila { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
  .rep-periodo { margin-top: 8px; font-size: 12px; color: var(--muted); }
  .rep-periodo b { color: var(--text); }
  .rep-tira { display: flex; gap: 18px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 16px;
              font-size: 12px; color: var(--muted); }
  .rep-tira b { color: var(--text); font-size: 13px; }
  @media (max-width: 780px) { .rep-topbar { position: static; } }

  /* Queluz: el ticket no es factura, pero se muestra el IVA discriminado para control */

  /* ═══════════ MOBILE RESPONSIVE ═══════════ */

  /* Botón hamburguesa - oculto en desktop */
  .mobile-menu-btn {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    background: var(--v2);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    align-items: center;
    justify-content: center;
  }

  /* Backdrop oscuro detrás del sidebar abierto en mobile */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
  }
  .sidebar-backdrop.open {
    display: block;
  }

  /* Clase utilitaria para ocultar en mobile */
  .hide-mobile { /* visible por default */ }

  /* Clase utilitaria: visible solo en mobile (oculta en desktop) */
  .solo-mobile { display: none !important; }

  /* Botones sticky dentro de un modal (siempre visibles al hacer scroll) */
  .modal-botones-sticky {
    position: sticky;
    bottom: -80px;
    left: 0;
    right: 0;
    margin: 18px -24px -80px;
    padding: 12px 24px;
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
    z-index: 10;
  }

  @media (max-width: 768px) {
    /* Layout en mobile: 1 columna */
    .layout { grid-template-columns: 1fr; }

    /* Mostrar botón hamburguesa */
    .mobile-menu-btn {
      display: flex;
    }

    /* Sidebar deslizable desde la izquierda */
    .sidebar {
      position: fixed;
      top: 0;
      left: 0;
      bottom: 0;
      width: 280px;
      max-width: 80vw;
      transform: translateX(-100%);
      transition: transform 0.3s ease;
      z-index: 100;
      box-shadow: 4px 0 20px rgba(0,0,0,0.15);
      display: flex;
      flex-direction: column;
      padding: 20px 16px;
      overflow-y: auto;
    }
    .sidebar.open {
      transform: translateX(0);
    }
    .sidebar-brand {
      display: flex;
      flex-shrink: 0;
      margin-bottom: 12px;
    }

    /* Sidebar footer ordenado vertical sin encimar */
    .sidebar-footer {
      display: flex !important;
      flex-direction: column;
      gap: 6px;
      margin-top: auto;
      padding-top: 16px;
      border-top: 1px solid rgba(255,255,255,0.15);
      flex-shrink: 0;
    }
    .sidebar-footer .user-info {
      padding: 10px 12px;
      background: rgba(255,255,255,0.08);
      border-radius: 8px;
      font-size: 12px;
      line-height: 1.4;
      margin: 0 0 4px 0 !important;
      word-break: break-word;
    }
    .sidebar-footer .logout-btn {
      width: 100%;
      margin: 0 !important;
      padding: 10px;
      font-size: 13px;
      text-align: center;
    }

    /* Ocultar atajos de teclado en mobile (no aplican) */
    .kbd-hint,
    label[for="auto-print"],
    #auto-print,
    .auto-print-label {
      display: none !important;
    }

    /* Main content ocupa todo el ancho */
    .main {
      margin-left: 0 !important;
      padding: 70px 14px 30px;
    }

    /* Header de cada página */
    .page-header,
    section > div:first-child {
      flex-wrap: wrap;
      gap: 8px;
    }
    .page-title {
      font-size: 1.25rem !important;
      padding-left: 50px;
      margin-bottom: 0 !important;
    }

    /* POS grid: 1 columna apilada */
    .pos-grid {
      grid-template-columns: 1fr;
      gap: 12px;
    }
    .pos-right {
      position: static;
      order: 2;
    }

    /* Cards más compactas */
    .card {
      padding: 14px;
    }

    /* Datos del cliente: TODO apilado vertical en mobile */
    #cliente-section .row {
      display: flex !important;
      flex-direction: column !important;
      gap: 10px !important;
      flex-wrap: nowrap !important;
    }
    #cliente-section .row > div {
      width: 100% !important;
      max-width: 100% !important;
      min-width: 0 !important;
      flex: none !important;
      box-sizing: border-box !important;
    }
    #cliente-section .row > div button {
      width: 100% !important;
    }
    #cliente-section input,
    #cliente-section select {
      width: 100% !important;
      box-sizing: border-box !important;
    }

    /* RUBROS como SELECT desplegable en mobile */
    .rubros-grid {
      display: none !important;
    }
    .rubros-mobile-select {
      display: block !important;
      margin-bottom: 12px;
    }

    /* Producto/agregar item: layout más compacto */
    .card .row {
      flex-wrap: wrap;
      gap: 10px;
    }

    /* Inputs amigables al toque */
    input, select, textarea {
      font-size: 16px;
      padding: 11px 12px;
    }

    /* 📅 Fecha en mobile: forzar mismas medidas exactas que el resto de inputs */
    /* (los inputs date de iOS tienen padding interno que los hace más altos) */
    #fecha-comprobante,
    input[type="date"] {
      width: 100% !important;
      max-width: 100% !important;
      height: 44px !important;
      min-height: 44px !important;
      max-height: 44px !important;
      font-size: 16px !important;
      padding: 0 12px !important;
      font-weight: normal !important;
      box-sizing: border-box !important;
      line-height: 44px !important;
      -webkit-appearance: none !important;
      appearance: none !important;
    }
    /* Igualar también el select de Tipo Doc para que matcheen */
    #doc-tipo,
    #cliente-section select {
      height: 44px !important;
      min-height: 44px !important;
      max-height: 44px !important;
      padding: 0 12px !important;
      box-sizing: border-box !important;
    }

    /* 📄 Filtros de Facturas (Desde / Hasta / botones) — apilados en mobile */
    #page-facturas .row {
      display: flex !important;
      flex-direction: column !important;
      gap: 10px !important;
    }
    #page-facturas .row > div {
      width: 100% !important;
      max-width: 100% !important;
      flex: none !important;
      align-self: stretch !important;
    }
    #page-facturas .row > div button {
      flex: 1;
      min-width: 0;
    }
    /* La fila de botones (Filtrar / Restablecer / Excel) en una sola línea con scroll si no entran */
    #page-facturas .row > div[style*="align-self"] {
      flex-wrap: wrap !important;
      gap: 6px !important;
    }

    button, .btn, .btn-primary, .btn-secondary {
      min-height: 44px;
    }

    /* Tablas con scroll horizontal */
    .table-wrap {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }
    table {
      font-size: 13px;
      min-width: 100%;
    }

    /* Modal */
    .modal {
      max-width: 95%;
      width: 95%;
      padding: 16px;
      padding-bottom: 90px; /* espacio para los botones sticky */
      max-height: 88vh;
      max-height: 88dvh; /* dynamic viewport - corrige iOS Safari */
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }
    .modal-overlay {
      align-items: flex-start;
      padding-top: 3vh;
      padding-top: 3dvh;
    }

    /* Stats grid en 2 columnas */
    .stats-grid {
      grid-template-columns: 1fr 1fr;
    }

    /* Charts más bajitos */
    canvas {
      max-height: 220px !important;
    }

    /* Tipo de comprobante: scroll horizontal si no entra */
    .tipo-cbte-tabs {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      flex-wrap: nowrap !important;
    }
    .tipo-cbte-tab {
      white-space: nowrap;
      flex-shrink: 0;
    }

    /* Login */
    .login-card {
      width: 92% !important;
      max-width: 380px !important;
      padding: 30px 24px !important;
    }

    /* Ocultar la clase global hide-mobile */
    .hide-mobile {
      display: none !important;
    }

    /* Mostrar la clase solo-mobile (oculta en desktop, visible en mobile) */
    .solo-mobile {
      display: flex !important;
    }
  }

  /* Mostrar el select mobile solo en mobile */
  .rubros-mobile-select {
    display: none;
  }

  /* Pantallas muy chicas (iPhone SE etc.) */
  @media (max-width: 380px) {
    .main { padding: 70px 10px 30px; }
    .card { padding: 12px; }
    .page-title { font-size: 1.1rem !important; }
  }
