/* ============================================================
   hercam-dashboard.css  v10.0  —  2026-06-06
   Layout propio (sin Materio). Fuente única: Montserrat.
   ============================================================ */

/* ── 0. FUENTES LOCALES (solo Montserrat) ────────────────────── */
@font-face {
    font-family: 'Montserrat';
    src: url('/assets/fonts/montserrat-300.woff2') format('woff2');
    font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('/assets/fonts/montserrat-400.woff2') format('woff2');
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('/assets/fonts/montserrat-500.woff2') format('woff2');
    font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('/assets/fonts/montserrat-600.woff2') format('woff2');
    font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('/assets/fonts/montserrat-700.woff2') format('woff2');
    font-weight: 700; font-style: normal; font-display: swap;
}

/* ── 1. VARIABLES ────────────────────────────────────────────── */
:root {
    /* Layout */
    --hc-sidebar-w:           240px;
    --hc-sidebar-collapsed-w: 64px;
    --hc-navbar-h:            56px;

    /* Colores corporativos (fijos en ambos modos) */
    --hc-corporate: #004B80;
    --hc-accent:    #FBC32D;

    /* Paleta UI */
    --hc-blue:    #4f6ef7;
    --hc-green:   #22c55e;
    --hc-red:     #ef4444;
    --hc-amber:   #f59e0b;
    --hc-purple:  #a855f7;
    --hc-gray:    #94a3b8;
    --hc-neutral: #6b7194;

    /* Tipografía */
    --hc-font-mono:    'Montserrat', sans-serif;
    --hc-font-display: 'Montserrat', sans-serif;

    /* Espaciado contenido */
    --hc-wrap-x: 20px;
    --hc-wrap-y: 16px;
    --hc-wrap-b: 40px;

    /* Semánticas light mode */
    --hc-bg:          #f0f2f5;
    --hc-surface:     #ffffff;
    --hc-surface-2:   #f3f4f8;
    --hc-border:      #e2e5ec;
    --hc-text:        #1a1d2e;
    --hc-text-muted:  #6b6f8e;
}

/* ── 2. BASE ──────────────────────────────────────────────────── */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
    font-family: 'Montserrat', sans-serif;
    font-size: 18px;
    font-weight: 400;
    line-height: 1.65;
    background: var(--hc-bg);
    color: var(--hc-text);
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    color: var(--hc-text);
}

/* ── 3. DARK MODE ────────────────────────────────────────────── */
[data-bs-theme="dark"] {
    --bs-body-bg:        #07090f;
    --bs-body-bg-rgb:    7, 9, 15;
    --bs-paper-bg:       #111420;
    --bs-body-color:     #b8bcd0;
    --bs-secondary-bg:   #1a1d2e;
    --bs-secondary-color:#9295a5;
    --bs-border-color:   #212438;
    --bs-heading-color:  #e4e6f0;

    --hc-bg:         #07090f;
    --hc-surface:    #111420;
    --hc-surface-2:  #1a1d2e;
    --hc-border:     #212438;
    --hc-text:       #e4e6f0;
    --hc-text-muted: #9295a5;

    color-scheme: dark;
}

