/* ============================================================
   POS Restaurante — Design System
   Lenguaje visual: Linear / Vercel / Raycast
   Neutral, baja saturación, un solo acento, tema claro/oscuro.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

/* ================================================================
   TOKENS — TEMA CLARO (por defecto)
   ================================================================ */
:root {
    /* Superficies */
    --bg-app:        #fbfbfc;
    --bg-surface:    #ffffff;
    --bg-subtle:     #f6f6f7;
    --bg-hover:      #f2f2f4;
    --bg-active:     #ececef;

    /* Bordes */
    --border:        #e8e8eb;
    --border-strong: #dcdce0;

    /* Texto */
    --text-primary:   #17171a;
    --text-secondary: #60646c;
    --text-muted:     #8b8f98;
    --text-faint:     #b0b3ba;

    /* Acento único */
    --accent:        #5b5fc7;   /* indigo sobrio */
    --accent-hover:  #4f53b8;
    --accent-active: #454aa8;
    --accent-fg:     #ffffff;
    --accent-soft:   rgba(91,95,199,.10);
    --accent-ring:   rgba(91,95,199,.22);

    /* Estados semánticos (usados con moderación) */
    --success:       #12805c;
    --success-soft:  #e4f6ee;
    --danger:        #d1293d;
    --danger-soft:   #fbe9eb;
    --warning:       #a35b00;
    --warning-soft:  #fbf0dd;
    --info:          #0e6fb8;
    --info-soft:     #e5f1fb;

    /* Sidebar (adapta al tema) */
    --sidebar-bg:      #fbfbfc;
    --sidebar-border:  #ececef;
    --sidebar-item:    #52565e;
    --sidebar-item-hv: #17171a;
    --sidebar-active-bg: var(--accent-soft);
    --sidebar-active-fg: var(--accent);
    --sidebar-label:   #9598a1;

    /* Radios */
    --r-xs: 5px;
    --r-sm: 7px;
    --r:    9px;
    --r-md: 11px;
    --r-lg: 14px;
    --r-xl: 18px;

    /* Sombras (muy suaves) */
    --shadow-xs: 0 1px 2px rgba(17,17,26,.04);
    --shadow-sm: 0 1px 3px rgba(17,17,26,.05), 0 1px 2px rgba(17,17,26,.04);
    --shadow-md: 0 4px 12px rgba(17,17,26,.06), 0 2px 4px rgba(17,17,26,.04);
    --shadow-lg: 0 12px 32px rgba(17,17,26,.10), 0 4px 8px rgba(17,17,26,.05);
    --shadow-pop: 0 8px 28px rgba(17,17,26,.14);

    /* Transiciones */
    --t-fast: .12s cubic-bezier(.4,0,.2,1);
    --t:      .18s cubic-bezier(.4,0,.2,1);

    --sidebar-width: 244px;
    --sidebar-collapsed: 64px;
    --topbar-h: 56px;
}

/* ================================================================
   TOKENS — TEMA OSCURO
   ================================================================ */
:root[data-theme="dark"] {
    --bg-app:        #0c0c0e;
    --bg-surface:    #151518;
    --bg-subtle:     #1a1a1e;
    --bg-hover:      #202024;
    --bg-active:     #26262b;

    --border:        #242428;
    --border-strong: #303036;

    --text-primary:   #f5f5f7;
    --text-secondary: #a4a7b0;
    --text-muted:     #77797f;
    --text-faint:     #55565b;

    --accent:        #7c80e8;
    --accent-hover:  #888cee;
    --accent-active: #9599f2;
    --accent-fg:     #ffffff;
    --accent-soft:   rgba(124,128,232,.14);
    --accent-ring:   rgba(124,128,232,.30);

    --success:       #3ecf8e;
    --success-soft:  rgba(62,207,142,.12);
    --danger:        #f16b7d;
    --danger-soft:   rgba(241,107,125,.12);
    --warning:       #e0a24e;
    --warning-soft:  rgba(224,162,78,.12);
    --info:          #56aef0;
    --info-soft:     rgba(86,174,240,.12);

    --sidebar-bg:      #0c0c0e;
    --sidebar-border:  #202024;
    --sidebar-item:    #9a9da4;
    --sidebar-item-hv: #f5f5f7;
    --sidebar-active-bg: var(--accent-soft);
    --sidebar-active-fg: var(--accent);
    --sidebar-label:   #66686e;

    --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.5);
    --shadow-md: 0 4px 14px rgba(0,0,0,.45);
    --shadow-lg: 0 14px 40px rgba(0,0,0,.55);
    --shadow-pop: 0 10px 34px rgba(0,0,0,.6);
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    min-width: 320px;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background var(--t), color var(--t);
}

