/* ============================================================
   MULTI-SISTEMA MANAGER · DESIGN SYSTEM
   Glassmorphism Dark · Linear/Vercel inspired
   ============================================================ */

/* ---------- DESIGN TOKENS ---------- */
:root {
    /* Base palette */
    --bg-base:        #0B0E14;
    --bg-elevated:    #11151E;
    --bg-glass:       rgba(255, 255, 255, 0.035);
    --bg-glass-hover: rgba(255, 255, 255, 0.06);

    /* Borders */
    --border:         rgba(255, 255, 255, 0.08);
    --border-strong:  rgba(255, 255, 255, 0.14);
    --border-focus:   rgba(99, 102, 241, 0.55);

    /* Text */
    --text:           #E4E4E7;
    --text-soft:      #B4B8C3;
    --text-muted:     #6B7280;
    --text-faint:     #4B5563;

    /* Brand accents */
    --accent:         #6366F1;
    --accent-hover:   #4F46E5;
    --accent-2:       #A855F7;
    --accent-glow:    rgba(99, 102, 241, 0.45);

    /* Status colors */
    --success:        #10B981;
    --success-bg:     rgba(16, 185, 129, 0.12);
    --warning:        #F59E0B;
    --warning-bg:    rgba(245, 158, 11, 0.12);
    --danger:         #EF4444;
    --danger-bg:      rgba(239, 68, 68, 0.12);
    --info:           #3B82F6;
    --info-bg:        rgba(59, 130, 246, 0.12);

    /* Legacy aliases (for compatibility with existing JS) */
    --gray-500:       #6B7280;
    --dark:           #E4E4E7;

    /* Icon colors (stat cards) */
    --icon-blue:      #60A5FA;
    --icon-purple:    #C084FC;
    --icon-green:     #34D399;
    --icon-amber:     #FBBF24;

    /* Typography */
    --font-ui:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono:      'JetBrains Mono', 'SF Mono', Menlo, monospace;

    /* Radii */
    --r-sm:  6px;
    --r-md:  10px;
    --r-lg:  14px;
    --r-xl:  18px;
    --r-2xl: 24px;

    /* Shadows */
    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md:  0 4px 14px rgba(0, 0, 0, 0.35);
    --shadow-lg:  0 12px 36px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 0 1px var(--border-focus), 0 8px 32px rgba(99, 102, 241, 0.25);

    /* Motion */
    --ease:         cubic-bezier(0.22, 1, 0.36, 1);
    --ease-out:     cubic-bezier(0.16, 1, 0.3, 1);
    --d-fast:       140ms;
    --d-base:       220ms;
    --d-slow:       360ms;
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; }

body {
    margin: 0;
    background: var(--bg-base);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
}

p { margin: 0; }

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--d-fast) var(--ease);
}
a:hover { color: var(--accent-hover); }

code, pre {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, select, textarea, button { font: inherit; }

::selection {
    background: var(--accent-glow);
    color: #fff;
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.18); background-clip: padding-box; }

/* ---------- BACKGROUND DECORATION ---------- */
.bg-orbs {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    overflow: hidden;
}
.bg-orbs .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
    animation: float 18s ease-in-out infinite;
}
.orb-1 { width: 480px; height: 480px; top: -160px; left: -120px; background: radial-gradient(circle, #6366F1, transparent 70%); }
.orb-2 { width: 560px; height: 560px; bottom: -200px; right: -160px; background: radial-gradient(circle, #A855F7, transparent 70%); animation-delay: -6s; }
.orb-3 { width: 360px; height: 360px; top: 50%; left: 50%; transform: translate(-50%, -50%); background: radial-gradient(circle, #3B82F6, transparent 70%); opacity: 0.18; animation-delay: -12s; }

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(30px, -40px) scale(1.05); }
    66%      { transform: translate(-25px, 25px) scale(0.95); }
}

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(circle at 50% 40%, black 0%, transparent 70%);
    -webkit-mask-image: radial-gradient(circle at 50% 40%, black 0%, transparent 70%);
}

/* ---------- GLASS UTILITY ---------- */
.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 28px;
    margin: 16px 24px 0;
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-md);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}
.brand-icon {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: #fff;
    box-shadow: 0 4px 18px var(--accent-glow);
}
.brand-icon-lg { width: 56px; height: 56px; border-radius: 16px; }

.nav-brand h1 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.nav-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
    letter-spacing: 0.02em;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.db-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-soft);
}
.db-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.6; transform: scale(0.85); }
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--d-base) var(--ease);
    white-space: nowrap;
    user-select: none;
}
.btn svg { flex-shrink: 0; }

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.btn:disabled,
.btn.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: var(--r-sm); }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: var(--r-md); }
.btn-block { width: 100%; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: #fff;
    box-shadow: 0 4px 18px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 6px 24px var(--accent-glow); color: #fff; }

.btn-secondary {
    background: rgba(255,255,255,0.06);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); color: var(--text); }

