@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================
   StreamManager Pro — Design System (ui-ux-pro-max-skill)
   Tokens, componentes base y responsividad Mobile-First.
   Dark Mode (por defecto) + Light Mode vía data-theme.
   ============================================================ */

/* ---------- 1. TOKENS ---------- */
:root {
    /* Paleta primaria (Violet) */
    --primary-50: #f5f3ff;
    --primary-100: #ede9fe;
    --primary-200: #ddd6fe;
    --primary-300: #c4b5fd;
    --primary-400: #a78bfa;
    --primary-500: #8b5cf6;
    --primary-600: #7c3aed;
    --primary-700: #6d28d9;

    /* Semánticos (basados en la paleta base) */
    --success-500: #10b981;
    --warning-500: #f59e0b;
    --danger-500: #ef4444;
    --info-500: #06b6d4;

    /* Tipografía */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --fs-xs: 0.75rem;
    --fs-sm: 0.875rem;
    --fs-base: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.375rem;
    --fs-2xl: 1.75rem;
    --fs-3xl: 2.25rem;
    --fw-regular: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;
    --lh-tight: 1.25;
    --lh-normal: 1.6;

    /* Espaciado (grid 4px) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Radios */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 999px;

    /* Sombras */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.12);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.14);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.18);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.28);

    /* Layout */
    --header-h: 64px;
    --container-max: 1440px;
    --sidebar-w: 400px;
    --breakpoint-md: 821px;
    --breakpoint-lg: 992px;
}

/* ---------- 2. TEMAS ---------- */
:root,
[data-theme="dark"] {
    --bg-base: #0b1220;
    --bg-surface: #101a2e;
    --bg-elevated: #16213a;
    --bg-muted: rgba(148, 163, 184, 0.07);
    --bg-hover: rgba(148, 163, 184, 0.12);
    --field-bg: rgba(15, 23, 42, 0.6);

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --border-subtle: rgba(148, 163, 184, 0.14);
    --border-strong: rgba(148, 163, 184, 0.28);

    --primary: var(--primary-400);
    --primary-strong: var(--primary-600);
    --primary-hover: var(--primary-500);
    --primary-soft: rgba(139, 92, 246, 0.14);
    --primary-border: rgba(139, 92, 246, 0.4);
    --on-primary: #ffffff;

    --success: #34d399;
    --success-soft: rgba(16, 185, 129, 0.12);
    --success-border: rgba(16, 185, 129, 0.35);

    --warning: #fbbf24;
    --warning-soft: rgba(245, 158, 11, 0.12);
    --warning-border: rgba(245, 158, 11, 0.35);

    --danger: #f87171;
    --danger-soft: rgba(239, 68, 68, 0.12);
    --danger-border: rgba(239, 68, 68, 0.35);

    --info: #38bdf8;
    --info-soft: rgba(6, 182, 212, 0.12);
    --info-border: rgba(6, 182, 212, 0.35);

    --focus-ring: var(--primary-400);
    --overlay: rgba(2, 6, 16, 0.78);

    --bg-grad-1: rgba(124, 58, 237, 0.25);
    --bg-grad-2: rgba(236, 72, 153, 0.15);
    --bg-grad-3: rgba(56, 189, 248, 0.2);
}

[data-theme="light"] {
    --bg-base: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-elevated: #ffffff;
    --bg-muted: rgba(100, 116, 139, 0.08);
    --bg-hover: rgba(100, 116, 139, 0.15);
    --field-bg: #f8fafc;

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;

    --border-subtle: rgba(100, 116, 139, 0.18);
    --border-strong: rgba(100, 116, 139, 0.35);

    --primary: var(--primary-600);
    --primary-strong: var(--primary-700);
    --primary-hover: var(--primary-500);
    --primary-soft: rgba(124, 58, 237, 0.1);
    --primary-border: rgba(124, 58, 237, 0.35);
    --on-primary: #ffffff;

    --success: #059669;
    --success-soft: rgba(5, 150, 105, 0.1);
    --success-border: rgba(5, 150, 105, 0.3);

    --warning: #b45309;
    --warning-soft: rgba(180, 83, 9, 0.1);
    --warning-border: rgba(180, 83, 9, 0.3);

    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.1);
    --danger-border: rgba(220, 38, 38, 0.3);

    --info: #0284c7;
    --info-soft: rgba(2, 132, 199, 0.1);
    --info-border: rgba(2, 132, 199, 0.3);

    --focus-ring: var(--primary-600);
    --overlay: rgba(15, 23, 42, 0.55);

    --bg-grad-1: rgba(124, 58, 237, 0.15);
    --bg-grad-2: rgba(56, 189, 248, 0.15);
    --bg-grad-3: rgba(236, 72, 153, 0.15);
}

