/* ============================================================
   base.css — Reset, tokens de tema, tipografía y utilidades
   Piel "Terra" (diseños de Stitch en .design/stitch_erp_financiero_colombiano):
   verde bosque, crema cálido, ámbar y terracota; esquinas de 12 px
   y sombras muy suaves. La tipografía se pide a Google Fonts desde
   index.html; sin red, la pila del sistema la sustituye sin romper nada.
   ============================================================ */

:root {
    color-scheme: light;

    --font-sans: "Nunito Sans", "Segoe UI Variable Text", "Segoe UI", system-ui,
                 -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Literata", Georgia, "Times New Roman", serif;
    --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, "SF Mono", monospace;

    /* Superficies: crema cálido en capas, nunca blanco clínico de fondo */
    --bg: #faf6f0;
    --bg-accent: none;
    --surface: #ffffff;
    --surface-2: #f5f1ea;
    --surface-glass: rgba(255, 255, 255, 0.86);
    --border: #e4e0d8;
    --border-strong: #d4ccbf;

    /* Texto: grises con matiz cálido */
    --text: #2e3230;
    --text-muted: #5a615a;
    --text-soft: #6b6358;
    --text-invert: #ffffff;

    /* Marca */
    --primary: #4a7c59;
    --primary-hover: #3d6649;
    --primary-soft: #e1ede4;
    --on-primary: #ffffff;       /* texto sobre el color primario */
    --accent: #e1ede4;           /* realce suave: acciones cortas y selección */
    --accent-hover: #c8e8d0;
    --accent-ink: #1b4d2e;       /* texto legible sobre el realce */
    --night: #3d6649;            /* tarjeta destacada de marca */
    --night-2: #4a7c59;

    /* Estados */
    --success: #2a6038;
    --success-soft: #e1ede4;
    --danger: #a8402f;
    --danger-solid: #c05646;
    --danger-soft: #fbeae7;
    --warning: #7a5410;
    --warning-soft: #fef3c7;
    --info: #3f6674;
    --info-soft: #e6eff1;

    /* Series de gráficos: tierra y bosque, legibles sobre crema y blanco.
       c1 = ingresos y marca, c2 = favorable, c6 = costos y desfavorable. */
    --c1: #4a7c59;
    --c2: #5e9470;
    --c3: #c49a3c;
    --c4: #8a6d3b;
    --c5: #5f8290;
    --c6: #c05646;
    --c7: #9aa095;
    --c8: #d97706;

    /* Formas */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 12px;
    --r-xl: 16px;
    --r-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(46, 50, 48, 0.05);
    --shadow-md: 0 4px 20px rgba(46, 50, 48, 0.06);
    --shadow-lg: 0 18px 48px rgba(46, 50, 48, 0.12);
    --shadow-primary: 0 4px 14px rgba(74, 124, 89, 0.24);

    /* Espaciado consistente */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;
    --sp-7: 48px;

    --sidebar-w: 262px;
    --sidebar-w-collapsed: 76px;
    --topbar-h: 72px;
}

[data-theme="dark"] {
    color-scheme: dark;

    --bg: #151816;
    --bg-accent: none;
    --surface: #1e2220;
    --surface-2: #252a27;
    --surface-glass: rgba(30, 34, 32, 0.86);
    --border: #313833;
    --border-strong: #414a44;

    --text: #eceae4;
    --text-muted: #bcc2b8;
    --text-soft: #a3a99e;

    --primary: #8ecf9e;
    --primary-hover: #a8dcb4;
    --primary-soft: #243529;
    --on-primary: #0f2417;
    --accent: #2a4031;
    --accent-hover: #335040;
    --accent-ink: #c8e8d0;
    --night: #1b4d2e;
    --night-2: #2a6038;

    --success: #8ecf9e;
    --success-soft: #1f3326;
    --danger: #f0a393;
    --danger-solid: #c05646;
    --danger-soft: #3a231f;
    --warning: #e8c67e;
    --warning-soft: #3a2f1a;
    --info: #9cc3cf;
    --info-soft: #1d2d31;

    --c1: #8ecf9e;
    --c2: #6fb383;
    --c3: #dcc48e;
    --c4: #c4a66a;
    --c5: #8fb5c2;
    --c6: #e08a7a;
    --c7: #9aa095;
    --c8: #f0a55a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 54px rgba(0, 0, 0, 0.55);
    --shadow-primary: 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* ---------- Reset ---------- */

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

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    background-image: var(--bg-accent);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, p, figure {
    margin: 0;
}

h1, h2, h3 {
    font-family: var(--font-display);
    letter-spacing: -0.01em;
}

h1 { font-size: 1.72rem; line-height: 1.15; font-weight: 700; }
h2 { font-size: 1.06rem; line-height: 1.3; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
h4 { font-size: 0.9rem; font-weight: 700; }

ul, ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

img, svg {
    max-width: 100%;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

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

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Foco visible y consistente en toda la aplicación (accesibilidad) */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}

/* ---------- Utilidades ---------- */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.is-hidden { display: none !important; }

.text-muted { color: var(--text-muted); }
.text-soft { color: var(--text-soft); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.strong { font-weight: 700; }

.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.row-wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.grow { flex: 1 1 auto; min-width: 0; }

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