.btn-ghost {
    background: transparent;
    color: var(--text-soft);
    border-color: var(--border);
}
.btn-ghost:hover {
    background: var(--bg-glass-hover);
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(16,185,129,0.3);
}
.btn-success:hover { color: #fff; }

.btn-danger {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    color: #fff;
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 4px 14px rgba(239,68,68,0.25);
}
.btn-danger:hover {
    background: linear-gradient(135deg, #F87171 0%, #EF4444 100%);
    color: #fff;
    box-shadow: 0 6px 20px rgba(239,68,68,0.4);
    border-color: rgba(239, 68, 68, 0.7);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 24px 80px;
}

.two-col-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* ============================================================
   WORKSPACE SELECTOR
   ============================================================ */
.workspace-container { margin-bottom: 22px; }

.workspace-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    overflow-x: auto;
}

.btn-workspace {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 10px 16px;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--d-base) var(--ease);
    white-space: nowrap;
}
.btn-workspace:hover {
    background: var(--bg-glass-hover);
    color: var(--text);
}
.btn-workspace.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.18) 0%, rgba(168,85,247,0.12) 100%);
    color: var(--text);
    border-color: rgba(99,102,241,0.35);
    box-shadow: 0 0 0 1px rgba(99,102,241,0.2), inset 0 1px 0 rgba(255,255,255,0.04);
}
.ws-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-faint);
    transition: background var(--d-base);
}
.btn-workspace.active .ws-dot {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    transition: transform var(--d-base) var(--ease), border-color var(--d-base);
}
.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
}