h1,h2,h3,h4,h5,h6 { letter-spacing: -0.012em; }

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

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

::selection { background: var(--accent-ring); }

/* Focus visible accesible */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}

/* ================================================================
   LAYOUT
   ================================================================ */
.wrapper { display: flex; min-height: 100vh; width: 100%; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: transform var(--t), width var(--t);
    overflow: hidden;
}

.sidebar-brand {
    height: var(--topbar-h);
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}
.sidebar-brand .brand-icon {
    width: 30px; height: 30px;
    background: var(--accent);
    border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: var(--accent-fg);
    flex-shrink: 0;
    box-shadow: var(--shadow-xs);
}
.sidebar-brand .brand-name {
    font-size: 14.5px; font-weight: 700; color: var(--text-primary); line-height: 1.1;
    letter-spacing: -0.01em; white-space: nowrap;
}

.sidebar-nav {
    list-style: none;
    padding: 10px 10px 16px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}
.nav-section-label {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--sidebar-label);
    padding: 14px 10px 5px;
    white-space: nowrap;
}
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin: 1px 0;
    color: var(--sidebar-item);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: var(--r-sm);
    transition: color var(--t-fast), background var(--t-fast);
    white-space: nowrap;
    position: relative;
}
.sidebar-nav li a .nav-icon {
    width: 18px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color var(--t-fast);
}
.sidebar-nav li a:hover {
    color: var(--sidebar-item-hv);
    background: var(--bg-hover);
}
.sidebar-nav li a:hover .nav-icon { color: var(--sidebar-item-hv); }
.sidebar-nav li.active > a {
    color: var(--sidebar-active-fg);
    background: var(--sidebar-active-bg);
    font-weight: 600;
}
.sidebar-nav li.active > a .nav-icon { color: var(--sidebar-active-fg); }

/* ── Sidebar colapsada (desktop) ── */
.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed); }
.sidebar-collapsed .sidebar .brand-name,
.sidebar-collapsed .sidebar .nav-section-label { opacity: 0; pointer-events: none; }
.sidebar-collapsed .sidebar .sidebar-nav li a { justify-content: center; padding: 9px; }
.sidebar-collapsed .sidebar .sidebar-nav li a > *:not(.nav-icon) { display: none; }
.sidebar-collapsed .sidebar .nav-icon { font-size: 16px; }
.sidebar-collapsed .main-content { margin-left: var(--sidebar-collapsed); }
/* Tooltip al pasar el mouse en colapsado */
.sidebar-collapsed .sidebar-nav li a::after {
    content: attr(data-label);
    position: absolute; left: calc(100% + 10px); top: 50%;
    transform: translateY(-50%) scale(.96);
    background: var(--text-primary); color: var(--bg-surface);
    font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: var(--r-sm);
    white-space: nowrap; opacity: 0; pointer-events: none;
    transition: opacity var(--t-fast), transform var(--t-fast);
    box-shadow: var(--shadow-md); z-index: 300;
}
.sidebar-collapsed .sidebar-nav li a:hover::after { opacity: 1; transform: translateY(-50%) scale(1); }

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    transition: margin-left var(--t);
}