[data-bs-theme="dark"] .card {
    background-color: #111420 !important;
    border-color: #212438 !important;
    color: #b8bcd0;
}
[data-bs-theme="dark"] .card h1,[data-bs-theme="dark"] .card h2,
[data-bs-theme="dark"] .card h3,[data-bs-theme="dark"] .card h4,
[data-bs-theme="dark"] .card h5,[data-bs-theme="dark"] .card h6 { color: #e4e6f0; }

[data-bs-theme="dark"] .table {
    --bs-table-bg: #22242d;
    --bs-table-hover-bg: #313148;
    color: #b8bcd0;
    border-color: #2e3040;
}
[data-bs-theme="dark"] .table th {
    background-color: #1e2028 !important;
    color: #9295a5 !important;
}
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #1e2028;
    border-color: #2e3040;
    color: #b8bcd0;
}
[data-bs-theme="dark"] .dropdown-menu {
    background-color: #22242d;
    border-color: #2e3040;
}
[data-bs-theme="dark"] .dropdown-item         { color: #b8bcd0; }
[data-bs-theme="dark"] .dropdown-item:hover   { background-color: #2a2d38; color: #fff; }
[data-bs-theme="dark"] .dropdown-divider      { border-color: #2e3040; }
[data-bs-theme="dark"] .dropdown-notifications {
    background-color: #22242d;
    border-color: #2e3040;
}
[data-bs-theme="dark"] .dropdown-notifications .dropdown-item:hover { background-color: #2a2d38; }

[data-bs-theme="dark"] .apexcharts-canvas text  { fill: #9295a5 !important; }
[data-bs-theme="dark"] .apexcharts-gridline      { stroke: #2e3040 !important; }
[data-bs-theme="dark"] .apexcharts-tooltip {
    background: #22242d !important;
    border-color: #2e3040 !important;
    color: #b8bcd0 !important;
}
[data-bs-theme="dark"] .apexcharts-legend-text  { color: #9295a5 !important; }
[data-bs-theme="dark"] .anomaly-badge { background: #422006; color: #fde68a; }

/* ── 4. LAYOUT — SIDEBAR ─────────────────────────────────────── */
.hc-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--hc-sidebar-w);
    z-index: 200;
    display: flex;
    flex-direction: column;
    background: var(--hc-surface);
    border-right: 1px solid var(--hc-border);
    transition: width 0.25s ease;
    overflow: hidden;
}
.hc-sidebar.collapsed { width: var(--hc-sidebar-collapsed-w); }

/* Brand en sidebar */
.hc-sidebar-brand {
    height: var(--hc-navbar-h);
    display: flex;
    align-items: center;
    padding: 0 14px;
    border-bottom: 1px solid var(--hc-border);
    flex-shrink: 0;
    overflow: hidden;
}
.hc-brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    overflow: hidden;
    white-space: nowrap;
    min-width: 0;
}
.hc-brand-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}
.hc-brand-text {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--hc-text);
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s, width 0.25s;
}
.hc-sidebar.collapsed .hc-brand-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* Nav contenedor */
.hc-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--hc-border) transparent;
}

.hc-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Cabeceras de sección */
.hc-nav-header {
    padding: 12px 16px 3px;
    font-size: 0.63rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--hc-text-muted);
    white-space: nowrap;
    overflow: hidden;
    opacity: 0.7;
    transition: padding 0.25s;
}
.hc-sidebar.collapsed .hc-nav-header { display: none; }

/* Ítems de menú */
.hc-nav-item { position: relative; }

.hc-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--hc-text-muted);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
    overflow: hidden;
    border-radius: 6px;
    margin: 1px 6px;
    cursor: pointer;
}
.hc-nav-link i {
    font-size: 20px;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    text-align: center;
    transition: background-color 0.15s;
    display: inline-block;
}
.hc-nav-link:hover {
    color: var(--hc-text);
    background: var(--hc-surface-2);
}
.hc-nav-item.active > .hc-nav-link {
    color: var(--hc-corporate);
    background: rgba(0, 75, 128, 0.08);
    font-weight: 600;
}
.hc-nav-item.active > .hc-nav-link i { color: var(--hc-corporate); }

[data-bs-theme="dark"] .hc-nav-item.active > .hc-nav-link {
    color: var(--hc-accent);
    background: rgba(251, 195, 45, 0.1);
}
[data-bs-theme="dark"] .hc-nav-item.active > .hc-nav-link i { color: var(--hc-accent); }

/* Texto y flecha de submenú */
.hc-nav-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s, width 0.25s;
}
.hc-submenu-arrow {
    flex-shrink: 0;
    transition: transform 0.2s;
    font-size: 1rem !important;
    opacity: 0.5;
}
.hc-nav-item.open > .hc-nav-link .hc-submenu-arrow { transform: rotate(90deg); }