.stat-icon {
    width: 44px; height: 44px;
    display: grid; place-items: center;
    border-radius: 12px;
    color: #fff;
    flex-shrink: 0;
}
.icon-blue   { background: linear-gradient(135deg, #3B82F6, #1D4ED8); box-shadow: 0 4px 16px rgba(59,130,246,0.35); }
.icon-purple { background: linear-gradient(135deg, #A855F7, #7C3AED); box-shadow: 0 4px 16px rgba(168,85,247,0.35); }
.icon-green  { background: linear-gradient(135deg, #10B981, #047857); box-shadow: 0 4px 16px rgba(16,185,129,0.35); }
.icon-amber  { background: linear-gradient(135deg, #F59E0B, #D97706); box-shadow: 0 4px 16px rgba(245,158,11,0.35); }

.stat-content h3 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
    line-height: 1.1;
}
.stat-content p {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============================================================
   TABS
   ============================================================ */
.main-tabs {
    display: flex;
    gap: 4px;
    padding: 6px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--r-md);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--d-base) var(--ease);
    white-space: nowrap;
}
.tab-btn:hover { color: var(--text-soft); background: var(--bg-glass-hover); }
.tab-btn.active {
    background: var(--bg-glass-hover);
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--border-strong);
}

.tab-content { display: none; animation: fadeIn var(--d-slow) var(--ease); }
.tab-content.active { display: block; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Sub-pill tabs */
.pill-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.pill-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--bg-glass);
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 500;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--d-base) var(--ease);
}
.pill-tab:hover {
    color: var(--text-soft);
    border-color: var(--border-strong);
}
.pill-tab.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(168,85,247,0.1));
    color: var(--text);
    border-color: rgba(99,102,241,0.35);
}

/* ============================================================
   CARD
   ============================================================ */
.card {
    padding: 22px 24px;
    box-shadow: var(--shadow-md);
    margin-bottom: 18px;
}
.card-narrow { max-width: 760px; margin: 0 auto 18px; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.card-header h2 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card-body { display: block; }

.muted-lead {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.6;
}
.muted-lead code {
    color: var(--accent);
    background: rgba(99,102,241,0.1);
    padding: 1px 6px;
    border-radius: 4px;
}

.form-actions {
    margin-top: 22px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============================================================
   TOOLBAR
   ============================================================ */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 14px;
    border-radius: var(--r-lg);
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 420px;
}
.search-icon {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.search-box input {
    width: 100%;
    padding: 9px 14px 9px 38px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    font-size: 13px;
    transition: all var(--d-base) var(--ease);
}
.search-box input::placeholder { color: var(--text-faint); }
.search-box input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

/* ============================================================
   TABLES
   ============================================================ */
.table-responsive {
    overflow-x: auto;
    margin: 0 -8px;
    padding: 0 8px;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
thead th {
    text-align: left;
    padding: 11px 14px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: rgba(255,255,255,0.02);
}
tbody td {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-soft);
    vertical-align: middle;
}
tbody tr {
    transition: background var(--d-fast) var(--ease);
}
tbody tr:hover { background: var(--bg-glass-hover); }
tbody tr:last-child td { border-bottom: none; }

.cell-strong { color: var(--text); font-weight: 500; }
.cell-prefix {
    font-family: var(--font-mono);
    font-size: 12px;
    background: rgba(99,102,241,0.12);
    color: #C7D2FE;
    padding: 2px 7px;
    border-radius: 4px;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.badge-success { background: var(--success-bg); color: #6EE7B7; border-color: rgba(16,185,129,0.3); }
.badge-warning { background: var(--warning-bg); color: #FCD34D; border-color: rgba(245,158,11,0.3); }
.badge-danger  { background: var(--danger-bg);  color: #FCA5A5; border-color: rgba(239,68,68,0.3); }

/* En modo claro: reforzamos el contraste de los badges con texto más oscuro */
.theme-light .badge-success,
body.theme-light .badge-success { color: #047857; border-color: rgba(16,185,129,0.4); }
.theme-light .badge-warning,
body.theme-light .badge-warning { color: #92400E; border-color: rgba(245,158,11,0.45); }
.theme-light .badge-danger,
body.theme-light .badge-danger  { color: #B91C1C; border-color: rgba(239,68,68,0.4); }

/* Prefijo cell-prefix: reforzar contraste en modo claro */
.theme-light .cell-prefix,
body.theme-light .cell-prefix {
    background: rgba(99,102,241,0.14);
    color: #4338CA;
}

.action-row { display: flex; gap: 6px; flex-wrap: wrap; }
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border-radius: var(--r-sm);
    background: var(--bg-glass);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--d-fast) var(--ease);
}
.action-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text);
    border-color: var(--border-strong);
}
.action-btn.danger:hover {
    background: var(--danger-bg);
    color: #FCA5A5;
    border-color: rgba(239,68,68,0.4);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-soft);
    letter-spacing: 0.01em;
}
.req { color: var(--danger); }

.form-control {
    width: 100%;
    padding: 9px 13px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    font-size: 13.5px;
    font-family: inherit;
    transition: all var(--d-base) var(--ease);
    -webkit-appearance: none;
    appearance: none;
}
.form-control::placeholder { color: var(--text-faint); }
.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
    background: var(--bg-base);
}

/* Forzar estilos oscuros incluso cuando el navegador autocompleta (Chrome pinta fondo amarillo/blanco) */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus,
.form-control:-webkit-autofill:active {
    -webkit-text-fill-color: var(--text) !important;
    -webkit-box-shadow: 0 0 0 1000px var(--bg-base) inset !important;
    caret-color: var(--text);
    transition: background-color 5000s ease-in-out 0s;
}
textarea.form-control { resize: vertical; min-height: 80px; line-height: 1.5; }
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' 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 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-text {
    margin-top: 5px;
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.4;
}

.form-control-file {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* File drop zone */
.file-drop {
    position: relative;
    border: 1.5px dashed rgba(255,255,255,0.18);
    border-radius: var(--r-lg);
    background: var(--bg-base);
    transition: all var(--d-base) var(--ease);
}
.file-drop:hover,
.file-drop.is-dragover {
    border-color: var(--border-focus);
    background: rgba(99,102,241,0.06);
}
.file-drop.is-dragover {
    transform: scale(1.005);
    box-shadow: 0 0 0 4px rgba(99,102,241,0.1);
}
.file-drop-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    color: var(--text-muted);
}
.file-drop-label svg { color: var(--accent); opacity: 0.85; transition: transform var(--d-base) var(--ease); }
.file-drop:hover .file-drop-label svg { transform: translateY(-2px); }
.file-drop-text { font-size: 13.5px; color: var(--text-muted); }
.file-drop-text strong { color: var(--text-soft); font-weight: 500; }
.file-drop-name {
    font-size: 11.5px;
    color: var(--text-faint);
    font-family: var(--font-mono);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-drop.has-file .file-drop-label { padding: 22px 20px; }
.file-drop.has-file .file-drop-label svg { color: var(--success); }

/* Password input with toggle */
.input-password {
    position: relative;
}
.input-password .form-control { padding-right: 40px; }
.toggle-pass {
    position: absolute;
    right: 6px; top: 50%;
    transform: translateY(-50%);
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--d-fast) var(--ease);
}
.toggle-pass:hover { color: var(--text); background: var(--bg-glass-hover); }
.toggle-pass.active { color: var(--accent); }

/* Password strength meter */
.pw-strength {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.pw-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-base);
    border-radius: 999px;
    overflow: hidden;
}
.pw-bar span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: var(--danger);
    transition: width var(--d-base) var(--ease), background var(--d-base);
}
.pw-label {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 80px;
    text-align: right;
}

.pw-checklist {
    list-style: none;
    padding: 0;
    margin: 10px 0 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 4px 12px;
}
.pw-checklist li {
    position: relative;
    padding-left: 18px;
    font-size: 11.5px;
    color: var(--text-muted);
    transition: color var(--d-base);
}
.pw-checklist li::before {
    content: '';
    position: absolute;
    left: 0; top: 5px;
    width: 11px; height: 11px;
    border-radius: 50%;
    border: 1.5px solid var(--text-faint);
    transition: all var(--d-base) var(--ease);
}
.pw-checklist li.is-ok {
    color: var(--success);
}
.pw-checklist li.is-ok::before {
    background: var(--success);
    border-color: var(--success);
    box-shadow: 0 0 0 2px rgba(16,185,129,0.18);
}

/* ============================================================
   INFO BOXES (used in modals)
   ============================================================ */
.info-box {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--text-soft);
}
.info-box-warn {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    background: var(--warning-bg);
    border-color: rgba(245,158,11,0.25);
    color: #FCD34D;
    font-size: 12px;
}
.info-box-warn svg { flex-shrink: 0; margin-top: 2px; }

