/* ============================================================
   Implementación Control - Design System
   Inspired by Monday.com / Airtable / Notion
   ============================================================ */

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.1);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --purple: #8b5cf6;
    --teal: #14b8a6;

    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #1e1e2d;
    --bg-sidebar-hover: rgba(255,255,255,0.06);
    --bg-topbar: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0c0c14;
    --bg-topbar: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --primary-light: rgba(99, 102, 241, 0.12);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    line-height: 1.6;
    overflow-x: hidden;
}

html.ic-theme-animate,
html.ic-theme-animate body,
html.ic-theme-animate .card,
html.ic-theme-animate .kpi-card,
html.ic-theme-animate .topbar,
html.ic-theme-animate .share-topbar,
html.ic-theme-animate .main-content,
html.ic-theme-animate .page-content,
html.ic-theme-animate .login-card,
html.ic-theme-animate .form-control,
html.ic-theme-animate .form-select,
html.ic-theme-animate .modal-content,
html.ic-theme-animate .modal-header,
html.ic-theme-animate .modal-footer,
html.ic-theme-animate .dropdown-menu,
html.ic-theme-animate .data-table-card,
html.ic-theme-animate .table-card,
html.ic-theme-animate .btn-outline-secondary,
html.ic-theme-animate .btn-outline-primary,
html.ic-theme-animate .alert,
html.ic-theme-animate .badge,
html.ic-theme-animate .dashboard-chart-card,
html.ic-theme-animate .share-layout-body {
    transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease !important;
}

/* ========== APP LAYOUT ========== */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #cbd5e1;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.logo i { color: var(--primary); font-size: 1.5rem; }

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; }

.nav-section { margin-bottom: 1.5rem; }

.nav-section-title {
    display: block;
    padding: 0 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.875rem;
    transition: var(--transition);
    margin-bottom: 2px;
}

.nav-link:hover { background: var(--bg-sidebar-hover); color: #fff; }
.nav-link.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }
.nav-link-add { color: var(--primary) !important; opacity: 0.8; }
.nav-link-add:hover { opacity: 1; }

.nav-campo-group { margin-bottom: 0.75rem; }
.nav-campo-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #cbd5e1;
    letter-spacing: 0.02em;
}
.nav-link-campo { padding-left: 1.25rem; font-size: 0.8125rem; }
.nav-link-disabled { opacity: 0.55; cursor: default; pointer-events: none; }

.campo-tabs { flex-wrap: wrap; }
.campo-tab { text-decoration: none; color: inherit; }
.campo-tab-disabled { opacity: 0.65; }

.dashboard-campo-panel.d-none { display: none !important; }
.dashboard-campo-empty { min-height: 200px; }