/* ── Topbar ── */
.topbar {
    background: color-mix(in srgb, var(--bg-surface) 80%, transparent);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    padding: 0 18px;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.icon-btn {
    background: transparent; border: none;
    color: var(--text-secondary); font-size: 16px;
    cursor: pointer; width: 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--r-sm);
    transition: background var(--t-fast), color var(--t-fast);
    flex-shrink: 0; text-decoration: none;
    position: relative;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.sidebar-toggle { display: none; }

/* Breadcrumbs */
.breadcrumbs { display: flex; align-items: center; gap: 7px; font-size: 13.5px; min-width: 0; }
.breadcrumbs .crumb { color: var(--text-muted); white-space: nowrap; }
.breadcrumbs .crumb.current { color: var(--text-primary); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.breadcrumbs .sep { color: var(--text-faint); font-size: 11px; }

/* Búsqueda global / disparador command palette */
.global-search {
    display: flex; align-items: center; gap: 8px;
    height: 34px; min-width: 200px; max-width: 300px;
    padding: 0 10px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-muted);
    font-size: 13px; cursor: pointer;
    transition: border-color var(--t-fast), background var(--t-fast);
}
.global-search:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.global-search .gs-text { flex: 1; text-align: left; }
.global-search kbd {
    font-family: inherit; font-size: 11px; font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 5px; padding: 1px 5px; line-height: 1.4;
}

.topbar-spacer { flex: 1; }
.topbar-meta { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }

/* Badge de notificaciones */
.icon-btn .dot {
    position: absolute; top: 6px; right: 7px;
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--danger); border: 1.5px solid var(--bg-surface);
}

/* Usuario en topbar */
.topbar-user { display: flex; align-items: center; gap: 9px; padding-left: 6px; }
.user-avatar {
    width: 30px; height: 30px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: var(--accent-fg); font-size: 12.5px;
    flex-shrink: 0;
}
.user-meta { line-height: 1.25; min-width: 0; }
.user-meta .u-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta .u-role { font-size: 11px; color: var(--text-muted); }
.btn-logout { color: var(--text-muted); }
.btn-logout:hover { color: var(--danger); }

.content-area { padding: 24px; width: 100%; min-width: 0; }

/* ── Overlay móvil ── */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(2px);
    z-index: 199;
}

/* ================================================================
   BOTONES  (override Bootstrap → lenguaje del sistema)
   ================================================================ */
.btn {
    font-size: 13.5px;
    font-weight: 600;
    border-radius: var(--r-sm);
    padding: 8px 14px;
    border: 1px solid transparent;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
    line-height: 1.3;
    letter-spacing: -0.005em;
}
.btn:active { transform: translateY(.5px); }
.btn:focus { box-shadow: none; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn-lg { padding: 11px 18px; font-size: 15px; border-radius: var(--r); }

.btn-primary, .btn-primary:focus {
    background: var(--accent); border-color: var(--accent); color: var(--accent-fg);
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-fg); }
.btn-primary:active { background: var(--accent-active); border-color: var(--accent-active); }