.danger-box {
    background: rgba(239,68,68,0.06);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: var(--r-md);
    padding: 12px 14px;
    margin-bottom: 16px;
}
.danger-box-name {
    font-weight: 600;
    color: #FCA5A5;
    font-size: 14px;
}
.danger-box-meta {
    font-size: 12px;
    color: #F87171;
    margin-top: 4px;
}
.danger-box-meta code {
    color: #FCA5A5;
    background: rgba(239,68,68,0.18);
    padding: 1px 5px;
    border-radius: 3px;
}

.text-danger { color: var(--danger); }

/* ============================================================
   HERO CTA (WordPress installer card)
   ============================================================ */
.hero-cta {
    text-align: center;
    padding: 32px 20px;
    background: var(--bg-base);
    border-radius: var(--r-lg);
    border: 1px dashed var(--border-strong);
}
.hero-cta-icon {
    width: 64px; height: 64px;
    margin: 0 auto 14px;
    display: grid; place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(168,85,247,0.12));
    color: var(--accent);
    border: 1px solid var(--border);
}
.hero-cta h3 {
    font-size: 17px;
    margin-bottom: 8px;
    color: var(--text);
}
.hero-cta p {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 460px;
    margin: 0 auto 18px;
    line-height: 1.6;
}

/* ============================================================
   DB CONNECTION STATUS
   ============================================================ */
