/* =============================================================================
   WebCórdoba · Cuentas — Hoja de estilos
   Paleta corporativa (manual de marca): #744293, #1D1D1B, #FFFFFF
   Acentos logo footer: #EDAB32, #6CBA78, #70C7D6, #724997
   ============================================================================= */

/* --- Variables de tema (tokens de marca) --- */
:root {
    --theme-font: "Acumin Variable", "Poppins", sans-serif;
    --theme-font-two: "Gotham", "Open Sans", sans-serif;
    --theme-gray: #808080;
    --theme-gray-rgb: 128, 128, 128;
    --theme-white: #ffffff;
    --theme-white-rgb: 255, 255, 255;
    --theme-base: #744293;
    --theme-base-rgb: 116, 66, 147;
    --theme-black: #1D1D1B;
    --theme-black-rgb: 29, 29, 27;
    --theme-primary: #EDAB32;
    --theme-primary-rgb: 237, 171, 50;
    --theme-secundary: #724997;
    --theme-secundary-rgb: 114, 73, 151;
    --theme-accent-green: #6CBA78;
    --theme-accent-green-rgb: 108, 186, 120;
    --theme-accent-cyan: #70C7D6;
    --theme-accent-cyan-rgb: 112, 199, 214;
    --theme-bdr-color: #e0dcd3;

    --bg: #f4f1f8;
    --surface: #ffffff;
    --surface-2: #f8f6fb;
    --text: #1D1D1B;
    --text-muted: #6b6770;
    --border: #e0dcd3;
    --primary: #744293;
    --primary-strong: #63398a;
    --primary-soft: rgba(116, 66, 147, 0.12);
    --accent: #EDAB32;
    --success: #6CBA78;
    --success-soft: rgba(108, 186, 120, 0.14);
    --info: #70C7D6;
    --info-soft: rgba(112, 199, 214, 0.14);
    --danger: #c0392b;
    --danger-soft: rgba(192, 57, 43, 0.12);
    --warning: #EDAB32;
    --warning-soft: rgba(237, 171, 50, 0.16);
    --shadow: 0 2px 10px rgba(29, 29, 27, 0.06);
    --radius: 12px;
}

[data-theme="dark"] {
    --bg: #141318;
    --surface: #1D1D1B;
    --surface-2: #26242b;
    --text: #f2f0f5;
    --text-muted: #a9a4b2;
    --border: #3a3744;
    --primary: #8f63b8;
    --primary-strong: #a47cc7;
    --primary-soft: rgba(143, 99, 184, 0.22);
    --success-soft: rgba(108, 186, 120, 0.18);
    --info-soft: rgba(112, 199, 214, 0.18);
    --danger-soft: rgba(231, 76, 60, 0.18);
    --warning-soft: rgba(237, 171, 50, 0.2);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: dark) {
    [data-theme="auto"] {
        --bg: #141318;
        --surface: #1D1D1B;
        --surface-2: #26242b;
        --text: #f2f0f5;
        --text-muted: #a9a4b2;
        --border: #3a3744;
        --primary: #8f63b8;
        --primary-strong: #a47cc7;
        --primary-soft: rgba(143, 99, 184, 0.22);
        --success-soft: rgba(108, 186, 120, 0.18);
        --info-soft: rgba(112, 199, 214, 0.18);
        --danger-soft: rgba(231, 76, 60, 0.18);
        --warning-soft: rgba(237, 171, 50, 0.2);
        --shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
    }
}

/* --- Base --- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--theme-font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--primary); }
img { max-width: 100%; }

.sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: 1rem; top: -3rem; z-index: 1000;
    background: var(--primary); color: #fff; padding: .6rem 1rem;
    border-radius: 8px; transition: top .2s ease; text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* --- Cabecera --- */
