/* ============================================================
   Futur IA — sistema de diseño v2 (se carga al final de cada pantalla
   y manda sobre los estilos antiguos que cada archivo trae incrustados)
   ============================================================ */
:root {
    --fx-ink: #0f172a;
    --fx-ink-2: #334155;
    --fx-muted: #64748b;
    --fx-line: #e2e8f0;
    --fx-bg: #f4f6fb;
    --fx-card: #ffffff;
    --fx-side: #0b1020;
    --fx-side-2: #151b33;
    --fx-primary: #4f46e5;
    --fx-primary-2: #4338ca;
    --fx-primary-soft: #eef2ff;
    --fx-accent: #06b6d4;
    --fx-sun: #fbbf24;
    --fx-ok: #059669;       --fx-ok-soft: #d1fae5;
    --fx-warn: #b45309;     --fx-warn-soft: #fef3c7;
    --fx-bad: #dc2626;      --fx-bad-soft: #fee2e2;
    --fx-info: #0369a1;     --fx-info-soft: #e0f2fe;
    --fx-radius: 14px;
    --fx-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -12px rgba(15, 23, 42, .12);
    --fx-side-w: 256px;
    /* los archivos antiguos usan estas variables */
    --primary-color: #4f46e5;
    --secondary-color: #06b6d4;
    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
    --bs-link-color: #4f46e5;
    --bs-link-hover-color: #4338ca;
    --bs-body-font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--fx-bg);
    color: var(--fx-ink);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}
html body h1, html body h2, html body h3, html body h4, html body h5, html body h6 { color: var(--fx-ink); font-weight: 700; letter-spacing: -.01em; }
html body a { color: var(--fx-primary); }
html body .text-muted { color: var(--fx-muted) !important; }