/* Modo colapsado: solo iconos */
.hc-sidebar.collapsed .hc-nav-text,
.hc-sidebar.collapsed .hc-submenu-arrow {
    display: none !important;
}
.hc-sidebar.collapsed .hc-sidebar-brand {
    justify-content: center;
    padding: 0 8px;
}
.hc-sidebar.collapsed .hc-nav-link {
    padding: 14px 0;
    justify-content: center;
    align-items: center;
    margin: 2px 6px;
    gap: 0;
    overflow: visible;
}
/*
  Los iconos Remix usan SVG mask (background-color + mask-image), NO font glyphs.
  Para que sean visibles en el sidebar colapsado (position:fixed + overflow:hidden)
  hay que usar display:inline-block y background-color explícito (no currentColor).
*/
.hc-sidebar.collapsed .hc-nav-link > i {
    display: inline-block !important;
    font-size: 30px !important;
    width: 30px !important;
    height: 30px !important;
    background-color: var(--hc-text-muted) !important;
    block-size: 30px !important;
    inline-size: 30px !important;
    flex: 0 0 30px !important;
    opacity: 0.7;
}
.hc-sidebar.collapsed .hc-nav-item.active > .hc-nav-link > i {
    background-color: var(--hc-corporate) !important;
    opacity: 1;
}
[data-bs-theme="dark"] .hc-sidebar.collapsed .hc-nav-item.active > .hc-nav-link > i {
    background-color: var(--hc-accent) !important;
    opacity: 1;
}
[data-bs-theme="dark"] .hc-sidebar.collapsed .hc-nav-link > i {
    background-color: #b0b3c8 !important;
}

/* Submenú */
.hc-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: var(--hc-surface-2);
    border-radius: 0 0 6px 6px;
    margin: 0 6px;
}
.hc-nav-item.open > .hc-submenu { max-height: 600px; }
.hc-sidebar.collapsed .hc-submenu { display: none; }
.hc-submenu .hc-nav-link {
    padding: 8px 16px 8px 42px;
    font-size: 0.85rem;
    margin: 0;
    border-radius: 0;
}
.hc-submenu .hc-nav-item:last-child .hc-nav-link { border-radius: 0 0 6px 6px; }

/* ── 5. LAYOUT — OVERLAY MÓVIL ───────────────────────────────── */
.hc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 190;
    backdrop-filter: blur(2px);
}
.hc-overlay.visible { display: block; }

/* ── 6. LAYOUT — WRAPPER ─────────────────────────────────────── */
.hc-wrapper {
    margin-left: var(--hc-sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s ease;
}
body.sidebar-collapsed .hc-wrapper {
    margin-left: var(--hc-sidebar-collapsed-w);
}

/* ── 7. LAYOUT — NAVBAR ──────────────────────────────────────── */
.hc-navbar {
    height: var(--hc-navbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--hc-surface);
    border-bottom: 1px solid var(--hc-border);
    flex-shrink: 0;
}
.hc-navbar-left  { display: flex; align-items: center; gap: 8px; }
.hc-navbar-right { display: flex; align-items: center; gap: 2px; }

.hc-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--hc-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.15s, color 0.15s;
    position: relative;
    flex-shrink: 0;
    padding: 0;
}
.hc-icon-btn:hover { background: var(--hc-surface-2); }

.hc-badge-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #ef4444;
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 0 3px;
    min-width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
}

.hc-navbar-brand {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.hc-navbar-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--hc-text);
    letter-spacing: -0.01em;
}

.hc-avatar-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--hc-border);
    padding: 0;
    background: transparent;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.15s;
    flex-shrink: 0;
}
.hc-avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.hc-avatar-btn:hover { border-color: var(--hc-corporate); }

