/* ═══════════════════════════════════════════════════════════
   Mi Plataforma Personal — Design System
   Dark navy + white + green (#57cc98) · Poppins · Visual
   ═══════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─── */
:root {
    /* Brand – Dark navy blue */
    --brand-dark: #0f1923;
    --brand: #162231;
    --brand-light: #1e2d3f;
    --brand-end: #111d2a;

    /* Accent – Green */
    --gold: #57cc98;
    --gold-hover: #45b584;
    --gold-muted: rgba(87, 204, 152, 0.15);

    /* Functional greens */
    --green-action: #57cc98;
    --green-action-hover: #45b584;

    /* Module colors */
    --color-ideas: #f59e0b;
    --color-notas: #3b82f6;
    --color-tareas: #57cc98;
    --color-enlaces: #8b5cf6;
    --color-inventario: #f97316;
    --color-contabilidad: #06b6d4;
    --color-tableros: #ec4899;
    --color-hoy: #34d399;
    --color-dieta: #f472b6;
    --color-findhub: #f97316;

    /* Surfaces */
    --bg: #f4f6f8;
    --surface: #FFFFFF;
    --surface-alt: #f0f2f5;
    --surface-hover: #eaedf1;

    /* Borders */
    --border: #dde1e6;
    --border-light: #e8ecf0;

    /* Text */
    --text: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --text-inverse: #FFFFFF;

    /* Accent link */
    --accent: #57cc98;
    --accent-hover: #45b584;
    --accent-light: rgba(87, 204, 152, 0.08);

    /* Status */
    --success: #009688;
    --success-light: #e6f7f5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #3b82f6;
    --info-light: #eff6ff;

    /* Focus */
    --focus-ring: #57cc98;

    /* Elevation (dual shadows for depth) */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07), 0 1px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10), 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);

    /* Shape */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-pill: 999px;

    /* Spacing (8pt base) */
    --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;

    /* Layout */
    --header-height: 60px;
    --sidebar-width: 62px;
    --sidebar-width-expanded: 230px;

    /* Transitions */
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;
}


/* ─── Reset ─── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

::selection {
    background: rgba(87, 204, 152, 0.25);
    color: var(--text);
}

/* ─── Base ─── */
/* Layout viewport-fit: body NO scrollea, scroll va en .main.
   Fix bug "scroll vertical extra con espacio vacío al final".
   Patrón Gmail/Notion/Linear: viewport exacto + scroll interno en main. */
body {
    font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
}

:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }


/* ─── Custom Scrollbar ─── */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
html { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }


/* ─── Environment accents ─── */
body[data-env="local"] {
    --env-accent: #57cc98;
    --env-surface: rgba(87, 204, 152, 0.08);
    --env-border: rgba(87, 204, 152, 0.24);
}

body[data-env="shared-dev"] {
    --env-accent: #f59e0b;
    --env-surface: rgba(245, 158, 11, 0.08);
    --env-border: rgba(245, 158, 11, 0.24);
}

body[data-env="production"] {
    --env-accent: #ef4444;
    --env-surface: rgba(239, 68, 68, 0.08);
    --env-border: rgba(239, 68, 68, 0.24);
}


/* ─── Keyframes ─── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}


/* ═══════════════════════════════════════
   HEADER
   ═══════════════════════════════════════ */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-light) 100%);
    display: flex;
    align-items: center;
    padding: 0 var(--space-6);
    z-index: 200;
    box-shadow: 0 4px 15px rgba(15, 25, 35, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    white-space: nowrap;
    letter-spacing: 0.02em;
    transition: color 0.2s, transform 0.15s;
    cursor: pointer;
    text-decoration: none;
}