/* ---------- Menú lateral ---------- */
html body .sidebar.fx-side {
    position: fixed; inset: 0 auto 0 0; width: var(--fx-side-w); height: 100vh;
    background: linear-gradient(180deg, var(--fx-side) 0%, var(--fx-side-2) 100%);
    color: #cbd5e1; display: flex; flex-direction: column; z-index: 1040;
    box-shadow: none; overflow: hidden; padding: 0; transform: none; transition: transform .25s ease;
}
.fx-brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; }
.fx-logo {
    width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
    background: linear-gradient(135deg, var(--fx-primary), var(--fx-accent)); color: #fff; font-size: 17px;
    box-shadow: 0 8px 20px -6px rgba(79, 70, 229, .7);
}
.fx-brand-name { font-size: 20px; font-weight: 800; color: #fff; line-height: 1.1; letter-spacing: -.02em; }
.fx-brand-name span { color: var(--fx-sun); }
.fx-brand-sub { font-size: 11px; color: #7c89a8; margin-top: 2px; }
.fx-nav { flex: 1; overflow-y: auto; padding: 8px 12px; scrollbar-width: thin; }
.fx-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 2px; border-radius: 10px;
    color: #aab4cf !important; text-decoration: none; font-weight: 500; font-size: 14.5px; transition: background .15s, color .15s;
}
.fx-link i { width: 20px; text-align: center; font-size: 15px; opacity: .9; }
.fx-link:hover { background: rgba(255, 255, 255, .06); color: #fff !important; }
.fx-link.is-active { background: linear-gradient(90deg, rgba(79, 70, 229, .95), rgba(79, 70, 229, .65)); color: #fff !important; box-shadow: 0 6px 16px -8px rgba(79, 70, 229, .9); }
.fx-sep { height: 1px; background: rgba(255, 255, 255, .08); margin: 10px 8px; }
.fx-user { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, .08); background: rgba(0, 0, 0, .18); }
.fx-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--fx-primary-soft); color: var(--fx-primary-2); display: grid; place-items: center; font-weight: 800; flex: none; }
.fx-user-data { min-width: 0; flex: 1; }
.fx-user-name { color: #fff; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-user-role { color: #7c89a8; font-size: 11.5px; }
.fx-logout { color: #aab4cf !important; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; }
.fx-logout:hover { background: rgba(220, 38, 38, .18); color: #fecaca !important; }
.fx-backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 1035; }

/* ---------- Área de contenido (dos esqueletos antiguos: content-wrapper y main-content) ---------- */
html body .content-wrapper, html body .main-content {
    margin-left: var(--fx-side-w); width: auto; min-height: 100vh; padding: 0; background: transparent; transition: none;
}
html body .main-content { padding: 0 28px 40px; }
html body .content-wrapper > .container-fluid, html body .content-wrapper > .container { padding: 24px 28px 40px !important; max-width: 1500px; }
html body .top-navbar, html body .top-bar {
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: rgba(255, 255, 255, .88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--fx-line);
    padding: 14px 28px; margin: 0 0 4px; box-shadow: none; min-height: 64px;
}
html body .main-content > .top-bar { margin: 0 -28px 24px; }
html body .page-title { font-size: 20px; font-weight: 800; margin: 0; color: var(--fx-ink); letter-spacing: -.02em; }
html body #sidebarToggle, html body #menu-toggle { display: none; color: var(--fx-ink) !important; cursor: pointer; padding: 6px 8px; }
html body .section-header { font-size: 15px; font-weight: 700; color: var(--fx-ink); border: 0; padding: 0; margin: 4px 0 14px; background: none; }
html body .section-header i { color: var(--fx-primary); }

/* ---------- Tarjetas ---------- */
html body .card { border: 1px solid var(--fx-line); border-radius: var(--fx-radius); box-shadow: var(--fx-shadow); background: var(--fx-card); overflow: hidden; }
html body .card-header { background: #fff; border-bottom: 1px solid var(--fx-line); padding: 14px 20px; font-weight: 700; color: var(--fx-ink); }
html body .card-header.bg-primary, html body .card-header.bg-info, html body .card-header.bg-success, html body .card-header.bg-dark { background: #fff !important; color: var(--fx-ink) !important; }
html body .card-header.text-white, html body .card-header .text-white, html body .card-header h5, html body .card-header h4, html body .card-header h6 { color: var(--fx-ink) !important; margin-bottom: 0; }
html body .card-body { padding: 20px; }
html body .card-footer { background: #fafbfe; border-top: 1px solid var(--fx-line); }
html body .card.bg-light { background: #f8fafc !important; box-shadow: none; }
html body .stat-card { border-radius: var(--fx-radius); border: 1px solid var(--fx-line); box-shadow: var(--fx-shadow); background: #fff; padding: 20px; }
html body .stat-value { font-size: 30px; font-weight: 800; color: var(--fx-ink); letter-spacing: -.03em; }
html body .stat-title { color: var(--fx-muted); font-size: 13px; font-weight: 600; text-transform: none; }
html body .stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--fx-primary-soft); color: var(--fx-primary); font-size: 19px; }

/* ---------- Indicadores (nuevos) ---------- */
.fx-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.fx-kpi { background: #fff; border: 1px solid var(--fx-line); border-radius: var(--fx-radius); box-shadow: var(--fx-shadow); padding: 18px; display: flex; gap: 14px; align-items: center; text-decoration: none; color: inherit !important; transition: transform .15s, box-shadow .15s; }
a.fx-kpi:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(15, 23, 42, .06), 0 16px 32px -14px rgba(79, 70, 229, .35); }
.fx-kpi-ico { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; font-size: 19px; flex: none; background: var(--fx-primary-soft); color: var(--fx-primary); }
.fx-kpi-ico.ok { background: var(--fx-ok-soft); color: var(--fx-ok); }
.fx-kpi-ico.warn { background: var(--fx-warn-soft); color: var(--fx-warn); }
.fx-kpi-ico.info { background: var(--fx-info-soft); color: var(--fx-info); }
.fx-kpi-num { font-size: 26px; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.fx-kpi-lbl { color: var(--fx-muted); font-size: 12.5px; font-weight: 600; margin-top: 5px; }
.fx-hero { background: linear-gradient(120deg, #1e1b4b 0%, #4338ca 55%, #0891b2 100%); border-radius: 18px; color: #fff; padding: 26px 28px; margin-bottom: 22px; position: relative; overflow: hidden; }
.fx-hero h2, .fx-hero h3, .fx-hero h4 { color: #fff !important; margin: 0 0 6px; }
.fx-hero p { color: #dbe4ff; margin: 0; }
.fx-hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(circle, rgba(251, 191, 36, .35), transparent 65%); }
.fx-hero .btn { position: relative; z-index: 1; }
.fx-timeline { list-style: none; margin: 0; padding: 0; }
.fx-timeline li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--fx-line); font-size: 14px; }
.fx-timeline li:last-child { border-bottom: 0; }
.fx-dot { width: 32px; height: 32px; border-radius: 10px; background: var(--fx-primary-soft); color: var(--fx-primary); display: grid; place-items: center; flex: none; font-size: 13px; }
.fx-when { color: var(--fx-muted); font-size: 12px; }
.fx-qr-box { background: #fff; border: 1px solid var(--fx-line); border-radius: 18px; padding: 22px; display: inline-block; box-shadow: var(--fx-shadow); }
.fx-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 44px; font-weight: 800; letter-spacing: .18em; color: var(--fx-primary-2); }
.fx-copy { display: flex; gap: 8px; }
.fx-copy input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; background: #f8fafc; }

/* ---------- Tablas ---------- */
html body .table { --bs-table-bg: transparent; margin-bottom: 0; font-size: 14px; color: var(--fx-ink-2); vertical-align: middle; }
html body .table > thead > tr > th, html body .table thead th {
    background: #f8fafc !important; color: var(--fx-muted) !important; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    border-bottom: 1px solid var(--fx-line) !important; border-top: 0; padding: 11px 14px; white-space: nowrap;
}
html body .table > tbody > tr > td { padding: 12px 14px; border-color: #eef2f7; }
html body .table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-accent-bg: transparent; }
html body .table-hover > tbody > tr:hover > *, html body .table > tbody > tr:hover > td { background: #f8faff; }
html body .table-responsive { border-radius: 12px; }
html body th[data-fx-sort] { cursor: pointer; user-select: none; }
html body th[data-fx-sort]::after { content: ' \2195'; opacity: .35; font-size: 11px; }
html body th[data-fx-sort].asc::after { content: ' \2191'; opacity: 1; color: var(--fx-primary); }
html body th[data-fx-sort].desc::after { content: ' \2193'; opacity: 1; color: var(--fx-primary); }
.fx-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--fx-line); background: #fff; }
.fx-tools .fx-search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.fx-tools .fx-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--fx-muted); font-size: 13px; }
.fx-tools .fx-search input { padding-left: 34px; }
.fx-count { color: var(--fx-muted); font-size: 12.5px; }

/* ---------- Botones, insignias, formularios ---------- */
html body .btn { border-radius: 10px; font-weight: 600; font-size: 14px; padding: 8px 15px; box-shadow: none; }
html body .btn-sm { border-radius: 8px; font-size: 12.5px; padding: 5px 10px; }
html body .btn-lg { border-radius: 12px; font-size: 16px; padding: 12px 22px; }
html body .btn-primary { background: var(--fx-primary); border-color: var(--fx-primary); color: #fff; }
html body .btn-primary:hover, html body .btn-primary:focus { background: var(--fx-primary-2); border-color: var(--fx-primary-2); }
html body .btn-outline-primary { color: var(--fx-primary); border-color: #c7d2fe; background: #fff; }
html body .btn-outline-primary:hover { background: var(--fx-primary-soft); color: var(--fx-primary-2); border-color: var(--fx-primary); }
html body .btn-secondary { background: #fff; color: var(--fx-ink-2); border-color: var(--fx-line); }
html body .btn-secondary:hover { background: #f1f5f9; color: var(--fx-ink); border-color: #cbd5e1; }
html body .btn-outline-secondary { color: var(--fx-ink-2); border-color: var(--fx-line); background: #fff; }
html body .btn-outline-secondary:hover { background: #f1f5f9; color: var(--fx-ink); }
html body .btn-info { background: var(--fx-info-soft); border-color: transparent; color: var(--fx-info) !important; }
html body .btn-info:hover { background: #bae6fd; }
html body .btn-warning { background: var(--fx-warn-soft); border-color: transparent; color: var(--fx-warn) !important; }
html body .btn-warning:hover { background: #fde68a; }
html body .btn-danger { background: var(--fx-bad-soft); border-color: transparent; color: var(--fx-bad); }
html body .btn-danger:hover { background: var(--fx-bad); color: #fff; }
html body .btn-success { background: var(--fx-ok); border-color: var(--fx-ok); color: #fff; }
html body .btn-success:hover { background: #047857; border-color: #047857; }
html body .badge { border-radius: 999px; font-weight: 700; font-size: 11.5px; padding: 5px 10px; letter-spacing: .01em; }
html body .badge.bg-success { background: var(--fx-ok-soft) !important; color: var(--fx-ok) !important; }
html body .badge.bg-danger { background: var(--fx-bad-soft) !important; color: var(--fx-bad) !important; }
html body .badge.bg-warning { background: var(--fx-warn-soft) !important; color: var(--fx-warn) !important; }
html body .badge.bg-info { background: var(--fx-info-soft) !important; color: var(--fx-info) !important; }
html body .badge.bg-primary { background: var(--fx-primary-soft) !important; color: var(--fx-primary-2) !important; }
html body .badge.bg-secondary, html body .badge.bg-light { background: #f1f5f9 !important; color: var(--fx-ink-2) !important; }
html body .form-control, html body .form-select { border-radius: 10px; border-color: #d5dbe7; padding: 9px 12px; font-size: 14.5px; }
html body .form-control:focus, html body .form-select:focus { border-color: var(--fx-primary); box-shadow: 0 0 0 4px rgba(79, 70, 229, .14); }
html body .form-label { font-weight: 600; font-size: 13.5px; color: var(--fx-ink-2); margin-bottom: 6px; }
html body .form-text { color: var(--fx-muted); }
html body .alert { border: 0; border-radius: 12px; font-size: 14.5px; padding: 13px 16px; }
html body .alert-success { background: var(--fx-ok-soft); color: #065f46; }
html body .alert-danger { background: var(--fx-bad-soft); color: #991b1b; }
html body .alert-warning { background: var(--fx-warn-soft); color: #92400e; }
html body .alert-info { background: var(--fx-info-soft); color: #075985; }
html body .modal-content { border: 0; border-radius: 16px; box-shadow: 0 30px 60px -20px rgba(15, 23, 42, .4); }
html body .modal-header, html body .modal-footer { border-color: var(--fx-line); }
html body .progress { border-radius: 999px; background: #e9eef7; height: 9px; }
html body .progress-bar { background: linear-gradient(90deg, var(--fx-primary), var(--fx-accent)); border-radius: 999px; }
html body .list-group-item { border-color: var(--fx-line); }
html body .bg-primary { background-color: var(--fx-primary) !important; }
html body .text-primary { color: var(--fx-primary) !important; }
html body .text-yellow { color: var(--fx-sun); }
html body .empty-state { text-align: center; padding: 38px 16px; color: var(--fx-muted); }
html body .empty-state i { color: #c7d2fe; }

/* ---------- Pantallas públicas (login, registro, recuperar) ---------- */
html body.fx-auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
    background: radial-gradient(1200px 600px at 10% -10%, rgba(79, 70, 229, .35), transparent 60%),
                radial-gradient(900px 500px at 100% 110%, rgba(6, 182, 212, .28), transparent 60%), #0b1020; }
.fx-auth-card { width: 100%; max-width: 440px; background: #fff; border-radius: 22px; padding: 34px 32px; box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .6); }
.fx-auth-card.wide { max-width: 720px; }
.fx-auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.fx-auth-brand .fx-brand-name { color: var(--fx-ink); font-size: 24px; }
.fx-auth-brand .fx-brand-name span { color: var(--fx-primary); }
.fx-auth-brand .fx-brand-sub { color: var(--fx-muted); font-size: 12.5px; }
.fx-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: #f1f5f9; border-radius: 12px; padding: 4px; margin-bottom: 20px; }
.fx-tabs button, .fx-tabs a { border: 0; background: transparent; border-radius: 9px; padding: 9px 6px; font-weight: 600; font-size: 13.5px; color: var(--fx-muted); text-align: center; text-decoration: none; cursor: pointer; }
.fx-tabs .is-active { background: #fff; color: var(--fx-primary-2); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.fx-auth-foot { text-align: center; color: #94a3b8; font-size: 12.5px; margin-top: 18px; }
.fx-auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 13.5px; margin-top: 16px; }

/* ---------- Celular ---------- */
@media (max-width: 991.98px) {
    html body .sidebar.fx-side { transform: translateX(-105%); width: min(84vw, 300px); }
    html body.fx-menu-open .sidebar.fx-side { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .5); }
    html body.fx-menu-open .fx-backdrop { display: block; }
    html body .content-wrapper, html body .main-content { margin-left: 0; }
    html body .main-content { padding: 0 14px 32px; }
    html body .main-content > .top-bar { margin: 0 -14px 18px; }
    html body .content-wrapper > .container-fluid, html body .content-wrapper > .container { padding: 16px 14px 32px !important; }
    html body .top-navbar, html body .top-bar { padding: 10px 14px; min-height: 56px; }
    html body #sidebarToggle, html body #menu-toggle, html body .fx-burger { display: inline-flex !important; }
    html body .page-title { font-size: 17px; }
    .fx-auth-card { padding: 26px 20px; }
    .fx-code { font-size: 34px; }
}
.fx-burger { display: none; border: 0; background: transparent; font-size: 18px; color: var(--fx-ink); padding: 6px 10px 6px 0; }
@media print {
    html body .sidebar.fx-side, html body .top-navbar, html body .top-bar, .fx-tools, .btn { display: none !important; }
    html body .content-wrapper, html body .main-content { margin: 0; }
}
