/* SDIG 5.2 — identidad editorial, componentes y temas. Sin dependencias de build. */
:root {
    --ink: #192d29;
    --muted: #637670;
    --paper: #f3f5f1;
    --surface: #ffffff;
    --surface-muted: #f6f8f5;
    --surface-lifted: #ffffff;
    --line: #dce5df;
    --field-line: #cad8d0;
    --field-hover: #8aaca0;
    --primary: #176754;
    --primary-deep: #103e35;
    --primary-soft: #e5f1ea;
    --on-primary: #ffffff;
    --accent: #bb865b;
    --accent-soft: #fcf5eb;
    --danger: #a53e3b;
    --danger-soft: #fff0ed;
    --danger-border: #e7b9b1;
    --success-soft: #e7f4eb;
    --success-border: #b4d9c2;
    --warning-text: #875a22;
    --warning-soft: #fff3e1;
    --warning-border: #ebd1a7;
    --focus-ring: rgba(38, 131, 104, .19);
    --shadow: 0 12px 36px rgba(25, 50, 42, .065);
    --sidebar-width: 244px;
    color-scheme: light;
}
html[data-theme="dark"] {
    --ink: #eaf2ed;
    --muted: #a6b8af;
    --paper: #101916;
    --surface: #17231e;
    --surface-muted: #1d2d26;
    --surface-lifted: #21332b;
    --line: #31483d;
    --field-line: #466156;
    --field-hover: #79b79c;
    --primary: #8bdbb6;
    --primary-deep: #0e241d;
    --primary-soft: #264b3b;
    --on-primary: #10271d;
    --accent: #e5af7f;
    --accent-soft: #32271f;
    --danger: #ff938c;
    --danger-soft: #3c2426;
    --danger-border: #704448;
    --success-soft: #1b382a;
    --success-border: #385b46;
    --warning-text: #f5c68e;
    --warning-soft: #382d21;
    --warning-border: #775635;
    --focus-ring: rgba(139, 219, 182, .2);
    --shadow: 0 16px 38px rgba(0, 0, 0, .14);
    color-scheme: dark;
}
html { scroll-behavior: smooth; }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
h1 { font-weight: 750; letter-spacing: -.045em; font-size: clamp(2rem, 3.15vw, 2.85rem); line-height: 1.12; }
h2 { letter-spacing: -.035em; font-size: clamp(1.2rem, 1.6vw, 1.55rem); }
h3 { letter-spacing: -.025em; }
.eyebrow { font-size: .68rem; letter-spacing: .13em; font-weight: 750; }
.page-lead, .login-copy { font-size: .95rem; line-height: 1.6; }
.page-header { align-items: center; gap: 20px; }
.page-header .page-lead { margin-top: 9px; }
.main-content { width: min(1540px, 100%); padding: 43px clamp(22px, 3vw, 55px) 85px; }
.app-shell { background: var(--paper); }
.sidebar { background: #122c26; padding: 26px 13px 18px; }
.brand { padding: 0 10px; }
.brand__mark { border-radius: 10px; background: #e5ebd7; color: #17392d; font-size: 1.06rem; }
.brand__text { font-size: .82rem; font-weight: 660; }
.nav-list { margin-top: 34px; gap: 3px; }
.nav-item { min-height: 40px; padding: 9px 12px; border-radius: 7px; color: #bacbc2; font-size: .86rem; transition: background .16s ease, color .16s ease, transform .16s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.is-active { color: #fff; background: #285247; box-shadow: inset 3px 0 #a4e2bf; }
.nav-item__icon { width: 21px; color: #a7cabc; font-size: 1.07rem; }
.sidebar__footer { border-top: 1px solid rgba(230,255,246,.1); gap: 16px; margin-top: auto; padding: 20px 11px 4px; }
.user-summary__avatar { background: #e5ebd7; color: #163a2e; }
.logout-button { font-size: .8rem; }
.theme-control { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 4px; padding: 4px; border: 1px solid rgba(255,255,255,.14); border-radius: 9px; background: rgba(255,255,255,.04); }
.theme-control__option { min-height: 34px; border: 0; border-radius: 6px; color: #bdcec6; background: transparent; font-size: .77rem; font-weight: 650; cursor: pointer; transition: color .15s, background .15s; }
.theme-control__option.is-selected { color: #133e2e; background: #e6eee0; }
.theme-control__option:focus-visible, .theme-header-toggle:focus-visible { outline: 2px solid #b6e9cf; outline-offset: 2px; }
.theme-header-toggle { display: none; align-items: center; justify-content: center; flex: none; border: 1px solid var(--line); border-radius: 9px; height: 38px; width: 38px; font-size: 1.25rem; color: var(--ink); background: var(--surface); cursor: pointer; }
.panel, .list-section, .dashboard-panel, .user-budget, .comparison-list, .login-panel, .error-card { border-radius: 10px; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 2px 10px rgba(20, 45, 35, .018); }
.panel, .list-section, .dashboard-panel { padding: clamp(20px, 2.2vw, 27px); }
.dashboard-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: 14px; margin-top: 18px; }
.dashboard-panel { min-height: 180px; }
.dashboard-panel__header { padding-bottom: 13px; }
.dashboard-panel__metric strong { overflow-wrap: anywhere; white-space: normal; }
.dashboard-panel__stats dd, .metric strong, .record-row > .money, .comparison-row strong { overflow-wrap: anywhere; white-space: normal; }
.metric-grid { gap: 12px; margin-top: 26px; }
.metric { border: 1px solid var(--line); border-left: 3px solid var(--primary); border-radius: 9px; padding: 15px 17px; min-width: 0; background: var(--surface); }
.metric span { min-height: 2.25em; }
.metric--accent { border-left-color: var(--accent); background: var(--accent-soft); }
.metric strong { font-weight: 730; letter-spacing: -.025em; }
.content-grid { gap: 15px; margin-top: 24px; }
.content-grid--income { grid-template-columns: minmax(320px, .82fr) minmax(0, 1.18fr); }
.list-section { margin-top: 16px; }
.dashboard-users, .user-summary-grid { gap: 15px; }
.user-budget > header { padding: 18px 21px; }
.budget-section { padding: 19px 21px; }
.record-row { gap: 12px; padding: 14px 0; }
.record-row__main strong { font-weight: 650; }
.record-actions { gap: 13px; }
.record-actions a { text-underline-offset: 3px; }
.summary-config { gap: 12px 25px; }
.page-header + .content-grid, .page-header + .settings-grid { margin-top: 24px; }
.monthly-note__content { background: var(--accent-soft); }
.percentage-readonly > div { background: var(--surface-muted); }
.generated-credential { background: var(--surface-muted); }
.validation-summary { border-color: var(--success-border); background: var(--success-soft); }
.validation-summary h3 { color: var(--ink); }
.danger-zone { border-color: var(--danger-border); }
.historical-warning { color: var(--warning-text); }
.comparison--missing { color: var(--warning-text); }
.comparison--reached { color: var(--primary); }
.comparison--exceeded { color: var(--accent); }
.alert { border-radius: 8px; }
.alert--error { border-color: var(--danger-border); color: var(--danger); background: var(--danger-soft); }
.alert--success { border-color: var(--success-border); color: var(--ink); background: var(--success-soft); }
.alert--warning { border-color: var(--warning-border); color: var(--warning-text); background: var(--warning-soft); }
.button { border-radius: 7px; font-size: .86rem; font-weight: 650; transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.button:not(:disabled):active { transform: scale(.985); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button--primary { color: var(--on-primary); background: var(--primary); }
.button--primary:hover { background: var(--primary-deep); color: #fff; }
html[data-theme="dark"] .button--primary:hover { background: #b6efd2; color: #10271d; }
.button--secondary { border-color: var(--field-line); color: var(--primary); background: var(--surface); }
.button--secondary:hover, .button--quiet:hover { background: var(--primary-soft); }
.button--quiet { color: var(--primary); }
.button--danger { color: #fff; background: #a84641; }
.button--danger:hover { background: #902f30; }
.field { min-width: 0; }
.field label, fieldset.field legend { color: var(--ink); font-size: .83rem; font-weight: 670; }
.field input, .field select, .field textarea, .month-nav input[type="month"], .update-card input[type="file"], .update-card input[type="password"], .update-card input[name="confirmation_phrase"] { border-color: var(--field-line); border-radius: 7px; color: var(--ink); background-color: var(--surface-muted); font-size: .9rem; }
.field input, .field select, .field textarea { min-height: 44px; }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: .76; }
.field input:hover:not(:disabled), .field select:hover:not(:disabled), .field textarea:hover:not(:disabled), .month-nav input:hover:not(:disabled) { border-color: var(--field-hover); }
.field input:focus, .field select:focus, .field textarea:focus, .month-nav input:focus, .update-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring); outline: 0; }
.field input:disabled, .field select:disabled, .field textarea:disabled { background: var(--paper); color: var(--muted); opacity: .75; }
.field select { appearance: none; padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23176754' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 7 5 5 5-5'/%3E%3C/svg%3E"); background-position: right 12px center; background-size: 16px; background-repeat: no-repeat; }
html[data-theme="dark"] .field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%238bdbb6' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 7 5 5 5-5'/%3E%3C/svg%3E"); }
.field input[type="file"]::file-selector-button { color: var(--primary); background: var(--primary-soft); border-color: var(--line); }
.field input[type="checkbox"], .check-field input { accent-color: var(--primary); }
.field .segmented span { border-color: var(--field-line); color: var(--ink); background: var(--surface-muted); }
.segmented input:checked + span { border-color: var(--primary); color: var(--on-primary); background: var(--primary); }
.month-nav__arrow { min-height: 42px; border-radius: 7px; color: var(--ink); }
.month-nav__today { color: var(--primary); }
.month-nav__picker { position: relative; }
.record-actions .delete-confirm form { background: var(--danger-soft); border-color: var(--danger-border); }
.update-version, .update-status { background: var(--primary-soft); color: var(--primary); }
.update-file-action, .update-history__row > span { color: var(--primary); }
.update-card input[type="file"]::file-selector-button { color: var(--on-primary); background: var(--primary); }
.update-steps { color: var(--ink); }
.login-panel { box-shadow: var(--shadow); }
.auth-body { background: linear-gradient(90deg, #19483d 0%, #19483d 35%, var(--paper) 35%); }
.login-mark { background: var(--primary); color: var(--on-primary); }
.error-card { box-shadow: var(--shadow); }
html[data-theme="dark"] .debug-message { color: var(--danger); }
html[data-theme="dark"] .percentage-total { color: var(--primary); }
html[data-theme="dark"] .user-budget > header { background: #1b4034; }
html[data-theme="dark"] .user-budget > header p { color: #becfc5; }
html[data-theme="dark"] .month-nav input[type="month"], html[data-theme="dark"] .field input[type="date"], html[data-theme="dark"] .field input[type="month"] { color-scheme: dark; }
html[data-theme="dark"] .comparison-list__heading { background: #214335; }
html[data-theme="dark"] .login-panel, html[data-theme="dark"] .settings-card { box-shadow: none; }
html[data-theme="dark"] .update-card input[type="file"], html[data-theme="dark"] .update-card input[type="password"], html[data-theme="dark"] .update-card input[name="confirmation_phrase"] { border-color: var(--field-line); background: var(--surface-muted); }
/* Selector de fecha/mes propio: input original sigue existiendo para envíos PHP y móvil. */
.sdig-date-trigger { display: none; min-height: 44px; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; padding: 9px 12px; border: 1px solid var(--field-line); border-radius: 7px; background: var(--surface-muted); color: var(--ink); text-align: left; font-size: .9rem; font-weight: 550; cursor: pointer; }
.sdig-date-trigger:hover { border-color: var(--field-hover); }
.sdig-date-trigger:focus-visible { border-color: var(--primary); outline: 3px solid var(--focus-ring); outline-offset: 0; }
.sdig-date-trigger__icon { flex: none; color: var(--primary); font-size: 1.17rem; }
.sdig-calendar { position: fixed; z-index: 120; width: 294px; max-width: calc(100vw - 16px); padding: 12px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: var(--surface-lifted); box-shadow: 0 18px 50px rgba(0,0,0,.19); font-size: .85rem; }
.sdig-calendar:focus { outline: none; }
.sdig-calendar__header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.sdig-calendar__title { font-size: .88rem; font-weight: 750; text-transform: capitalize; }
.sdig-calendar__navigation { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 7px; color: var(--ink); background: var(--surface-muted); cursor: pointer; font-size: 1.3rem; }
.sdig-calendar__navigation:hover { background: var(--primary-soft); }
.sdig-calendar__days { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 3px; }
.sdig-calendar__months { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px; }
.sdig-calendar__weekday { display: grid; place-items: center; padding: 8px 0; font-size: .69rem; color: var(--muted); font-weight: 750; }
.sdig-calendar__empty { min-height: 32px; }
.sdig-calendar__cell { min-height: 34px; border: 0; border-radius: 7px; color: var(--ink); background: transparent; cursor: pointer; font-size: .78rem; text-transform: capitalize; }
.sdig-calendar__months .sdig-calendar__cell { min-height: 42px; }
.sdig-calendar__cell:hover:not(:disabled) { background: var(--primary-soft); }
.sdig-calendar__cell.is-today { box-shadow: inset 0 0 0 1px var(--primary); }
.sdig-calendar__cell.is-selected { background: var(--primary); color: var(--on-primary); font-weight: 750; }
.sdig-calendar__cell:disabled { opacity: .25; cursor: not-allowed; }
.sdig-calendar__cell:focus-visible, .sdig-calendar__navigation:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sdig-calendar__footer { display: flex; justify-content: space-between; align-items: center; padding-top: 10px; margin-top: 12px; border-top: 1px solid var(--line); }
.sdig-calendar__footer button { border: 0; padding: 6px 7px; border-radius: 5px; background: transparent; color: var(--primary); font-size: .77rem; font-weight: 700; cursor: pointer; }
.sdig-calendar__footer button:hover { background: var(--primary-soft); }
.sdig-calendar__footer button:disabled { opacity: .4; cursor: not-allowed; }
@media (min-width: 768px) and (pointer: fine) {
    input.sdig-native-date { position: absolute !important; width: 1px !important; height: 1px !important; min-width: 1px !important; min-height: 1px !important; padding: 0 !important; opacity: 0 !important; pointer-events: none !important; }
    .sdig-date-trigger.sdig-date-enhanced { display: flex; }
    .month-nav__picker .sdig-date-trigger { min-width: 170px; }
}
@media (max-width: 1170px) { .dashboard-overview { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
    .auth-body { background: var(--paper); }
    .main-content { padding: 30px 22px 70px; }
    .mobile-header { position: sticky; top: 0; z-index: 12; background: var(--surface); border-bottom-color: var(--line); }
    .mobile-header .theme-header-toggle { display: inline-flex; margin-left: auto; }
    .sidebar { z-index: 40; }
    .theme-control { max-width: 210px; }
}
@media (max-width: 560px) {
    .main-content { padding: 27px 16px 62px; }
    .page-header { gap: 15px; }
    .metric-grid { margin-top: 20px; }
    .metric { padding: 14px; }
    .dashboard-overview { gap: 12px; }
    .panel, .list-section, .dashboard-panel { padding: 19px 17px; }
    .month-nav { gap: 7px; }
    .month-nav__picker .sdig-date-trigger { min-width: 0; }
    .record-row > .money { overflow-wrap: anywhere; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
.auth-theme-picker { position: fixed; z-index: 15; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; top: 18px; right: 22px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.auth-theme-picker .theme-control__option { color: var(--muted); }
.auth-theme-picker .theme-control__option.is-selected { background: var(--primary-soft); color: var(--primary); }
@media(max-width:560px){.auth-theme-picker{top:10px;right:10px}.auth-theme-picker .theme-control__option{min-height:30px}}

.sdig-calendar__selects { display: flex; align-items: center; justify-content: center; gap: 3px; min-width: 0; }
.sdig-calendar__select { min-width: 0; width: 109px; height: 34px; padding: 5px 7px; border: 1px solid transparent; border-radius: 6px; color: var(--ink); background: var(--surface-muted); font-family: inherit; font-size: .81rem; font-weight: 700; cursor: pointer; }
.sdig-calendar__year { width: 76px; }
.sdig-calendar__select:hover, .sdig-calendar__select:focus { border-color: var(--field-line); outline: none; }
@keyframes sdig-reveal { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: no-preference) {
    .main-content > .page-header { animation: sdig-reveal .24s ease-out both; }
    .metric-grid > .metric, .dashboard-overview > .dashboard-panel, .user-summary-grid > .user-budget { animation: sdig-reveal .3s ease-out both; }
    .metric-grid > :nth-child(2), .dashboard-overview > :nth-child(2), .user-summary-grid > :nth-child(2) { animation-delay: 50ms; }
    .metric-grid > :nth-child(3) { animation-delay: 85ms; }
    .metric-grid > :nth-child(4) { animation-delay: 115ms; }
    .sdig-calendar { animation: sdig-reveal .12s ease-out both; }
}