.edit-campo-section { border-left: 3px solid var(--primary); padding-left: 1rem; margin-bottom: 1.5rem; }
.edit-campo-section h6 { font-weight: 600; margin-bottom: 0.75rem; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info { display: flex; align-items: center; gap: 0.75rem; }
.user-avatar, .user-avatar-sm, .user-avatar-xs {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.875rem;
}
.user-avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
.user-avatar-xs { width: 28px; height: 28px; font-size: 0.7rem; }
.user-details { display: flex; flex-direction: column; }
.user-name { font-size: 0.875rem; color: #fff; font-weight: 500; }
.user-role { font-size: 0.75rem; color: #64748b; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}
.main-content:has(.table-view-fill) {
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar-search {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.topbar-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.topbar-search input {
    padding-left: 2.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-primary);
}

.topbar-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }

.btn-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
    position: relative;
}
.btn-icon:hover { background: var(--primary-light); color: var(--primary); }

.btn-user {
    display: flex; align-items: center; gap: 0.5rem;
    border: none; background: transparent;
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}
.btn-user:hover { background: var(--primary-light); }

.notif-badge {
    position: absolute; top: 4px; right: 4px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    width: 18px; height: 18px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

.notif-dropdown { width: 360px; max-height: 400px; overflow-y: auto; }

.page-content { padding: 1.5rem 2rem; flex: 1; min-width: 0; max-width: 100%; }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
}

/* ========== PAGE HEADER ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title { font-size: 1.75rem; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--text-secondary); margin: 0.25rem 0 0; font-size: 0.9rem; }
.page-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ========== KPI CARDS ========== */
.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    animation: fadeInUp 0.5s ease forwards;
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.kpi-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
}

.kpi-primary .kpi-icon { background: rgba(99,102,241,0.12); color: var(--primary); }
.kpi-success .kpi-icon { background: rgba(34,197,94,0.12); color: var(--success); }
.kpi-warning .kpi-icon { background: rgba(245,158,11,0.12); color: var(--warning); }
.kpi-danger .kpi-icon { background: rgba(239,68,68,0.12); color: var(--danger); }
.kpi-info .kpi-icon { background: rgba(6,182,212,0.12); color: var(--info); }
.kpi-secondary .kpi-icon { background: rgba(100,116,139,0.12); color: var(--text-secondary); }
.kpi-purple .kpi-icon { background: rgba(139,92,246,0.12); color: var(--purple); }
.kpi-teal .kpi-icon { background: rgba(20,184,166,0.12); color: var(--teal); }

.kpi-value { display: block; font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.kpi-label { display: block; font-size: 0.8rem; color: var(--text-secondary); }

.dashboard-kpi-row {
    display: grid;
    gap: 1rem;
    width: 100%;
}
.dashboard-kpi-row[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-kpi-row[data-cols="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dashboard-kpi-row[data-cols="6"] { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.dashboard-kpi-item { min-width: 0; }
.dashboard-kpi-row .kpi-card { width: 100%; height: 100%; }

@media (max-width: 1199.98px) {
    .dashboard-kpi-row[data-cols="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 991.98px) {
    .dashboard-kpi-row[data-cols="3"],
    .dashboard-kpi-row[data-cols="4"],
    .dashboard-kpi-row[data-cols="6"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 575.98px) {
    .dashboard-kpi-row { grid-template-columns: 1fr !important; }
}

/* ========== CARDS ========== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
}

.card-header h5 { margin: 0; font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }

.chart-card .card-body { padding: 1.25rem; }
.chart-preview-plot,
.saved-chart-plot {
    position: relative;
    height: 300px;
    max-height: 300px;
    overflow: hidden;
}
.saved-chart-plot {
    height: 220px;
    max-height: 220px;
}
.chart-preview-plot canvas,
.saved-chart-plot canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}
.saved-chart-card .card-body {
    padding: 0.5rem !important;
    overflow: hidden;
}

/* ========== TABLE CARDS ========== */
.table-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
    animation: fadeInUp 0.4s ease forwards;
}

.table-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.table-card-header {
    padding: 1.25rem 1.25rem 0;
    display: flex;
    justify-content: space-between;
}

.table-card-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--card-color) 12%, transparent);
    color: var(--card-color);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
}

.table-card-body {
    display: block;
    padding: 1rem 1.25rem 1.25rem;
    text-decoration: none;
    color: inherit;
}

.table-card-body h3 { font-size: 1.1rem; margin: 0 0 0.5rem; }
.table-card-body p { font-size: 0.85rem; color: var(--text-secondary); margin: 0 0 0.75rem; }
.table-card-stats { font-size: 0.8rem; color: var(--text-muted); }

/* ========== DATA TABLE ========== */
.data-table-card .card-body { padding: 0; }
.data-table-card .table { margin: 0; }
.data-table-card .table thead th {
    background: var(--bg-body);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    padding: 0.875rem 1rem;
    white-space: nowrap;
}
.data-table-card .table tbody td { padding: 0.75rem 1rem; vertical-align: middle; font-size: 0.875rem; }
.data-table-card .table tbody tr { transition: var(--transition); }
.data-table-card .table tbody tr:hover { background: var(--primary-light); }

/* Zoom solo en tabla — ocupa casi toda la pantalla */
.page-content:has(.table-view-fill) {
    display: flex;
    flex-direction: column;
    padding-bottom: 0.75rem;
    min-height: calc(100vh - var(--topbar-height));
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}
.page-content:has(.table-view-fill) .page-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 1rem;
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    position: relative;
    z-index: 20;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.page-content:has(.table-view-fill) .page-actions {
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    align-self: start;
}
.table-view-fill {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}
.table-zoom-shell.table-view-fill {
    margin-bottom: 0.5rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
}
.table-toolbar { padding: 0 0.15rem; flex-shrink: 0; max-width: 100%; }
.table-zoom-bar { flex-shrink: 0; }
.table-zoom-label { min-width: 3.5rem; pointer-events: none; opacity: 1 !important; font-weight: 600; }
.table-zoom-size-host {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 420px;
    min-width: 0;
    width: 100%;
}
.table-zoom-scroll-wrap {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 400px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
}
.table-zoom-scroll-wrap.has-user-height {
    flex: 0 0 auto;
}
.table-height-resize {
    flex-shrink: 0;
    height: 12px;
    margin-top: 2px;
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    background: var(--bg-body);
    cursor: row-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: background 0.15s ease;
}
.table-height-resize:hover,
.table-height-resize.active {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.35);
}
.table-height-resize-grip {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1;
    pointer-events: none;
}
body.table-height-resizing {
    cursor: row-resize !important;
    user-select: none !important;
}
.table-zoom-scroll-top {
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    min-height: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.table-zoom-scroll-top-inner {
    height: 12px;
}
.table-zoom-scroll-wrap:not(.has-h-scroll) .table-zoom-scroll-top {
    display: none;
}
.table-zoom-scroll-wrap.has-h-scroll .table-zoom-viewport {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}
.table-zoom-viewport {
    overflow-x: auto;
    overflow-y: auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex: 1;
    min-height: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    position: relative;
}
.table-zoom-scroll-wrap.has-h-scroll .table-zoom-viewport {
    overflow-x: scroll;
    scrollbar-color: transparent transparent;
}
.table-zoom-scroll-wrap.has-h-scroll .table-zoom-viewport::-webkit-scrollbar:horizontal {
    height: 0;
    display: none;
}
.table-zoom-scroll-bottom {
    display: none !important;
}
.table-zoom-scaler {
    display: block;
    width: max-content;
    min-width: 100%;
    transform-origin: top left;
    transition: zoom 0.12s ease, transform 0.12s ease;
    overflow: visible;
}
.table-zoom-scaler #recordsTable {
    width: max-content;
    min-width: 100%;
}
.table-zoom-viewport .dataTables_wrapper,
.table-zoom-viewport .dataTables_scroll,
.table-zoom-viewport .dataTables_scrollBody,
.table-zoom-viewport .dataTables_scrollHead {
    overflow: visible !important;
    max-height: none !important;
}
.table-zoom-scaler .data-table-card {
    margin-bottom: 0;
    border: none;
    box-shadow: none;
}
.table-zoom-scaler .data-table-card .card-body {
    padding-bottom: 0.5rem;
}
/* Tabla un poco más legible */
.table-zoom-viewport .data-table-card .table {
    font-size: 0.9rem;
}
.table-zoom-viewport .data-table-card .table thead th {
    padding: 0.65rem 0.85rem;
    font-size: 0.78rem;
}
.table-zoom-viewport .data-table-card .table tbody td {
    padding: 0.55rem 0.85rem;
}
.table-zoom-viewport .dataTables_wrapper .dataTables_length,
.table-zoom-viewport .dataTables_wrapper .dataTables_filter,
.table-zoom-viewport .dataTables_wrapper .dataTables_info,
.table-zoom-viewport .dataTables_wrapper .dataTables_paginate {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}
.table-zoom-viewport .dataTables_wrapper .dt-table-top {
    margin-bottom: 0.5rem;
}
.table-zoom-viewport .dataTables_wrapper .dataTables_filter {
    text-align: left;
    float: none;
}
.table-zoom-viewport .dataTables_wrapper .dataTables_filter label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
    margin-bottom: 0;
    width: 100%;
}
.table-zoom-viewport .dataTables_wrapper .dataTables_filter input {
    margin-left: 0 !important;
    max-width: 280px;
}