.db-status-list { display: grid; gap: 10px; }
.db-status-loading {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}
.db-status-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 13px;
}
.db-status-item.ok { border-color: rgba(16,185,129,0.3); }
.db-status-item.fail { border-color: rgba(239,68,68,0.3); }
.db-status-info { display: flex; align-items: center; gap: 10px; }
.db-status-info .db-name { color: var(--text); font-weight: 500; }
.db-status-info .db-host { color: var(--text-muted); font-size: 11.5px; font-family: var(--font-mono); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 10, 16, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: overlayIn var(--d-base) var(--ease);
}
.modal-overlay.open { display: flex; }
@keyframes overlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal {
    width: 100%;
    max-width: 540px;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, rgba(28,32,46,0.85) 0%, rgba(18,21,30,0.9) 100%);
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    animation: modalIn var(--d-slow) var(--ease-out);
    overflow: hidden;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-lg { max-width: 920px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.modal-close {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: all var(--d-fast) var(--ease);
}
.modal-close:hover {
    background: var(--bg-glass-hover);
    color: var(--text);
}

.modal-body {
    padding: 20px 22px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,0.15);
}

/* Explorer modal layout */
.explorer-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 500px;
}
.explorer-side {
    border-right: 1px solid var(--border);
    overflow-y: auto;
    background: rgba(0,0,0,0.15);
}
.explorer-main {
    padding: 20px;
    overflow-y: auto;
}

/* Snippet code box */
.code-box {
    position: relative;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 18px 18px 18px 18px;
    overflow-x: auto;
    margin-top: 12px;
}
.code-box code {
    display: block;
    color: #A5B4FC;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.65;
    white-space: pre;
}
.copy-btn {
    position: absolute;
    top: 10px; right: 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-soft);
    font-size: 11.5px;
    cursor: pointer;
    transition: all var(--d-fast) var(--ease);
}
.copy-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text);
    border-color: var(--border-strong);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    min-width: 280px;
    max-width: 380px;
    padding: 14px 18px;
    background: linear-gradient(180deg, rgba(28,32,46,0.95), rgba(18,21,30,0.95));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    color: var(--text);
    font-size: 13px;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all var(--d-slow) var(--ease-out);
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error   { border-left: 3px solid var(--danger); }
.toast.toast-warning { border-left: 3px solid var(--warning); }
.toast.toast-info    { border-left: 3px solid var(--info); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}
.login-wrap {
    width: 100%;
    max-width: 420px;
}
.login-card {
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
    border-radius: var(--r-2xl);
}
.login-brand {
    text-align: center;
    margin-bottom: 28px;
}
.login-brand .brand-icon {
    margin: 0 auto 16px;
}
.login-brand h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 0%, #C7D2FE 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.login-brand p {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    font-size: 13px;
    margin-bottom: 18px;
}
.alert svg { flex-shrink: 0; }
.alert-danger {
    background: var(--danger-bg);
    border: 1px solid rgba(239,68,68,0.3);
    color: #FCA5A5;
}

.login-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: 11.5px;
    color: var(--text-faint);
}

/* ============================================================
   SKELETON LOADER
   ============================================================ */