.btn-secondary, .btn-light, .btn-outline-secondary {
    background: var(--bg-surface); border-color: var(--border-strong); color: var(--text-primary);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover, .btn-light:hover, .btn-outline-secondary:hover {
    background: var(--bg-hover); border-color: var(--border-strong); color: var(--text-primary);
}

.btn-success  { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.94); color: #fff; }
.btn-danger   { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); color: #fff; }
.btn-warning  { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-warning:hover { filter: brightness(.94); color: #fff; }
.btn-info     { background: var(--info); border-color: var(--info); color: #fff; }

.btn-outline-primary { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn-outline-primary:hover { background: var(--accent); color: var(--accent-fg); }
.btn-outline-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }

.btn-link { color: var(--accent); text-decoration: none; box-shadow: none; }

/* ================================================================
   CARDS
   ================================================================ */
.card {
    background: var(--bg-surface);
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    min-width: 0;
}
.card-header {
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: transparent;
}
.card-header h5, .card-header h6 { margin: 0; font-weight: 700; font-size: 14px; color: var(--text-primary); letter-spacing: -0.01em; }
.card-body { padding: 18px; }

/* ── Stat / KPI Cards — limpias, tinte suave (no degradados) ── */
.stat-card {
    border-radius: var(--r-lg);
    padding: 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
    transition: border-color var(--t), box-shadow var(--t);
}
.stat-card:hover { box-shadow: var(--shadow-sm); }
.stat-card .sc-icon {
    width: 34px; height: 34px; border-radius: var(--r-sm);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 15px; margin-bottom: 12px;
    background: var(--accent-soft); color: var(--accent);
    position: static; transform: none; opacity: 1;
}
.stat-card::after { display: none; }
.stat-card .sc-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); text-transform: none; letter-spacing: 0; }
.stat-card .sc-value { font-size: 25px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; color: var(--text-primary); }
.stat-card .sc-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* Variantes de color aplicadas SOLO al icono/acento, no al fondo */
.sc-blue   .sc-icon { background: var(--info-soft);    color: var(--info); }
.sc-green  .sc-icon { background: var(--success-soft); color: var(--success); }
.sc-purple .sc-icon { background: var(--accent-soft);  color: var(--accent); }
.sc-amber  .sc-icon { background: var(--warning-soft); color: var(--warning); }
.sc-red    .sc-icon { background: var(--danger-soft);  color: var(--danger); }
.sc-teal   .sc-icon { background: var(--info-soft);    color: var(--info); }

/* ── Account / tarjetas con hover ── */
.account-card { transition: transform var(--t), box-shadow var(--t), border-color var(--t); cursor: default; }
.account-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.acct-icon {
    width: 40px; height: 40px; border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.acct-icon.bank           { background: var(--info-soft);    color: var(--info); }
.acct-icon.cash           { background: var(--success-soft); color: var(--success); }
.acct-icon.mobile_banking { background: var(--accent-soft);  color: var(--accent); }
.acct-icon.crypto         { background: var(--warning-soft); color: var(--warning); }
.acct-icon.receivable     { background: var(--info-soft);    color: var(--info); }
.acct-icon.other          { background: var(--bg-subtle);    color: var(--text-secondary); }
.acct-balance { font-size: 21px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.acct-name    { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.acct-type    { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

/* ================================================================
   TABLAS (estilo Linear / GitHub)
   ================================================================ */
.table-responsive { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.table { margin: 0; color: var(--text-primary); }
.table thead th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
    border-top: none;
    padding: 10px 16px;
    white-space: nowrap;
}
.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    background: transparent;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover td { background: var(--bg-subtle); }

/* ================================================================
   BADGES
   ================================================================ */
.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    letter-spacing: .01em;
    line-height: 1.5;
}
.bg-primary   { background: var(--accent) !important; color: var(--accent-fg) !important; }
.bg-success   { background: var(--success) !important; }
.bg-danger    { background: var(--danger) !important; }
.bg-warning   { background: var(--warning) !important; color:#fff !important; }
.bg-secondary { background: var(--text-muted) !important; }

.status-active    { background: var(--success-soft); color: var(--success); }
.status-matured   { background: var(--warning-soft); color: var(--warning); }
.status-renewed   { background: var(--info-soft);    color: var(--info); }
.status-withdrawn { background: var(--bg-active);     color: var(--text-secondary); }

.tx-deposit     { background: var(--success-soft); color: var(--success); }
.tx-withdrawal  { background: var(--danger-soft);  color: var(--danger); }
.tx-investment  { background: var(--info-soft);    color: var(--info); }
.tx-profit      { background: var(--success-soft); color: var(--success); }
.tx-transfer_in  { background: var(--info-soft);   color: var(--info); }
.tx-transfer_out { background: var(--warning-soft);color: var(--warning); }
.tx-renewal     { background: var(--info-soft);    color: var(--info); }

/* ================================================================
   BOTONES DE ACCIÓN (iconos en tablas)
   ================================================================ */
.btn-act {
    width: 30px; height: 30px;
    border: 1px solid transparent; border-radius: var(--r-xs);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
    text-decoration: none;
    background: var(--bg-subtle); color: var(--text-secondary);
}
.btn-act:hover { background: var(--bg-active); color: var(--text-primary); }
.btn-view     { color: var(--info); }
.btn-view:hover     { background: var(--info-soft); color: var(--info); }
.btn-edit     { color: var(--text-secondary); }
.btn-edit:hover     { background: var(--accent-soft); color: var(--accent); }
.btn-delete   { color: var(--danger); }
.btn-delete:hover   { background: var(--danger-soft); color: var(--danger); }
.btn-renew    { color: var(--warning); }
.btn-renew:hover    { background: var(--warning-soft); color: var(--warning); }
.btn-withdraw { color: var(--warning); }
.btn-withdraw:hover { background: var(--warning-soft); color: var(--warning); }
.btn-addmoney { color: var(--success); }
.btn-addmoney:hover { background: var(--success-soft); color: var(--success); }

/* ================================================================
   REPORT TABLES (compactas)
   ================================================================ */
.report-chart { position: relative; height: 260px; width: 100%; }
.report-table-wrap { overflow-x: visible; }
.report-table { min-width: 0; table-layout: fixed; }
.report-table th, .report-table td {
    white-space: normal; overflow-wrap: anywhere;
    padding: 8px 7px; font-size: 12px; line-height: 1.25;
}
.report-table thead th { font-size: 9.5px; padding: 8px 7px; }
.report-table .amount-neutral, .report-table .amount-pos, .report-table .amount-neg { font-size: 11.5px; font-weight: 700; }
.report-table .badge { font-size: 10px; padding: 3px 6px; }

.report-account-table th:nth-child(1), .report-account-table td:nth-child(1) { width: 34%; }
.report-account-table th:nth-child(2), .report-account-table td:nth-child(2),
.report-account-table th:nth-child(3), .report-account-table td:nth-child(3),
.report-account-table th:nth-child(4), .report-account-table td:nth-child(4) { width: 22%; }
.report-category-table th:nth-child(1), .report-category-table td:nth-child(1) { width: 34%; }
.report-category-table th:nth-child(2), .report-category-table td:nth-child(2) { width: 14%; text-align: center; }
.report-category-table th:nth-child(3), .report-category-table td:nth-child(3),
.report-category-table th:nth-child(4), .report-category-table td:nth-child(4) { width: 26%; }
.report-profit-table th:nth-child(1), .report-profit-table td:nth-child(1) { width: 48%; }
.report-profit-table th:nth-child(2), .report-profit-table td:nth-child(2) { width: 52%; }

.maintenance-action { width: 100%; max-width: 260px; }
@media (max-width: 767.98px) { .maintenance-action { max-width: none; } }

/* ================================================================
   FORMULARIOS & MODALES
   ================================================================ */
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: none; letter-spacing: 0; }
.form-control, .form-select {
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    font-size: 14px;
    padding: 9px 12px;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    background: var(--bg-surface);
    color: var(--text-primary);
}
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
    outline: none;
    background: var(--bg-surface);
    color: var(--text-primary);
}
.form-control::placeholder { color: var(--text-faint); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.invalid-feedback { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-text { font-size: 12px; color: var(--text-muted); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--accent-ring); border-color: var(--accent); }
.form-switch .form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }

.modal-content { border-radius: var(--r-xl); border: 1px solid var(--border); box-shadow: var(--shadow-lg); background: var(--bg-surface); overflow: hidden; }
.modal-header { background: transparent; border-bottom: 1px solid var(--border); padding: 16px 20px; }
.modal-title { font-size: 15.5px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.01em; }
.modal-body { padding: 20px; color: var(--text-primary); }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--bg-subtle); }
.modal .table { min-width: auto; }
.modal-backdrop.show { opacity: .4; }
.btn-close { transition: opacity var(--t-fast); }
:root[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(1.4); }

/* ================================================================
   MONTOS & NÚMEROS
   ================================================================ */
.amount-pos { color: var(--success); font-weight: 700; }
.amount-neg { color: var(--danger); font-weight: 700; }
.amount-neutral { color: var(--text-primary); font-weight: 600; }
.fw-700 { font-weight: 700; } .fw-600 { font-weight: 600; } .fs-13 { font-size: 13px; }
.text-muted { color: var(--text-muted) !important; }
.text-dark { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.border-start { border-color: var(--border) !important; }

/* ── Maturity badges ── */
.maturity-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 12px; }
.maturity-badge.overdue { background: var(--danger-soft); color: var(--danger); }
.maturity-badge.soon    { background: var(--warning-soft); color: var(--warning); }
.maturity-badge.ok      { background: var(--success-soft); color: var(--success); }

/* ================================================================
   EMPTY STATE / PAGE ACTIONS / DIVIDER
   ================================================================ */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state .es-icon {
    font-size: 26px; margin-bottom: 14px; color: var(--text-faint);
    width: 60px; height: 60px; border-radius: var(--r-lg);
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-subtle); opacity: 1;
}
.empty-state p { font-size: 14px; }

.page-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; justify-content: space-between; }
.page-actions h2 { font-size: 21px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.page-actions .sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.section-divider { border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Toast area ── */
.toast-area { position: fixed; top: 68px; right: 20px; z-index: 9999; min-width: 280px; display: flex; flex-direction: column; gap: 8px; }
.toast-area .alert {
    border: 1px solid var(--border); border-radius: var(--r-md);
    box-shadow: var(--shadow-lg); background: var(--bg-surface); color: var(--text-primary);
    padding: 11px 14px; animation: toastIn var(--t) both;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(12px) scale(.98); } to { opacity: 1; transform: none; } }
.alert-success { border-left: 3px solid var(--success); }
.alert-danger  { border-left: 3px solid var(--danger); }
.alert-warning { border-left: 3px solid var(--warning); }
.alert-info    { border-left: 3px solid var(--info); }

/* Detail rows */
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--text-muted); }
.detail-row .value { font-weight: 600; color: var(--text-primary); }