/* ---------- 3. BASE ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-normal);
    background-color: var(--bg-base);
    background-image:
        radial-gradient(circle at 10% 10%, var(--bg-grad-1) 0%, transparent 60%),
        radial-gradient(circle at 80% 20%, var(--bg-grad-2) 0%, transparent 60%),
        radial-gradient(circle at 50% 90%, var(--bg-grad-3) 0%, transparent 60%);
    background-size: 100% 100%;
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color 0.4s ease, color 0.4s ease;
    animation: bgFloat 15s ease-in-out infinite alternate;
}

@keyframes bgFloat {
    0% { background-position: 0% 0%; }
    100% { background-position: 100% 100%; }
}

img, svg { vertical-align: middle; }
button { font-family: inherit; }

::selection { background: var(--primary-soft); color: var(--text-primary); }

/* Foco visible (WCAG 2.1 AA) */
:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Scrollbar sutil */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-muted); background-clip: content-box; }

/* ---------- 4. HEADER ---------- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(16, 26, 46, 0.75);
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .header {
    background: rgba(255, 255, 255, 0.75);
}

.header-content {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-5);
    height: var(--header-h);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    letter-spacing: -0.01em;
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
}

.logo svg { color: var(--primary); flex: none; }

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-full);
    background: var(--primary-soft);
    color: var(--primary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    white-space: nowrap;
}

/* ---------- 5. BOTONES ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-tight);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s ease, border-color 0.2s ease,
        color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--primary-strong);
    color: var(--on-primary);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled { background: var(--primary-strong); }

.btn-ghost {
    background: transparent;
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--primary-border);
}
.btn-ghost.danger:hover:not(:disabled) {
    color: var(--danger);
    border-color: var(--danger-border);
    background: var(--danger-soft);
}

.btn-danger {
    background: var(--danger-500);
    color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-block { width: 100%; }

.btn-icon {
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon.danger:hover { color: var(--danger); background: var(--danger-soft); }

/* ---------- 6. FORMULARIOS ---------- */
.field { margin-bottom: var(--space-4); }
.field-label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--text-secondary);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: var(--space-3) var(--space-3);
    background: var(--field-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--fs-base);
    line-height: var(--lh-normal);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.input::placeholder, .textarea::placeholder { color: var(--text-muted); }

.input:hover, .select:hover { border-color: var(--border-strong); }

.input:focus, .select:focus, .textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.input:disabled { opacity: 0.55; cursor: not-allowed; }

.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    padding-right: var(--space-8);
    cursor: pointer;
}

.select option, .select optgroup { background: var(--bg-elevated); color: var(--text-primary); }

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

/* ---------- 7. TARJETAS / SUPERFICIES ---------- */
.card {
    background: rgba(16, 26, 46, 0.5);
    border: 1px solid var(--border-subtle);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .card {
    background: rgba(255, 255, 255, 0.7);
    border-top: 1px solid rgba(255, 255, 255, 0.9);
}

.card-title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

/* ---------- 8. TABLA (desktop) ---------- */
.table-wrapper {
    background: rgba(16, 26, 46, 0.5);
    border: 1px solid var(--border-subtle);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    overflow: hidden;
    overflow-x: auto;
    display: none;
    transition: box-shadow 0.2s ease;
}

[data-theme="light"] .table-wrapper {
    background: rgba(255, 255, 255, 0.8);
    border-top: 1px solid rgba(255, 255, 255, 0.9);
}

.dashboard-toolbar {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-3); margin-bottom: var(--space-4); }
.stat-card {
    padding: var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    text-align: center;
}
.stat-card span { display: block; color: var(--text-muted); font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-card strong { display: block; margin-top: 2px; color: var(--text-primary); font-size: var(--fs-xl); font-weight: var(--fw-bold); }
.stat-clients strong { color: var(--text-primary); }
.stat-active strong { color: var(--success); }
.stat-warning strong { color: var(--warning); }
.stat-danger strong { color: var(--danger); }
.filters-row { display: grid; grid-template-columns: 1fr 220px; gap: var(--space-3); }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}

.table thead { background: var(--bg-muted); }

.table th {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    white-space: nowrap;
}

