/* TechService Pro — estilos principales */
  :root {
    --bg: #0a0b0f;
    --bg2: #111318;
    --bg3: #181b22;
    --card: #1c1f28;
    --border: #252933;
    --accent: #f0a500;
    --accent2: #ff6b35;
    --accent3: #00d4aa;
    --text: #e8eaf0;
    --text2: #8b8fa8;
    --text3: #5a5e72;
    --danger: #ff4757;
    --success: #2ed573;
    --info: #1e90ff;
    --purple: #a855f7;
    --sidebar-w: 260px;
    --radius: 12px;
    --radius-sm: 8px;
  }

  /* ===== LIGHT THEME ===== */
  body.light {
    --bg:      #eef0f8;
    --bg2:     #f5f6fc;
    --bg3:     #e4e7f2;
    --card:    #ffffff;
    --border:  #d0d5e8;
    --accent:  #c97000;
    --accent2: #d44d12;
    --accent3: #008f6e;
    --text:    #191c2e;
    --text2:   #505778;
    --text3:   #8f97b8;
    --danger:  #d92f3f;
    --success: #159c4a;
    --info:    #1260c8;
    --purple:  #7228d8;
  }
  body.light .login-grid {
    border: 1px solid var(--border);
  }
  body.light #login-screen {
    background-image:
      radial-gradient(ellipse 80% 60% at 20% 80%, rgba(201,112,0,0.10) 0%, transparent 60%),
      radial-gradient(ellipse 60% 80% at 80% 20%, rgba(0,143,110,0.08) 0%, transparent 60%);
  }
  body.light .sidebar {
    border-right: 1px solid var(--border);
  }
  body.light .topbar {
    border-bottom: 1px solid var(--border);
  }
  body.light .modal {
    border: 1px solid var(--border);
  }
  body.light .modal-overlay {
    background: rgba(20,25,60,0.45);
  }
  body.light .table-card,
  body.light .stat-card,
  body.light .rs-card {
    border-color: rgba(0,10,60,0.12);
  }
  body.light .nav-item:hover,
  body.light .nav-item.active {
    background: rgba(201,112,0,0.10);
  }
  body.light .badge-efectivo     { background: rgba(21,156,74,0.13);  color: var(--success); }
  body.light .badge-tarjeta      { background: rgba(18,96,200,0.12);  color: var(--info); }
  body.light .badge-transferencia{ background: rgba(114,40,216,0.11); color: var(--purple); }
  body.light .badge-credito      { background: rgba(201,112,0,0.13);  color: var(--accent); }
  body.light .badge-mixto        { background: rgba(212,77,18,0.12);  color: var(--accent2); }
  body.light .sp-pending    { background: rgba(201,112,0,0.13);  color: var(--accent); }
  body.light .sp-done       { background: rgba(21,156,74,0.13);  color: var(--success); }
  body.light .sp-progress   { background: rgba(18,96,200,0.12);  color: var(--info); }
  body.light .sp-delivered  { background: rgba(0,143,110,0.12);  color: var(--accent3); }
  body.light .sp-cancelled  { background: rgba(217,47,63,0.12);  color: var(--danger); }
  body.light .f-input,
  body.light .f-select,
  body.light .filter-select,
  body.light .form-input {
    background: var(--card);
    border-color: var(--border);
    color: var(--text);
  }
  body.light .f-input:focus,
  body.light .f-select:focus,
  body.light .filter-select:focus,
  body.light .form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(201,112,0,0.12);
  }
  body.light .btn-outline {
    border-color: var(--border);
    color: var(--text2);
  }
  body.light .btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(201,112,0,0.06);
  }
  body.light .pos-pay-btn {
    background: var(--bg3);
    border-color: var(--border);
  }
  body.light .pos-pay-btn.selected {
    background: rgba(201,112,0,0.12);
    border-color: var(--accent);
    color: var(--accent);
  }
  body.light .cfg-collapse {
    border-color: rgba(0,10,60,0.10);
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }

  html, body { height: 100%; overflow: hidden; }

  body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
  }

  /* ===== LOGIN ===== */
  #login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg);
    background-image: 
      radial-gradient(ellipse 80% 60% at 20% 80%, rgba(240,165,0,0.08) 0%, transparent 60%),
      radial-gradient(ellipse 60% 80% at 80% 20%, rgba(0,212,170,0.06) 0%, transparent 60%);
  }

  .login-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: 900px;
    width: 90%;
    min-height: 520px;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 40px 80px rgba(0,0,0,0.6);
  }

  .login-brand {
    background: linear-gradient(135deg, #0d0e14 0%, #1a1d28 100%);
    padding: 60px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
  }

  .login-brand::before {
    content: '';
    position: absolute;
    width: 300px; height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(240,165,0,0.15) 0%, transparent 70%);
    top: -80px; left: -80px;
  }

  .login-brand::after {
    content: '';
    position: absolute;
    width: 200px; height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0,212,170,0.1) 0%, transparent 70%);
    bottom: -40px; right: -40px;
  }

  .brand-logo {
    font-family: 'Syne', sans-serif;
    font-size: 32px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -1px;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
  }

  .brand-logo span { color: var(--text); }

  .brand-tagline {
    font-size: 14px;
    color: var(--text2);
    line-height: 1.7;
    position: relative;
    z-index: 1;
    max-width: 240px;
  }

  .brand-stats {
    display: flex;
    gap: 24px;
    margin-top: 48px;
    position: relative;
    z-index: 1;
  }

  .brand-stat { text-align: left; }
  .brand-stat-num {
    font-family: 'Syne', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
  }
  .brand-stat-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }

  .login-form-area {
    background: var(--bg2);
    padding: 60px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .login-form-area h2 {
    font-family: 'Syne', sans-serif;
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 8px;
  }
  .login-form-area p { font-size: 14px; color: var(--text2); margin-bottom: 36px; }

  .form-group { margin-bottom: 20px; }
  .form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
  }

  .input-wrap {
    position: relative;
  }

  .input-wrap i.icon-left {
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--text3);
    font-size: 14px;
  }

  .form-input {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 13px 42px 13px 40px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
    outline: none;
  }

  .form-input:focus {
    border-color: var(--accent);
    background: var(--card);
    box-shadow: 0 0 0 3px rgba(240,165,0,0.1);
  }

  .toggle-pass {
    position: absolute;
    right: 14px; top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    transition: color 0.2s;
  }
  .toggle-pass:hover { color: var(--accent); }

  .btn-primary {
    width: 100%;
    background: var(--accent);
    color: #0a0b0f;
    border: none;
    border-radius: var(--radius-sm);
    padding: 14px;
    font-family: 'Syne', sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
    letter-spacing: 0.3px;
    margin-top: 8px;
  }
  .btn-primary:hover { background: #ffc107; transform: translateY(-1px); box-shadow: 0 8px 20px rgba(240,165,0,0.3); }
  .btn-primary:active { transform: translateY(0); }

  .login-hint { font-size: 12px; color: var(--text3); text-align: center; margin-top: 16px; }

  /* ===== APP SHELL ===== */
  #app {
    display: none;
    height: 100vh;
    overflow: hidden;
  }

  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
  }

  .sidebar-logo {
    padding: 28px 24px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .sidebar-logo .brand {
    font-family: 'Syne', sans-serif;
    font-size: 20px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.5px;
  }
  .sidebar-logo .brand span { color: var(--text); }
  .sidebar-logo .sub { font-size: 11px; color: var(--text3); margin-top: 2px; text-transform: uppercase; letter-spacing: 1px; }

  .sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    overflow-y: auto;
  }

  .nav-section-label {
    font-size: 10px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 0 12px;
    margin: 20px 0 8px;
    font-weight: 600;
  }
  .nav-section-label:first-child { margin-top: 0; }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    color: var(--text2);
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    margin-bottom: 2px;
    border: 1px solid transparent;
    text-decoration: none;
  }

  .nav-item i { width: 18px; font-size: 15px; flex-shrink: 0; }

  .nav-item:hover { background: var(--bg3); color: var(--text); }

  .nav-item.active {
    background: rgba(240,165,0,0.12);
    color: var(--accent);
    border-color: rgba(240,165,0,0.2);
    font-weight: 500;
  }

  .nav-item .badge {
    margin-left: auto;
    background: var(--accent);
    color: #0a0b0f;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
  }

  .sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
  }

  .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
  }

  .user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: #0a0b0f;
    flex-shrink: 0;
  }

  .user-name { font-size: 13px; font-weight: 500; }
  .user-role { font-size: 11px; color: var(--text3); }

  .btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(255,71,87,0.1);
    border: 1px solid rgba(255,71,87,0.2);
    color: var(--danger);
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.15s;
  }
  .btn-logout:hover { background: rgba(255,71,87,0.2); }

  /* ===== MAIN CONTENT ===== */
  .main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .topbar {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 50;
  }

  /* ===== NOTIFICATION FILTER BANNER ===== */
  .notif-filter-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    background: linear-gradient(90deg, rgba(201,112,0,0.14), rgba(201,112,0,0.06));
    border-bottom: 1px solid rgba(201,112,0,0.35);
    color: var(--text);
    font-size: 13px;
    flex-shrink: 0;
    animation: nfbSlideIn 0.22s ease-out;
  }
  .notif-filter-banner[hidden] { display: none !important; }

  @keyframes nfbSlideIn {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
  }

  .nfb-icon {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent); color: #fff;
    border-radius: 8px;
    font-size: 13px;
    flex-shrink: 0;
  }
  .nfb-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
  }
  .nfb-label {
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    line-height: 1.2;
  }
  .nfb-detail {
    font-size: 11.5px;
    color: var(--text2);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .nfb-close {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid rgba(201,112,0,0.5);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    flex-shrink: 0;
  }
  .nfb-close:hover {
    background: rgba(201,112,0,0.12);
    border-color: var(--accent);
  }
  .nfb-close i { font-size: 11px; }

  @media (max-width: 600px) {
    .notif-filter-banner { padding: 8px 14px; gap: 10px; }
    .nfb-close span { display: none; }
    .nfb-close { padding: 6px 10px; }
  }

  /* Filas resaltadas por alerta de notificación */
  tbody tr.row-alerted {
    background: linear-gradient(90deg, rgba(201,112,0,0.10), transparent 70%);
    box-shadow: inset 3px 0 0 var(--accent);
    position: relative;
  }
  tbody tr.row-alerted:hover {
    background: linear-gradient(90deg, rgba(201,112,0,0.18), rgba(201,112,0,0.04) 70%);
  }
  tbody tr.row-alerted td:first-child::before {
    content: "";
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
    margin-right: 6px;
    vertical-align: middle;
    box-shadow: 0 0 0 3px rgba(201,112,0,0.18);
    animation: rowAlertPulse 1.6s ease-in-out infinite;
  }
  @keyframes rowAlertPulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(201,112,0,0.18); }
    50%      { box-shadow: 0 0 0 5px rgba(201,112,0,0.08); }
  }

  .topbar-title {
    font-family: 'Syne', sans-serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
  }
  .topbar-subtitle {
    font-size: 11px;
    color: var(--text3);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-top: 2px;
  }

  .topbar-actions { display: flex; align-items: center; gap: 12px; }

  .icon-btn {
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text2);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: border-color 0.15s, color 0.15s;
  }
  .icon-btn:hover { border-color: var(--accent); color: var(--accent); }

  .notif-dot { position: relative; }
  .notif-badge {
    position: absolute; top: 4px; right: 4px;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 8px; background: var(--danger);
    color: #fff; font-size: 9px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg2); pointer-events: none;
    line-height: 1;
  }
  .notif-badge.hidden { display: none; }

  /* Notification panel */
  .notif-panel {
    position: fixed; top: 60px; right: 14px; z-index: 1200;
    width: 360px; max-height: calc(100vh - 80px);
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 8px 32px rgba(0,0,0,0.28);
    display: flex; flex-direction: column; overflow: hidden;
  }
  .notif-panel-header {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    background: var(--bg3);
  }
  .notif-panel-header h4 { margin: 0; font-size: 14px; font-weight: 700; flex: 1; }
  .notif-panel-body { overflow-y: auto; flex: 1; }
  .notif-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background 0.1s;
  }
  .notif-item:hover { background: var(--bg3); }
  .notif-item:last-child { border-bottom: none; }
  .notif-icon {
    width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 15px;
  }
  .notif-icon.alta    { background: rgba(255,71,87,0.12);  color: var(--danger); }
  .notif-icon.media   { background: rgba(240,165,0,0.12);  color: var(--accent); }
  .notif-icon.baja    { background: rgba(30,144,255,0.12); color: var(--info); }
  .notif-item-body { flex: 1; min-width: 0; }
  .notif-item-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
  .notif-item-detail { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .notif-item-count {
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: 12px; padding: 2px 8px; font-size: 11px;
    font-weight: 700; color: var(--text2); flex-shrink: 0; align-self: center;
  }
  .notif-item-dismiss {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text3);
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0; align-self: center;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    font-size: 11px;
    padding: 0;
  }
  .notif-item-dismiss:hover {
    background: rgba(255,71,87,0.12);
    color: var(--danger);
    border-color: rgba(255,71,87,0.35);
  }
  .notif-empty { padding: 32px 16px; text-align: center; color: var(--text3); }
  .notif-panel-footer {
    padding: 10px 16px; border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg3);
  }

  /* Notif config in accordion */
  .notif-estado-row {
    display: grid; grid-template-columns: 1fr auto auto; align-items: center;
    gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border);
  }
  .notif-estado-row:last-child { border-bottom: none; }
  .notif-estado-row .estado-label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
  .notif-horas-input { width: 72px; text-align: center; padding: 6px 8px; font-size: 13px; }

  .page { display: none; }
  .page.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 32px;
  }
  .page-header { flex-shrink: 0; }
  .page-content {
    flex: 1;
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .page-content > .table-card { flex: 1; min-height: 0; }

  /* Suppress transitions during page/panel show to prevent flickering */
  .notransition,
  .notransition * {
    transition: none !important;
  }

  /* ===== DASHBOARD ===== */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
  }

  .stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.2s;
  }
  .stat-card:hover { border-color: var(--accent); transform: translateY(-2px); }

  .stat-card::before {
    content: '';
    position: absolute;
    right: -20px; top: -20px;
    width: 80px; height: 80px;
    border-radius: 50%;
    opacity: 0.06;
  }

  .stat-card.orange::before { background: var(--accent); }
  .stat-card.teal::before { background: var(--accent3); }
  .stat-card.red::before { background: var(--danger); }
  .stat-card.purple::before { background: var(--purple); }

  .stat-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    margin-bottom: 16px;
  }
  .stat-icon.orange { background: rgba(240,165,0,0.15); color: var(--accent); }
  .stat-icon.teal { background: rgba(0,212,170,0.15); color: var(--accent3); }
  .stat-icon.red { background: rgba(255,71,87,0.15); color: var(--danger); }
  .stat-icon.purple { background: rgba(168,85,247,0.15); color: var(--purple); }

  .stat-value {
    font-family: 'Syne', sans-serif;
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    margin-bottom: 6px;
  }

  .stat-label { font-size: 13px; color: var(--text2); margin-bottom: 12px; }

  .stat-change {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .stat-change.up { color: var(--success); }
  .stat-change.down { color: var(--danger); }

  .dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
  }

  /* Dashboard configurable: grid de 4 columnas + cards con span 1-4. */
  .dash-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }
  .dash-card-wrap {
    position: relative;
    min-height: 80px;
  }
  .dash-card-wrap[data-span="1"] { grid-column: span 1; }
  .dash-card-wrap[data-span="2"] { grid-column: span 2; }
  .dash-card-wrap[data-span="3"] { grid-column: span 3; }
  .dash-card-wrap[data-span="4"] { grid-column: span 4; }
  /* Modo edición: borde discontinuo + cursor de movimiento + controles visibles */
  body.dash-editing .dash-card-wrap {
    outline: 2px dashed rgba(168,85,247,0.4);
    outline-offset: -4px;
    border-radius: var(--radius);
    cursor: grab;
  }
  body.dash-editing .dash-card-wrap:hover {
    outline-color: #a855f7;
  }
  body.dash-editing .dash-card-wrap.dragging {
    opacity: 0.4;
    cursor: grabbing;
  }
  body.dash-editing .dash-card-wrap.drag-over {
    outline-color: #00d4aa;
    background: rgba(0,212,170,0.06);
  }
  .dash-card-controls {
    position: absolute;
    top: 6px;
    right: 6px;
    display: none;
    gap: 4px;
    z-index: 10;
  }
  body.dash-editing .dash-card-controls { display: flex; }
  .dash-card-controls button {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: none;
    background: var(--bg2);
    color: var(--text2);
    cursor: pointer;
    font-size: 11px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  }
  .dash-card-controls button:hover { color: #a855f7; background: var(--bg3); }
  .dash-card-controls button.btn-remove:hover { color: #ef4444; }

  @media (max-width: 1100px) {
    .dash-cards-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-card-wrap[data-span="3"], .dash-card-wrap[data-span="4"] { grid-column: span 2; }
  }
  @media (max-width: 640px) {
    .dash-cards-grid { grid-template-columns: 1fr; gap: 12px; }
    .dash-card-wrap, .dash-card-wrap[data-span="2"], .dash-card-wrap[data-span="3"], .dash-card-wrap[data-span="4"] { grid-column: span 1; }
  }

  .widget {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: clip;
  }

  .widget-header {
    padding: 20px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
  }

  .widget-title {
    font-family: 'Syne', sans-serif;
    font-size: 15px;
    font-weight: 700;
  }

  .widget-badge {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
  }
  .wb-orange { background: rgba(240,165,0,0.15); color: var(--accent); }
  .wb-teal { background: rgba(0,212,170,0.15); color: var(--accent3); }

  .chart-area {
    padding: 20px 24px 24px;
  }

  /* Simple bar chart via CSS */
  .bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 140px;
  }

  .bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    height: 100%;
    justify-content: flex-end;
  }

  .bar {
    width: 100%;
    border-radius: 6px 6px 0 0;
    background: var(--accent);
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
    cursor: pointer;
    position: relative;
  }
  .bar:hover { opacity: 1; transform: scaleY(1.03); transform-origin: bottom; }
  .bar.teal { background: var(--accent3); }

  .bar-label { font-size: 10px; color: var(--text3); }

  .recent-list { padding: 0 24px 24px; }

  .recent-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
  }
  .recent-item:last-child { border-bottom: none; }

  .ri-avatar {
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    background: var(--bg3);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    color: var(--accent);
    flex-shrink: 0;
  }

  .ri-name { font-size: 13px; font-weight: 500; }
  .ri-sub { font-size: 11px; color: var(--text2); margin-top: 2px; }
  .ri-price {
    margin-left: auto;
    font-family: 'Syne', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent3);
  }

  .status-pill {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .sp-pending { background: rgba(240,165,0,0.15); color: var(--accent); }
  .sp-done { background: rgba(46,213,115,0.15); color: var(--success); }
  .sp-progress { background: rgba(30,144,255,0.15); color: var(--info); }
  .sp-delivered { background: rgba(0,212,170,0.15); color: var(--accent3); }
  .sp-cancelled { background: rgba(255,71,87,0.15); color: var(--danger); }

  .status-pill.clickable { cursor: pointer; }
  .status-pill.clickable::after { content: ' ▾'; opacity: 0.6; font-size: 9px; }
  .status-pill.clickable:hover { filter: brightness(1.15); }

  .status-popover {
    position: fixed; z-index: 9999;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    padding: 6px; min-width: 190px; display: none;
  }
  .status-popover.open { display: block; }
  .status-popover-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 6px; cursor: pointer;
    font-size: 13px; color: var(--text2); transition: background 0.12s;
  }
  .status-popover-item:hover { background: var(--bg2); color: var(--text); }
  .status-popover-item.current { opacity: 0.4; cursor: default; pointer-events: none; }
  .status-popover-item .sp-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  }

  .sd-status-selector {
    display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px;
  }
  .sd-status-btn {
    cursor: pointer; padding: 4px 11px; border-radius: 20px; font-size: 10px;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
    border: 2px solid transparent; transition: filter 0.12s, transform 0.1s, border-color 0.12s;
    opacity: 0.45;
  }
  .sd-status-btn:hover { filter: brightness(1.15); opacity: 0.75; transform: scale(1.05); }
  .sd-status-btn.active { opacity: 1; border-color: currentColor; }

  .donut-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 24px;
  }

  .donut-svg { width: 120px; height: 120px; }

  .donut-legend { display: flex; flex-direction: column; gap: 10px; }
  .dl-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
  .dl-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .dl-label { color: var(--text2); }
  .dl-val { font-weight: 600; margin-left: auto; font-size: 13px; }

  /* ===== SERVICES MODULE ===== */
  .page-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
  }

  .btn-accent {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: #0a0b0f;
    border: none;
    border-radius: var(--radius-sm);
    padding: 11px 20px;
    font-family: 'Syne', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
  }
  .btn-accent:hover { background: #ffc107; box-shadow: 0 6px 16px rgba(240,165,0,0.3); }

  .btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: var(--text2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 18px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
  }
  .btn-outline:hover { border-color: var(--accent); color: var(--accent); }

  /* Modal */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 500;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
  }
  .modal-overlay.open { display: flex; }

  .modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 100%;
    max-width: 760px;
    overflow: hidden;
    animation: slideUp 0.25s ease;
  }

  @keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .modal-header {
    padding: 28px 32px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .modal-title {
    font-family: 'Syne', sans-serif;
    font-size: 20px;
    font-weight: 700;
  }

  .modal-close {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text2);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    transition: border-color 0.15s, color 0.15s;
  }
  .modal-close:hover { border-color: var(--danger); color: var(--danger); }

  .modal-body { padding: 28px 32px; }

  .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }

  .form-grid .full { grid-column: 1 / -1; }

  .form-group { display: flex; flex-direction: column; gap: 6px; }

  .f-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.6px;
  }

  .f-input, .f-select, .f-textarea {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
  }

  .f-input:focus, .f-select:focus, .f-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(240,165,0,0.08);
  }

  .f-select { appearance: none; cursor: pointer; }
  .f-select option { background: var(--bg3); }

  .f-textarea { resize: vertical; min-height: 80px; }

  /* Garantia checkboxes */
  .garantia-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
  }

  .garantia-option {
    position: relative;
  }

  .garantia-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  .garantia-label {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
    background: var(--bg3);
    color: var(--text2);
  }

  .garantia-option input:checked + .garantia-label {
    border-color: var(--accent);
    background: rgba(240,165,0,0.1);
    color: var(--accent);
  }

  /* Image upload */
  .img-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    position: relative;
    overflow: hidden;
  }
  .img-upload:hover { border-color: var(--accent); background: rgba(240,165,0,0.03); }
  .img-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
  .img-upload i { font-size: 28px; color: var(--text3); margin-bottom: 8px; display: block; }
  .img-upload p { font-size: 13px; color: var(--text2); }
  .img-upload span { font-size: 11px; color: var(--text3); }

  #preview-img {
    max-height: 80px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: none;
  }

  .modal-footer {
    padding: 20px 32px 28px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
  }

  /* ===== TABLE ===== */
  .table-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .table-toolbar {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    flex-shrink: 0;
  }

  .search-wrap {
    position: relative;
    flex: 1;
    min-width: 240px;
  }

  .search-wrap i {
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--text3);
    font-size: 14px;
  }

  .search-input {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px 10px 40px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
  }
  .search-input:focus { border-color: var(--accent); }

  .filter-select {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    color: var(--text2);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    outline: none;
    cursor: pointer;
  }
  .filter-select:focus { border-color: var(--accent); }
  .filter-select option { background: var(--bg3); }

  .table-wrap { overflow-x: auto; overflow-y: auto; flex: 1; min-height: 0; }

  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
  }

  thead th {
    padding: 14px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
  }
  thead th:hover { color: var(--text); }
  thead th .sort-icon { margin-left: 4px; opacity: 0.4; font-style: normal; }
  thead th[data-sort] { cursor: pointer; user-select: none; }
  thead th[data-sort]:hover { color: var(--accent); }
  thead th[data-sort].sort-active .sort-icon { opacity: 1; color: var(--accent); }

  tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
  }
  tbody tr:last-child { border-bottom: none; }
  tbody tr:hover { background: var(--bg3); }

  tbody td {
    padding: 14px 16px;
    color: var(--text);
    vertical-align: middle;
  }

  .td-name { font-weight: 500; }
  .td-sub { font-size: 11px; color: var(--text2); margin-top: 2px; }

  .td-actions { display: flex; gap: 8px; }

  .act-btn {
    width: 32px; height: 32px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text2);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
  }
  .act-btn.edit:hover { border-color: var(--info); color: var(--info); background: rgba(30,144,255,0.1); }
  .act-btn.del:hover { border-color: var(--danger); color: var(--danger); background: rgba(255,71,87,0.1); }
  .act-btn.view-btn:hover { border-color: var(--accent3); color: var(--accent3); background: rgba(0,212,170,0.1); }
  .act-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(240,165,0,0.08); }

  /* Badges de método de pago */
  .badge-metodo { display:inline-block; padding:3px 9px; border-radius:20px; font-size:11px; font-weight:600; }
  .badge-efectivo     { background:rgba(46,213,115,0.12); color:#2ed573; }
  .badge-tarjeta      { background:rgba(30,144,255,0.12); color:#1e90ff; }
  .badge-transferencia{ background:rgba(168,85,247,0.12); color:#a855f7; }
  .badge-credito      { background:rgba(240,165,0,0.12);  color:#f0a500; }
  .badge-mixto        { background:rgba(255,107,53,0.12); color:#ff6b35; }

  .table-pagination {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text2);
    flex-shrink: 0;
  }

  .pag-btns { display: flex; gap: 4px; }
  .pag-btn {
    width: 32px; height: 32px;
    border-radius: 6px;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text2);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
  }
  .pag-btn:hover:not(:disabled), .pag-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(240,165,0,0.1); }
  .pag-btn.disabled, .pag-btn:disabled { opacity: .35; cursor: not-allowed; pointer-events: none; }
  .pag-btns { flex-wrap: wrap; }

  /* ===== REPORTS ===== */
  .report-filters {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
  }

  .report-filters h3 {
    font-family: 'Syne', sans-serif;
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 16px;
  }

  .filter-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
  }

  .filter-row .form-group { flex: 1; min-width: 160px; }

  .report-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
  }

  .rs-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    position: relative;
    overflow: clip;
  }
  .rs-card::after {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
  }
  .rs-card.income::after { background: var(--success); }
  .rs-card.expenses::after { background: var(--danger); }
  .rs-card.profit::after { background: var(--accent3); }
  .rs-card.services::after { background: var(--purple); }

  .rs-label { font-size: 12px; color: var(--text2); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
  .rs-value {
    font-family: 'Syne', sans-serif;
    font-size: 24px;
    font-weight: 800;
  }
  .rs-card.income .rs-value { color: var(--success); }
  .rs-card.expenses .rs-value { color: var(--danger); }
  .rs-card.profit .rs-value { color: var(--accent3); }
  .rs-card.services .rs-value { color: var(--purple); }

  .report-table-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: clip;
  }

  .rtw-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .rtw-header h3 {
    font-family: 'Syne', sans-serif;
    font-size: 15px;
    font-weight: 700;
  }

  .btn-export {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,212,170,0.1);
    color: var(--accent3);
    border: 1px solid rgba(0,212,170,0.25);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s;
  }
  .btn-export:hover { background: rgba(0,212,170,0.2); }

  /* Confirm dialog */
  .confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 600;
    align-items: center;
    justify-content: center;
  }
  .confirm-overlay.open { display: flex; }

  .confirm-box {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 36px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    animation: slideUp 0.2s ease;
  }

  .confirm-icon {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: rgba(255,71,87,0.1);
    border: 1px solid rgba(255,71,87,0.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    color: var(--danger);
    margin: 0 auto 20px;
  }

  .confirm-box h3 {
    font-family: 'Syne', sans-serif;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
  }
  .confirm-box p { font-size: 13px; color: var(--text2); margin-bottom: 28px; }

  .confirm-actions { display: flex; gap: 12px; justify-content: center; }

  .btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 11px 24px;
    font-family: 'Syne', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s;
  }
  .btn-danger:hover { background: #ff6b7a; }

  /* Toast */
  .toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
  }

  .toast {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    min-width: 280px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    animation: toastIn 0.3s ease;
    pointer-events: all;
  }

  @keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
  }

  /* ── Skeleton / loading ─────────────────────────────────────── */
  @keyframes skel-shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position: 600px 0; }
  }

  /* Pop-in animado para la medalla del tier en el historial del cliente:
     parte invisible y pequeño, hace un sutil "bounce" al aparecer con un
     resplandor del color del tier. */
  @keyframes tier-pop-in {
    0%   { transform: scale(0.3) rotate(-30deg); opacity: 0; filter: brightness(1.6); }
    60%  { transform: scale(1.15) rotate(8deg);  opacity: 1; filter: brightness(1.3); }
    80%  { transform: scale(0.95) rotate(-3deg); }
    100% { transform: scale(1)    rotate(0deg);  opacity: 1; filter: brightness(1); }
  }
  .tier-pop {
    display: inline-flex;
    transform-origin: center;
    animation: tier-pop-in 0.55s cubic-bezier(.4, 1.6, .55, 1);
  }
  .skel-cell {
    height: 12px; border-radius: 4px; display: inline-block; width: 80%;
    background: linear-gradient(90deg, var(--bg3) 25%, color-mix(in srgb, var(--bg3) 60%, var(--bg2)) 50%, var(--bg3) 75%);
    background-size: 1200px 100%;
    animation: skel-shimmer 1.5s infinite linear;
  }
  .skel-row td { padding: 12px 10px; border-top: 1px solid var(--border); }
  .btn-loading { opacity: .7 !important; pointer-events: none !important; }
  .btn-loading i.fa-spin-on-load { animation: spin .7s linear infinite; }

  .toast i { font-size: 16px; }
  .toast.success { border-left: 3px solid var(--success); }
  .toast.success i { color: var(--success); }
  .toast.error { border-left: 3px solid var(--danger); }
  .toast.error i { color: var(--danger); }
  .toast.info { border-left: 3px solid var(--info); }
  .toast.info i { color: var(--info); }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text3); }

  /* ===== HAMBURGER BUTTON ===== */
  .hamburger-btn {
    display: none;
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text2);
    align-items: center; justify-content: center;
    cursor: pointer; font-size: 16px;
    transition: border-color 0.15s, color 0.15s;
    flex-shrink: 0;
  }
  .hamburger-btn:hover { border-color: var(--accent); color: var(--accent); }

  .sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 99;
  }
  .sidebar-overlay.open { display: block; }

  /* ===== CONFIG TABS ===== */
  .config-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    align-items: start;
  }
  .config-sidebar {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 8px;
    position: sticky;
    top: 96px;
  }
  .config-nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 13px; color: var(--text2);
    transition: background-color 0.15s, color 0.15s, border-color 0.15s; border: 1px solid transparent; margin-bottom: 2px;
  }
  .config-nav-item:hover { background: var(--bg3); color: var(--text); }
  .config-nav-item.active {
    background: rgba(240,165,0,0.12); color: var(--accent);
    border-color: rgba(240,165,0,0.2); font-weight: 500;
  }
  .config-nav-item i { width: 18px; font-size: 14px; text-align: center; }
  .config-section { display: none; }

  /* Config tab bar */
  .cfg-tab {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 14px; border-radius: var(--radius-sm);
    border: none; cursor: pointer; font-size: 13px; font-family: inherit;
    font-weight: 500; color: var(--text2); background: transparent;
    transition: background-color 0.15s, color 0.15s, box-shadow 0.15s; white-space: nowrap;
  }
  .cfg-tab:hover { background: var(--bg3); color: var(--text); }
  .cfg-tab.active {
    background: var(--card); color: var(--accent);
    border: 1px solid var(--border);
  }
  .config-section.active { display: block; }

  /* ===== CFG ACCORDION ===== */
  .cfg-collapse {
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--card); margin-bottom: 8px; overflow: hidden;
  }
  .cfg-collapse-header {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 20px; cursor: pointer; user-select: none;
    transition: background 0.15s;
  }
  .cfg-collapse-header:hover { background: var(--bg3); }
  .cfg-collapse-icon {
    width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 15px;
  }
  .cfg-collapse-chevron { color: var(--text3); font-size: 12px; transition: transform 0.3s ease; margin-left: auto; }
  .cfg-collapse.open > .cfg-collapse-header .cfg-collapse-chevron { transform: rotate(180deg); }
  .cfg-collapse-body {
    display: block;
    border-top: 0px solid var(--border);
    padding: 0 24px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.25s ease, border-top-width 0.25s ease;
  }
  .cfg-collapse.open > .cfg-collapse-body {
    max-height: 3000px;
    padding: 24px 24px 20px;
    border-top-width: 1px;
  }
  /* Toggles compactos para configuración del ticket (legacy) */
  .cfg-tk-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text2);
    cursor: pointer;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
  }
  .cfg-tk-toggle:last-child { border-bottom: none; }
  .cfg-tk-toggle input[type="checkbox"] { flex-shrink: 0; }
  .cfg-tk-toggle i { width: 16px; color: var(--text3); font-size: 12px; }
  .cfg-tk-toggle:hover { color: var(--text); }

  /* ===== Permisos granulares: ocultar UI según perm =====
     Cuando un elemento tiene la clase .perm-hidden, no se renderiza.
     El JS aplica/quita esa clase basado en hasPermiso(). */
  .perm-hidden { display: none !important; }
  /* Variante "readonly" para inputs que el user puede ver pero no editar. */
  .perm-readonly { pointer-events: none; opacity: 0.65; background: var(--bg3) !important; }

  /* Defensa: cualquier preview impreso (etiqueta, ticket, folio QR) tiene
     fondo blanco; sus hijos deben tener texto negro aunque el tema sea oscuro.
     Forzamos color heredado en los IDs conocidos para evitar texto invisible. */
  #label-preview, #label-preview *,
  #folio-qr-preview, #folio-qr-preview *,
  #ticket-print-area, #ticket-print-area * {
    color: #000;
  }
  /* Los íconos de los botones del label-modal (FA inside btn-accent) deben
     mantener su color original — los excluimos explícitamente. */
  #label-modal .modal-footer button,
  #label-modal .modal-footer button * {
    color: inherit;
  }

  /* ===== TICKET DESIGNER — tarjetas visuales tipo dashboard ===== */
  .tk-group-title {
    font-size: 11px; font-weight: 700; color: var(--text3);
    text-transform: uppercase; letter-spacing: .05em;
    margin: 18px 0 8px;
    display: flex; align-items: center; gap: 8px;
  }
  .tk-group-title::before {
    content: ''; flex: 1; height: 1px; background: var(--border); margin-right: 6px;
  }
  .tk-group-title::after {
    content: ''; flex: 1; height: 1px; background: var(--border); margin-left: 6px;
  }
  .tk-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
  }
  .tk-card {
    background: var(--bg3);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all .15s;
    display: flex; align-items: center; gap: 10px;
    user-select: none;
    position: relative;
  }
  .tk-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(0,0,0,0.15);
  }
  .tk-card.tk-card-on {
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 8%, var(--bg3)), var(--bg3));
    border-color: var(--accent);
  }
  .tk-card.tk-card-off {
    opacity: 0.55;
  }
  .tk-card-icon {
    width: 34px; height: 34px; border-radius: 8px;
    background: var(--bg2);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    color: var(--text3);
    font-size: 14px;
    transition: all .15s;
  }
  .tk-card.tk-card-on .tk-card-icon {
    background: var(--accent);
    color: #0a0b0f;
  }
  .tk-card-label {
    flex: 1; min-width: 0;
    font-size: 13px; font-weight: 600;
    color: var(--text);
    line-height: 1.2;
  }
  .tk-card-status {
    width: 28px; height: 16px;
    border-radius: 999px;
    background: var(--bg2);
    border: 1px solid var(--border);
    position: relative;
    flex-shrink: 0;
    transition: all .2s;
  }
  .tk-card-status::after {
    content: ''; position: absolute;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--text3);
    top: 1px; left: 1px;
    transition: all .2s;
  }
  .tk-card.tk-card-on .tk-card-status {
    background: var(--accent);
    border-color: var(--accent);
  }
  .tk-card.tk-card-on .tk-card-status::after {
    background: #fff; left: 13px;
  }
  /* Hide the actual checkbox — el card sirve como label */
  .tk-card input[type="checkbox"] {
    position: absolute; opacity: 0; pointer-events: none;
  }

  @media (max-width: 700px) {
    .tk-cards-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
    .tk-card { padding: 10px 12px; }
    .tk-card-icon { width: 30px; height: 30px; font-size: 13px; }
    .tk-card-label { font-size: 12px; }
  }
  /* ===== NAV SUB-ITEM ===== */
  .nav-sub-item {
    padding-left: 36px !important;
    font-size: 13px !important;
  }
  .nav-sub-item i { font-size: 12px !important; }

  /* ===== IMPORT PAGE ===== */
  .imp-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    background: var(--bg);
  }
  .imp-drop-zone:hover, .imp-drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(240,165,0,.05);
  }
  .imp-stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 110px;
    flex: 1;
  }
  .imp-stat-num { font-size: 28px; font-weight: 800; font-family: 'Syne', sans-serif; }
  .imp-stat-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: .8px; }
  .imp-badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 700; padding: 3px 9px;
    border-radius: 99px; white-space: nowrap;
  }
  .imp-badge.nuevo     { background: rgba(46,213,115,.15); color: #2ed573; }
  .imp-badge.actualizar{ background: rgba(240,165,0,.15);  color: #f0a500; }
  .imp-badge.sin_cambio{ background: rgba(150,150,150,.12);color: var(--text3); }
  .imp-badge.error     { background: rgba(255,71,87,.15);  color: var(--danger); }
  .imp-change-pill {
    display: inline-block; font-size: 10px; background: rgba(240,165,0,.12);
    color: var(--accent); border-radius: 4px; padding: 1px 5px; margin: 1px;
  }

  .cfg-section-sep {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 22px 0 6px;
  }
  .cfg-section-sep span {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text3);
    white-space: nowrap;
  }
  .cfg-section-line {
    flex: 1;
    height: 1px;
    background: var(--border);
  }

  /* ===== SERVICE DETAIL MODAL ===== */
  .sd-section { padding: 16px 0; border-bottom: 1px solid var(--border); }
  .sd-section:last-child { border-bottom: none; }
  .sd-section-title { font-family: 'Syne', sans-serif; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text2); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
  .sd-section-title i { color: var(--accent); font-size: 14px; }
  .sd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
  .sd-grid .full { grid-column: 1 / -1; }
  .sd-field { }
  .sd-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text3); margin-bottom: 4px; }
  .sd-value { font-size: 14px; color: var(--text); line-height: 1.4; }
  .sd-value.accent { color: var(--accent); font-weight: 700; font-size: 16px; }
  .sd-value.muted { color: var(--text3); font-style: italic; }
  .sd-img { max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-top: 8px; }
  .btn-success { background: var(--success); color: #fff; border: none; border-radius: var(--radius-sm); padding: 13px 24px; font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
  .btn-success:hover { filter: brightness(1.1); }

  /* Ticket template dropdown */
  .ticket-dropdown { position: relative; display: inline-block; }
  .ticket-dropdown-btn { background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm); padding: 13px 24px; font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
  .ticket-dropdown-btn:hover { filter: brightness(1.1); }
  .ticket-dropdown-menu { display: none; position: absolute; bottom: calc(100% + 6px); right: 0; min-width: 220px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); z-index: 1001; overflow: hidden; }
  .ticket-dropdown-menu.open { display: block; }
  .ticket-dropdown-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 11px 16px; background: none; border: none; color: var(--text); font-size: 14px; font-family: 'Syne', sans-serif; cursor: pointer; text-align: left; transition: background .15s; }
  .ticket-dropdown-menu button:hover { background: var(--hover); }
  .ticket-dropdown-menu button i { color: var(--accent); font-size: 13px; }

  /* ===== COLUMN PRIORITY (responsive tables) ===== */
  @media (max-width: 1400px) {
    .col-priority-5 { display: none !important; }
  }
  @media (max-width: 1200px) {
    .col-priority-2 { display: none !important; }
  }

  /* ===== RESPONSIVE: TABLET (≤900px) ===== */
  @media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .report-summary { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: 1; }
    .login-brand { display: none; }
    .login-grid { grid-template-columns: 1fr; max-width: 480px; }
    .col-priority-3 { display: none !important; }
    .profile-layout { grid-template-columns: 1fr !important; }
    .config-layout { grid-template-columns: 1fr; }
    .pos-layout { grid-template-columns: 1fr; min-height: 0; }
    .pos-right { min-height: 400px; }
    .config-sidebar {
      position: static; display: flex; gap: 4px;
      padding: 8px; overflow-x: auto;
    }
    .config-nav-item { white-space: nowrap; margin-bottom: 0; }
    .table-toolbar { flex-direction: column; align-items: stretch; }
    .search-wrap { min-width: unset; width: 100%; }
  }

  /* ===== RESPONSIVE: MOBILE (≤768px) ===== */
  @media (max-width: 768px) {
    .hamburger-btn { display: flex; }
    .sidebar {
      transform: translateX(-100%);
      transition: transform 0.3s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .topbar { padding: 0 16px; }
    .page.active { padding: 16px; }
    .page-content > .table-card { flex: 1; min-height: 0; }
    .page-header {
      flex-direction: column; align-items: stretch; gap: 12px;
    }
    .page-header .btn-accent,
    .page-header .btn-export {
      width: 100%; justify-content: center; text-align: center;
    }
    .modal-overlay { padding: 16px 8px; }
    .modal { border-radius: 14px; }
    .sandbox-stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
    .pos-layout { gap: 12px; }
    .pos-cobrar-btn { font-size: 16px; padding: 14px; }
  }

  /* ===== RESPONSIVE: FILTROS Y MENÚS EN MÓVIL (≤768px) ===== */
  @media (max-width: 768px) {
    /* Toolbars de tablas (servicios, productos, empresas, locales):
       el buscador ocupa toda la fila y los filtros se acomodan en cuadrícula
       de 2 por fila, en vez de apilarse a lo alto y empujar la tabla fuera
       de la vista. El !important neutraliza los min-width inline (180/140/90px). */
    .table-toolbar {
      flex-direction: row;
      flex-wrap: wrap;
      align-items: stretch;
      gap: 8px;
      padding: 12px 14px;
    }
    .table-toolbar .search-wrap {
      flex: 1 1 100% !important;
      min-width: 0 !important;
      width: 100%;
    }
    .table-toolbar > .filter-select,
    .table-toolbar > .btn-outline {
      flex: 1 1 calc(50% - 4px) !important;
      min-width: 0 !important;
      width: auto;
    }

    /* Barra de pestañas de Reportes: que ajusten en varias filas y se vean todas. */
    .rep-tabbar { flex-wrap: wrap !important; }
    .rep-tabbar .cfg-tab {
      flex: 1 1 auto !important;
      min-width: 92px;
      padding: 8px 10px;
      font-size: 12px;
    }

    /* Pestañas genéricas un poco más compactas en móvil. */
    .cfg-tab { padding: 8px 12px; font-size: 12px; }

    /* Filtros de reportes con menos relleno para aprovechar el ancho. */
    .report-filters { padding: 16px; }

    /* Tabla de Auditoría: ancho mínimo para que se pueda desplazar
       horizontalmente en móvil (el contenedor tiene overflow-x:auto). */
    #rep-panel-auditoria table { min-width: 640px; }
  }

  /* ===== RESPONSIVE: TELÉFONOS (≤480px) ===== */
  @media (max-width: 480px) {
    /* Cada control de filtro de reporte ocupa toda la fila (mejor para tocar). */
    .filter-row .form-group { flex: 1 1 100%; min-width: 0; }
    .filter-row .btn-accent,
    .filter-row .btn-outline { width: 100%; justify-content: center; }

    /* Encabezado del widget de backups (sandbox): título arriba, botones abajo. */
    .sbx-widget-head { flex-wrap: wrap !important; }
    .sbx-widget-head > button { flex: 1 1 auto !important; }

    /* Botones de la sección Base de datos del sandbox a ancho completo. */
    #page-sandbox .widget .btn-outline,
    #page-sandbox .widget label.btn-outline { flex: 1 1 100%; justify-content: center; }
  }

  /* ===== RESPONSIVE: POS / CAJA EN MÓVIL (≤768px) ===== */
  @media (max-width: 768px) {
    /* El POS está diseñado como dos paneles de altura fija con scroll interno
       anidado (ideal en escritorio, imposible de ver completo en celular).
       Aquí lo convertimos en UNA columna con scroll vertical natural: se ve
       todo de corrido — buscador, carrito, servicios, resumen, pagos y cobrar.
       Los !important vencen los estilos inline que pone initPageLayout(). */
    #page-pos.page.active { overflow-y: auto; }
    #page-pos .page-content {
      overflow: visible !important;
      display: block !important;
      padding-bottom: 16px;
    }
    #page-pos .pos-layout {
      display: flex;
      flex-direction: column;
      flex: none;
      min-height: 0;
      gap: 14px;
    }
    #page-pos .pos-left,
    #page-pos #pos-panel-productos,
    #page-pos .pos-tables-wrapper {
      overflow: visible;
      min-height: 0;
      flex: none;
    }
    #page-pos .pos-tables-wrapper { display: block; }

    /* Cada tabla del carrito: altura acotada con scroll propio (vertical) y
       ancho mínimo para que los inputs de cantidad/precio no se aplasten
       (scroll horizontal dentro de la tabla cuando hace falta). */
    #page-pos .pos-items-table { flex: none; margin-bottom: 12px; }
    #page-pos .pos-items-table .table-wrap { max-height: 42vh; }
    #page-pos .pos-items-table table { min-width: 480px; }

    /* Panel derecho (resumen + pagos) deja de ser columna de altura fija
       y fluye debajo del carrito. */
    #page-pos .pos-right { min-height: 0; overflow: visible; }
    #page-pos .pos-summary { overflow: visible; }
    #page-pos #pos-mini-recibo { flex: none !important; }
    #page-pos #pos-recibo-list { max-height: 30vh; }

    /* Barra de escaneo un poco más compacta. */
    #page-pos .pos-scan-bar { padding: 12px 14px; gap: 8px; }
  }

  /* ===== FILTROS EN MODAL (móvil/tablet ≤900px) ===== */
  /* Botón "Filtros": oculto en escritorio, visible en ≤900px. */
  .mfilters-btn {
    display: none;
    align-items: center; gap: 7px;
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 9px 16px;
    color: var(--text); font-family: 'DM Sans', sans-serif;
    font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  }
  .mfilters-btn i { color: var(--accent); }
  .mfilters-btn:hover { border-color: var(--accent); }

  /* Bottom-sheet y backdrop (ocultos por defecto). */
  .mf-backdrop { display: none; }
  .filtros-sheet { display: none; }

  .filtros-sheet-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
  }
  .filtros-sheet-head span {
    font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
  }
  .filtros-sheet-head span i { color: var(--accent); }
  .filtros-sheet-close {
    background: none; border: none; color: var(--text2); font-size: 20px;
    cursor: pointer; width: 36px; height: 36px; border-radius: 8px;
  }
  .filtros-sheet-close:hover { background: var(--hover); color: var(--text); }
  .filtros-sheet-body { padding: 18px 20px; overflow-y: auto; flex: 1; min-height: 0; }
  .filtros-sheet-foot { padding: 14px 20px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }

  @keyframes mfSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  @keyframes mfFade { from { opacity: 0; } to { opacity: 1; } }

  @media (max-width: 900px) {
    .mfilters-btn { display: inline-flex; }
    /* En toolbars, Filtros comparte fila con el botón de QR. */
    .table-toolbar > .mfilters-btn,
    .table-toolbar > .btn-outline { flex: 1 1 calc(50% - 4px); justify-content: center; }
    /* En reportes el botón ocupa todo el ancho, antes de la tabla. */
    .mfilters-btn.mf-block { display: flex; width: 100%; justify-content: center; margin-bottom: 14px; }

    /* Todos los contenedores de filtros se ocultan en la página: van al modal. */
    .tbl-filters { display: none !important; }

    /* Al moverse al modal, el contenedor muestra sus filtros en columna. */
    .tbl-filters.tbl-filters-inmodal {
      display: flex !important;
      flex-direction: column !important;
      align-items: stretch !important;
      gap: 14px !important;
      width: 100%;
      padding: 0 !important; margin: 0 !important;
      border: none !important; background: none !important;
    }
    .tbl-filters-inmodal .filter-select,
    .tbl-filters-inmodal .f-select,
    .tbl-filters-inmodal .f-input,
    .tbl-filters-inmodal .search-input,
    .tbl-filters-inmodal input[type="date"],
    .tbl-filters-inmodal input[type="text"],
    .tbl-filters-inmodal select {
      width: 100% !important; min-width: 0 !important; flex: none !important; box-sizing: border-box;
    }
    .tbl-filters-inmodal .form-group { width: 100% !important; min-width: 0 !important; flex: none !important; display: block; }
    .tbl-filters-inmodal .form-group label { display: block; }
    .tbl-filters-inmodal .btn-accent,
    .tbl-filters-inmodal .btn-outline { width: 100% !important; justify-content: center; }
    .tbl-filters-inmodal h3 { display: none; }

    .mf-backdrop.open {
      display: block; position: fixed; inset: 0;
      background: rgba(0,0,0,0.55); z-index: 1400; animation: mfFade .15s ease;
    }
    .filtros-sheet.open {
      display: flex; flex-direction: column;
      position: fixed; left: 0; right: 0; bottom: 0;
      max-height: 88vh; z-index: 1401;
      background: var(--card); border-top: 1px solid var(--border);
      border-radius: 18px 18px 0 0; box-shadow: 0 -12px 48px rgba(0,0,0,0.45);
      animation: mfSlideUp .22s ease;
    }
  }

  /* ===== MODAL DETALLE DE SERVICIO: footer responsivo (≤640px) ===== */
  @media (max-width: 640px) {
    /* Los botones (Cerrar / WhatsApp / Imprimir / Finalizar) se apilan a
       ancho completo en lugar de desbordarse en una sola fila. */
    .sd-footer {
      flex-direction: column;
      align-items: stretch;
      gap: 10px;
    }
    .sd-footer-actions {
      flex-direction: column !important;
      align-items: stretch !important;
      width: 100%;
      gap: 8px !important;
    }
    .sd-footer-close,
    .sd-footer-actions > #sd-btn-wa,
    .sd-footer-actions > #sd-btn-finalizar,
    .sd-footer-actions .ticket-dropdown,
    .sd-footer-actions .ticket-dropdown-btn {
      width: 100%;
      justify-content: center;
    }
    /* La acción principal (Finalizar) primero; Cerrar al final. */
    .sd-footer-actions { order: 1; }
    .sd-footer-close { order: 2; }
    /* El menú desplegable del ticket abarca el ancho del botón. */
    .sd-footer-actions .ticket-dropdown-menu { left: 0; right: 0; width: auto; }
  }

  /* ===== OVERLAY DE CARGA GLOBAL =====
     Cubre toda la pantalla, atrapa los clics y muestra un spinner centrado.
     Se controla por JS con showLoading()/hideLoading(). */
  .loading-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
    z-index: 2000;
    display: none;
    align-items: center; justify-content: center;
    animation: mfFade .15s ease;
  }
  .loading-overlay.open { display: flex; }
  .loading-box {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 14px; padding: 24px 36px;
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    min-width: 220px; max-width: 90%;
  }
  .loading-box .loading-spinner i {
    font-size: 36px; color: var(--accent);
  }
  .loading-box .loading-msg {
    font-family: 'Syne', sans-serif; font-weight: 600; font-size: 14px;
    color: var(--text); text-align: center;
  }

  /* ===== REPORTE OPERACIÓN: ocultar filtros internos de cada panel ===== */
  /* Cuando el tab Operación está activo, la barra de filtros compartida
     (#rep-panel-operacion) controla las fechas de los 4 panels. Los filtros
     y botones internos de cada panel quedan ocultos para evitar duplicación. */
  #page-reportes.operacion-mode #filters-rep-ventas,
  #page-reportes.operacion-mode #filters-rep-srv,
  #page-reportes.operacion-mode #filters-rep-cortes,
  #page-reportes.operacion-mode #filters-rep-gastos,
  #page-reportes.operacion-mode #rep-panel-ventas    > .mfilters-btn,
  #page-reportes.operacion-mode #rep-panel-servicios > .mfilters-btn,
  #page-reportes.operacion-mode #rep-panel-cortes    > .mfilters-btn,
  #page-reportes.operacion-mode #rep-panel-gastos    > .mfilters-btn {
    display: none !important;
  }
  /* Pequeño separador visual entre secciones cuando Operación está activo. */
  #page-reportes.operacion-mode #rep-panel-ventas,
  #page-reportes.operacion-mode #rep-panel-servicios,
  #page-reportes.operacion-mode #rep-panel-cortes,
  #page-reportes.operacion-mode #rep-panel-gastos {
    margin-bottom: 28px;
  }

  /* ===== RESUMEN DE REPORTES (combinado) ===== */
  .res-section { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
  .res-section-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; font-size: 14px; padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }
  .res-detail-btn {
    font-size: 11px; padding: 5px 10px;
    display: inline-flex; align-items: center; gap: 5px;
  }
  .res-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .res-card {
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 12px; text-align: center;
  }
  .res-card-label {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .5px; color: var(--text3); margin-bottom: 4px;
  }
  .res-card-value {
    font-family: 'Syne', sans-serif; font-weight: 800; font-size: 16px; color: var(--text);
  }
  .res-chip { font-size: 12px; padding: 6px 12px; }
  .res-chip.active { background: var(--card); color: var(--accent); border: 1px solid var(--border); }
  @media (max-width: 480px) {
    .res-cards { grid-template-columns: repeat(2, 1fr); }
    .res-section-head { flex-wrap: wrap; }
  }

  .pos-ac-item:hover { background: var(--bg2); }

  /* ===== RESPONSIVE: SMALL MOBILE (≤640px) ===== */
  @media (max-width: 640px) {
    .col-priority-4 { display: none !important; }
    .stats-grid { grid-template-columns: 1fr; }
    .report-summary { grid-template-columns: 1fr; }
  }

  .empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text3);
  }
  .empty-state i { font-size: 40px; margin-bottom: 12px; display: block; }
  .empty-state p { font-size: 14px; }

  .modal-section-label {
    font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:1px;
    color:var(--accent);margin-bottom:12px;margin-top:4px;
    display:flex;align-items:center;gap:7px;
    padding-bottom:8px;border-bottom:1px solid var(--border);
  }

  /* Autocomplete dropdown */
  .autocomplete-wrap { position: relative; }
  .autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: none;
  }
  .autocomplete-list.show { display: block; }
  .autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
  }
  .autocomplete-item:last-child { border-bottom: none; }
  .autocomplete-item:hover { background: var(--bg3); }
  .autocomplete-item .ac-name { font-weight: 500; color: var(--text); }
  .autocomplete-item .ac-sub { font-size: 11px; color: var(--text2); margin-top: 2px; }
  .autocomplete-item.ac-new { color: var(--accent); font-style: italic; }

  /* Permisos table */
  .permisos-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .permisos-table th, .permisos-table td { padding: 10px 14px; text-align: center; border-bottom: 1px solid var(--border); }
  .permisos-table th:first-child, .permisos-table td:first-child { text-align: left; }
  .permisos-table th { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; background: var(--bg3); }
  .permisos-table input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

  /* Tipo badge */
  .tipo-badge { font-size: 10px; font-weight: 600; padding: 3px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.5px; }
  .tipo-root { background: rgba(168,85,247,0.15); color: var(--purple); }
  .tipo-admin { background: rgba(240,165,0,0.15); color: var(--accent); }
  .tipo-empleado { background: rgba(30,144,255,0.15); color: var(--info); }

  .text-right { text-align: right; }
  .font-mono { font-family: monospace; }
  .text-accent { color: var(--accent); }
  .text-success { color: var(--success); }
  .text-danger { color: var(--danger); }
  .text-muted { color: var(--text2); }
  .fw-bold { font-weight: 600; }

  /* ===== POS TERMINAL ===== */
  .pos-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    flex: 1;
    min-height: 0;
  }
  .pos-left { display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
  #pos-panel-productos { flex: 1; display: flex; flex-direction: column; min-height: 0; gap: 12px; overflow: hidden; }
  .pos-tables-wrapper { flex: 1; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
  .pos-table-label {
    display: flex; align-items: center; justify-content: space-between;
    padding: 7px 14px; border-bottom: 1px solid var(--border);
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text2); flex-shrink: 0;
  }
  .pos-scan-bar {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 20px;
    display: flex; gap: 12px; align-items: center;
  }
  .pos-scan-input {
    flex: 1; width: 100%; background: var(--bg3); border: 2px solid var(--accent);
    border-radius: var(--radius-sm); padding: 14px 18px 14px 44px;
    color: var(--text); font-family: 'DM Sans', sans-serif;
    font-size: 16px; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
  }
  .pos-scan-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(240,165,0,0.15); }
  .pos-scan-input::placeholder { color: var(--text3); }
  .pos-items-table {
    flex: 1; background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    display: flex; flex-direction: column; min-height: 0;
  }
  .pos-items-table .table-wrap { flex: 1; overflow-y: auto; min-height: 0; }
  .pos-right {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden;
  }
  .pos-summary { padding: 24px; flex: 1; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; justify-content: space-between; }
  .pos-summary-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--text2); }
  .pos-summary-row.total {
    font-size: 24px; font-family: 'Syne', sans-serif; font-weight: 800;
    color: var(--text); padding-top: 12px; border-top: 2px solid var(--border);
  }
  .pos-summary-row.total .pos-amount { color: var(--accent); }
  .pos-amount { font-family: 'Syne', sans-serif; font-weight: 700; }
  .pos-payment-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .pos-pay-btn {
    padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--bg3); color: var(--text2); cursor: pointer;
    font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500;
    display: flex; align-items: center; justify-content: center; gap: 8px; transition: border-color 0.15s, color 0.15s, background-color 0.15s;
  }
  .pos-pay-btn:hover { border-color: var(--accent); color: var(--text); }
  .pos-pay-btn.selected { border-color: var(--accent); background: rgba(240,165,0,0.12); color: var(--accent); font-weight: 600; }
  .pos-credit-fields {
    display: none; flex-direction: column; gap: 12px; padding: 12px;
    background: rgba(240,165,0,0.04); border: 1px solid rgba(240,165,0,0.15);
    border-radius: var(--radius-sm);
  }
  .pos-credit-fields.show { display: flex; }
  .pos-cobrar-btn {
    background: var(--accent); color: #0a0b0f; border: none;
    border-radius: var(--radius-sm); padding: 16px; width: 100%;
    font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 800;
    cursor: pointer; transition: background-color 0.2s, box-shadow 0.2s, transform 0.2s; letter-spacing: 0.5px;
  }
  .pos-cobrar-btn:hover { background: #ffc107; box-shadow: 0 8px 24px rgba(240,165,0,0.4); transform: translateY(-1px); }
  .pos-qty-input {
    width: 60px; background: var(--bg3); border: 1px solid var(--border);
    border-radius: 6px; padding: 6px 8px; color: var(--text);
    font-size: 14px; text-align: center; outline: none;
  }
  .pos-qty-input:focus { border-color: var(--accent); }
  .pos-price-input {
    width: 90px; background: var(--bg3); border: 1px solid var(--border);
    border-radius: 6px; padding: 6px 8px; color: var(--accent);
    font-family: 'Syne', sans-serif; font-weight: 700;
    font-size: 14px; text-align: right; outline: none;
  }
  .pos-price-input:focus { border-color: var(--accent); }

  /* Split payment */
  .pos-split-row {
    display: flex; align-items: center; gap: 8px;
  }
  .pos-split-toggle {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
  }
  .pos-split-toggle-btn {
    font-size: 12px; padding: 5px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg3); color: var(--text2);
    cursor: pointer; transition: border-color 0.15s, color 0.15s, background-color 0.15s; display: flex; align-items: center; gap: 6px;
  }
  .pos-split-toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
  .pos-split-toggle-btn.active { border-color: var(--accent); background: rgba(240,165,0,0.12); color: var(--accent); }
  .pos-split-add-btn {
    width: 100%; padding: 8px; border-radius: var(--radius-sm); margin-top: 8px;
    border: 1px dashed var(--border); background: transparent; color: var(--text2);
    cursor: pointer; font-size: 13px; transition: border-color 0.15s, color 0.15s; display: flex; align-items: center; justify-content: center; gap: 6px;
  }
  .pos-split-add-btn:hover { border-color: var(--accent); color: var(--accent); }
  .pos-pendiente {
    font-size: 13px; font-weight: 600; padding: 6px 10px;
    border-radius: var(--radius-sm); background: var(--bg3);
    text-align: center;
  }


  /* ===== COBRAR SERVICIO MODAL ===== */
  .csrv-info-card { background:var(--bg3); border:1px solid var(--border); border-radius:var(--radius-sm); padding:14px 16px; display:flex; flex-direction:column; gap:6px; }
  .csrv-info-row { display:flex; align-items:center; gap:8px; font-size:13px; }
  .csrv-info-label { color:var(--text3); min-width:64px; flex-shrink:0; }
  .csrv-resumen { background:var(--bg2); border:1px solid var(--border); border-radius:var(--radius-sm); padding:14px 16px; }
  .csrv-resumen-row { display:flex; justify-content:space-between; font-size:13px; color:var(--text2); padding:3px 0; }
  .csrv-resumen-row.total { font-weight:700; font-size:15px; color:var(--text1); border-top:1px solid var(--border); padding-top:8px; margin-top:4px; }
  .csrv-resumen-row.saldo { font-weight:700; font-size:16px; color:var(--accent); }
  .csrv-pago-hist { max-height:120px; overflow-y:auto; display:flex; flex-direction:column; gap:4px; margin-top:8px; }
  .csrv-pago-item { display:flex; justify-content:space-between; align-items:center; font-size:12px; padding:5px 8px; background:var(--bg3); border-radius:4px; }
  .csrv-search-result { padding:10px 14px; border-bottom:1px solid var(--border); cursor:pointer; transition:background .15s; }
  .csrv-search-result:hover { background:var(--bg3); }
  .csrv-search-result:last-child { border-bottom:none; }
  .csrv-search-list { border:1px solid var(--border); border-radius:var(--radius-sm); overflow:hidden; max-height:280px; overflow-y:auto; }
  .concepto-pill { display:inline-flex; align-items:center; gap:4px; font-size:11px; font-weight:600; padding:2px 8px; border-radius:20px; }
  .concepto-anticipo   { background:rgba(240,165,0,.15); color:var(--accent); }
  .concepto-saldo      { background:rgba(46,213,115,.15); color:var(--success); }
  .concepto-refaccion  { background:rgba(99,102,241,.15); color:#6366f1; }
  .concepto-mano_obra  { background:rgba(6,182,212,.15);  color:#06b6d4; }
  .concepto-otro       { background:var(--bg3); color:var(--text2); }

  /* Toggle switch */
  .toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
  .toggle-switch input { opacity: 0; width: 0; height: 0; }
  .toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: 24px; transition: background-color 0.2s, border-color 0.2s;
  }
  .toggle-slider:before {
    content: ''; position: absolute;
    width: 16px; height: 16px; left: 3px; bottom: 3px;
    background: var(--text3); border-radius: 50%; transition: transform 0.2s, background-color 0.2s;
  }
  .toggle-switch input:checked + .toggle-slider { background: rgba(240,165,0,0.2); border-color: var(--accent); }
  .toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); background: var(--accent); }

  /* Cortes */
  .corte-bar {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 18px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-shrink: 0; flex-wrap: wrap;
  }
  .corte-bar-info { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
  .corte-stat { display: flex; align-items: center; gap: 6px; font-size: 13px; }
  .corte-stat-val { font-family: 'Syne', sans-serif; font-weight: 700; color: var(--accent); }
  .corte-stat-other { color: var(--text2); }
  .corte-actions { display: flex; align-items: center; gap: 8px; }

  /* Venta success modal */
  .venta-success-icon {
    width: 72px; height: 72px; border-radius: 50%;
    background: rgba(46,213,115,0.15);
    display: flex; align-items: center; justify-content: center;
    font-size: 32px; color: var(--success);
    margin: 0 auto 20px;
  }

  /* Report card variants for POS */
  .rs-card.ventas::after { background: var(--accent); }
  .rs-card.ventas .rs-value { color: var(--accent); }
  .rs-card.tickets::after { background: var(--info); }
  .rs-card.tickets .rs-value { color: var(--info); }

/* ─────────────────────────────────────────────────────────────────
   Modo Offline — pill en topbar + banner global
   ───────────────────────────────────────────────────────────────── */

/* Pill que vive en topbar-actions: muestra estado de conexión.
   Color cambia vía atributo data-state: 'online' | 'offline' | 'pending'. */
.offline-pill {
  position: relative;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.offline-pill[data-state="online"] {
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.25);
}
.offline-pill[data-state="offline"] {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
  animation: offlinePulse 2s ease-in-out infinite;
}
.offline-pill[data-state="pending"] {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.35);
}
.offline-pill[data-state="syncing"] {
  background: rgba(59, 130, 246, 0.25);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.5);
}
.offline-pill[data-state="syncing"] i {
  animation: spin 1s linear infinite;
}