/* Filter bar */
.filter-bar {
    display: flex; gap: 10px; flex-wrap: wrap;
    padding: 13px 16px;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
}
.filter-bar .form-control, .filter-bar .form-select { font-size: 13px; padding: 7px 11px; max-width: 190px; }

/* ================================================================
   COMMAND PALETTE (Ctrl + K)
   ================================================================ */
.cmdk-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(10,10,15,.42);
    backdrop-filter: blur(3px);
    display: none;
    align-items: flex-start; justify-content: center;
    padding-top: 12vh;
    opacity: 0; transition: opacity var(--t);
}
.cmdk-overlay.open { display: flex; opacity: 1; }
.cmdk {
    width: 100%; max-width: 560px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-pop);
    overflow: hidden;
    transform: translateY(-8px) scale(.99);
    transition: transform var(--t);
}
.cmdk-overlay.open .cmdk { transform: none; }
.cmdk-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cmdk-input-row i { color: var(--text-muted); font-size: 15px; }
.cmdk-input { flex: 1; border: none; outline: none; background: transparent; font-size: 15px; color: var(--text-primary); font-family: inherit; }
.cmdk-input::placeholder { color: var(--text-faint); }
.cmdk-list { max-height: 360px; overflow-y: auto; padding: 8px; }
.cmdk-group-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 10px 10px 4px; }
.cmdk-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 10px; border-radius: var(--r-sm);
    cursor: pointer; color: var(--text-primary); font-size: 13.5px; font-weight: 500;
}
.cmdk-item .ci-icon { width: 18px; text-align: center; color: var(--text-muted); font-size: 14px; }
.cmdk-item .ci-hint { margin-left: auto; font-size: 11px; color: var(--text-faint); }
.cmdk-item.active, .cmdk-item:hover { background: var(--accent-soft); color: var(--accent); }
.cmdk-item.active .ci-icon, .cmdk-item:hover .ci-icon { color: var(--accent); }
.cmdk-empty { padding: 26px; text-align: center; color: var(--text-muted); font-size: 13.5px; }
.cmdk-footer { display: flex; align-items: center; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--border); background: var(--bg-subtle); font-size: 11.5px; color: var(--text-muted); }
.cmdk-footer kbd { font-family: inherit; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; font-size: 11px; }