.skeleton {
    display: inline-block;
    background: linear-gradient(90deg,
        rgba(255,255,255,0.04) 0%,
        rgba(255,255,255,0.09) 50%,
        rgba(255,255,255,0.04) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
    border-radius: var(--r-sm);
}
@keyframes shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}
.skeleton-row { height: 42px; margin: 6px 0; border-radius: var(--r-md); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.6;
}
.empty-state h4 {
    color: var(--text-soft);
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 6px;
}
.empty-state p {
    font-size: 13px;
    color: var(--text-muted);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .navbar {
        margin: 12px 12px 0;
        padding: 12px 16px;
        flex-wrap: wrap;
    }
    .nav-brand h1 { font-size: 14px; }
    .nav-actions { width: 100%; justify-content: flex-end; }
    .container { padding: 16px 12px 60px; }
    .two-col-grid { grid-template-columns: 1fr; }
    .explorer-grid { grid-template-columns: 200px 1fr; height: 400px; }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { padding: 14px 16px; }
    .modal-overlay { padding: 0; align-items: stretch; }
    .modal {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        height: 100vh;
    }
    .modal-lg { max-width: 100%; }
    .explorer-grid { grid-template-columns: 1fr; height: auto; }
    .explorer-side { border-right: none; border-bottom: 1px solid var(--border); max-height: 200px; }
    .toast {
        left: 12px; right: 12px;
        min-width: auto; max-width: none;
        bottom: 12px;
    }
    .pill-tabs { gap: 6px; }
    .pill-tab { font-size: 11.5px; padding: 7px 11px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar > div { display: flex; justify-content: flex-end; }
    .search-box { max-width: 100%; }
    .card { padding: 18px 16px; }
    .nav-actions .btn span { display: none; }
    .login-card { padding: 28px 22px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* ============================================================
   THEME TOGGLE BUTTON
   ============================================================ */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    color: var(--text-soft);
    cursor: pointer;
    transition: all var(--d-base) var(--ease);
    position: relative;
    overflow: hidden;
}
.theme-toggle:hover {
    background: var(--bg-glass-hover);
    color: var(--text);
    border-color: var(--border-strong);
    transform: rotate(15deg);
}
.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.theme-toggle svg {
    width: 18px; height: 18px;
    transition: transform var(--d-slow) var(--ease), opacity var(--d-base) var(--ease);
}
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }

/* Cuando el tema activo es claro, mostramos el sol (para volver a oscuro) */
.theme-light .theme-toggle .icon-sun  { display: block; }
.theme-light .theme-toggle .icon-moon { display: none; }

/* Botón flotante fijo en la esquina superior derecha (login) */
.theme-toggle-fixed {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 50;
    width: 42px; height: 42px;
}
.theme-toggle-fixed svg { width: 20px; height: 20px; }

/* ============================================================
   LIGHT THEME (Luz día)
   ------------------------------------------------------------
   Se activa con <body class="theme-light"> o <html class="theme-light">
   Sobrescribe solo las variables de color; todo el layout se mantiene.
   ============================================================ */
.theme-light {
    /* Base palette */
    --bg-base:        #F6F7FB;
    --bg-elevated:    #FFFFFF;
    --bg-glass:       rgba(255, 255, 255, 0.7);
    --bg-glass-hover: rgba(255, 255, 255, 0.95);

    /* Borders */
    --border:         rgba(15, 23, 42, 0.08);
    --border-strong:  rgba(15, 23, 42, 0.16);
    --border-focus:   rgba(99, 102, 241, 0.5);

    /* Text */
    --text:           #0F172A;
    --text-soft:      #334155;
    --text-muted:     #64748B;
    --text-faint:     #94A3B8;

    /* Brand accents (más saturados para mejor contraste sobre blanco) */
    --accent:         #4F46E5;
    --accent-hover:   #4338CA;
    --accent-2:       #9333EA;
    --accent-glow:    rgba(79, 70, 229, 0.25);

    /* Status */
    --success:        #059669;
    --success-bg:     rgba(16, 185, 129, 0.12);
    --warning:        #D97706;
    --warning-bg:     rgba(245, 158, 11, 0.14);
    --danger:         #DC2626;
    --danger-bg:      rgba(239, 68, 68, 0.10);
    --info:           #2563EB;
    --info-bg:        rgba(59, 130, 246, 0.12);

    /* Legacy aliases */
    --gray-500:       #64748B;
    --dark:           #0F172A;

    /* Stat card icon colors (más oscuros para mejor contraste) */
    --icon-blue:      #3B82F6;
    --icon-purple:    #9333EA;
    --icon-green:     #059669;
    --icon-amber:     #D97706;

    /* Shadows (más visibles sobre fondo claro) */
    --shadow-sm:  0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md:  0 4px 14px rgba(15, 23, 42, 0.08);
    --shadow-lg:  0 12px 36px rgba(15, 23, 42, 0.12);
    --shadow-glow: 0 0 0 1px var(--border-focus), 0 8px 24px rgba(79, 70, 229, 0.15);
}

/* En modo claro: el fondo base del body cambia */
.theme-light body,
body.theme-light {
    background: #F6F7FB;
    color: var(--text);
}

/* Glass en modo claro: más opaco para que se vea el blur */
.theme-light .glass,
body.theme-light .glass {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-md);
}

/* Orbes de luz: más sutiles en modo claro */
.theme-light .bg-orbs .orb,
body.theme-light .bg-orbs .orb {
    opacity: 0.18;
    filter: blur(100px);
}

/* Grid de fondo: más sutil en claro */
.theme-light .bg-grid,
body.theme-light .bg-grid {
    background-image:
        linear-gradient(rgba(15,23,42,0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15,23,42,0.035) 1px, transparent 1px);
}

/* Modal en modo claro */
.theme-light .modal,
body.theme-light .modal {
    background: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(248,250,252,0.95) 100%);
    border-color: rgba(15, 23, 42, 0.12);
}

.theme-light .modal-overlay,
body.theme-light .modal-overlay {
    background: rgba(241, 245, 249, 0.7);
}

