/* =============================================================================
   Control Financiero - sistema de diseño
   Paleta: fondo neutro con sesgo frio, acento indigo, verde/rojo semanticos
   Tipografia: Manrope (titulares) + Inter (interfaz) + JetBrains Mono (cifras)
   ============================================================================= */

:root {
    --ink: #0f1729;
    --ink-soft: #384259;
    --muted: #64708a;
    --paper: #f5f6fb;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --border: #e3e6f0;
    --border-soft: #edeff6;

    --accent: #4338ca;
    --accent-strong: #372aa8;
    --accent-soft: #eeecfd;
    --accent-contrast: #ffffff;

    --income: #16a34a;
    --income-soft: #e8f8ee;
    --expense: #dc2626;
    --expense-soft: #fdeaea;
    --warning: #b45309;
    --warning-soft: #fef3e2;

    --shadow-sm: 0 1px 2px rgba(15, 23, 41, 0.06);
    --shadow-md: 0 6px 20px rgba(15, 23, 41, 0.08);
    --shadow-lg: 0 20px 45px rgba(15, 23, 41, 0.14);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;

    --font-display: 'Manrope', 'Segoe UI', sans-serif;
    --font-body: 'Inter', 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ink: #e9ebf7;
        --ink-soft: #c3c8dc;
        --muted: #8b93ad;
        --paper: #0b0e1a;
        --surface: #131728;
        --surface-raised: #171c31;
        --border: #262c46;
        --border-soft: #1c2138;

        --accent: #8385f2;
        --accent-strong: #9fa1f7;
        --accent-soft: #201f45;
        --accent-contrast: #0b0e1a;

        --income: #4ade80;
        --income-soft: #123423;
        --expense: #f87171;
        --expense-soft: #3a1a1c;
        --warning: #fbbf6a;
        --warning-soft: #3a2c12;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
        --shadow-lg: 0 25px 60px rgba(0, 0, 0, 0.55);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --ink: #e9ebf7;
    --ink-soft: #c3c8dc;
    --muted: #8b93ad;
    --paper: #0b0e1a;
    --surface: #131728;
    --surface-raised: #171c31;
    --border: #262c46;
    --border-soft: #1c2138;

    --accent: #8385f2;
    --accent-strong: #9fa1f7;
    --accent-soft: #201f45;
    --accent-contrast: #0b0e1a;

    --income: #4ade80;
    --income-soft: #123423;
    --expense: #f87171;
    --expense-soft: #3a1a1c;
    --warning: #fbbf6a;
    --warning-soft: #3a2c12;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 25px 60px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
}

* { box-sizing: border-box; }
/* Que el atributo hidden gane siempre a reglas como display:flex de una clase */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    margin: 0;
    text-wrap: balance;
    letter-spacing: -0.01em;
}
p { margin: 0; }
a { color: var(--accent); }
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent-soft); }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 236px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 22px;
}
.sidebar-brand .mark {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 15px;
    flex-shrink: 0;
}
.sidebar-brand .name { font-family: var(--font-display); font-weight: 800; font-size: 15px; line-height: 1.2; }
.sidebar-brand .sub { font-size: 11.5px; color: var(--muted); }

.nav-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 10px 12px 4px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--ink-soft); text-decoration: none; font-size: 13.5px; font-weight: 600;
    border: 1px solid transparent;
}
.nav-link:hover { background: var(--border-soft); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav-link .icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link .badge-count {
    margin-left: auto; font-size: 11px; background: var(--accent); color: #fff;
    border-radius: 20px; padding: 1px 7px; font-weight: 700;
}

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.sync-indicator { font-size: 11.5px; color: var(--muted); padding: 8px 12px; display: flex; align-items: center; gap: 6px; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--income); flex-shrink: 0; }
.sync-dot.stale { background: var(--muted); }
.sync-dot.pulsing { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

.user-chip {
    display: flex; align-items: center; gap: 9px;
    padding: 8px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--paper);
}
.avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong);
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12.5px; flex-shrink: 0;
}
.user-chip .who { flex: 1; min-width: 0; }
.user-chip .who .name { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who .role { font-size: 11px; color: var(--muted); }
.icon-btn {
    border: none; background: transparent; color: var(--muted); border-radius: 8px; padding: 6px;
    display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--border-soft); color: var(--ink); }