/* Columnas fijas a la izquierda (acciones + #) */
#recordsTable {
    border-collapse: separate;
    border-spacing: 0;
}
#recordsTable .sticky-col {
    position: sticky;
    z-index: 5;
    background: var(--bg-card);
    background-clip: padding-box;
    box-shadow: 2px 0 4px rgba(15, 23, 42, 0.06);
}
#recordsTable thead .sticky-col {
    z-index: 8;
    background: var(--bg-body);
}
#recordsTable tbody td:not(.sticky-col),
#recordsTable tfoot td:not(.sticky-col) {
    position: relative;
    z-index: 1;
}
#recordsTable .col-actions {
    left: 0;
    min-width: 56px;
    width: 56px;
    max-width: 56px;
    padding-left: 4px;
    padding-right: 4px;
}
#recordsTable.has-actions-col .col-row-num {
    left: 56px;
}
#recordsTable:not(.has-actions-col) .col-row-num {
    left: 0;
}
#recordsTable .col-row-num {
    min-width: 36px;
    width: 36px;
    max-width: 40px;
    text-align: center;
    color: var(--text-secondary);
    font-weight: 500;
}
#recordsTable tbody tr:hover .sticky-col {
    background: var(--primary-light);
}

/* Columnas redimensionables */
#recordsTable thead th.resizable-col,
#recordsTable thead th[data-col] {
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
}
#recordsTable thead th.sticky-col {
    position: sticky;
}
.col-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    z-index: 2;
}
.col-resize-handle:hover,
.col-resize-handle.active {
    background: rgba(99, 102, 241, 0.35);
}
body.col-resizing { cursor: col-resize !important; user-select: none !important; }