/* Code box en claro */
.theme-light .code-box,
body.theme-light .code-box {
    background: #0F172A;
    border-color: #1E293B;
}
.theme-light .code-box code,
body.theme-light .code-box code {
    color: #A5B4FC;
}

/* Inputs: el autofill en modo claro debe verse blanco */
.theme-light .form-control:-webkit-autofill,
body.theme-light .form-control:-webkit-autofill {
    -webkit-text-fill-color: var(--text) !important;
    -webkit-box-shadow: 0 0 0 1000px #FFFFFF inset !important;
}

/* Skeleton loader en claro */
.theme-light .skeleton,
body.theme-light .skeleton {
    background: linear-gradient(90deg,
        rgba(15,23,42,0.04) 0%,
        rgba(15,23,42,0.09) 50%,
        rgba(15,23,42,0.04) 100%);
}

/* Tabla: hover más visible en claro */
.theme-light thead th,
body.theme-light thead th {
    background: rgba(15, 23, 42, 0.025);
    color: var(--text-muted);
}
.theme-light tbody tr:hover,
body.theme-light tbody tr:hover {
    background: rgba(99, 102, 241, 0.04);
}

/* File drop zone en claro */
.theme-light .file-drop,
body.theme-light .file-drop {
    background: rgba(248, 250, 252, 0.6);
}

/* Login card en modo claro */
.theme-light .login-card,
body.theme-light .login-card {
    background: rgba(255, 255, 255, 0.85);
}

/* Botón primario en claro: ya tiene su gradiente, pero reforzamos sombra */
.theme-light .btn-primary,
body.theme-light .btn-primary {
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

/* Smooth transition al cambiar de tema */
body, .glass, .modal, .form-control, .btn, .stat-card,
.btn-workspace, .tab-btn, .pill-tab, .action-btn, .navbar,
.workspace-selector, .main-tabs, .toolbar, .card, .toast {
    transition: background-color var(--d-slow) var(--ease),
                border-color var(--d-slow) var(--ease),
                color var(--d-slow) var(--ease),
                box-shadow var(--d-base) var(--ease),
                transform var(--d-base) var(--ease);
}

/* ============================================================
   AUTO-DETECCIÓN DEL SISTEMA (sin JS)
   Si el usuario no ha elegido manualmente, respetamos prefers-color-scheme
   ============================================================ */
@media (prefers-color-scheme: light) {
    :root:not(.theme-light):not(.theme-dark) {
        /* Mismas variables que .theme-light */
        --bg-base:        #F6F7FB;
        --bg-elevated:    #FFFFFF;
        --bg-glass:       rgba(255, 255, 255, 0.7);
        --bg-glass-hover: rgba(255, 255, 255, 0.95);
        --border:         rgba(15, 23, 42, 0.08);
        --border-strong:  rgba(15, 23, 42, 0.16);
        --border-focus:   rgba(99, 102, 241, 0.5);
        --text:           #0F172A;
        --text-soft:      #334155;
        --text-muted:     #64748B;
        --text-faint:     #94A3B8;
        --accent:         #4F46E5;
        --accent-hover:   #4338CA;
        --accent-2:       #9333EA;
        --accent-glow:    rgba(79, 70, 229, 0.25);
        --success:        #059669;
        --warning:        #D97706;
        --danger:         #DC2626;
        --info:           #2563EB;
        --gray-500:       #64748B;
        --dark:           #0F172A;
        --icon-blue:      #3B82F6;
        --icon-purple:    #9333EA;
        --icon-green:     #059669;
        --icon-amber:     #D97706;
        --shadow-sm:  0 1px 2px rgba(15, 23, 42, 0.06);
        --shadow-md:  0 4px 14px rgba(15, 23, 42, 0.08);
        --shadow-lg:  0 12px 36px rgba(15, 23, 42, 0.12);
    }
    :root:not(.theme-light):not(.theme-dark) body {
        background: #F6F7FB;
    }
    :root:not(.theme-light):not(.theme-dark) .glass {
        background: rgba(255, 255, 255, 0.7);
        border-color: rgba(255, 255, 255, 0.9);
        box-shadow: var(--shadow-md);
    }
    :root:not(.theme-light):not(.theme-dark) .bg-orbs .orb {
        opacity: 0.18;
        filter: blur(100px);
    }
}
