/* =====================================================================
   CorpAnalytics · Sistema de diseño
   ===================================================================== */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/inter-latin.woff2') format('woff2');
}

:root {
    --brand-50: #fff5ef;
    --brand-100: #ffe6d5;
    --brand-200: #fdc9a8;
    --brand-400: #f7824a;
    --brand-500: #ee5f24;
    --brand-600: #d9480f;
    --brand-700: #b3380b;
    --brand-800: #8a2d0d;

    --side-bg: #1f1613;
    --side-bg-2: #2a1e1a;
    --side-line: rgba(255, 255, 255, .07);
    --side-text: #c8bbb5;
    --side-muted: #8c7c75;

    --bg: #f5f4f2;
    --surface: #ffffff;
    --surface-2: #faf9f8;
    --line: #e8e5e2;
    --line-strong: #d6d1cd;
    --ink: #1c1917;
    --ink-2: #44403c;
    --muted: #78716c;
    --muted-2: #a8a29e;

    --success: #15803d;
    --success-bg: #ecfdf3;
    --danger: #c0262d;
    --danger-bg: #fef2f2;
    --warning: #b45309;
    --warning-bg: #fffbeb;
    --info: #1d4ed8;
    --info-bg: #eff6ff;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(28, 25, 23, .06);
    --shadow: 0 1px 3px rgba(28, 25, 23, .08), 0 1px 2px rgba(28, 25, 23, .04);
    --shadow-lg: 0 12px 32px -8px rgba(28, 25, 23, .22), 0 4px 10px -4px rgba(28, 25, 23, .08);
    --focus: 0 0 0 3px rgba(238, 95, 36, .28);

    --sidebar-w: 260px;
    --topbar-h: 64px;
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'cv11', 'ss01';
}
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--brand-600); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; }
svg.lucide { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.nowrap { white-space: nowrap; }
.w-full { width: 100%; }
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d6d1cd; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #b9b2ad; background-clip: padding-box; border: 2px solid transparent; }

/* ------------------------------ Botones ------------------------------ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
    border: 1px solid transparent; background: none; cursor: pointer;
    font-size: 13.5px; font-weight: 600; white-space: nowrap; text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg.lucide { width: 16px; height: 16px; }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: 0 1px 2px rgba(217, 72, 15, .3); }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); }
.btn-secondary { background: var(--surface); color: var(--ink-2); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: #c4bdb8; color: var(--ink); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: rgba(28, 25, 23, .05); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a11d23; }
.btn-danger-soft { background: var(--danger-bg); color: var(--danger); border-color: #fbd5d5; }
.btn-danger-soft:hover:not(:disabled) { background: #fde4e4; }
.btn-success { background: #15803d; color: #fff; }
.btn-success:hover:not(:disabled) { background: #116932; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: var(--radius-sm); border: 0; background: none;
    color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: rgba(28, 25, 23, .06); color: var(--ink); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn svg.lucide { width: 16px; height: 16px; }

/* ---------------------------- Formularios ---------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.hint { font-size: 12px; color: var(--muted); }
.input, .select {
    width: 100%; height: 38px; padding: 0 12px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink); font: inherit; font-size: 13.5px;
    transition: border-color .15s, box-shadow .15s;
}
.select {
    appearance: none; padding-right: 32px; cursor: pointer;
    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='%2378716c' 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 10px center;
}
.input:hover, .select:hover { border-color: #bdb5b0; }
.input:focus, .select:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--focus); }
.input-lg { height: 46px; font-size: 15px; }
.input-code { text-align: center; letter-spacing: .5em; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.input-icon { position: relative; }
.input-icon > svg.lucide { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }
.input-icon > .input { padding-left: 40px; }
.input-icon > .input-action { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; padding: 8px; color: var(--muted); cursor: pointer; border-radius: var(--radius-sm); display: flex; }
.input-icon > .input-action:hover { color: var(--ink); background: rgba(28, 25, 23, .05); }
.input-icon > .input:has(+ .input-action) { padding-right: 44px; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13.5px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand-600); cursor: pointer; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .span-2 { grid-column: span 2; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink-2); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 34px; height: 20px; border-radius: 20px; background: #d6d1cd; position: relative; transition: background .2s; flex-shrink: 0; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + .track { background: var(--brand-600); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }

/* ------------------------------ Alertas ------------------------------ */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; border: 1px solid; }
.alert svg.lucide { width: 17px; height: 17px; margin-top: 1px; }
.alert-danger { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }
.alert-info { background: var(--info-bg); color: #1e40af; border-color: #bfdbfe; }
.alert-warning { background: var(--warning-bg); color: #92400e; border-color: #fde68a; }
.alert-success { background: var(--success-bg); color: #166534; border-color: #bbf7d0; }

/* ------------------------------- Login ------------------------------- */
.login-body { background: var(--bg); min-height: 100vh; }
.login-shell { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.login-brand {
    position: relative; overflow: hidden; color: #f4ece8; padding: 56px;
    display: flex; flex-direction: column; justify-content: space-between;
    background:
        radial-gradient(1200px 500px at -10% 110%, rgba(238, 95, 36, .35), transparent 60%),
        radial-gradient(700px 400px at 110% -10%, rgba(238, 95, 36, .18), transparent 60%),
        linear-gradient(160deg, #2a1c17 0%, #1a120f 100%);
}
.login-brand::after {
    content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
    background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}
.login-brand-inner { position: relative; z-index: 1; max-width: 460px; margin: auto 0; }
.login-logo { width: 120px; height: auto; margin-bottom: 28px; filter: drop-shadow(0 8px 24px rgba(0,0,0,.35)); }
.login-brand h1 { font-size: 40px; font-weight: 800; letter-spacing: -.03em; color: #fff; }
.login-brand h1 span { color: var(--brand-400); }
.login-brand p { margin-top: 14px; color: #cbbdb6; font-size: 15.5px; line-height: 1.65; }
.login-features { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 14px; }
.login-features li { display: flex; align-items: center; gap: 12px; color: #e9ddd7; font-size: 14px; }
.login-features svg.lucide { color: var(--brand-400); width: 20px; height: 20px; }
.login-brand-foot { position: relative; z-index: 1; color: #8c7c75; font-size: 12.5px; }
.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; gap: 20px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 36px 32px; }
.login-head { margin-bottom: 26px; }
.login-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--brand-50); color: var(--brand-600); display: flex; align-items: center; justify-content: center; margin-bottom: 18px; border: 1px solid var(--brand-100); }
.login-icon svg.lucide { width: 22px; height: 22px; }
.login-head h2 { font-size: 22px; font-weight: 700; }
.login-head p { color: var(--muted); margin-top: 6px; }
.login-help { margin-top: 20px; text-align: center; color: var(--muted); font-size: 12.5px; }
.login-secure { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.login-secure svg.lucide { width: 14px; height: 14px; }
.caps-warning { display: flex; align-items: center; gap: 6px; color: var(--warning); font-size: 12px; font-weight: 500; }
.caps-warning svg.lucide { width: 14px; height: 14px; }

@media (max-width: 900px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { padding: 32px 24px; min-height: auto; }
    .login-brand-inner { margin: 0; }
    .login-logo { width: 72px; margin-bottom: 14px; }
    .login-brand h1 { font-size: 28px; }
    .login-features, .login-brand-foot { display: none; }
    .login-brand p { font-size: 14px; }
}

/* ---------------------------- Estructura ----------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
    background: var(--side-bg); color: var(--side-text);
    display: flex; flex-direction: column;
    border-right: 1px solid #120c0a;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px; height: var(--topbar-h); border-bottom: 1px solid var(--side-line); }
.sidebar-brand img { width: 38px; height: 38px; object-fit: contain; }
.sidebar-brand .name { font-size: 17px; font-weight: 800; color: #fff; letter-spacing: -.02em; }
.sidebar-brand .name span { color: var(--brand-400); }
.sidebar-brand .sub { font-size: 11px; color: var(--side-muted); font-weight: 500; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-group { margin-bottom: 18px; }
.nav-group-title { padding: 0 10px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--side-muted); }
.nav-item {
    position: relative; display: flex; align-items: center; gap: 11px; width: 100%;
    padding: 8px 10px; margin-bottom: 2px; border: 0; border-radius: 8px; background: none;
    color: var(--side-text); font-size: 13.5px; font-weight: 500; text-align: left; cursor: pointer; text-decoration: none;
    transition: background .15s, color .15s;
}
.nav-item svg.lucide { width: 18px; height: 18px; color: var(--side-muted); transition: color .15s; }
.nav-item:hover { background: var(--side-bg-2); color: #fff; }
.nav-item:hover svg.lucide { color: #e6d9d3; }
.nav-item.active { background: rgba(238, 95, 36, .14); color: #fff; }
.nav-item.active svg.lucide { color: var(--brand-400); }
.nav-item.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-500); }
.nav-item:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--brand-500); }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--side-line); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-700)); color: #fff; font-weight: 700; font-size: 13px;
}
.side-user .who { min-width: 0; flex: 1; }
.side-user .who strong { display: block; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who span { color: var(--side-muted); font-size: 11.5px; }
.side-user .icon-btn { color: var(--side-muted); }
.side-user .icon-btn:hover { background: var(--side-bg-2); color: #fff; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
    position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
    display: flex; align-items: center; gap: 14px; padding: 0 28px;
    background: rgba(255, 255, 255, .88); backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar .menu-toggle { display: none; }
.topbar-title { min-width: 0; flex: 1; }
.topbar-title .crumb { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.topbar-title h1 { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip svg.lucide { width: 14px; height: 14px; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.user-menu { position: relative; }
.user-menu-btn { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border: 1px solid var(--line); border-radius: 30px; background: var(--surface); cursor: pointer; }
.user-menu-btn:hover { border-color: var(--line-strong); }
.user-menu-btn .avatar { width: 28px; height: 28px; font-size: 11.5px; }
.user-menu-btn .uname { font-size: 13px; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head strong { display: block; font-size: 13px; }
.menu-head span { font-size: 12px; color: var(--muted); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--surface-2); color: var(--ink); }
.menu-item svg.lucide { width: 16px; height: 16px; color: var(--muted); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger svg.lucide { color: var(--danger); }

.content { flex: 1; padding: 28px; max-width: 1600px; width: 100%; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; animation: viewIn .25s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.view-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.view-head p { color: var(--muted); margin-top: 4px; }
.view-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.sidebar-backdrop { display: none; }

@media (max-width: 1080px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: none; }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(28, 25, 23, .45); z-index: 35; }
    .sidebar.open + .sidebar-backdrop { display: block; }
    .main { margin-left: 0; }
    .topbar { padding: 0 16px; }
    .topbar .menu-toggle { display: inline-flex; }
    .content { padding: 20px 16px; }
}
@media (max-width: 640px) {
    .topbar .chip, .user-menu-btn .uname { display: none; }
    .view-head h2 { font-size: 19px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
}

/* ------------------------------ Tarjetas ----------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card + .card, .card + .grid, .grid + .card, .grid + .grid, .toolbar + .card, .toolbar + .grid, .kpi-strip + .card, .kpi-strip + .grid, .card + .kpi-strip { margin-top: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-header h3 { font-size: 15px; font-weight: 650; }
.card-header .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-5-3 { grid-template-columns: minmax(0, 5fr) minmax(0, 3fr); }
@media (max-width: 1280px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-5-3 { grid-template-columns: 1fr; } }
@media (max-width: 800px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ----------------------------- Toolbar ------------------------------- */
.toolbar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 14px;
    padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.toolbar .tb-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.toolbar .tb-field > span { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.toolbar .select, .toolbar .input { height: 36px; font-size: 13px; }
.toolbar .tb-sep { width: 1px; align-self: stretch; background: var(--line); }
.toolbar .tb-spacer { flex: 1; }
.toolbar .tb-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.preset { height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface-2); font-size: 12px; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.preset:hover { border-color: var(--brand-200); color: var(--brand-700); background: var(--brand-50); }

/* Control segmentado */
.seg { display: inline-flex; padding: 3px; background: #efece9; border-radius: 8px; gap: 2px; }
.seg button { height: 30px; padding: 0 12px; border: 0; border-radius: 6px; background: none; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button svg.lucide { width: 15px; height: 15px; }
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* Selector múltiple */
.ms { position: relative; }
.ms-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 200px; max-width: 280px; height: 36px; padding: 0 10px 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; cursor: pointer; text-align: left; }
.ms-btn:hover { border-color: #bdb5b0; }
.ms-btn:focus-visible { outline: none; border-color: var(--brand-500); box-shadow: var(--focus); }
.ms-btn .ms-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-btn .ms-count { background: var(--brand-50); color: var(--brand-700); border-radius: 10px; padding: 0 7px; font-size: 11.5px; font-weight: 700; }
.ms-btn svg.lucide { width: 16px; height: 16px; color: var(--muted); }
.ms-panel { position: absolute; top: calc(100% + 6px); left: 0; width: 280px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 50; }
.ms-panel.right { left: auto; right: 0; }
.ms-search { padding: 8px; border-bottom: 1px solid var(--line); }
.ms-search .input { height: 32px; font-size: 12.5px; }
.ms-actions { display: flex; justify-content: space-between; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.ms-actions button { border: 0; background: none; color: var(--brand-600); font-size: 12px; font-weight: 600; cursor: pointer; padding: 2px 0; }
.ms-list { max-height: 260px; overflow-y: auto; padding: 4px; }
.ms-opt { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.ms-opt:hover { background: var(--surface-2); }
.ms-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ------------------------------- KPIs -------------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1280px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .kpi-grid { grid-template-columns: 1fr; } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 18px 20px; display: flex; flex-direction: column; min-width: 0; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.kpi-title { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kpi-ico { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--brand-50); color: var(--brand-600); }
.kpi-ico svg.lucide { width: 16px; height: 16px; }
.kpi-tag { font-size: 11.5px; font-weight: 600; color: var(--brand-700); background: var(--brand-50); border: 1px solid var(--brand-100); padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.kpi-value { font-size: 28px; font-weight: 750; letter-spacing: -.025em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.kpi-compare .lbl { font-size: 11.5px; color: var(--muted); }
.kpi-compare .val { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.kpi-compare .val svg.lucide { width: 14px; height: 14px; }
.kpi-compare .abs { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi-compare .na { color: var(--muted-2); font-weight: 600; }
.progress { position: relative; height: 6px; background: #efece9; border-radius: 6px; overflow: visible; margin-top: 12px; }
.progress > .bar { height: 100%; border-radius: 6px; background: var(--brand-500); max-width: 100%; }
.progress > .bar.ok { background: #16a34a; }
.progress > .bar.warn { background: #f59e0b; }
.progress > .bar.bad { background: #dc2626; }
.progress > .mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-2); border-radius: 2px; }
.progress-meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.kpi-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi-strip .mini { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); min-width: 0; }
.kpi-strip .mini .lbl { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-strip .mini .val { font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-strip .mini .foot { font-size: 12px; color: var(--muted); margin-top: 2px; }
@media (max-width: 1000px) { .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ------------------------------- Tablas ------------------------------ */
.table-wrap { overflow: auto; }
.table-wrap.tall { max-height: 640px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table thead th {
    position: sticky; top: 0; z-index: 2; background: var(--surface-2);
    font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
    white-space: nowrap; border-bottom: 1px solid var(--line-strong);
}
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink); }
.table th.sortable .sort-ico { display: inline-block; margin-left: 4px; opacity: .35; font-size: 10px; }
.table th.sorted .sort-ico { opacity: 1; color: var(--brand-600); }
.table tbody tr:hover td { background: #fcfbfa; }
.table tbody tr.selected td { background: var(--brand-50); }
.table tfoot td { background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--line-strong); border-bottom: 0; position: sticky; bottom: 0; }
.table tr.total td { background: var(--surface-2); font-weight: 700; }
.table tr.group-sep td { border-top: 2px solid var(--line-strong); }
.table .sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
.table thead .sticky-col { z-index: 3; background: var(--surface-2); }
.table tfoot .sticky-col, .table tr.total .sticky-col { background: var(--surface-2); }
.table td.col-total, .table th.col-total { background: var(--brand-50); color: var(--brand-800); font-weight: 700; }
.table td.projected { color: var(--muted); font-style: italic; }
.table td.actions { text-align: right; white-space: nowrap; width: 1%; }
.table td.check, .table th.check { width: 1%; padding-right: 0; }
.table .strong { font-weight: 600; color: var(--ink); }
.table-empty { padding: 48px 20px !important; text-align: center; color: var(--muted); }
.table-compact th, .table-compact td { padding: 8px 10px; }
.bar-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-cell .mini-bar { width: 70px; height: 6px; border-radius: 4px; background: #efece9; overflow: hidden; }
.bar-cell .mini-bar > span { display: block; height: 100%; border-radius: 4px; background: var(--brand-400); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.pager .pages { display: flex; align-items: center; gap: 6px; }
.pager .select { height: 30px; width: auto; font-size: 12.5px; padding-left: 8px; }

/* ------------------------------ Badges ------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge svg.lucide { width: 12px; height: 12px; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: #f1efed; color: var(--ink-2); }
.badge-brand { background: var(--brand-50); color: var(--brand-700); }

/* ----------------------------- Gráficas ------------------------------ */
.chart-box { position: relative; height: 360px; width: 100%; }
.chart-box.sm { height: 280px; }
.chart-box.lg { height: 420px; }
.legend-note { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend-note .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ----------------------------- Estados ------------------------------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 56px 24px; color: var(--muted); }
.empty-state .ico { width: 52px; height: 52px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; color: var(--muted-2); }
.empty-state .ico svg.lucide { width: 24px; height: 24px; }
.empty-state h4 { color: var(--ink); font-size: 15px; font-weight: 650; margin-bottom: 4px; }
.empty-state p { max-width: 420px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--brand-100); border-top-color: var(--brand-600); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; background: rgba(245, 244, 242, .75); backdrop-filter: blur(2px); }
.loading-box { display: flex; align-items: center; gap: 14px; background: var(--surface); padding: 16px 22px; border-radius: var(--radius); box-shadow: var(--shadow-lg); border: 1px solid var(--line); font-weight: 600; }
.note { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; color: var(--muted); background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 10px 14px; }
.note svg.lucide { width: 16px; height: 16px; margin-top: 1px; color: var(--muted-2); }

/* ------------------------------ Modales ------------------------------ */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(28, 25, 23, .5); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 100%; max-width: 520px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: modalIn .2s ease; }
.modal.lg { max-width: 820px; }
.modal.xl { max-width: 1080px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-header .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.modal-body { padding: 18px 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); flex-wrap: wrap; }
.modal-icon { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.modal-icon.danger { background: var(--danger-bg); color: var(--danger); }
.modal-icon.warning { background: var(--warning-bg); color: var(--warning); }
.modal-icon.info { background: var(--brand-50); color: var(--brand-600); }
.secret-box { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 16px; font-weight: 600; letter-spacing: .03em; word-break: break-all; }
.secret-box span { flex: 1; }

/* ------------------------------- Toasts ------------------------------ */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: #1c1917; color: #f5f5f4; box-shadow: var(--shadow-lg); font-size: 13px; animation: toastIn .25s ease; }
.toast svg.lucide { width: 18px; height: 18px; margin-top: 1px; }
.toast.success svg.lucide { color: #4ade80; }
.toast.error svg.lucide { color: #f87171; }
.toast.warning svg.lucide { color: #fbbf24; }
.toast.info svg.lucide { color: #fb923c; }
.toast .t-close { margin-left: auto; background: none; border: 0; color: #a8a29e; cursor: pointer; padding: 0 0 0 8px; display: flex; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .2s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------- Carga ------------------------------- */
.upload-card .card-body { display: flex; flex-direction: column; }
.upload-card .card-header .ico { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--brand-50); color: var(--brand-600); }
.upload-card.alt .card-header .ico { background: #f1efed; color: var(--ink-2); }
.upload-card.budget .card-header .ico { background: var(--info-bg); color: var(--info); }
.dropzone { position: relative; border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 26px 16px; text-align: center; background: var(--surface-2); transition: all .15s; cursor: pointer; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand-400); background: var(--brand-50); }
.dropzone.has-file { border-style: solid; border-color: #86efac; background: var(--success-bg); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone svg.lucide { width: 28px; height: 28px; color: var(--muted-2); margin-bottom: 8px; }
.dropzone.has-file svg.lucide { color: var(--success); }
.dropzone .dz-title { font-weight: 600; color: var(--ink-2); font-size: 13.5px; word-break: break-all; }
.dropzone .dz-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 12px; font-size: 13px; color: var(--ink-2); }
.steps .n { width: 22px; height: 22px; border-radius: 50%; background: var(--brand-50); color: var(--brand-700); font-weight: 700; font-size: 11.5px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.map-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ----------------------------- Mi cuenta ----------------------------- */
.profile { display: flex; align-items: center; gap: 16px; }
.profile .avatar { width: 56px; height: 56px; font-size: 20px; }
.profile h3 { font-size: 18px; }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; }
.policy { list-style: none; padding: 0; margin: 4px 0 16px; display: grid; gap: 6px; font-size: 12.5px; color: var(--muted); }
.policy li { display: flex; align-items: center; gap: 8px; }
.policy li svg.lucide { width: 14px; height: 14px; }
.policy li.ok { color: var(--success); }
.strength { display: flex; gap: 4px; margin-top: 8px; }
.strength span { flex: 1; height: 4px; border-radius: 4px; background: #e7e5e4; }
.strength[data-level="1"] span:nth-child(-n+1) { background: #dc2626; }
.strength[data-level="2"] span:nth-child(-n+2) { background: #f59e0b; }
.strength[data-level="3"] span:nth-child(-n+3) { background: #84cc16; }
.strength[data-level="4"] span:nth-child(-n+4) { background: #16a34a; }
.qr-wrap { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.qr { background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); line-height: 0; }
.qr svg { width: 180px; height: 180px; }
.role-cards { display: grid; gap: 10px; }
.role-card { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.role-card svg.lucide { color: var(--brand-600); margin-top: 2px; }
.role-card strong { display: block; font-size: 13px; }
.role-card span { font-size: 12.5px; color: var(--muted); }

/* ------------------------------ Impresión ---------------------------- */
@media print {
    .sidebar, .topbar, .toolbar, .actions, .pager, .toasts { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; }
    .card { box-shadow: none; }
}