/* Dropdowns navbar */
.theme-menu { min-width: 140px; }
.theme-menu .dropdown-item.active {
    background: var(--hc-corporate);
    color: #fff;
}
.dropdown-notifications { min-width: 340px; max-width: 380px; }
.dropdown-notifications .dropdown-item { white-space: normal; padding: .6rem 1rem; }
.notif-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.notif-dot.bg-danger  { background: #ff3e1d; }
.notif-dot.bg-warning { background: #ffab00; }
.notif-time { font-size: .72rem; color: var(--hc-text-muted); white-space: nowrap; }

/* ── 8. LAYOUT — MAIN Y FOOTER ───────────────────────────────── */
.hc-main {
    flex: 1;
    background: var(--hc-bg);
    min-width: 0;
}
.hc-footer {
    padding: 10px 16px;
    font-size: 0.75rem;
    font-weight: 300;
    color: var(--hc-text-muted);
    border-top: 1px solid var(--hc-border);
    text-align: center;
    background: var(--hc-surface);
}

/* ── 9. LAYOUT — RESPONSIVE ──────────────────────────────────── */
@media (max-width: 1023px) {
    .hc-sidebar {
        transform: translateX(-100%);
        width: var(--hc-sidebar-w) !important;
        transition: transform 0.25s ease;
    }
    .hc-sidebar.open  { transform: translateX(0); }
    .hc-wrapper       { margin-left: 0 !important; }
}

/* ── 10. CONTENEDOR PRINCIPAL ────────────────────────────────── */
.cmi-wrap {
    padding: var(--hc-wrap-y) var(--hc-wrap-x) var(--hc-wrap-b);
}

/* ── 11. CABECERA CMI ────────────────────────────────────────── */
.cmi-title {
    font-family: var(--hc-font-display);
    font-size: clamp(26px, 3vw, 38px);
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.05;
}
.cmi-title span { color: var(--hc-corporate); }

.cmi-sub {
    font-family: var(--hc-font-mono);
    font-size: 15px;
    font-weight: 300;
    margin-top: 5px;
    opacity: .55;
}
.cmi-sync {
    font-family: var(--hc-font-mono);
    font-size: 14px;
    font-weight: 300;
    opacity: .6;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.cmi-sync b { font-weight: 600; opacity: .9; }

/* ── 12. FILTROS ─────────────────────────────────────────────── */
.cmi-filters {
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 16px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    background: var(--hc-surface);
    border: 1px solid var(--hc-border);
}
.cmi-filters label {
    font-size: .72rem;
    font-family: var(--hc-font-mono);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    display: block;
    margin-bottom: 3px;
    opacity: .5;
}
.cmi-filters select,
.cmi-filters input[type=date] {
    background: var(--hc-bg);
    border: 1px solid var(--hc-border);
    color: var(--hc-text);
    border-radius: 6px;
    padding: 5px 9px;
    font-size: .9rem;
    font-family: var(--hc-font-mono);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: border-color .15s;
    max-width: 135px;
}
.cmi-filters select:focus,
.cmi-filters input[type=date]:focus {
    outline: none;
    border-color: var(--hc-corporate);
}
.btn-filter {
    background: var(--hc-corporate);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 18px;
    font-size: .9rem;
    font-family: var(--hc-font-mono);
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
    white-space: nowrap;
}
.btn-filter:hover { opacity: .85; }

/* ── 13. KPI GRID ────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.kpi-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.kpi {
    border-radius: 10px;
    padding: 13px 15px;
    position: relative;
    overflow: hidden;
    background: var(--hc-surface);
    border: 1px solid var(--hc-border);
    min-width: 0;
    container-type: inline-size;
}
.kpi::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--kpi-color, var(--hc-blue));
}
.kpi-label {
    font-family: var(--hc-font-mono);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-bottom: 6px;
    opacity: .5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kpi-value {
    font-family: var(--hc-font-display);
    font-size: clamp(26px, 13cqw, 42px);
    font-weight: 700;
    line-height: 1.05;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}
.kpi-value.green  { color: var(--hc-green); }
.kpi-value.amber  { color: var(--hc-amber); }
.kpi-value.red    { color: var(--hc-red); }
.kpi-value.blue   { color: var(--hc-blue); }
.kpi-sub {
    font-family: var(--hc-font-mono);
    font-size: 13px;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
    opacity: .5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kpi-icon {
    position: absolute;
    top: 10px; right: 10px;
    opacity: .08;
    font-size: 1.4rem;
    pointer-events: none;
}
.kpi-compare {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 12px;
    min-width: 0;
}
.kpi-prev {
    opacity: .5;
    font-family: var(--hc-font-mono);
    font-size: 13px;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex-shrink: 1;
}

/* ── 14. BADGES ──────────────────────────────────────────────── */
.badge-up {
    background: rgba(34,197,94,.15);
    color: var(--hc-green);
    font-family: var(--hc-font-mono);
    font-size: .73rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.badge-down {
    background: rgba(239,68,68,.15);
    color: var(--hc-red);
    font-family: var(--hc-font-mono);
    font-size: .73rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.badge-neu {
    background: rgba(107,113,148,.12);
    color: var(--hc-neutral);
    font-family: var(--hc-font-mono);
    font-size: .73rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── 15. CARDS ───────────────────────────────────────────────── */
.cmi-card {
    border-radius: 10px;
    overflow: clip;
    background: var(--hc-surface);
    border: 1px solid var(--hc-border);
    margin-bottom: 14px;
    width: 100%;
}
.cmi-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    border-bottom: 1px solid var(--hc-border);
    cursor: pointer;
    user-select: none;
    min-width: 0;
}
.cmi-card-head:hover { background: rgba(0,75,128,.03); }
.cmi-card-title {
    font-family: var(--hc-font-mono);
    font-size: .73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    opacity: .5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cmi-card-body { padding: 14px; }
.cmi-card-foot {
    padding: 5px 14px 8px;
    border-top: 1px solid var(--hc-border);
    font-family: var(--hc-font-mono);
    font-size: .72rem;
    font-weight: 300;
    opacity: .5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.kpi-source {
    font-family: var(--hc-font-mono);
    font-size: .72rem;
    font-weight: 300;
    opacity: .45;
    margin-top: -8px;
    margin-bottom: 16px;
    padding: 0 2px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px;
}
.section-label {
    font-family: var(--hc-font-mono);
    font-size: .73rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    opacity: .4;
    margin-bottom: 10px;
    margin-top: 6px;
}

/* ── 16. GRIDS DE LAYOUT ─────────────────────────────────────── */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
    width: 100%;
}
.main-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
    width: 100%;
}

/* ── 17. TABLAS CMI ──────────────────────────────────────────── */
.cmi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    table-layout: auto;
}
.cmi-table th {
    font-family: var(--hc-font-mono);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 10px 14px;
    text-align: right;
    border-bottom: 1px solid var(--hc-border);
    white-space: nowrap;
    opacity: .45;
}
.cmi-table th:first-child { text-align: left; }
.cmi-table th.th-left     { text-align: left; }
.cmi-table th[data-sort]  { cursor: pointer; user-select: none; }
.cmi-table th.sort-asc::after  { content: ' ↑'; opacity: .7; }
.cmi-table th.sort-desc::after { content: ' ↓'; opacity: .7; }
.cmi-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--hc-border);
    font-family: var(--hc-font-mono);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}
.cmi-table td:first-child   { text-align: left; font-weight: 500; }
.cmi-table tr:last-child td { border-bottom: none; }
.cmi-table tr:hover td      { background: rgba(0,75,128,.03); }
.cmi-table tfoot td {
    border-top: 2px solid var(--hc-border);
    border-bottom: none;
    font-weight: 700;
    background: var(--hc-surface-2);
}
.td-expand {
    text-align: left !important;
    max-width: 0;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── 18. COLORES MARGEN / VALOR ──────────────────────────────── */
.mrg-hi  { color: var(--hc-green);  font-weight: 600; }
.mrg-mid { color: var(--hc-amber);  font-weight: 600; }
.mrg-low { color: var(--hc-red);    font-weight: 600; }

.val-hi  { font-weight: 700; opacity: 1 !important; }
.val-red { color: var(--hc-red);    font-weight: 600; }
.val-grn { color: var(--hc-green);  font-weight: 600; }
.val-amb { color: var(--hc-amber);  font-weight: 600; }
.val-pur { color: var(--hc-purple); font-weight: 600; }
.val-dim { opacity: .3 !important; }

/* ── 19. BUSCADOR ────────────────────────────────────────────── */
.search-box {
    font-family: var(--hc-font-mono);
    font-size: .85rem;
    font-weight: 500;
    border-radius: 6px;
    padding: 4px 9px;
    border: 1px solid var(--hc-border);
    background: var(--hc-bg);
    color: var(--hc-text);
    width: 180px;
    transition: border-color .15s, width .2s;
}
.search-box:focus {
    outline: none;
    border-color: var(--hc-corporate);
    width: 220px;
}

/* ── 20. DETALLE PEDIDOS ─────────────────────────────────────── */
.detail-row td   { padding: 0 !important; }
.detail-inner    { background: var(--hc-surface-2); border-top: 1px solid var(--hc-border); }
.detail-table    { width: 100%; border-collapse: collapse; font-size: .82rem; }
.detail-table th {
    font-family: var(--hc-font-mono);
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 5px 9px;
    opacity: .4;
    border-bottom: 1px solid var(--hc-border);
    text-align: right;
}
.detail-table th:first-child { text-align: left; }
.detail-table td {
    padding: 5px 9px;
    font-family: var(--hc-font-mono);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    text-align: right;
    border-bottom: 1px solid var(--hc-border);
}
.detail-table td:first-child { text-align: left; }
.detail-table tr:last-child td { border-bottom: none; }
.toggle-icon { transition: transform .2s; display: inline-block; }
.toggle-icon.open { transform: rotate(90deg); }

/* ── 21. FILAS EXPANDIBLES COSTES ────────────────────────────── */
.expand-btn   { cursor: pointer; user-select: none; }
.row-sub      { display: none; }
.row-sub.open { display: table-row; }
.row-det      { display: none; background: rgba(0,75,128,.02); }
.row-det.open { display: table-row; }
.indent1      { padding-left: 24px !important; }
.indent2      { padding-left: 42px !important; font-size: .84rem; opacity: .65; }

/* ── 22. TABLA TARIFA ────────────────────────────────────────── */
.tarifa-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.tarifa-table th {
    font-family: var(--hc-font-mono);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 10px 14px;
    text-align: right;
    border-bottom: 1px solid var(--hc-border);
    white-space: nowrap;
    opacity: .4;
}
.tarifa-table th:first-child,
.tarifa-table th.th-left { text-align: left; }
.tarifa-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--hc-border);
    font-family: var(--hc-font-mono);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
    opacity: .85;
}
.tarifa-table td:first-child { text-align: left; }
.tarifa-table td.td-desc {
    text-align: left;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: .9;
}
.tarifa-table td.td-code      { opacity: .4; font-size: 13px; }
.tarifa-table tr:hover td     { background: rgba(0,75,128,.03); }
.tarifa-table tr.no-ventas td { opacity: .4; }
.tarifa-table tfoot td        { border-top: 1px solid var(--hc-border); font-weight: 700; opacity: 1; }

/* ── 22b. LOG-TABLE / USR-TABLE — mismos estilos que cmi-table ── */
.log-table,
.usr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    table-layout: auto;
}
.log-table th,
.usr-table th {
    font-family: var(--hc-font-mono);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--hc-border);
    white-space: nowrap;
    opacity: .45;
    background: var(--hc-surface);
}
.log-table td,
.usr-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--hc-border);
    font-family: var(--hc-font-mono);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    text-align: left;
    vertical-align: middle;
}
.log-table tr:hover td,
.usr-table tr:hover td { background: rgba(0,75,128,.03); }
.log-table tr:last-child td,
.usr-table tr:last-child td { border-bottom: none; }