/* ================================================================
   LOGIN PAGE
   ================================================================ */
.login-page {
    min-height: 100vh;
    background: var(--bg-app);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    position: relative; overflow: hidden;
}
.login-page::before {
    content: ''; position: absolute; top: -30%; left: 50%; transform: translateX(-50%);
    width: 640px; height: 640px; border-radius: 50%;
    background: radial-gradient(circle, var(--accent-soft), transparent 68%);
    pointer-events: none;
}
.login-card {
    width: 100%; max-width: 400px; position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.login-card-top { padding: 32px 32px 8px; text-align: center; }
.login-logo-icon {
    width: 52px; height: 52px;
    background: var(--accent);
    border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: var(--accent-fg);
    margin: 0 auto 16px;
    box-shadow: var(--shadow-sm);
}
.login-card-top h1 { font-size: 21px; font-weight: 700; margin: 0 0 5px; color: var(--text-primary); letter-spacing: -0.02em; }
.login-card-top p  { font-size: 13.5px; color: var(--text-muted); margin: 0; }
.login-card-body { padding: 24px 32px 32px; }

/* ================================================================
   SKELETON LOADERS
   ================================================================ */
.skeleton {
    background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--bg-hover) 37%, var(--bg-subtle) 63%);
    background-size: 400% 100%;
    animation: skeleton 1.4s ease infinite;
    border-radius: var(--r-xs);
}
@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
    .sidebar-toggle { display: inline-flex !important; }
    .sidebar-collapse-btn { display: none !important; }
    .sidebar-overlay.show { display: block; }
    .content-area { padding: 16px; }
    .sidebar { width: min(var(--sidebar-width), 86vw); }
    /* En móvil la sidebar nunca queda colapsada a iconos */
    .sidebar-collapsed .sidebar { width: min(var(--sidebar-width), 86vw); }
    .sidebar-collapsed .sidebar .brand-name, .sidebar-collapsed .sidebar .nav-section-label { opacity: 1; }
    .sidebar-collapsed .sidebar .sidebar-nav li a { justify-content: flex-start; padding: 8px 10px; }
    .sidebar-collapsed .sidebar .sidebar-nav li a > *:not(.nav-icon) { display: inline; }
    .sidebar-collapsed .sidebar-nav li a::after { display: none; }
}