/* Modo Excel */
/* Modo Excel / edición inline */
.inline-edit-hint,
.excel-mode-hint {
    padding: 0.5rem 1rem;
    background: rgba(34, 197, 94, 0.1);
    border-bottom: 1px solid rgba(34, 197, 94, 0.25);
    font-size: 0.8rem;
}
.table-section-row td {
    background: var(--section-bg, #111827) !important;
    border-color: color-mix(in srgb, var(--section-bg, #111827) 85%, #000) !important;
}
.table-section-row .section-actions-cell {
    background: var(--section-bg, #111827) !important;
    vertical-align: middle;
    text-align: center;
}
.table-section-row .section-label-cell {
    text-align: center;
    padding: 0.55rem 1rem !important;
}
.table-section-row .section-label {
    color: var(--section-fg, #fff);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.table-section-row:hover td {
    background: var(--section-bg, #111827) !important;
}
.section-preview-wrap { margin-top: 0.5rem; }
.section-preview-bar {
    margin-top: 0.35rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
#recordsTable tbody tr.row-selected {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}
.excel-cell-wrap {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    overflow: hidden;
}
.excel-cell-wrap .excel-cell-main {
    flex: 1;
    min-width: 0;
    width: 100%;
}
.excel-cell-wrap textarea.excel-cell {
    width: 100%;
}
.excel-cell-wrap .excel-attach-link {
    flex-shrink: 0;
    padding: 0.1rem 0.35rem;
    line-height: 1;
}
.excel-cell-wrap .excel-attach-link.has-link {
    color: var(--primary);
    border-color: var(--primary);
}
.excel-link-mini {
    flex-shrink: 0;
}
.cell-link-inline {
    font-size: 0.85rem;
    margin-left: 0.15rem;
}

.excel-mode-hint {
    padding: 0.5rem 1rem;
    background: rgba(34, 197, 94, 0.1);
    border-bottom: 1px solid rgba(34, 197, 94, 0.25);
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.excel-mode-hint kbd {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    font-size: 0.75rem;
}
.data-table-card.excel-mode .table {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
}
.data-table-card.excel-mode .table tbody td {
    padding: 0.25rem 0.35rem;
    vertical-align: top;
    white-space: normal;
    height: auto;
    overflow: hidden;
    word-wrap: break-word;
    word-break: break-word;
}
.data-table-card.excel-mode .excel-cell {
    border: 1px solid transparent;
    border-radius: 4px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 0.875rem;
}
.data-table-card.excel-mode textarea.excel-cell {
    display: block;
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    min-height: 2rem;
    height: auto;
    overflow-x: hidden;
    overflow-y: hidden;
    resize: none;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.4;
    padding: 0.35rem 0.5rem;
    box-sizing: border-box;
}
.data-table-card.excel-mode input.excel-cell:not([type="checkbox"]) {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 2rem;
    box-sizing: border-box;
}
.data-table-card.excel-mode .excel-cell:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    outline: none;
    position: relative;
    z-index: 1;
}
.data-table-card.excel-mode .excel-cell.excel-saved {
    background: rgba(34, 197, 94, 0.12);
}
.data-table-card.excel-mode .excel-cell.excel-error {
    background: rgba(239, 68, 68, 0.12);
    border-color: var(--danger);
}
.data-table-card.excel-mode .excel-cell.excel-saving {
    opacity: 0.6;
}
.data-table-card.excel-mode tr.excel-new-row {
    background: rgba(34, 197, 94, 0.08);
}
.data-table-card.excel-mode tr.excel-new-row td {
    padding: 0.35rem;
}
.data-table-card.excel-mode .excel-new-cell .excel-cell {
    background: var(--bg-card);
}
.excel-enlace-cell {
    min-width: 140px;
}
.excel-enlace-cell .excel-link-preview {
    margin-bottom: 0.2rem;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.excel-enlace-cell .excel-link-preview .cell-link {
    font-size: 0.8rem;
    max-width: 100%;
}
.excel-enlace-cell .excel-link-field {
    font-size: 0.75rem;
    min-width: 120px;
}
.excel-embedded-link {
    margin-top: 0.15rem;
    font-size: 0.75rem;
}
#btnExcelMode.active {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-pendiente, .status-abierta { background: rgba(245,158,11,0.15); color: #d97706; }
.status-en-proceso, .status-en-revisin { background: rgba(99,102,241,0.15); color: var(--primary); }
.status-finalizada, .status-cerrada { background: rgba(34,197,94,0.15); color: var(--success); }
.status-suspendida, .status-crtica { background: rgba(239,68,68,0.15); color: var(--danger); }

.smart-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    margin: 0.1rem 0.15rem 0.1rem 0;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--chip-bg, rgba(99,102,241,0.12));
    color: var(--chip-color, var(--primary));
    border: 1px solid color-mix(in srgb, var(--chip-color, var(--primary)) 25%, transparent);
    white-space: nowrap;
}

.cell-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cell-link:hover { text-decoration: underline; color: var(--primary); }

.excel-chips-wrap { min-width: 140px; }
.chip-quick-picks { display: flex; flex-wrap: wrap; gap: 0.2rem; margin-top: 0.25rem; }
.chip-quick-picks .chip-pick-btn {
    border: none;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.68rem;
    cursor: pointer;
    background: rgba(99,102,241,0.1);
    color: var(--primary);
}
.chip-quick-picks .chip-pick-btn:hover { background: rgba(99,102,241,0.2); }

.row-overdue { background: rgba(239,68,68,0.06) !important; }

/* ========== ACTIVITY FEED ========== */
.activity-feed { padding: 0.5rem 0; }
.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}
.activity-item:hover { background: var(--primary-light); }
.activity-item:last-child { border-bottom: none; }

.activity-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}
.activity-create { background: rgba(34,197,94,0.12); color: var(--success); }
.activity-update { background: rgba(99,102,241,0.12); color: var(--primary); }
.activity-delete { background: rgba(239,68,68,0.12); color: var(--danger); }
.activity-login { background: rgba(6,182,212,0.12); color: var(--info); }
.activity-circle { background: rgba(100,116,139,0.12); color: var(--text-secondary); }

.activity-content { flex: 1; }
.activity-content span { color: var(--text-secondary); margin-left: 0.25rem; }
.activity-time { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }

/* ========== PROGRESS BAR ========== */
.progress-bar-mini {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    width: 80px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--purple));
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* ========== ROLES ========== */
.role-admin { background: rgba(99,102,241,0.15); color: var(--primary); }
.role-supervisor { background: rgba(6,182,212,0.15); color: var(--info); }
.role-operador { background: rgba(245,158,11,0.15); color: var(--warning); }
.role-lectura { background: rgba(100,116,139,0.15); color: var(--text-secondary); }

/* ========== NOTIFICATIONS ========== */
.notif-list { padding: 0; }
.notif-item {
    display: flex; gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.notif-item.unread { background: var(--primary-light); }
.notif-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    flex-shrink: 0;
}
.notif-content p { margin: 0.25rem 0; font-size: 0.875rem; color: var(--text-secondary); }

/* ========== LOGIN PAGE ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    display: flex;
    width: 100%;
    max-width: 960px;
    margin: 2rem;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.6s ease;
}

.login-card {
    flex: 1;
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(6px);
}
.login-theme-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}
[data-theme="light"] .login-theme-toggle {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
}
[data-theme="light"] .login-theme-toggle:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo {
    width: 64px; height: 64px;
    background: var(--primary-light);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem;
    font-size: 2rem;
    color: var(--primary);
}
.login-header h1 { font-size: 1.5rem; margin: 0; color: var(--text-primary); }
.login-header p { color: var(--text-secondary); margin: 0.5rem 0 0; }

.btn-login {
    padding: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: var(--primary);
    border: none;
}
.btn-login:hover { background: var(--primary-hover); }

.login-footer { text-align: center; margin-top: 2rem; }

.login-decoration {
    flex: 1;
    background: linear-gradient(135deg, #1e1e2d 0%, #2d2d44 100%);
    padding: 3rem;
    display: flex;
    align-items: center;
    color: #fff;
}

.decoration-content h2 { font-size: 1.75rem; margin-bottom: 1rem; }
.decoration-content p { color: #94a3b8; margin-bottom: 2rem; }
.feature-list div {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 0.75rem;
    color: #cbd5e1;
}
.feature-list i { color: var(--success); }

/* ========== FORM OVERRIDES ========== */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    padding: 0.6rem 0.875rem;
    transition: var(--transition);
    background: var(--bg-card);
    color: var(--text-primary);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: var(--transition);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-outline-secondary {
    border-radius: var(--radius-sm);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.modal-content {
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
}

.table { color: var(--text-primary); }
.dropdown-menu {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    background: var(--bg-card);
}
.dropdown-item { color: var(--text-primary); }
.dropdown-item:hover { background: var(--primary-light); }

/* ========== TOAST ========== */
.ic-toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.ic-toast {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.875rem;
    box-shadow: var(--shadow-md);
    animation: slideInRight 0.3s ease;
    min-width: 280px;
}
.ic-toast-success { background: var(--success); }
.ic-toast-error { background: var(--danger); }
.ic-toast-info { background: var(--primary); }

/* ========== ANIMATIONS ========== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========== VIEW TABS (Tabla / Gráficas) ========== */
.view-tabs {
    display: inline-flex;
    gap: 0.25rem;
    background: var(--bg-body);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.view-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.view-tab:hover { color: var(--text-primary); background: var(--primary-light); }
.view-tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.view-panel { animation: fadeInUp 0.3s ease; }

/* Dashboard gráficas redimensionables */
.dashboard-chart-cell.d-none { display: none !important; }

.dashboard-charts-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-start;
}
.dashboard-chart-cell {
    box-sizing: border-box;
    min-width: 200px;
    flex-shrink: 0;
    overflow: hidden;
}
.dashboard-chart-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}
.dashboard-chart-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 0.5rem;
}
.dashboard-chart-plot {
    flex: 1 1 auto;
    min-height: 72px;
    position: relative;
    overflow: hidden;
}
.dashboard-chart-plot canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}
body.dashboard-chart-resizing {
    user-select: none;
    cursor: nwse-resize;
}
body.dashboard-chart-resizing .dashboard-chart-card {
    pointer-events: none;
}
body.dashboard-chart-resizing .chart-resize-handle {
    pointer-events: auto;
}
.chart-resize-handle {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    opacity: 0.5;
    background: linear-gradient(135deg, transparent 50%, var(--primary) 50%);
    border-radius: 0 0 4px 0;
    z-index: 5;
    pointer-events: auto;
}
.chart-resize-handle:hover {
    opacity: 0.95;
}

.chart-drill-header {
    gap: 0.75rem;
}
.chart-drill-header .modal-title {
    flex: 1 1 auto;
    min-width: 0;
}
.chart-drill-cols-btn {
    margin-left: auto;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.4rem 0.9rem;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}
.chart-drill-cols-btn:hover {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.45);
    transform: translateY(-1px);
}
.chart-drill-header .btn-close {
    flex-shrink: 0;
    margin-left: 0.25rem;
}

