/* =============================================
   AdminFac — Mobile-First Design System
   ============================================= */

:root {
    --primary:       #0f2544;
    --primary-mid:   #1a3a6b;
    --primary-light: #2563a8;
    --accent:        #f0a500;
    --accent-light:  #fbbf24;
    --success:       #059669;
    --success-light: #10b981;
    --danger:        #dc2626;
    --danger-light:  #ef4444;
    --warning:       #d97706;
    --warning-light: #f59e0b;
    --bg:            #f0f2f8;
    --surface:       #ffffff;
    --surface-2:     #f8f9fc;
    --border:        #e2e8f0;
    --text:          #1e293b;
    --text-2:        #475569;
    --text-3:        #94a3b8;
    --radius:        14px;
    --radius-sm:     8px;
    --shadow:        0 2px 12px rgba(15,37,68,.09);
    --shadow-md:     0 6px 24px rgba(15,37,68,.13);
    --shadow-lg:     0 16px 48px rgba(15,37,68,.18);
    --nav-h:         64px;
    --bot-nav-h:     68px;
    --sidebar-w:     256px;
    --transition:    .22s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
a { color: var(--primary-light); text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; }

/* ── Login ─────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, var(--primary) 0%, var(--primary-mid) 50%, #1d4ed8 100%);
    padding: 20px;
}
.login-box {
    background: var(--surface);
    border-radius: 24px;
    padding: 40px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-logo {
    width: 72px; height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 20px rgba(37,99,168,.35);
}
.login-logo i { font-size: 2rem; color: #fff; }
.login-box h2 { font-size: 1.6rem; font-weight: 800; color: var(--primary); letter-spacing: -.5px; }
.login-box .sub { color: var(--text-3); font-size: .88rem; margin-top: 4px; margin-bottom: 28px; }
.pin-input {
    width: 100%;
    text-align: center;
    font-size: 2.2rem;
    letter-spacing: 12px;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    outline: none;
    transition: border-color var(--transition);
    color: var(--primary);
    font-weight: 700;
}
.pin-input:focus { border-color: var(--primary-light); background: #fff; }
.btn-login {
    width: 100%; padding: 15px;
    background: linear-gradient(135deg, var(--primary-mid), var(--primary-light));
    color: #fff; border: none; border-radius: var(--radius);
    font-size: 1rem; font-weight: 700; cursor: pointer;
    margin-top: 16px; letter-spacing: .3px;
    box-shadow: 0 4px 16px rgba(37,99,168,.3);
    transition: transform var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
}
.btn-login:active { transform: scale(.97); box-shadow: 0 2px 8px rgba(37,99,168,.2); }

/* ── App Shell (mobile) ─────────────────────── */
.topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 200;
    height: var(--nav-h);
    background: var(--primary);
    display: flex; align-items: center; gap: 12px;
    padding: 0 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.topbar-brand {
    font-size: 1.2rem; font-weight: 800; color: #fff;
    letter-spacing: -.3px; flex: 1;
}
.topbar-brand span { color: var(--accent-light); }
.topbar-date {
    font-size: .75rem; color: rgba(255,255,255,.7);
    background: rgba(255,255,255,.12);
    border-radius: 20px; padding: 4px 10px;
    white-space: nowrap;
}
.btn-hamburger {
    background: rgba(255,255,255,.12); border: none;
    width: 40px; height: 40px; border-radius: 10px;
    color: #fff; font-size: 1.1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition);
    flex-shrink: 0;
}
.btn-hamburger:active { background: rgba(255,255,255,.25); }

/* Sidebar drawer */
.sidebar-overlay {
    display: none; position: fixed; inset: 0; z-index: 300;
    background: rgba(0,0,0,.5);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 400;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-mid) 100%);
    display: flex; flex-direction: column;
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }
.sidebar-head {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex; align-items: center; justify-content: space-between;
}
.sidebar-head .brand { font-size: 1.2rem; font-weight: 800; color: #fff; letter-spacing: -.3px; }
.sidebar-head .brand span { color: var(--accent-light); }
.btn-close-sidebar {
    background: rgba(255,255,255,.15); border: none;
    width: 34px; height: 34px; border-radius: 8px;
    color: #fff; cursor: pointer; font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
}
.sidebar nav { padding: 10px 0; flex: 1; }
.sidebar nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 20px; color: rgba(255,255,255,.78);
    font-size: .9rem; font-weight: 500;
    transition: background var(--transition), color var(--transition);
    border-left: 3px solid transparent;
}
.sidebar nav a:hover, .sidebar nav a.active {
    background: rgba(255,255,255,.12); color: #fff;
    border-left-color: var(--accent-light);
}
.sidebar nav a i { width: 20px; text-align: center; font-size: 1.05rem; }
.sidebar-footer {
    padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-footer a {
    display: flex; align-items: center; gap: 10px;
    color: rgba(255,255,255,.6); font-size: .85rem;
    transition: color var(--transition);
}
.sidebar-footer a:hover { color: #fff; }

/* Bottom navigation (mobile) */
.bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0,0,0,.08);
    height: var(--bot-nav-h);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav a {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 4px; color: var(--text-3); font-size: .65rem;
    font-weight: 600; text-transform: uppercase;
    letter-spacing: .4px;
    transition: color var(--transition);
    -webkit-tap-highlight-color: transparent;
    position: relative;
}
.bottom-nav a i { font-size: 1.3rem; }
.bottom-nav a.active { color: var(--primary-light); }
.bottom-nav a.active::before {
    content: ''; position: absolute; top: 0; left: 20%; right: 20%;
    height: 3px; background: var(--primary-light);
    border-radius: 0 0 4px 4px;
}
.bottom-nav a:active { opacity: .7; }

/* Main content area */
.main-content {
    padding: calc(var(--nav-h) + 16px) 14px calc(var(--bot-nav-h) + 16px);
    min-height: 100vh;
}

/* ── Cards ─────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 16px;
    margin-bottom: 14px;
}
.card-title {
    font-size: .95rem; font-weight: 700; color: var(--primary);
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 14px;
}
.card-title i { color: var(--primary-light); }

/* Card header inside card */
.card-header-custom {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.card-header-custom h5 {
    font-size: .95rem; font-weight: 700; color: var(--primary);
    display: flex; align-items: center; gap: 8px; margin: 0;
}

/* ── Stat cards ─────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px; margin-bottom: 14px;
}
.stat-card {
    border-radius: var(--radius);
    padding: 16px 14px;
    display: flex; flex-direction: column; gap: 6px;
}
.stat-card .stat-icon { font-size: 1.5rem; opacity: .85; }
.stat-card .stat-value { font-size: 1.4rem; font-weight: 800; color: #fff; line-height: 1; }
.stat-card .stat-label { font-size: .72rem; color: rgba(255,255,255,.8); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-blue   { background: linear-gradient(135deg, var(--primary), var(--primary-light)); }
.stat-green  { background: linear-gradient(135deg, #065f46, var(--success-light)); }
.stat-amber  { background: linear-gradient(135deg, #92400e, var(--warning-light)); }
.stat-red    { background: linear-gradient(135deg, #7f1d1d, var(--danger-light)); }

/* ── Quick actions ──────────────────────────── */
.qa-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.qa-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px 12px;
    text-align: center;
    border: 2px solid var(--border);
    color: var(--primary);
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
    -webkit-tap-highlight-color: transparent;
    display: block;
}
.qa-card:active { transform: scale(.96); }
.qa-card i { font-size: 1.6rem; color: var(--primary-light); display: block; margin-bottom: 8px; }
.qa-card .qa-label { font-size: .8rem; font-weight: 700; color: var(--text); line-height: 1.3; }

/* ── Buttons ─────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 7px; padding: 11px 18px;
    border-radius: var(--radius-sm); border: none;
    font-size: .88rem; font-weight: 700; cursor: pointer;
    transition: transform var(--transition), opacity var(--transition), box-shadow var(--transition);
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap; text-decoration: none;
    min-height: 44px;
    font-family: inherit;
}
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--primary-light); color: #fff; box-shadow: 0 2px 8px rgba(37,99,168,.25); }
.btn-primary:active { background: var(--primary-mid); }
.btn-success { background: var(--success); color: #fff; box-shadow: 0 2px 8px rgba(5,150,105,.25); }
.btn-danger  { background: var(--danger-light); color: #fff; box-shadow: 0 2px 8px rgba(239,68,68,.25); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-ghost   { background: transparent; color: var(--primary-light); border: 2px solid var(--primary-light); }
.btn-ghost:active { background: var(--primary-light); color: #fff; }
.btn-dark    { background: var(--primary); color: #fff; }
.btn-sm      { padding: 7px 13px; font-size: .8rem; min-height: 36px; }
.btn-full    { width: 100%; }
.btn-copy {
    background: linear-gradient(135deg, #0ea5e9, #2563a8);
    color: #fff; border: none;
    box-shadow: 0 2px 10px rgba(14,165,233,.3);
}
.btn-copy:active { opacity: .85; }

/* ── Button aliases (legacy compat) ─────────── */
.btn-primary-custom {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 7px; padding: 10px 18px;
    border-radius: var(--radius-sm); border: none;
    background: var(--primary-light); color: #fff;
    font-size: .88rem; font-weight: 700; cursor: pointer;
    white-space: nowrap; text-decoration: none;
    min-height: 42px; font-family: inherit;
    box-shadow: 0 2px 8px rgba(37,99,168,.25);
    transition: transform var(--transition), opacity var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.btn-primary-custom:active { transform: scale(.96); opacity: .9; }
.btn-outline-custom {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 7px; padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--primary-light);
    background: transparent; color: var(--primary-light);
    font-size: .85rem; font-weight: 700; cursor: pointer;
    white-space: nowrap; text-decoration: none;
    min-height: 42px; font-family: inherit;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.btn-outline-custom:active { background: var(--primary-light); color: #fff; }
.btn-success-custom {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 7px; padding: 10px 18px;
    border-radius: var(--radius-sm); border: none;
    background: var(--success); color: #fff;
    font-size: .88rem; font-weight: 700; cursor: pointer;
    white-space: nowrap; text-decoration: none;
    min-height: 42px; font-family: inherit;
    box-shadow: 0 2px 8px rgba(5,150,105,.25);
    transition: transform var(--transition), opacity var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.btn-success-custom:active { transform: scale(.96); }
.btn-danger-custom {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 7px; padding: 9px 13px;
    border-radius: var(--radius-sm); border: none;
    background: var(--danger-light); color: #fff;
    font-size: .85rem; font-weight: 700; cursor: pointer;
    white-space: nowrap; text-decoration: none;
    min-height: 40px; font-family: inherit;
    transition: transform var(--transition), opacity var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.btn-danger-custom:active { transform: scale(.96); }
.btn-wa {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 7px; padding: 9px 16px;
    border-radius: var(--radius-sm); border: none;
    background: #25d366; color: #fff;
    font-size: .88rem; font-weight: 700; cursor: pointer;
    white-space: nowrap; text-decoration: none;
    min-height: 40px; font-family: inherit;
    transition: transform var(--transition), opacity var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.btn-wa:active { transform: scale(.96); }

/* ── Forms ───────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-size: .83rem; font-weight: 700;
    color: var(--text-2); margin-bottom: 6px; letter-spacing: .2px;
}
.form-control, .form-select {
    width: 100%; padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .92rem; font-family: inherit;
    background: var(--surface); color: var(--text);
    outline: none; appearance: none; -webkit-appearance: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    min-height: 48px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37,99,168,.12);
}
.form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }
textarea.form-control { min-height: 80px; resize: vertical; }
.form-row { display: grid; gap: 12px; }

/* ── Visibility defaults (desktop first) ────── */
/* Cards hidden by default, shown on mobile via media query */
.invoice-card-list  { display: none; }
.invoice-table-wrap { display: block; }
.empresa-card-list  { display: none; }
.empresa-table-wrap { display: block; }
.panel-2col { display: block; }

/* ── Invoice cards (historial mobile) ─────── */
.invoice-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 16px 14px;
    margin-bottom: 10px;
    border-left: 5px solid var(--border);
    transition: box-shadow var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.invoice-card.estado-pagado    { border-left-color: var(--success); background: #fafffe; }
.invoice-card.estado-moroso    { border-left-color: var(--danger-light); background: #fffafa; }
.invoice-card.estado-pendiente { border-left-color: var(--warning-light); background: #fffdf5; }
.invoice-card-top {
    display: flex; align-items: flex-start;
    justify-content: space-between; margin-bottom: 6px; gap: 8px;
}
.invoice-num { font-size: .75rem; font-weight: 700; color: var(--text-3); letter-spacing: .5px; }
.invoice-client { font-size: 1rem; font-weight: 800; color: var(--text); margin-bottom: 6px; line-height: 1.3; }
.invoice-row {
    display: flex; align-items: center;
    justify-content: space-between; margin-top: 6px; gap: 8px; flex-wrap: wrap;
}
.invoice-amount { font-size: 1.2rem; font-weight: 800; color: var(--primary); }
.invoice-date { font-size: .75rem; color: var(--text-3); }
.invoice-actions {
    display: flex; gap: 8px; margin-top: 12px;
    padding-top: 10px; border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* ── Empresa cards (lista mobile) ─────────── */
.empresa-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
    display: flex; gap: 14px; align-items: flex-start;
}
.empresa-card.inactiva { opacity: .55; }
.empresa-avatar {
    width: 46px; height: 46px; flex-shrink: 0;
    border-radius: 12px; display: flex;
    align-items: center; justify-content: center;
    font-size: 1.2rem; font-weight: 800;
}
.empresa-avatar.tipo-cunningham { background: #dbeafe; color: #1e40af; }
.empresa-avatar.tipo-paqueteria  { background: #d1fae5; color: #065f46; }
.empresa-body { flex: 1; min-width: 0; }
.empresa-nombre { font-size: 1rem; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.empresa-meta { font-size: .78rem; color: var(--text-3); margin-bottom: 6px; }
.empresa-monto { font-size: .95rem; font-weight: 800; color: var(--primary); }
.empresa-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ── Tables (mobile scroll — fallback) ─────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
.table-custom { width: 100%; border-collapse: collapse; font-size: .82rem; min-width: 520px; }
.table-custom thead th {
    background: var(--primary); color: #fff;
    padding: 11px 12px; text-align: left;
    font-weight: 600; font-size: .78rem; letter-spacing: .3px;
    white-space: nowrap;
}
.table-custom thead th:first-child { border-radius: 8px 0 0 0; }
.table-custom thead th:last-child  { border-radius: 0 8px 0 0; }
.table-custom tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
.table-custom tbody tr:last-child { border-bottom: none; }
.table-custom tbody tr:active { background: var(--surface-2); }
.table-custom tbody td { padding: 10px 12px; vertical-align: middle; }

/* ── Badges ─────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 20px;
    font-size: .72rem; font-weight: 700; white-space: nowrap;
}
.badge-tipo { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.badge-cunningham { background: #dbeafe; color: #1e40af; }
.badge-paqueteria  { background: #d1fae5; color: #065f46; }
.badge-pagado   { background: #d1fae5; color: #065f46; }
.badge-pendiente{ background: #fef3c7; color: #92400e; }
.badge-moroso   { background: #fee2e2; color: #b91c1c; }
.badge-mensual  { background: #ede9fe; color: #4c1d95; }
.badge-limpia   { background: #fef9c3; color: #713f12; }

/* ── Alerts ─────────────────────────────────── */
.alert {
    padding: 13px 16px; border-radius: var(--radius-sm);
    font-size: .88rem; display: flex; gap: 10px;
    align-items: flex-start; margin-bottom: 14px; line-height: 1.5;
}
.alert i { flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #f0fdf4; color: #065f46; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fff5f5; color: #b91c1c; border: 1px solid #fecaca; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ── Payment rows ───────────────────────────── */
.pago-row {
    display: flex; align-items: center; gap: 12px;
    padding: 14px; border-radius: var(--radius);
    margin-bottom: 10px; border: 2px solid transparent;
    transition: all var(--transition);
}
.pago-row.moroso { background: #fff5f5; border-color: #fecaca; }
.pago-row.pendiente { background: #fffbeb; border-color: #fde68a; }
.pago-row.pagado { background: #f0fdf4; border-color: #bbf7d0; opacity: .8; }
.pago-check {
    width: 26px; height: 26px; flex-shrink: 0;
    accent-color: var(--success); cursor: pointer;
}
.pago-info { flex: 1; min-width: 0; }
.pago-nombre { font-size: .95rem; font-weight: 700; color: var(--text); }
.pago-meta   { font-size: .78rem; color: var(--text-3); margin-top: 2px; }
.pago-monto  { font-size: 1rem; font-weight: 800; white-space: nowrap; flex-shrink: 0; }
.pago-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── WhatsApp copy box ──────────────────────── */
.wa-copy-box {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 2px solid #86efac;
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 12px;
}
.wa-copy-box .msg-preview {
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 14px;
    font-size: .88rem; line-height: 1.7;
    color: var(--text); white-space: pre-line;
    border: 1px solid #d1fae5;
    margin-bottom: 12px;
    max-height: 200px; overflow-y: auto;
}
.wa-copy-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Progress bar */
.progress-bar-wrap { background: var(--border); border-radius: 99px; height: 12px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; transition: width .6s ease; }

/* ── Filters (mobile-first) ─────────────────── */
.filter-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 14px;
}
.filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.filter-grid .filter-full { grid-column: 1 / -1; }
.filter-actions { display: flex; gap: 8px; margin-top: 10px; }
.filter-actions .btn, .filter-actions a { flex: 1; justify-content: center; }

.filter-strip {
    display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.filter-strip::-webkit-scrollbar { display: none; }
.filter-chip {
    flex-shrink: 0; padding: 7px 14px;
    background: var(--surface); border: 2px solid var(--border);
    border-radius: 99px; font-size: .8rem; font-weight: 600;
    color: var(--text-2); cursor: pointer; white-space: nowrap;
    transition: all var(--transition); -webkit-tap-highlight-color: transparent;
}
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Section header ─────────────────────────── */
.section-header {
    display: flex; align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.section-title { font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; }

/* ── Toast ──────────────────────────────────── */
#toast {
    position: fixed; bottom: calc(var(--bot-nav-h) + 16px); left: 16px; right: 16px;
    background: var(--primary); color: #fff;
    border-radius: var(--radius); padding: 14px 18px;
    font-size: .9rem; font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 9999; display: none;
    align-items: center; gap: 10px;
    animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Page header ─────────────────────────────── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.page-title { font-size: 1.2rem; font-weight: 800; color: var(--primary); letter-spacing: -.3px; display: flex; align-items: center; gap: 8px; }
.page-title i { color: var(--primary-light); font-size: 1rem; }

/* ── Empty state ─────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state i { font-size: 3rem; color: var(--border); display: block; margin-bottom: 14px; }
.empty-state p { color: var(--text-3); font-size: .9rem; }

/* ── Misc ────────────────────────────────────── */
.text-muted { color: var(--text-3); }
.text-sm    { font-size: .82rem; }
.divider    { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.chip-estado {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 12px; border-radius: 99px;
    font-size: .78rem; font-weight: 700;
}
.chip-pagado   { background: #d1fae5; color: #065f46; }
.chip-pendiente{ background: #fef3c7; color: #92400e; }
.chip-moroso   { background: #fee2e2; color: #b91c1c; }

/* ── Empresa tipo selector (botones estilo card) */
.tipo-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tipo-option {
    border: 2px solid var(--border); border-radius: var(--radius);
    padding: 14px 12px; cursor: pointer; text-align: center;
    transition: all var(--transition); -webkit-tap-highlight-color: transparent;
}
.tipo-option.selected-cunningham { border-color: var(--primary-light); background: #eff6ff; }
.tipo-option.selected-paqueteria  { border-color: var(--success); background: #f0fdf4; }
.tipo-option i { font-size: 1.4rem; display: block; margin-bottom: 6px; }
.tipo-option strong { font-size: .82rem; display: block; }
.tipo-option small  { font-size: .72rem; color: var(--text-3); }

/* ── Tipo selector responsivo (empresa forms) ── */
.tipo-flex-wrap {
    display: flex; gap: 12px; margin-top: 4px; flex-wrap: wrap;
}
.tipo-flex-wrap > label {
    display: flex; align-items: center; gap: 10px;
    cursor: pointer; padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm); flex: 1; min-width: 140px;
    transition: border-color var(--transition), background var(--transition);
    background: var(--surface);
}
.tipo-flex-wrap > label:hover { border-color: var(--primary-light); background: #f5f9ff; }

/* ── Desktop enhancements ────────────────────── */
@media (min-width: 768px) {
    .btn-hamburger { display: none; }
    .bottom-nav    { display: none; }
    .sidebar {
        transform: translateX(0);
        position: fixed; top: 0; bottom: 0;
        box-shadow: none;
        border-right: 1px solid rgba(255,255,255,.06);
    }
    .sidebar-overlay { display: none !important; }
    .btn-close-sidebar { display: none; }
    .topbar { left: var(--sidebar-w); padding: 0 28px; }
    .topbar-brand { display: none; }
    .main-content {
        margin-left: var(--sidebar-w);
        padding: calc(var(--nav-h) + 28px) 32px 32px;
    }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .qa-grid    { grid-template-columns: repeat(3, 1fr); }
    .form-row   { grid-template-columns: 1fr 1fr; }
    .form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
    .filter-grid { grid-template-columns: repeat(4, 1fr); }
    .filter-grid .filter-full { grid-column: auto; }
    /* Tables visible on desktop — override defaults */
    .invoice-card-list  { display: none; }
    .invoice-table-wrap { display: block; }
    .empresa-card-list  { display: none; }
    .empresa-table-wrap { display: block; }
    /* 2-col form panels on desktop */
    .panel-2col { display: grid; grid-template-columns: 1fr 340px; gap: 20px; }
}
@media (max-width: 767px) {
    /* Cards visible on mobile — override defaults */
    .invoice-card-list  { display: block; }
    .invoice-table-wrap { display: none; }
    .empresa-card-list  { display: block; }
    .empresa-table-wrap { display: none; }
    .panel-2col { display: block; }
    /* Smaller page titles */
    .page-title { font-size: 1.05rem; }
    /* Tipo selector apila verticalmente en móvil */
    .tipo-flex-wrap { flex-direction: column; }
    .tipo-flex-wrap > label { min-width: 0; width: 100%; }
}