.table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color 0.15s ease; }
.table tbody tr:hover { background: var(--bg-muted); }

.cell-name { color: var(--text-primary); font-weight: var(--fw-semibold); }
.cell-sub { color: var(--text-muted); font-size: var(--fs-sm); }
.cell-svc { color: var(--text-primary); font-weight: var(--fw-semibold); }

/* ---------- 9. BADGES / ESTADOS ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 4px var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-success { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.badge-warning { color: var(--warning); background: var(--warning-soft); border-color: var(--warning-border); }
.badge-danger { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.badge-info { color: var(--info); background: var(--info-soft); border-color: var(--info-border); }
.badge-expired { color: #fca5a5; background: rgba(185, 28, 28, 0.18); border-color: rgba(185, 28, 28, 0.45); }

/* ---------- 10. CREDENCIALES ---------- */
.creds-box {
    background: var(--field-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-2);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    font-size: var(--fs-sm);
}

.creds-box .input {
    padding: var(--space-1) var(--space-2);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    border-radius: 0;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
}
.creds-box .input:focus {
    border-bottom-color: var(--primary);
    box-shadow: none;
    color: var(--text-primary);
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    background: var(--primary-strong);
    color: var(--on-primary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    cursor: pointer;
    transition: background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.copy-btn:hover { background: var(--primary-hover); }

/* ---------- 11. BLOQUES DE SERVICIO (form) ---------- */
.service-block {
    background: var(--bg-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

.service-block-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.service-block-title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.btn-remove {
    background: var(--danger-soft);
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    transition: background-color 0.2s ease;
}
.btn-remove:hover { background: var(--danger-border); color: var(--danger); }

.btn-add {
    width: 100%;
    background: transparent;
    border: 1px dashed var(--primary-border);
    color: var(--primary);
    margin-bottom: var(--space-5);
}
.btn-add:hover:not(:disabled) {
    background: var(--primary-soft);
    border-style: solid;
}

/* Filas de perfil (casilla + nombre + PIN) */
.perfil-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.perfil-check {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-strong);
    flex: none;
    cursor: pointer;
}

.p-label {
    flex: none;
    color: var(--text-muted);
    font-size: var(--fs-sm);
    text-align: center;
}

.p-name {
    flex: 1;
    min-width: 0;
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    font-size: var(--fs-base);
    padding: var(--space-2) var(--space-3);
    background: var(--field-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

/* ---------- 12. MODALES ---------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 999;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.modal-overlay.show { display: flex; }

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    animation: modal-in 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.wide { max-width: 580px; text-align: left; }

@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.modal-title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.modal-desc {
    color: var(--text-muted);
    font-size: var(--fs-sm);
    margin-bottom: var(--space-4);
}

.modal-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    margin-top: var(--space-5);
}

/* ---------- 13. TOAST ---------- */
.toast {
    position: fixed;
    bottom: var(--space-5);
    right: var(--space-5);
    left: var(--space-5);
    margin: 0 auto;
    max-width: 420px;
    background: var(--success-500);
    color: #fff;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-weight: var(--fw-semibold);
    font-size: var(--fs-sm);
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 2000;
    animation: toast-in 0.25s ease;
}

.toast.error { background: var(--danger-500); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

/* ---------- 14. LISTA DE USUARIOS / CHIPS ---------- */
.user-list { list-style: none; }

.user-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    background: var(--bg-muted);
}

.user-list .uname { font-weight: var(--fw-semibold); color: var(--text-primary); }
.user-list .role { font-size: var(--fs-xs); color: var(--primary); font-weight: var(--fw-bold); }

.chip-list { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 4px var(--space-3);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    font-size: var(--fs-sm);
    background: var(--bg-muted);
    color: var(--text-secondary);
}

.chip .chip-x {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: var(--fs-base);
    line-height: 1;
    padding: 0;
}
.chip .chip-x:hover { color: var(--danger); }

.chip .chip-move {
    padding: 0 2px;
    border: none;
    background: none;
    color: var(--primary);
    cursor: pointer;
    font-size: var(--fs-sm);
    line-height: 1;
}
.chip .chip-move:hover:not(:disabled) { color: var(--primary-hover); }
.chip .chip-move:disabled { opacity: 0.3; cursor: default; }

.cat-block {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-3);
    background: var(--bg-muted);
}

.cat-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.cat-title {
    color: var(--primary);
    text-transform: uppercase;
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    letter-spacing: 0.06em;
}

/* ---------- 15. ESTADOS VACÍOS ---------- */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-5);
    color: var(--text-muted);
}

.empty-state svg { margin-bottom: var(--space-4); opacity: 0.5; }

/* ---------- 16. TARJETAS MÓVILES ---------- */
#cardsContainer { display: block; }

.client-card {
    background: rgba(16, 26, 46, 0.5);
    border: 1px solid var(--border-subtle);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.client-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
[data-theme="light"] .client-card {
    background: rgba(255, 255, 255, 0.8);
    border-top: 1px solid rgba(255, 255, 255, 0.9);
}

.client-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.cc-name { color: var(--text-primary); font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.cc-phone { color: var(--text-muted); font-size: var(--fs-sm); margin-top: 2px; }

.svc-card {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin-bottom: var(--space-2);
    background: var(--bg-muted);
}
.svc-card:last-child { margin-bottom: 0; }

.svc-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.svc-name { color: var(--text-primary); font-weight: var(--fw-semibold); font-size: var(--fs-base); }

.svc-meta {
    display: flex;
    gap: var(--space-4);
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.svc-profiles { margin-bottom: var(--space-2); }

/* ---------- 17. LOGIN ---------- */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
}

.login-card {
    background: rgba(16, 26, 46, 0.6);
    border: 1px solid var(--border-subtle);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-theme="light"] .login-card {
    background: rgba(255, 255, 255, 0.85);
    border-top: 1px solid rgba(255, 255, 255, 0.9);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: none; }
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    margin-bottom: var(--space-8);
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
}

.login-logo svg { color: var(--primary); }

.form-error {
    display: none;
    background: var(--danger-soft);
    border: 1px solid var(--danger-border);
    color: var(--danger);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    margin-bottom: var(--space-4);
}

.form-hint {
    margin-top: var(--space-5);
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

/* Toggle de tema */
.theme-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 24px;
    flex: none;
    cursor: pointer;
}
.theme-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.theme-toggle .track {
    position: absolute;
    inset: 0;
    background: var(--bg-hover);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    transition: background-color 0.25s ease;
}
.theme-toggle .thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease;
}
.theme-toggle .thumb svg { width: 10px; height: 10px; color: #fff; }
.theme-toggle input:checked + .track .thumb { transform: translateX(16px); }
.theme-toggle input:focus-visible + .track { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ---------- 18. FAB (Botón flotante) ---------- */
.fab {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: 500;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-strong);
    color: var(--on-primary);
    border: none;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.fab:hover { transform: scale(1.06); box-shadow: 0 6px 28px rgba(124, 58, 237, 0.55); background: var(--primary-hover); }
.fab:active { transform: scale(0.96); }

/* ---------- 19. TABLA ANCHO COMPLETO ---------- */
.table-full { max-width: none; }

/* ---------- 20. TARJETA DE CREDENCIALES ---------- */
.creds-card {
    background: var(--bg-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-2);
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 200px;
}
.creds-field {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 4px var(--space-2);
    background: var(--field-bg);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: border-color 0.2s ease;
}
.creds-field:focus-within { border-color: var(--primary-border); }
.creds-field input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: var(--fs-sm);
    padding: 2px 0;
}
.creds-field input::placeholder { color: var(--text-muted); }
.creds-field input:focus { outline: none; }
.creds-action {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: color 0.15s ease;
}
.creds-action:hover { color: var(--text-primary); }
.creds-copy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 4px var(--space-3);
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-sm);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    width: 100%;
    font-family: inherit;
}
.creds-copy:hover { background: var(--primary-strong); color: var(--on-primary); }

/* ---------- 21. RESPONSIVE (Mobile-First) ---------- */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-4) var(--space-8);
}

.table-full { max-width: none; }

@media (min-width: 821px) {
    #cardsContainer { display: none; }
    .table-wrapper { display: block; }
    .toast { left: auto; margin: 0; }
}

@media (max-width: 767px) {
    .form-row-2 { grid-template-columns: 1fr; gap: 0; }
    .header-content { flex-wrap: wrap; height: auto; padding-top: var(--space-3); padding-bottom: var(--space-3); gap: var(--space-2); }
    .header-actions { max-width: 100%; justify-content: flex-end; }
    .header-actions .btn { padding: var(--space-2) var(--space-3); font-size: var(--fs-xs); }
    .logo { font-size: var(--fs-base); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .filters-row { grid-template-columns: 1fr; }
}