.chart-drill-body {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.chart-drill-column-panel {
    order: -1;
    width: 100%;
    margin-bottom: 1rem;
    padding: 1rem 1.1rem;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}
.chart-drill-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    width: 100%;
}
.chart-drill-stat-card {
    flex: 1 1 100%;
    text-align: center;
    padding: 1.1rem 1.5rem;
    border-radius: var(--radius-sm);
    border: 2px solid var(--primary);
    background: var(--bg-card);
}
.chart-drill-stats:has(.chart-drill-stat-sum) .chart-drill-stat-card {
    flex: 1 1 calc(50% - 0.375rem);
    min-width: min(100%, 220px);
}
.chart-drill-stat-primary .chart-drill-stat-value {
    color: var(--primary);
}
.chart-drill-stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 0.35rem;
}
.chart-drill-stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.chart-drill-stat-sum {
    border-color: var(--border-color);
    background: var(--bg-body);
}

.share-layout-body {
    background: var(--bg-body);
    min-height: 100vh;
}
.share-topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

/* Import preview */
.import-info {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
}
.import-info i { font-size: 1.5rem; flex-shrink: 0; margin-top: 2px; }
.import-preview-table { max-height: 200px; overflow: auto; }
.import-preview-table th { background: var(--bg-body); font-size: 0.75rem; white-space: nowrap; }
.import-preview-table td { font-size: 0.8rem; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ========== RESPONSIVE ========== */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .main-content { margin-left: 0; }
    .login-decoration { display: none; }
    .page-content { padding: 1rem; }
}