.offline-pill-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
}

@keyframes offlinePulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .55; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Banner persistente: aparece cuando se pierde conexión o hay pendientes.
   No es modal, ocupa una franja entre topbar y el contenido. */
.offline-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(245,158,11,0.12), rgba(245,158,11,0.06));
  border-bottom: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--text);
  font-size: 13px;
  flex-wrap: wrap;
}
/* Sin esta regla, .offline-banner { display: flex } gana sobre el atributo
   hidden (que aplica display:none vía user-agent stylesheet). Forzar display:
   none cuando el atributo está presente es lo que permite que el JS pueda
   ocultar el banner con banner.hidden = true. */
.offline-banner[hidden] {
  display: none !important;
}
.offline-banner[data-state="pending"] {
  background: linear-gradient(90deg, rgba(59,130,246,0.12), rgba(59,130,246,0.06));
  border-bottom-color: rgba(59, 130, 246, 0.3);
}
.offline-banner-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(245, 158, 11, 0.18);
  color: #f59e0b;
  font-size: 14px;
  flex-shrink: 0;
}
.offline-banner[data-state="pending"] .offline-banner-icon {
  background: rgba(59, 130, 246, 0.18);
  color: #3b82f6;
}
.offline-banner-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 200px;
}
.offline-banner-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}
.offline-banner-detail {
  font-size: 12px;
  color: var(--text2);
  margin-top: 1px;
}
.offline-banner-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--accent);
  color: #0a0b0f;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.offline-banner-btn:hover { filter: brightness(1.1); }
.offline-banner-btn:disabled { opacity: .6; cursor: wait; }