/* Bootstrap .table override para admin/import — misma densidad */
.table.table-sm th,
.table.table-sm td {
    padding: 10px 14px !important;
    font-size: 15px;
    font-family: 'Montserrat', sans-serif;
}

/* ── 23. BADGES FAMILIA ──────────────────────────────────────── */
.familia-badge {
    font-family: var(--hc-font-mono);
    font-size: .72rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
}
.fam-SERVICIOS     { background: rgba(79,142,247,.15); color: #4f8ef7; }
.fam-CLIMATIZACION { background: rgba(72,187,120,.15); color: #48bb78; }
.fam-CLIMATEGAL    { background: rgba(72,187,120,.10); color: #68d39a; }
.fam-REFRIGERANTES { background: rgba(99,179,237,.15); color: #63b3ed; }
.fam-CALEFACCION   { background: rgba(245,101,101,.15); color: #f56565; }
.fam-CALEFACCIONAL { background: rgba(245,101,101,.10); color: #f88080; }
.fam-ELECTRO       { background: rgba(236,201,75,.15);  color: #ecc94b; }
.fam-ELECTROLEGAL  { background: rgba(236,201,75,.10);  color: #f6d870; }
.fam-TELECO        { background: rgba(159,122,234,.15); color: #9f7aea; }
.fam-SOLAR         { background: rgba(237,137,54,.15);  color: #ed8936; }
.fam-SOLARLEGAL    { background: rgba(237,137,54,.10);  color: #f6a85a; }
.fam-ENVIOS        { background: rgba(113,128,150,.15); color: #718096; }
.fam-SEXTRNOS      { background: rgba(113,128,150,.10); color: #8896aa; }

/* ── 24. COLLAPSE / MINI-BAR / ANOMALÍA ─────────────────────── */
.collapse-icon { transition: transform .25s; display: inline-block; }
.collapsed .collapse-icon { transform: rotate(-90deg); }

.mini-bar {
    display: inline-block;
    height: 4px;
    border-radius: 2px;
    vertical-align: middle;
    margin-left: 4px;
}
.anomaly-badge {
    font-size: .72rem;
    font-weight: 600;
    padding: .12rem .4rem;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
    font-family: var(--hc-font-mono);
    margin-left: .3rem;
}

/* ── 25. GRID SERVICIOS 50/50 ────────────────────────────────── */
.servicios-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    width: 100%;
}
.servicios-grid > div:first-child { border-right: 1px solid var(--hc-border); }

/* ── 26. CMI INGRESOS: dots + bottom-grid ────────────────────── */
.dot   { display:inline-block; width:7px; height:7px; border-radius:50%; margin-right:7px; }
.dot-H { background: var(--hc-corporate); }
.dot-L { background: var(--hc-green); }
.dot-S { background: var(--hc-amber); }
.dot-C { background: var(--hc-purple); }
.dot-O { background: var(--hc-gray); }

.bottom-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; }

/* ── 27. CMI TESORERÍA: barras + aging ───────────────────────── */
.bar-wrap  { display:flex; align-items:center; gap:8px; }
.bar-track { flex:1; height:4px; background:var(--hc-border); border-radius:2px; min-width:60px; }
.bar-fill  { height:4px; border-radius:2px; background:var(--hc-corporate); transition:width .4s; }
.bar-fill.amber { background: var(--hc-amber); }
.bar-pct   { font-family:var(--hc-font-mono); font-weight:500; font-variant-numeric:tabular-nums; font-size:.75rem; opacity:.45; min-width:30px; text-align:right; }

.aging-track { flex:1; height:5px; background:var(--hc-border); border-radius:3px; min-width:80px; }
.aging-fill  { height:5px; border-radius:3px; }
.aging-ok    { background: var(--hc-green); }
.aging-warn  { background: var(--hc-amber); }
.aging-mid   { background: #fb923c; }
.aging-bad   { background: var(--hc-red); }

/* ── 28. CMI COSTES: etiqueta mes ────────────────────────────── */
.mes-tag {
    display: inline-block;
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
    opacity: .5;
    margin-right: 6px;
    min-width: 28px;
}

/* ── 29. ADMIN USUARIOS: botones ─────────────────────────────── */
.cambiar-btn {
    background-color: var(--hc-corporate);
    color: white;
}
.cambiar-btn:hover,
.cambiar-btn:active {
    background-color: #003560 !important;
    color: white !important;
    box-shadow: 0 2px 3px rgba(37,37,37,.33);
}
.edit-btn { background-color: var(--hc-accent); }
.edit-btn:hover,
.edit-btn:active {
    background-color: #e0ac20;
    box-shadow: 0 2px 3px rgba(37,37,37,.33);
}

/* ── 30. BOOTSTRAP — BOTONES CORPORATIVOS ────────────────────── */
.btn-save {
    background-color: var(--hc-accent);
    color: #1a1d2e;
    border-color: var(--hc-accent);
}
.btn-save:hover { background-color: #e0ac20; border-color: #e0ac20; }

.btn-password {
    background-color: var(--hc-corporate);
    color: white;
    border-color: var(--hc-corporate);
}
.btn-password:hover { background-color: #003560; border-color: #003560; color: white; }

/* ── 31. LOGIN ───────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: url('/assets/img/backgrounds/fondo-total-hercam.png') center/cover no-repeat;
    background-color: #002a4a;
    padding: 20px;
}
.login-card {
    border-radius: 14px;
    border: none;
    box-shadow: 0 24px 48px rgba(0,0,0,.35);
    width: 100%;
    max-width: 420px;
    background: #fff;
}
[data-bs-theme="dark"] .login-card {
    background: #111420;
    box-shadow: 0 24px 48px rgba(0,0,0,.6);
}
.login-card .form-control {
    height: 48px;
    border-radius: 8px;
}
.login-card input:focus {
    border-color: var(--hc-corporate);
    box-shadow: 0 0 0 3px rgba(0,75,128,.15);
}
.btn-login {
    height: 48px;
    border-radius: 8px;
    font-weight: 600;
    letter-spacing: .3px;
    background-color: var(--hc-corporate);
    border-color: var(--hc-corporate);
    color: white;
    width: 100%;
    font-size: 1rem;
}
.btn-login:hover,
.btn-login:active {
    background-color: #003560 !important;
    border-color: #003560 !important;
    color: white;
}

/* ── 32. RESPONSIVE COMPLETO ─────────────────────────────────── */
@media (max-width: 1100px) {
    .main-grid        { grid-template-columns: 1fr; }
    .main-grid-3      { grid-template-columns: 1fr 1fr; }
    .servicios-grid   { grid-template-columns: 1fr !important; }
    .servicios-grid > div:first-child {
        border-right: none !important;
        border-bottom: 1px solid var(--hc-border);
    }
    .bottom-grid      { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    :root {
        --hc-wrap-x: 12px;
        --hc-wrap-y: 12px;
        --hc-wrap-b: 28px;
    }
    .cmi-title   { font-size: clamp(22px, 6vw, 30px); }
    .kpi-value   { font-size: clamp(22px, 11cqw, 32px); }
    .kpi-grid    { grid-template-columns: 1fr 1fr; gap: 8px; }
    .kpi         { padding: 10px 12px; }
    .cmi-filters { gap: 7px; padding: 8px 10px; }
    .cmi-filters select,
    .cmi-filters input[type=date] { font-size: .82rem; padding: 3px 7px; max-width: 110px; }
    .cmi-filters .btn-filter { min-height: 44px; }
    .search-box       { width: 120px; }
    .search-box:focus { width: 150px; }
    .main-grid-3      { grid-template-columns: 1fr; }
    .cmi-table th,
    .cmi-table td     { padding: 8px 10px; }
    .col-hide-mobile  { display: none; }
    .cmi-card-foot    { flex-direction: column; align-items: flex-start; gap: 2px; }
    .kpi-source       { flex-direction: column; gap: 2px; }
    .cmi-card-head    { flex-wrap: wrap; gap: 4px; }
    .table-responsive-hercam { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .dropdown-notifications { min-width: 290px; max-width: 95vw; }
    /* En móvil: no truncar primera columna, la tabla ya tiene scroll horizontal */
    .td-expand {
        max-width: none !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }
}

@media (max-width: 430px) {
    :root { --hc-wrap-x: 8px; }
    .kpi-grid  { grid-template-columns: 1fr 1fr; gap: 6px; }
    .kpi-value { font-size: clamp(20px, 11cqw, 26px); }
    .btn-filter { padding: 4px 11px; }
    .login-card { border-radius: 10px; }
}