@media (max-width: 768px) {
    .topbar { height: 54px; padding: 0 12px; gap: 6px; }
    .sidebar-toggle { width: 36px; height: 36px; }
    .global-search { display: none; }
    .breadcrumbs .crumb:not(.current) { display: none; }
    .breadcrumbs .sep { display: none; }
    .topbar-meta { display: none !important; }
    .content-area { padding: 14px; }
    .card { border-radius: var(--r-md); }
    .card-header { padding: 14px; align-items: flex-start; flex-direction: column; }
    .card-header > .btn, .card-header > a.btn { width: 100%; }
    .card-header > .btn-card-action { width: auto; align-self: flex-start; }
    .card-body { padding: 14px; }
    .stat-card { padding: 15px; }
    .stat-card .sc-value { font-size: 20px; }
    .acct-balance { font-size: 19px; overflow-wrap: anywhere; }
    .account-card:hover { transform: none; }
    .page-actions { margin-bottom: 14px; gap: 12px; }
    .page-actions > div, .page-actions > .btn, .page-actions > button { width: 100%; }
    .page-actions .btn, .page-actions button { justify-content: center; }
    .page-actions h2 { font-size: 19px; }
    .filter-bar { padding: 12px; }
    .filter-bar form, .card-header form { gap: 8px !important; }
    .filter-bar .form-control, .filter-bar .form-select, .filter-bar select,
    .card-header .form-select, .card-header form, .card-header form select, .card-header form .btn {
        width: 100% !important; max-width: none !important; min-width: 0 !important;
    }
    .filter-bar .btn, .card-header .btn { min-height: 36px; }
    .filter-bar .ms-auto, .card-header .ms-auto { margin-left: 0 !important; }
    .table-responsive { border-radius: 0 0 var(--r-md) var(--r-md); overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table { min-width: 720px; }
    .table thead th { padding: 10px 12px; font-size: 10px; }
    .table tbody td { padding: 11px 12px; font-size: 13px; }
    .report-chart { height: 220px; }
    .report-table th, .report-table td { padding: 7px 5px; font-size: 11px; }
    .report-table thead th { font-size: 9px; padding: 7px 5px; }
    .report-table .amount-neutral, .report-table .amount-pos, .report-table .amount-neg { font-size: 10.5px; }
    .report-table .badge { white-space: normal; }
    .btn-act { width: 34px; height: 34px; }
    .modal-dialog { margin: 10px; }
    .modal-content { max-height: calc(100vh - 20px); }
    .modal-body { padding: 16px; overflow-y: auto; }
    .modal-footer { padding: 12px 16px; flex-wrap: nowrap; }
    .toast-area { left: 12px; right: 12px; top: 66px; min-width: 0; }
    .toast-area .alert { min-width: 0 !important; width: 100%; }
    .cmdk-overlay { padding: 10vh 14px 0; }
    .user-meta { display: none; }
}

@media (max-width: 576px) {
    .content-area { padding: 12px; }
    .report-chart { height: 200px; }
    .report-optional-sm { display: none; }
    .row.g-3 { --bs-gutter-x: .75rem; --bs-gutter-y: .75rem; }
    .stat-card { padding: 14px; }
    .stat-card .sc-value { font-size: 18px; }
    .stat-card .sc-sub { font-size: 10px; }
    .empty-state { padding: 34px 14px; }
    .login-card-body { padding: 24px; }
    .login-card-top { padding: 26px 24px 6px; }
}

@media (max-width: 400px) {
    .stat-card .sc-value { font-size: 17px; }
    .modal-footer { flex-direction: column-reverse; align-items: stretch; }
    .modal-footer .btn { width: 100%; }
}

/* ================================================================
   COMPATIBILIDAD BOOTSTRAP → tokens (coherencia en tema oscuro)
   ================================================================ */
.bg-light, .bg-white, .bg-body, .bg-body-tertiary { background-color: var(--bg-subtle) !important; color: var(--text-primary); }
.input-group-text {
    background: var(--bg-subtle);
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
}
.input-group .form-control { border-color: var(--border-strong); }
.table-light, .table-light > th, .table-light > td { background: var(--bg-subtle) !important; color: var(--text-primary) !important; }
.list-group { border-radius: var(--r-md); }
.list-group-item {
    background: var(--bg-surface);
    border-color: var(--border);
    color: var(--text-primary);
}
.list-group-item.active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.dropdown-menu {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-pop);
    padding: 6px;
}
.dropdown-item { border-radius: var(--r-sm); color: var(--text-primary); font-size: 13.5px; padding: 7px 10px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-divider { border-color: var(--border); }
.nav-tabs { border-bottom: 1px solid var(--border); gap: 2px; }
.nav-tabs .nav-link {
    color: var(--text-secondary); border: none; border-bottom: 2px solid transparent;
    border-radius: 0; font-size: 13.5px; font-weight: 500; padding: 9px 14px;
    transition: color var(--t-fast), border-color var(--t-fast);
}
.nav-tabs .nav-link:hover { color: var(--text-primary); border-color: transparent; }
.nav-tabs .nav-link.active { color: var(--accent); background: transparent; border-bottom-color: var(--accent); }
.nav-pills .nav-link.active { background: var(--accent); }
.pagination { --bs-pagination-color: var(--text-secondary); gap: 4px; }
.page-link {
    color: var(--text-secondary); background: var(--bg-surface);
    border: 1px solid var(--border); border-radius: var(--r-sm) !important; font-size: 13px;
}
.page-link:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.progress { background: var(--bg-active); border-radius: 20px; }
.progress-bar { background: var(--accent); }
hr { border-color: var(--border); opacity: 1; }
.border, .border-top, .border-bottom, .border-start, .border-end { border-color: var(--border) !important; }
.text-bg-light { background: var(--bg-subtle) !important; color: var(--text-primary) !important; }
.tooltip-inner { background: var(--text-primary); color: var(--bg-surface); border-radius: var(--r-sm); font-size: 12px; }
.popover { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-pop); }
.popover-body { color: var(--text-primary); }
.accordion-item { background: var(--bg-surface); border-color: var(--border); }
.accordion-button { background: var(--bg-surface); color: var(--text-primary); }
.accordion-button:not(.collapsed) { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.accordion-button:focus { box-shadow: 0 0 0 3px var(--accent-ring); border-color: var(--accent); }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