.app-header {
    position: sticky; top: 0; z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.app-header__inner {
    max-width: 1280px; margin: 0 auto; padding: .65rem 1.25rem;
    display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
}
.app-header__brand { display: inline-flex; align-items: center; text-decoration: none; }
.app-header__logo { height: 34px; width: auto; display: block; }

.app-nav__toggle {
    display: none; background: none; border: 1px solid var(--border);
    border-radius: 8px; padding: .4rem .5rem; cursor: pointer; margin-left: auto;
}
.app-nav__toggle-bar { display: block; width: 18px; height: 2px; background: var(--text); margin: 3px 0; border-radius: 2px; }

.app-nav__list { list-style: none; display: flex; gap: .25rem; margin: 0; padding: 0; flex-wrap: wrap; }
.app-nav__link {
    display: inline-block; padding: .5rem .8rem; border-radius: 8px;
    color: var(--text-muted); text-decoration: none; font-weight: 600; font-size: .92rem;
    transition: background .15s ease, color .15s ease;
}
.app-nav__link:hover, .app-nav__link.is-active { background: var(--primary-soft); color: var(--primary); }

.app-header__actions { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.app-header__user { font-weight: 600; font-size: .9rem; color: var(--text-muted); }

.theme-toggle {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
    width: 38px; height: 38px; cursor: pointer; font-size: 1.05rem; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { border-color: var(--primary); }

/* --- Principal --- */
.app-main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem 2.5rem; }
.app-footer {
    border-top: 1px solid var(--border); background: var(--surface);
    color: var(--text-muted); font-size: .82rem; text-align: center; padding: 1rem;
}
.app-footer p { margin: 0; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head__title { font-family: var(--theme-font-two); font-weight: 700; font-size: 1.65rem; margin: 0; color: var(--primary); }
.page-head__sub { margin: .2rem 0 0; color: var(--text-muted); }

/* --- Botones --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    border: 1px solid transparent; border-radius: 9px; cursor: pointer;
    padding: .55rem 1.1rem; font-family: inherit; font-size: .92rem; font-weight: 600;
    text-decoration: none; color: var(--text); background: var(--surface-2);
    border-color: var(--border); transition: filter .15s ease, background .15s ease, transform .1s ease;
}
.btn:hover { filter: brightness(.96); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); filter: none; }
.btn--ghost { background: transparent; }
.btn--danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn--mini { padding: .3rem .6rem; font-size: .8rem; border-radius: 7px; }
.btn--block { width: 100%; }
.btn--sm { padding: .4rem .8rem; font-size: .85rem; }

/* --- Tarjetas KPI --- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem 1.1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .3rem;
    animation: fadeIn .35s ease both;
}
.kpi__label { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
.kpi__value { font-family: var(--theme-font-two); font-size: 1.5rem; font-weight: 700; }
.kpi__value--pos { color: var(--success); }
.kpi__value--neg { color: var(--danger); }
.kpi__delta { font-size: .8rem; color: var(--text-muted); }
.kpi__delta.is-up { color: var(--success); }
.kpi__delta.is-down { color: var(--danger); }

/* --- Cards / grid --- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem;
    animation: fadeIn .35s ease both;
}
.card__title { font-family: var(--theme-font-two); font-size: 1.1rem; font-weight: 700; margin: 0 0 1rem; }
.card__title--mt { margin-top: 1.5rem; }
.grid { display: grid; gap: 1.25rem; }
.grid--2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 980px) { .grid--2 { grid-template-columns: 1fr; } }

/* --- Tablas --- */
.table-scroll { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla th, .tabla td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--border); }
.tabla thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); background: var(--surface-2); }
.tabla tbody tr:hover { background: var(--surface-2); }
.tabla tfoot { font-weight: 700; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla .strong { font-weight: 600; }
.tabla tr.is-selected { background: var(--primary-soft); }
.acciones { white-space: nowrap; }
.inline { display: inline; }
.empty { text-align: center; color: var(--text-muted); padding: 1.5rem 0; margin: 0; }

/* --- Badges / tags --- */
.badge {
    display: inline-block; padding: .15rem .55rem; border-radius: 999px;
    font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--text-muted);
    border: 1px solid var(--border);
}
.badge--cobrado, .badge--pagado { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge--previsto, .badge--pendiente, .badge--emitido, .badge--recibido { background: var(--warning-soft); color: #b98a13; border-color: transparent; }
.badge--cancelado { opacity: .55; }
.tag {
    display: inline-block; padding: .1rem .5rem; border-radius: 6px; font-size: .75rem;
    background: var(--primary-soft); color: var(--primary); font-weight: 600;
}
.tag--muted { background: var(--surface-2); color: var(--text-muted); }
.sel-mini { padding: .3rem .4rem; font-size: .8rem; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); }
.tabla tr.is-dup { opacity: .55; }

/* --- Filtros --- */
.filtros { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1.25rem; }

/* --- Formularios --- */
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field__label { font-size: .82rem; font-weight: 600; color: var(--text-muted); }
.field input, .field select {
    font-family: inherit; font-size: .95rem; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
    padding: .55rem .7rem; min-width: 0;
}
.field input:focus, .field select:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
.field--check { flex-direction: row; align-items: center; gap: .5rem; }
.field--check input { width: auto; }
.field--full { grid-column: 1 / -1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.note { font-size: .82rem; color: var(--text-muted); font-style: italic; margin-top: .75rem; }

/* --- Resumen (dl) --- */
.resumen { margin: 0; }
.resumen__row { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px dashed var(--border); }
.resumen__row dt { color: var(--text-muted); }
.resumen__row dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.resumen__row dd.pos { color: var(--success); }
.resumen__row dd.neg { color: var(--danger); }
.resumen__row--total { border-bottom: none; font-size: 1.1rem; }
.resumen__row--total dt { color: var(--text); font-weight: 700; }
.resumen__row--total dd { color: var(--primary); }

/* --- Alertas --- */
.alert {
    padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem;
    font-size: .92rem; border: 1px solid transparent; animation: fadeIn .3s ease both;
}
.alert--success { background: var(--success-soft); color: var(--success); }
.alert--error { background: var(--danger-soft); color: var(--danger); }
.alert--warning { background: var(--warning-soft); color: #b98a13; }

/* --- Modales (dialog) --- */.modal {
    border: none; border-radius: 14px; padding: 0; width: min(640px, 92vw);
    background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.modal::backdrop { background: rgba(20, 19, 24, .55); }
.modal__body { padding: 1.5rem; }
.modal__title { font-family: var(--theme-font-two); font-size: 1.2rem; margin: 0 0 1rem; color: var(--primary); }
.modal__actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.25rem; }

/* --- Tabs --- */
.tabs { display: flex; gap: .5rem; margin-bottom: 1.25rem; border-bottom: 2px solid var(--border); }
.tabs__tab {
    padding: .6rem 1.2rem; text-decoration: none; color: var(--text-muted); font-weight: 600;
    border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tabs__tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }

/* --- Login --- */
.auth-body { align-items: center; justify-content: center; display: flex; }
.auth-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: var(--shadow); padding: 2rem; width: min(400px, 100%);
    animation: fadeIn .4s ease both;
}
.auth-card__logo { height: 40px; margin-bottom: 1.25rem; display: block; }
.auth-card__title { font-family: var(--theme-font-two); color: var(--primary); margin: 0 0 .25rem; font-size: 1.4rem; }
.auth-card__sub { color: var(--text-muted); margin: 0 0 1.25rem; font-size: .9rem; }
.auth-card__form { display: flex; flex-direction: column; gap: .9rem; }
.auth-card__actions { margin-top: 1rem; display: flex; justify-content: flex-end; }

/* --- Gráficos --- */
canvas { width: 100%; }

/* --- Animaciones --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* --- Impresión / PDF --- */
@media print {
    .app-header, .app-footer, .filtros, .page-head__actions, .acciones, .theme-toggle, .btn, .tabs, .empty { display: none !important; }
    body { background: #fff; color: #000; }
    .app-main { max-width: none; padding: 0; }
    .card { box-shadow: none; border: none; padding: 0; }
    .tabla th, .tabla td { border-color: #ccc; }
    a { color: #000; text-decoration: none; }
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .app-nav__toggle { display: block; }
    .app-nav { order: 3; width: 100%; display: none; }
    .app-nav.is-open { display: block; }
    .app-nav__list { flex-direction: column; }
    .app-header__actions { margin-left: auto; }
    .app-header__user { display: none; }
}