@media (max-width: 575.98px) {
    .login-card { padding: 2rem 1.5rem; }
    .kpi-value { font-size: 1.35rem; }
}

/* DataTables dark mode */
[data-theme="dark"] .dataTables_wrapper .dataTables_filter input,
[data-theme="dark"] .dataTables_wrapper .dataTables_length select {
    background: var(--bg-body);
    color: var(--text-primary);
    border-color: var(--border-color);
}
[data-theme="dark"] .page-link { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-color); }

/* ========== DARK MODE (global) ========== */
[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
    --bs-table-hover-bg: rgba(99, 102, 241, 0.1);
    --bs-table-active-bg: rgba(99, 102, 241, 0.14);
}

[data-theme="dark"] .table > :not(caption) > * > * {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
    box-shadow: none;
}

[data-theme="dark"] .table thead th,
[data-theme="dark"] .data-table-card .table thead th {
    background: #162032;
    color: var(--text-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .table tbody tr,
[data-theme="dark"] .data-table-card .table tbody tr {
    background: var(--bg-card);
}

[data-theme="dark"] .table tbody tr:nth-child(even),
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(255, 255, 255, 0.02);
}

[data-theme="dark"] .table-hover > tbody > tr:hover > *,
[data-theme="dark"] .data-table-card .table tbody tr:hover {
    background: rgba(99, 102, 241, 0.08) !important;
    color: var(--text-primary);
}

[data-theme="dark"] .card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .page-header,
[data-theme="dark"] .view-tabs,
[data-theme="dark"] .table-card {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .card-header,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .topbar-search input,
[data-theme="dark"] .dataTables_wrapper .dataTables_filter input,
[data-theme="dark"] .dataTables_wrapper .dataTables_length select {
    background: #0f172a;
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .topbar-search input:focus {
    background: #0f172a;
    color: var(--text-primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .form-control::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="time"],
[data-theme="dark"] input[type="datetime-local"] {
    color-scheme: dark;
}

[data-theme="dark"] .data-table-card.excel-mode .excel-cell,
[data-theme="dark"] .data-table-card.excel-mode input.excel-cell:not([type="checkbox"]),
[data-theme="dark"] .data-table-card.excel-mode textarea.excel-cell,
[data-theme="dark"] .data-table-card.excel-mode select.excel-cell {
    background: #0f172a;
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .data-table-card.excel-mode .excel-cell:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

[data-theme="dark"] .data-table-card.excel-mode .excel-new-cell .excel-cell {
    background: #132033;
}

[data-theme="dark"] #recordsTable .sticky-col {
    background: var(--bg-card);
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] #recordsTable thead .sticky-col {
    background: #162032;
}

[data-theme="dark"] #recordsTable tbody tr:hover .sticky-col {
    background: rgba(99, 102, 241, 0.12);
}

[data-theme="dark"] .table-zoom-toolbar,
[data-theme="dark"] .excel-mode-hint,
[data-theme="dark"] .view-tab,
[data-theme="dark"] .btn-outline-secondary {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

[data-theme="dark"] .view-tab.active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: rgba(99, 102, 241, 0.35);
}

[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
[data-theme="dark"] .text-dark { color: var(--text-primary) !important; }
[data-theme="dark"] .bg-light,
[data-theme="dark"] .bg-white {
    background-color: #162032 !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .border,
[data-theme="dark"] .border-top,
[data-theme="dark"] .border-bottom {
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .badge.bg-light {
    background: rgba(255, 255, 255, 0.08) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .alert-success {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.35);
    color: #bbf7d0;
}
[data-theme="dark"] .alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fecaca;
}

[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(1) brightness(1.4);
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-primary);
}

[data-theme="dark"] .sidebar-overlay {
    background: rgba(0, 0, 0, 0.55);
}

[data-theme="dark"] hr,
[data-theme="dark"] .dropdown-divider {
    border-color: var(--border-color);
    opacity: 1;
}

[data-theme="dark"] .import-info {
    background: rgba(99, 102, 241, 0.12);
}

[data-theme="dark"] .import-preview-table th {
    background: #162032;
}

[data-theme="dark"] .page-content {
    background: var(--bg-body);
}