.main {
    flex: 1; min-width: 0; display: flex; flex-direction: column;
}
.topbar {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 28px; border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(8px);
    position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; }
.topbar .spacer { flex: 1; }
.mobile-menu-btn { display: none; }

.period-select {
    border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
    padding: 8px 12px; font-weight: 600; font-size: 13px; color: var(--ink-soft);
}

.content { padding: 24px 28px 60px; max-width: 1320px; width: 100%; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font-weight: 700; font-size: 13.5px; transition: transform .05s ease, background .15s ease;
    white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-income { background: var(--income); color: #fff; }
.btn-expense { background: var(--expense); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { background: var(--border-soft); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--border-soft); }
.btn-danger { background: var(--expense-soft); color: var(--expense); }
.btn-danger:hover { background: var(--expense); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.fab-row { display: flex; gap: 10px; }

/* ---------- Cards / KPIs ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm); min-width: 0;
}
.card-pad { padding: 20px; }
.card-title { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.hero-balance {
    background: linear-gradient(160deg, var(--accent-strong), var(--accent) 60%, #6d28d9);
    color: #fff; border-radius: var(--radius-lg); padding: 32px 36px;
    box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
    margin-bottom: 20px;
}
.hero-balance::after {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(600px 200px at 85% -10%, rgba(255,255,255,0.25), transparent);
}
.hero-balance .label { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; position: relative; }
.hero-balance .value {
    font-family: var(--font-mono); font-weight: 700; font-size: clamp(38px, 6vw, 64px);
    margin: 6px 0 14px; position: relative; letter-spacing: -0.02em;
}
.hero-balance .sub-row { display: flex; gap: 26px; flex-wrap: wrap; position: relative; }
.hero-balance .sub-row .item { display: flex; flex-direction: column; gap: 2px; }
.hero-balance .sub-row .item .k { font-size: 11.5px; opacity: 0.75; font-weight: 600; }
.hero-balance .sub-row .item .v { font-family: var(--font-mono); font-weight: 700; font-size: 17px; }

.kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px;
    margin-bottom: 20px;
}
.kpi-card { padding: 16px 18px; }
.kpi-card .icon-wrap {
    width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
    margin-bottom: 10px;
}
.kpi-card .value { font-family: var(--font-mono); font-size: 22px; font-weight: 700; margin-top: 4px; }
.kpi-card .value.income { color: var(--income); }
.kpi-card .value.expense { color: var(--expense); }
.kpi-card .delta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.charts-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 16px; }
.charts-grid.two-col { grid-template-columns: 1fr 1fr; }
.chart-card { padding: 18px 20px; min-width: 0; }
.chart-card h3 { font-size: 14.5px; margin-bottom: 14px; }
.chart-card .chart-holder { position: relative; height: 260px; min-width: 0; min-height: 0; overflow: hidden; }
.chart-card .chart-holder.short { height: 200px; }
.chart-card .chart-holder canvas { max-width: 100%; }
.empty-chart { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: 13px; text-align: center; padding: 0 20px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13.3px; min-width: 720px; }
thead th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
    padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--border-soft);
    position: sticky; top: 0;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--ink); }
thead th .sort-arrow { opacity: 0.5; margin-left: 3px; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--border-soft); }
.amount-cell { font-family: var(--font-mono); font-weight: 700; white-space: nowrap; }
.amount-cell.income { color: var(--income); }
.amount-cell.expense { color: var(--expense); }
.cell-muted { color: var(--muted); }
.cell-truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.table-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.table-toolbar .spacer { flex: 1; }
.search-input {
    display: flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface);
    border-radius: var(--radius-sm); padding: 8px 12px; min-width: 220px;
}
.search-input input { border: none; outline: none; background: transparent; width: 100%; }
.search-input svg { color: var(--muted); flex-shrink: 0; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.select-field, .input-field {
    border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
    padding: 8px 11px; font-size: 12.8px; color: var(--ink-soft);
}

.pagination { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 14px; font-size: 12.8px; color: var(--muted); }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge-income { background: var(--income-soft); color: var(--income); }
.badge-expense { background: var(--expense-soft); color: var(--expense); }
.badge-neutral { background: var(--border-soft); color: var(--ink-soft); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.field .hint { font-size: 11.5px; color: var(--muted); }
.field input[type="text"], .field input[type="number"], .field input[type="date"],
.field input[type="password"], .field textarea, .field select {
    border: 1px solid var(--border); background: var(--paper); border-radius: var(--radius-sm);
    padding: 10px 12px; width: 100%; outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); background: var(--surface); }
.field textarea { resize: vertical; min-height: 64px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-error { color: var(--expense); font-size: 11.5px; }
.required-mark { color: var(--expense); }

/* Sin flechitas en los campos numericos: se cambiaba el valor sin querer */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.amount-input-wrap { position: relative; }
.amount-input-wrap input { padding-right: 40px; font-family: var(--font-mono); font-weight: 700; font-size: 16px; }
.amount-input-wrap .suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; }

.file-drop {
    border: 1.5px dashed var(--border); border-radius: var(--radius-sm); padding: 16px; text-align: center;
    color: var(--muted); font-size: 12.5px; cursor: pointer;
}
.file-drop:hover { border-color: var(--accent); color: var(--accent); }
.file-chip { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--border-soft); border-radius: 8px; font-size: 12.5px; margin-top: 8px; }
.file-chip button { border: none; background: none; color: var(--muted); margin-left: auto; }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(10, 12, 22, 0.55); backdrop-filter: blur(2px);
    display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 100; overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }
.modal {
    background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    width: 100%; max-width: 560px; border: 1px solid var(--border);
}
.modal.modal-lg { max-width: 760px; }
.modal-header { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 16.5px; flex: 1; }
.modal-body { padding: 22px; max-height: 72vh; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.detail-grid .full { grid-column: 1 / -1; }
.detail-item .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 3px; }
.detail-item .v { font-size: 13.5px; font-weight: 600; }
.detail-item .v.amount { font-family: var(--font-mono); font-size: 17px; }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; max-width: 340px; }
.toast {
    background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 10px;
    animation: toast-in .18s ease;
}
.toast.success { background: #0f3d24; color: #d5f9e3; }
.toast.error { background: #4a1414; color: #ffd9d9; }
.toast.info { background: var(--ink); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Misc ---------- */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-header h2 { font-size: 20px; }
.page-header .desc { color: var(--muted); font-size: 13px; margin-top: 3px; }
.section-block { margin-bottom: 28px; }
.two-col-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state svg { margin-bottom: 10px; opacity: 0.5; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: none; }
.skeleton { background: linear-gradient(90deg, var(--border-soft) 25%, var(--border) 37%, var(--border-soft) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.partner-card { padding: 18px; }
.partner-card .name-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.partner-card .stat-line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border-soft); font-size: 13px; }
.partner-card .stat-line:last-child { border-bottom: none; }
.partner-card .stat-line .amt { font-family: var(--font-mono); font-weight: 700; }
.partner-card .balance-line { margin-top: 10px; padding-top: 12px; border-top: 1.5px solid var(--border); display: flex; justify-content: space-between; align-items: baseline; }
.partner-card .balance-line .amt { font-size: 19px; }

.activity-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.activity-item:last-child { border-bottom: none; }
.activity-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex-shrink: 0; }
.activity-item .text { font-size: 13.3px; }
.activity-item .time { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.password-gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 12.8px; }

.bar-track { height: 6px; background: var(--border-soft); border-radius: 4px; overflow: hidden; }
.bar-track > div { height: 100%; background: var(--accent); }

/* ---------- Inventario ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.product-grid .empty-state { grid-column: 1 / -1; }
.product-card {
    padding: 0; overflow: hidden; text-align: left; font: inherit; color: inherit; width: 100%;
    transition: border-color .15s ease, transform .15s ease;
}
.product-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.product-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.product-card.out-of-stock { opacity: 0.6; }
.product-photo {
    aspect-ratio: 4 / 3; background: var(--border-soft); color: var(--muted);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.product-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-body { padding: 12px 14px 14px; }
.product-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; overflow-wrap: anywhere; }
.product-stock { font-size: 13px; }
.product-meta { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

.product-detail-top { display: grid; grid-template-columns: 220px 1fr; gap: 18px; margin-bottom: 18px; align-items: start; }
.product-detail-photo { border-radius: var(--radius-md); }
.product-detail-photo a { display: block; width: 100%; height: 100%; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat-tile { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat-tile .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.stat-tile .v { font-family: var(--font-mono); font-weight: 700; font-size: 14.5px; margin-top: 4px; }
.flow-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.flow-grid div { display: flex; flex-direction: column; font-size: 11.5px; color: var(--muted); }
.flow-grid strong { font-family: var(--font-mono); font-size: 13.5px; color: var(--ink); }
.flow-grid strong.income { color: var(--income); }
.flow-grid strong.expense { color: var(--expense); }
.stat-group { margin-bottom: 14px; }
.stat-group-title { font-size: 11.5px; font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.detail-section-title { font-size: 14.5px; margin: 22px 0 10px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.segmented button { border: none; background: none; padding: 7px 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.segmented button.active { background: var(--accent-soft); color: var(--accent); }
.photo-preview img { max-width: 100%; max-height: 180px; border-radius: var(--radius-sm); display: block; }

.negative { color: var(--expense); }

/* Pregunta inicial "¿es de inventario?" al añadir ingreso/gasto */
.choice-question { font-family: var(--font-display); font-size: 17px; font-weight: 700; text-align: center; margin: 4px 0 18px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice-card {
    border: 1.5px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--ink);
    padding: 24px 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
    transition: border-color .15s ease, background .15s ease;
}
.choice-card svg { color: var(--accent); }
.choice-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.choice-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice-title { font-weight: 700; font-size: 15px; }
.choice-desc { font-size: 12.5px; color: var(--muted); }
.mode-row { font-size: 12.5px; font-weight: 700; color: var(--accent); padding: 2px 4px 2px 12px; margin-bottom: 14px; }

/* Paquetes en camino */
.pending-card { margin-bottom: 20px; border-color: var(--warning); }
.pending-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-bottom: 10px; border-bottom: 1px solid var(--border-soft); }
.pending-row:last-child { border-bottom: none; padding-bottom: 0; }
.pending-text { color: var(--warning); }
.reservations-card { margin-bottom: 20px; border-color: var(--accent); }
.reserved-text { color: var(--accent); font-weight: 600; }
.delivery-question { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.delivery-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.delivery-option {
    display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface); cursor: pointer;
}
.delivery-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* Lineas de productos dentro del formulario de ingreso/gasto */
.items-section { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 14px; background: var(--paper); }
.items-title { font-weight: 700; font-size: 13.5px; }
.items-hint { font-size: 12px; color: var(--muted); margin: 8px 0 10px; }
.item-line { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; display: grid; gap: 8px; background: var(--surface); }
.il-head { display: flex; gap: 6px; }
.il-new { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.il-new .il-new-name { flex: 1; min-width: 160px; }
.il-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.il-nums label { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); display: flex; flex-direction: column; gap: 4px; }
.item-line select, .item-line input[type="text"], .item-line input[type="number"] {
    border: 1px solid var(--border); background: var(--paper); border-radius: var(--radius-sm);
    padding: 8px 10px; width: 100%; outline: none; min-width: 0;
}
.item-line select:focus, .item-line input:focus { border-color: var(--accent); background: var(--surface); }
.field input[readonly] { opacity: 0.75; cursor: not-allowed; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
    .charts-grid, .charts-grid.two-col, .two-col-layout { grid-template-columns: 1fr; }
    .content { padding: 18px 16px 90px; }
    .topbar { padding: 14px 16px; }
}

@media (max-width: 760px) {
    .sidebar {
        position: fixed; left: 0; bottom: 0; top: auto; width: 100%; height: auto;
        flex-direction: row; align-items: center; justify-content: flex-start;
        padding: 8px 6px; z-index: 50; border-right: none; border-top: 1px solid var(--border);
        overflow-x: auto;
    }
    .sidebar-brand, .sidebar-footer, .nav-label { display: none; }
    .nav-group { flex-direction: row; margin-bottom: 0; gap: 2px; }
    .nav-link { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 8px; }
    .nav-link .icon { width: 20px; height: 20px; }
    .main { padding-bottom: 64px; }
    .field-row { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
    .product-detail-top { grid-template-columns: 1fr; }
    .choice-grid, .delivery-options { grid-template-columns: 1fr; }
    table { min-width: 620px; }
    .hero-balance { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