.header-logo:hover { color: #fff; transform: scale(1.03); }

.header-logo .logo-accent {
    color: var(--green-action);
}

/* Header module navigation */
.header-modules {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: var(--space-6);
}

.header-module {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: rgba(0, 0, 0, 0.55);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all var(--duration-fast) ease;
    position: relative;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Each module gets its own iOS-style color */
.header-module:nth-child(1) { background: linear-gradient(145deg, #6ec6ff, #42a5f5); }  /* Dashboard - blue */
.header-module:nth-child(2) { background: linear-gradient(145deg, #ffca4f, #f59e0b); }  /* Ideas - amber */
.header-module:nth-child(3) { background: linear-gradient(145deg, #64b5f6, #3b82f6); }  /* Notas - blue */
.header-module:nth-child(4) { background: linear-gradient(145deg, #6ee7a0, #34d072); }  /* Tareas - green */
.header-module:nth-child(5) { background: linear-gradient(145deg, #b39ddb, #8b5cf6); }  /* Enlaces - purple */
.header-module:nth-child(6) { background: linear-gradient(145deg, #ffb74d, #f97316); }  /* Inventario - orange */
.header-module:nth-child(7) { background: linear-gradient(145deg, #4dd0e1, #06b6d4); }  /* Contabilidad - cyan */
.header-module:nth-child(8) { background: linear-gradient(145deg, #f48fb1, #ec4899); }  /* Tableros - pink */
.header-module:nth-child(9) { background: linear-gradient(145deg, #ffab91, #d97706); }   /* Plan Maestro - terracotta */
.header-module:nth-child(10) { background: linear-gradient(145deg, #ff8a80, #ef4444); }  /* Calendario - red */
.header-module:nth-child(11) { background: linear-gradient(145deg, #80deea, #14b8a6); }  /* Claude Workspace - teal */
.header-module:nth-child(12) { background: linear-gradient(145deg, #ce93d8, #a855f7); }  /* Voz - violet */
.header-module:nth-child(13) { background: linear-gradient(145deg, #a5d6a7, #57cc98); }  /* Agent - centella green */
.header-module:nth-child(14) { background: linear-gradient(145deg, #ffccbc, #ff7043); }  /* Avatar Lab - coral */
.header-module:nth-child(15) { background: linear-gradient(145deg, #fff59d, #eab308); }  /* Tutoriales - yellow */
.header-module:nth-child(16) { background: linear-gradient(145deg, #c4a3f5, #a855f7); }  /* Daily Scout - purple */
.header-module.mod-modulos { background: linear-gradient(145deg, #a5d6a7, #57cc98); }  /* Tablero de agentes - centella green */
.header-module.mod-findhub { background: linear-gradient(145deg, #fdba74, var(--color-findhub, #f97316)); }  /* Mi moto (localizador) */

.header-module:hover {
    transform: scale(1.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
    color: rgba(0, 0, 0, 0.7);
}

.header-module.active {
    color: rgba(0, 0, 0, 0.75);
    transform: scale(1.05);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-left: auto;
}

.header-env-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    background: var(--env-accent, var(--green-action));
    color: var(--text-inverse);
    border: none;
    font-family: inherit;
}

.header-env-badge--clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-env-badge--clickable:hover {
    filter: brightness(1.15);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}

.header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.65);
    border: none;
    cursor: pointer;
    transition: all var(--duration-fast) ease;
    text-decoration: none;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: var(--green-action);
    transform: scale(1.08);
}

.header-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.75;
}

/* Dev tools dropdown */
.dev-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--brand);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    z-index: 1000;
}
.header-dev-menu.open .dev-dropdown { display: block; }
.dev-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.82rem;
    transition: background 0.15s;
}
.dev-dropdown a:hover {
    background: rgba(255,255,255,0.08);
    color: var(--green-action);
}



/* Sidebar removed — navigation lives in header now */


/* ═══════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════ */
.main {
    /* Viewport-fit: main ocupa el espacio restante del body (que es flex
       column de altura 100vh). El header está fixed encima, así que
       compensamos con padding-top en lugar de margin-top — esto evita
       que main genere overflow del body. Si el contenido excede, scrollea
       INTERNAMENTE el main, no el body. */
    margin-left: 0;
    margin-top: 0;
    flex: 1 1 0%;
    min-height: 0;          /* crítico con flex column para que overflow auto funcione */
    height: 100%;
    padding-top: calc(var(--header-height) + var(--space-8));
    padding-right: var(--space-10);
    padding-bottom: var(--space-6);
    padding-left: var(--space-10);
    overflow-y: auto;
    scrollbar-gutter: stable; /* que el ancho no baile cuando aparece/desaparece la barra */
    overflow-x: hidden;
    animation: fadeIn var(--duration-normal) ease;
}

.page-header {
    margin-bottom: var(--space-8);
    animation: fadeInUp var(--duration-normal) ease;
}

.page-header h1 {
    font-size: 1.7rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.page-header h1 svg {
    width: 28px;
    height: 28px;
    stroke-width: 1.75;
    color: var(--green-action);
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: var(--space-1);
    font-weight: 400;
}


/* ─── Runtime banner ─── */
.runtime-banner {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--env-border, var(--border-light));
    border-radius: var(--radius);
    background: var(--env-surface, var(--surface-alt));
    animation: fadeInUp var(--duration-normal) ease 0.1s both;
}

.runtime-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    padding: 6px var(--space-4);
    border-radius: var(--radius-pill);
    background: var(--env-accent, var(--green-action));
    color: var(--text-inverse);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.runtime-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.runtime-copy strong {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
}

.runtime-copy span {
    color: var(--text-muted);
    font-size: 0.82rem;
    word-break: break-word;
}

.runtime-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}


/* ═══════════════════════════════════════
   STATS GRID (colorful icons)
   ═══════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-5);
    margin-bottom: var(--space-8);
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: transform 0.25s var(--ease-smooth), box-shadow 0.25s, border-color 0.25s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
    animation: fadeInUp 0.4s ease-out both;
    box-shadow: var(--shadow-xs);
}

.stat-card:nth-child(1) { animation-delay: 0.04s; }
.stat-card:nth-child(2) { animation-delay: 0.08s; }
.stat-card:nth-child(3) { animation-delay: 0.12s; }
.stat-card:nth-child(4) { animation-delay: 0.16s; }
.stat-card:nth-child(5) { animation-delay: 0.20s; }
.stat-card:nth-child(6) { animation-delay: 0.24s; }
.stat-card:nth-child(7) { animation-delay: 0.28s; }
.stat-card:nth-child(8) { animation-delay: 0.32s; }

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border);
}

.stat-card:active {
    transform: translateY(-1px);
}

.stat-card .icon-big {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    margin-bottom: var(--space-4);
}

/* Each module gets its own icon color */
.stat-card:nth-child(1) .icon-big { background: rgba(245, 158, 11, 0.12); color: var(--color-ideas); }
.stat-card:nth-child(2) .icon-big { background: rgba(59, 130, 246, 0.12); color: var(--color-notas); }
.stat-card:nth-child(3) .icon-big { background: rgba(87, 204, 152, 0.12); color: var(--color-tareas); }
.stat-card:nth-child(4) .icon-big { background: rgba(139, 92, 246, 0.12); color: var(--color-enlaces); }
.stat-card:nth-child(5) .icon-big { background: rgba(249, 115, 22, 0.12); color: var(--color-inventario); }
.stat-card:nth-child(6) .icon-big { background: rgba(6, 182, 212, 0.12); color: var(--color-contabilidad); }
.stat-card:nth-child(7) .icon-big { background: rgba(236, 72, 153, 0.12); color: var(--color-tableros); }

.stat-card .icon-big svg {
    width: 24px;
    height: 24px;
    stroke-width: 1.75;
}

.stat-card .label {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 500;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    margin-top: var(--space-1);
    color: var(--text);
    letter-spacing: -0.03em;
}


/* ═══════════════════════════════════════
   CARDS
   ═══════════════════════════════════════ */
.card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-5);
    transition: transform 0.25s var(--ease-smooth), box-shadow 0.25s, border-color 0.25s;
    box-shadow: var(--shadow-xs);
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border);
}

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

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.card-header h2 svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.75;
    color: var(--green-action);
}

.card-header a {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--green-action);
}

.card-header a:hover {
    color: var(--green-action-hover);
}


/* ═══════════════════════════════════════
   TABLES
   ═══════════════════════════════════════ */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }

th {
    position: sticky;
    top: 0;
    z-index: 10;
    text-align: left;
    padding: var(--space-3) var(--space-4);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
    user-select: none;
}

td {
    padding: 10px var(--space-4);
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

tbody tr:nth-child(even) { background: var(--surface-alt); }
tbody tr:hover td { background: rgba(87, 204, 152, 0.06); transition: background 0.15s; }


/* ═══════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px var(--space-5);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.4;
    font-family: inherit;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.01em;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255,255,255,0.12), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

.btn:hover::after { opacity: 1; }

.btn svg { width: 18px; height: 18px; stroke-width: 1.75; }

.btn-primary {
    background: var(--brand-dark);
    color: #fff;
    border-color: var(--brand-dark);
}

.btn-primary:hover {
    background: var(--brand-light);
    border-color: var(--brand-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--surface-alt);
    border-color: var(--border);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--surface-alt);
    color: var(--text);
}

.btn-gold {
    background: var(--green-action);
    color: #fff;
    border-color: var(--green-action);
    font-weight: 600;
}

.btn-gold:hover {
    background: var(--green-action-hover);
    border-color: var(--green-action-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(87, 204, 152, 0.3);
}

.btn-sm { padding: 5px 12px; font-size: 0.82rem; }

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-danger:hover { background: #dc2626; border-color: #dc2626; }

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}


/* ═══════════════════════════════════════
   FORMS
   ═══════════════════════════════════════ */
.form-group { margin-bottom: var(--space-5); }

.form-group label {
    display: block;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 11px var(--space-4);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:focus {
    border-color: var(--green-action);
    box-shadow: 0 0 0 3px rgba(87, 204, 152, 0.15);
}

textarea.form-control { min-height: 120px; resize: vertical; }

select.form-control {
    appearance: none;
    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='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--green-action);
    cursor: pointer;
}


/* ═══════════════════════════════════════
   MODAL
   ═══════════════════════════════════════ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 25, 35, 0.5);
    backdrop-filter: blur(4px);
    z-index: 300;
    justify-content: center;
    align-items: center;
}

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

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid var(--border-light);
    box-shadow: 0 16px 48px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.08);
    animation: scaleIn 0.25s ease-out;
}

.modal h2 {
    margin: 0;
    padding: var(--space-5) var(--space-6);
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-light) 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal form {
    padding: var(--space-6);
    background: var(--bg);
    animation: fadeIn 0.3s ease-out 0.1s both;
}

.modal-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    margin-top: var(--space-5);
    padding-top: var(--space-5);
    border-top: 1px solid var(--border-light);
}


/* ═══════════════════════════════════════
   TAGS
   ═══════════════════════════════════════ */
.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    background: var(--surface-alt);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    margin: 2px;
    font-weight: 500;
}


/* ═══════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: 56px var(--space-8);
    color: var(--text-muted);
}

.empty-state .icon-huge {
    width: 72px;
    height: 72px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: var(--surface-alt);
    color: var(--text-muted);
    margin: 0 auto var(--space-5);
}

.empty-state .icon-huge svg { width: 32px; height: 32px; stroke-width: 1.5; }
.empty-state p { margin-bottom: var(--space-5); font-size: 0.95rem; }


/* ═══════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: var(--space-8);
    left: 50%;
    transform: translateX(-50%);
    z-index: 400;
    width: 90%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.toast {
    background: #fff;
    border: none;
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-5);
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.4s ease-out;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.toast.success { background: var(--success-light); color: var(--success); border-left: 3px solid var(--success); }
.toast.error { background: var(--danger-light); color: var(--danger); border-left: 3px solid var(--danger); }


/* ═══════════════════════════════════════
   SEARCH BAR
   ═══════════════════════════════════════ */
.search-bar {
    position: relative;
    margin-bottom: var(--space-6);
    animation: fadeInUp var(--duration-normal) ease 0.1s both;
}

.search-bar input {
    width: 100%;
    padding: 14px var(--space-5) 14px 48px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
}

.search-bar input::placeholder { color: var(--text-muted); }

.search-bar input:focus {
    border-color: var(--green-action);
    box-shadow: 0 0 0 3px rgba(87, 204, 152, 0.15), 0 0 20px rgba(87, 204, 152, 0.08);
}

.search-bar .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.search-results {
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: var(--space-1);
    max-height: 320px;
    overflow-y: auto;
    z-index: 150;
    box-shadow: var(--shadow-xl);
    display: none;
    animation: fadeInUp 0.2s ease-out;
}

.search-results.active { display: block; }

.search-result-item {
    padding: var(--space-3) var(--space-5);
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.2s ease;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--surface-alt); }

.search-result-item .result-type {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--green-action);
    margin-bottom: 2px;
    font-weight: 600;
}

.search-result-item .result-title {
    font-size: 0.92rem;
    color: var(--text);
}


/* ═══════════════════════════════════════
   ACTIVITY LIST
   ═══════════════════════════════════════ */
.activity-item {
    display: flex;
    align-items: start;
    gap: var(--space-4);
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border-light);
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: rgba(87, 204, 152, 0.1);
    color: var(--green-action);
    flex-shrink: 0;
}

.activity-icon svg { width: 20px; height: 20px; stroke-width: 1.75; }

.activity-text { flex: 1; min-width: 0; }

.activity-text strong {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
}

.activity-text small {
    display: block;
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 3px;
}


/* ═══════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════ */
.alert {
    padding: var(--space-5) var(--space-6);
    border-radius: var(--radius);
    border: 1px solid;
    margin-bottom: var(--space-5);
    font-size: 0.92rem;
    display: flex;
    gap: var(--space-4);
    align-items: flex-start;
}

.alert svg { width: 22px; height: 22px; stroke-width: 1.75; flex-shrink: 0; margin-top: 1px; }

.alert-danger { background: var(--danger-light); border-color: rgba(239,68,68,0.2); color: var(--danger); }
.alert-success { background: var(--success-light); border-color: rgba(0,150,136,0.2); color: var(--success); }
.alert-warning { background: var(--warning-light); border-color: rgba(245,158,11,0.2); color: var(--warning); }


/* ═══════════════════════════════════════
   PRIORITY / INFRA / FINANCE
   ═══════════════════════════════════════ */
.priority-high { border-left: 4px solid var(--warning) !important; }
.priority-urgent { border-left: 4px solid var(--danger) !important; }

.btn-infra {
    background: #fff;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius);
    transition: all 0.3s ease;
    font-size: 0.92rem;
}

.btn-infra:hover {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.btn-infra svg { width: 20px; height: 20px; stroke-width: 1.75; }

.finance-cell { text-align: center; padding: var(--space-4); }

.finance-cell .finance-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.finance-cell .finance-value {
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: var(--space-1);
}


/* ═══════════════════════════════════════
   WELCOME BANNER (dashboard)
   ═══════════════════════════════════════ */
.welcome-banner {
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 50%, var(--brand-light) 100%);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    margin-bottom: var(--space-8);
    color: #fff;
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.5s ease-out;
    box-shadow: 0 6px 28px rgba(15, 25, 35, 0.3);
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -50%; right: -5%;
    width: 300px; height: 300px;
    border: 60px solid rgba(87, 204, 152, 0.08);
    border-radius: 50%;
    pointer-events: none;
}

.welcome-banner::after {
    content: '';
    position: absolute;
    bottom: -40%; left: 10%;
    width: 200px; height: 200px;
    border: 40px solid rgba(59, 130, 246, 0.06);
    border-radius: 50%;
    pointer-events: none;
}

.welcome-banner h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--space-2);
    position: relative;
    color: #fff;
    background: none;
    padding: 0;
    border-radius: 0;
}

.welcome-banner p {
    opacity: 0.65;
    font-size: 0.95rem;
    position: relative;
}


/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 768px) {
    .main {
        /* Mantenemos padding-top compensando el header fixed; el resto se
           reduce a space-5 (20px). */
        padding-top: calc(var(--header-height) + var(--space-5));
        padding-right: var(--space-5);
        padding-bottom: var(--space-5);
        padding-left: var(--space-5);
    }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .runtime-banner { flex-direction: column; align-items: flex-start; }

    .runtime-actions { margin-left: 0; width: 100%; }
    .runtime-actions .btn { width: 100%; justify-content: center; }

    .app-header { padding: 0 var(--space-3); gap: var(--space-2); }

    .header-modules { margin-left: var(--space-2); gap: 4px; overflow-x: auto; }
    .header-module { width: 30px; height: 30px; font-size: 0.8rem; border-radius: 8px; }

    div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}


/* ═══════════════════════════════════════
   DARK MODE
   ═══════════════════════════════════════ */
[data-theme="dark"] {
    /* Surfaces */
    --bg: #0c1520;
    --surface: #162231;
    --surface-alt: #1a2a3b;
    --surface-hover: #1e3045;

    /* Borders */
    --border: #1e2d3f;
    --border-light: #253749;

    /* Text */
    --text: #e8ecf0;
    --text-secondary: #9ca3af;
    --text-muted: #5c6672;

    /* Status lights (slightly brighter for dark bg) */
    --success-light: rgba(0, 150, 136, 0.12);
    --warning-light: rgba(245, 158, 11, 0.12);
    --danger-light: rgba(239, 68, 68, 0.12);
    --info-light: rgba(59, 130, 246, 0.12);

    /* Shadows (stronger for dark) */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3), 0 1px 4px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.2);

    color-scheme: dark;
}

/* Dark mode: explicit overrides for hardcoded whites */
[data-theme="dark"] .btn-secondary {
    background: var(--surface-alt);
    color: var(--text);
}

[data-theme="dark"] .modal {
    background: var(--surface);
}

[data-theme="dark"] .toast {
    background: var(--surface);
}

[data-theme="dark"] .search-bar input {
    background: var(--surface);
}

[data-theme="dark"] .search-results {
    background: var(--surface);
}

[data-theme="dark"] .btn-infra {
    background: var(--surface);
}

[data-theme="dark"] .btn-primary {
    background: var(--gold);
    border-color: var(--gold);
}

[data-theme="dark"] .btn-primary:hover {
    background: var(--gold-hover);
    border-color: var(--gold-hover);
}

/* Dark scrollbar */
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #2a3a4e; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #3a4f66; }
[data-theme="dark"] { scrollbar-color: #2a3a4e transparent; }

/* Dark mode toggle button in header */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.65);
    border: none;
    cursor: pointer;
    transition: all var(--duration-fast) ease;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.14);
    color: var(--gold);
    transform: scale(1.08);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.75;
}

/* ═══════════════════════════════════════════════════════════
   Global Search (Spotlight / Cmd+K)
   ═══════════════════════════════════════════════════════════ */

.header-search-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.header-search-btn:hover {
    color: var(--gold);
}

.gs-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 10vh;
}
.gs-modal.hidden { display: none; }
body.gs-open { overflow: hidden; }

.gs-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 25, 35, 0.55);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    animation: gsFadeIn 160ms var(--ease-smooth);
}

.gs-panel {
    position: relative;
    width: min(640px, calc(100vw - 24px));
    max-height: min(70vh, 600px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: gsSlideIn 200ms var(--ease-smooth);
}
[data-theme="dark"] .gs-panel {
    background: var(--brand);
    border-color: rgba(255, 255, 255, 0.08);
}

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

.gs-input-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-light);
}
[data-theme="dark"] .gs-input-wrap {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}
.gs-input-icon {
    width: 18px; height: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.gs-input {
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    font-size: 17px;
    font-family: inherit;
    color: var(--text);
    padding: 4px 0;
}
[data-theme="dark"] .gs-input { color: var(--text-inverse); }
.gs-input::placeholder { color: var(--text-muted); }
.gs-clear {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.gs-clear:hover { background: var(--surface-alt); color: var(--text); }
[data-theme="dark"] .gs-clear:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-inverse);
}

.gs-results {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2) 0;
}

.gs-empty,
.gs-error,
.gs-loading {
    padding: var(--space-6) var(--space-5);
}
.gs-empty-title {
    font-size: 14px;
    color: var(--text);
    font-weight: 500;
    margin-bottom: 4px;
}
[data-theme="dark"] .gs-empty-title { color: var(--text-inverse); }
.gs-empty-hint {
    font-size: 13px;
    color: var(--text-muted);
}
.gs-empty-shortcuts {
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px dashed var(--border-light);
}
[data-theme="dark"] .gs-empty-shortcuts {
    border-top-color: rgba(255, 255, 255, 0.08);
}
.gs-shortcut-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}
.gs-shortcut-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 0;
}
[data-theme="dark"] .gs-shortcut-row { color: rgba(255,255,255,0.7); }

.gs-error {
    color: var(--danger);
    font-size: 13px;
}

.gs-skeleton {
    height: 44px;
    margin: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--surface-alt) 25%, var(--surface-hover) 50%, var(--surface-alt) 75%);
    background-size: 200% 100%;
    animation: gsShimmer 1.2s linear infinite;
}
[data-theme="dark"] .gs-skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
    background-size: 200% 100%;
}
@keyframes gsShimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

.gs-group { padding: var(--space-2) 0; }
.gs-group-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 6px var(--space-5);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
}
.gs-group-header i { font-size: 12px; }
.gs-group-count {
    margin-left: auto;
    background: var(--surface-alt);
    color: var(--text-muted);
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    font-size: 10px;
    font-weight: 600;
}
[data-theme="dark"] .gs-group-count {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
}

.gs-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px var(--space-5);
    text-decoration: none;
    color: var(--text);
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: background var(--duration-fast) ease;
}
[data-theme="dark"] .gs-item { color: var(--text-inverse); }
.gs-item:hover,
.gs-item.gs-active {
    background: var(--surface-alt);
    border-left-color: var(--gold);
}
[data-theme="dark"] .gs-item:hover,
[data-theme="dark"] .gs-item.gs-active {
    background: rgba(87, 204, 152, 0.08);
}
.gs-item-icon {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
    font-size: 14px;
    opacity: 0.85;
}
.gs-item-body {
    flex: 1;
    min-width: 0;
}
.gs-item-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gs-item-snippet {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
[data-theme="dark"] .gs-item-snippet { color: rgba(255, 255, 255, 0.55); }
.gs-item-snippet mark {
    background: var(--gold-muted);
    color: var(--gold);
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 600;
}
.gs-item-snippet .gs-extra {
    color: var(--text-secondary);
    font-weight: 500;
    margin-right: 4px;
}
[data-theme="dark"] .gs-item-snippet .gs-extra { color: rgba(255,255,255,0.7); }
.gs-item-date {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.gs-item-enter {
    font-size: 11px;
    opacity: 0;
    color: var(--gold);
    transition: opacity var(--duration-fast) ease;
}
.gs-item:hover .gs-item-enter,
.gs-item.gs-active .gs-item-enter {
    opacity: 1;
}

.gs-total {
    text-align: center;
    padding: var(--space-3);
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.gs-footer {
    display: flex;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border-light);
    font-size: 11px;
    color: var(--text-muted);
    background: var(--surface-alt);
}
[data-theme="dark"] .gs-footer {
    border-top-color: rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
}
.gs-footer kbd {
    display: inline-block;
    padding: 1px 6px;
    margin-right: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-family: inherit;
    font-size: 10px;
    color: var(--text-secondary);
    box-shadow: 0 1px 0 var(--border);
}
[data-theme="dark"] .gs-footer kbd,
[data-theme="dark"] .gs-empty-shortcuts kbd {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}
.gs-empty-shortcuts kbd {
    display: inline-block;
    padding: 1px 8px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    min-width: 22px;
    text-align: center;
}

/* ─── Mobile ─── */
@media (max-width: 640px) {
    .gs-modal { padding-top: 0; }
    .gs-panel {
        width: 100vw;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        border: 0;
    }
    .gs-results { padding-bottom: 80px; } /* avoid keyboard overlap */
}

/* ─── Bump version cache ─── */
/* css-version: 20260505c — viewport-fit body+main, fix scroll vacío al final */
