/* =====================================================================
   QuiroControl · assets/css/style.css
   Diseño del panel de ingresos y gastos.
   ===================================================================== */

/* ---------- Tokens ---------- */
:root {
    color-scheme: light;

    --brand: #0f766e;
    --brand-dark: #115e59;
    --brand-soft: #ccfbf1;
    --brand-ink: #042f2c;

    --bg: #f3f7f8;
    --surface: #ffffff;
    --surface-2: #f7fafb;
    --surface-3: #eef3f5;
    --text: #0f1f26;
    --text-2: #33474f;
    --muted: #64808a;
    --line: #e4ecf0;
    --line-2: #d3e0e6;

    --good: #0f9d6b;
    --good-soft: #dcfaee;
    --bad: #d92d4b;
    --bad-soft: #fde8ed;
    --warn: #b47808;
    --warn-soft: #fdf3df;

    --sidebar-a: #0a2c2b;
    --sidebar-b: #061e1d;
    --sidebar-line: rgba(255, 255, 255, 0.07);

    --chart-1: #14b8a6;
    --chart-2: #fb7185;
    --chart-3: #6366f1;
    --chart-4: #f59e0b;
    --chart-5: #38bdf8;
    --chart-6: #a78bfa;

    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 22px;

    --shadow-sm: none;
    --shadow: none;
    --shadow-lg: none;

    --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

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

    --brand: #2dd4bf;
    --brand-dark: #14b8a6;
    --brand-soft: #10322f;
    --brand-ink: #d6fbf4;

    --bg: #070f14;
    --surface: #0f1b22;
    --surface-2: #132129;
    --surface-3: #182932;
    --text: #e8f2f5;
    --text-2: #bfd0d6;
    --muted: #8aa3ad;
    --line: #1d2f38;
    --line-2: #26404b;

    --good: #34d399;
    --good-soft: #0d2b25;
    --bad: #fb7185;
    --bad-soft: #33161d;
    --warn: #fbbf24;
    --warn-soft: #2c2413;

    --chart-1: #2dd4bf;
    --chart-2: #fb7185;
    --chart-3: #818cf8;
    --chart-4: #fbbf24;
    --chart-5: #38bdf8;
    --chart-6: #c4b5fd;

    --shadow-sm: none;
    --shadow: none;
}

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

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    margin: 0;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

h1 { font-size: 1.2rem; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 650; }

p { margin: 0; }

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

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.86em;
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--surface-3);
    color: var(--text-2);
}

button {
    font-family: inherit;
}

body.no-scroll {
    overflow: hidden;
}

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-good { color: var(--good); }
.text-bad { color: var(--bad); }
.amount { font-variant-numeric: tabular-nums; }
.amount-good { color: var(--good); font-variant-numeric: tabular-nums; }
.amount-bad { color: var(--bad); font-variant-numeric: tabular-nums; }

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

/* ---------- Estructura ---------- */
.app {
    display: grid;
    grid-template-columns: 256px minmax(0, 1fr);
    min-height: 100vh;
}

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.content {
    flex: 1;
    width: 100%;
    max-width: 1360px;
    margin: 0 auto;
    padding: 26px 30px 20px;
}

.page-foot {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 30px 26px;
    font-size: 0.8rem;
    color: var(--muted);
    max-width: 1360px;
    width: 100%;
    margin: 0 auto;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 22px 16px 18px;
    color: #d8e9e7;
    background: var(--sidebar-a);
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    overflow-y: auto;
    z-index: 40;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 4px 6px 0;
    color: #f2fbfa;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    color: #052e2b;
    background: #2dd4bf;
    flex-shrink: 0;
}

.brand-mark svg {
    width: 21px;
    height: 21px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-text strong {
    font-size: 0.98rem;
    letter-spacing: -0.01em;
}

.brand-text small {
    font-size: 0.72rem;
    color: rgba(216, 233, 231, 0.62);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-label {
    padding: 0 12px 6px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: rgba(216, 233, 231, 0.45);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: rgba(224, 240, 238, 0.78);
    font-size: 0.9rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #ffffff;
}

.nav-link.is-active {
    background: rgba(45, 212, 191, 0.18);
    color: #ffffff;
    box-shadow: none;
}

.nav-link.is-active svg {
    opacity: 1;
    color: #5eead4;
}

.sidebar-card {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid var(--sidebar-line);
}

.sidebar-card-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(216, 233, 231, 0.55);
}

.sidebar-card strong {
    font-size: 1.32rem;
    letter-spacing: -0.02em;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
}

.sidebar-card-foot {
    font-size: 0.76rem;
    color: rgba(216, 233, 231, 0.6);
}

.sidebar-foot {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 4px;
    border-top: 1px solid var(--sidebar-line);
}

.nav-link-muted {
    font-size: 0.84rem;
    padding: 8px 12px;
    color: rgba(216, 233, 231, 0.6);
}

.version {
    padding-left: 12px;
    font-size: 0.72rem;
    color: rgba(216, 233, 231, 0.38);
}

.scrim {
    position: fixed;
    inset: 0;
    background: rgba(4, 20, 19, 0.55);
    z-index: 35;
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 16px 30px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.topbar-heading {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-right: auto;
    min-width: 0;
}

.topbar-heading h1 {
    font-size: 1.16rem;
    font-weight: 700;
}

.topbar-heading p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.week-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.week-nav input[type='date'] {
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 550;
    color: var(--text);
    padding: 6px 4px;
    border-radius: 8px;
}

.week-nav input[type='date']:focus {
    outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent);
    outline-offset: 1px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-btn {
    display: none;
}

.progress {
    height: 2px;
    width: 100%;
    overflow: hidden;
    background: transparent;
}

.progress span {
    display: block;
    height: 100%;
    width: 40%;
    background: var(--brand);
    opacity: 0;
    transform: translateX(-100%);
}

.app.is-loading .progress span {
    opacity: 1;
    animation: progress-slide 1.1s ease-in-out infinite;
}

@keyframes progress-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(320%); }
}

/* ---------- Botones / controles ---------- */
.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--surface-2);
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.icon-btn:hover {
    background: var(--surface-3);
    color: var(--text);
}

.icon-btn.sm {
    width: 30px;
    height: 30px;
    border-radius: 9px;
}

.icon-btn.sm svg {
    width: 15px;
    height: 15px;
}

.icon-btn.danger {
    color: var(--bad);
    background: var(--bad-soft);
}

.icon-btn.danger:hover {
    background: color-mix(in srgb, var(--bad) 18%, var(--bad-soft));
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 11px;
    border: 1px solid transparent;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.16s ease, background 0.16s ease, color 0.16s ease;
    white-space: nowrap;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: progress;
}

.btn-primary {
    color: #04201d;
    background: var(--brand);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--brand-dark);
}

.btn-soft {
    color: var(--brand-ink);
    background: var(--brand-soft);
    border-color: color-mix(in srgb, var(--brand) 22%, transparent);
}

[data-theme='dark'] .btn-primary {
    color: #04201d;
}

.btn-ghost {
    color: var(--text-2);
    background: var(--surface-2);
    border-color: var(--line);
}

.btn-ghost:hover {
    background: var(--surface-3);
}

.btn-danger {
    color: #ffffff;
    background: var(--bad);
}

.btn-sm {
    padding: 7px 12px;
    font-size: 0.82rem;
    border-radius: 9px;
}

.select {
    padding: 10px 34px 10px 12px;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: var(--surface-2) url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364808a' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 15px;
    color: var(--text);
    font: inherit;
    font-size: 0.86rem;
    cursor: pointer;
    appearance: none;
}

.select:focus {
    outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent);
    outline-offset: 1px;
}

.search {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 250px;
}

.search svg {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--muted);
    pointer-events: none;
}

.search input {
    width: 100%;
    padding: 10px 12px 10px 34px;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 0.86rem;
}

.search input::placeholder {
    color: var(--muted);
}

.search input:focus {
    outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent);
    outline-offset: 1px;
    background: var(--surface);
}

.link-btn {
    border: 0;
    background: transparent;
    color: var(--brand);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 2px;
    border-radius: 6px;
}

.link-btn:hover {
    text-decoration: underline;
}

.icon-moon { display: block; }
.icon-sun { display: none; }

[data-theme='dark'] .icon-moon { display: none; }
[data-theme='dark'] .icon-sun { display: block; }

/* ---------- Vistas ---------- */
.vista {
    display: none;
    animation: vista-in 0.24s ease;
}

.vista.is-active {
    display: block;
}

@keyframes vista-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.page-head p {
    font-size: 0.86rem;
    margin-top: 2px;
}

.page-head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---------- KPIs ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.kpi {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 18px 15px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.kpi::after {
    content: '';
    position: absolute;
    inset: 0 0 auto auto;
    width: 120px;
    height: 120px;
    background: color-mix(in srgb, var(--brand) 8%, transparent);
    pointer-events: none;
}

.kpi-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.kpi-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
}

.kpi-icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    color: var(--brand);
    background: var(--brand-soft);
}

.kpi-icon svg {
    width: 16px;
    height: 16px;
}

.kpi-icon.is-good {
    color: var(--good);
    background: var(--good-soft);
}

.kpi-icon.is-bad {
    color: var(--bad);
    background: var(--bad-soft);
}

.kpi-value {
    font-size: 1.72rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.kpi-foot {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.78rem;
}

.kpi-trend {
    font-weight: 600;
    color: var(--muted);
}

.kpi-trend[data-tone='good'] { color: var(--good); }
.kpi-trend[data-tone='bad'] { color: var(--bad); }

.kpi-balance .kpi-value {
    color: var(--brand);
}

.kpi-balance.is-negative .kpi-value {
    color: var(--bad);
}

.kpi-balance.is-negative::after {
    background: color-mix(in srgb, var(--bad) 10%, transparent);
}

/* ---------- Cards y gráficos ---------- */
.grid-charts {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px;
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.card-head h3 {
    font-size: 0.98rem;
}

.card-head p {
    margin-top: 1px;
}

.card-table {
    padding: 4px;
}

.chart-box {
    position: relative;
    height: 260px;
}

.chart-box canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-box-doughnut {
    display: grid;
    place-items: center;
}

.chart-empty {
    position: absolute;
    inset: auto 12px 12px;
    text-align: center;
    font-size: 0.84rem;
    color: var(--muted);
}

/* ---------- Feed / ranking ---------- */
.feed,
.rank {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.feed-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 6px;
    border-radius: 11px;
    transition: background 0.15s ease;
}

.feed-item:hover {
    background: var(--surface-2);
}

.feed-avatar,
.avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--brand-ink);
    background: var(--brand-soft);
    border: 1px solid color-mix(in srgb, var(--brand) 18%, transparent);
}

.avatar {
    width: 32px;
    height: 32px;
}

.feed-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.feed-body strong {
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed-body small {
    font-size: 0.76rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed-amount {
    font-size: 0.88rem;
    font-weight: 650;
    color: var(--good);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.feed-empty {
    padding: 18px 6px;
    text-align: center;
    font-size: 0.84rem;
    color: var(--muted);
}

.rank-item {
    padding: 7px 6px;
}

.rank-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.85rem;
}

.rank-top span {
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-top strong {
    font-variant-numeric: tabular-nums;
}

.rank-bar {
    margin-top: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
}

.rank-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--brand);
}

[data-theme='dark'] .rank-bar span {
    background: var(--brand);
}

/* ---------- Tablas ---------- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 620px;
}

.table thead th {
    padding: 12px 14px;
    text-align: left;
    font-size: 0.68rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table thead th:first-child {
    border-top-left-radius: 11px;
}

.table thead th:last-child {
    border-top-right-radius: 11px;
}

.table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 0.88rem;
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table tbody tr {
    transition: background 0.14s ease;
}

.table tbody tr:hover {
    background: var(--surface-2);
}

.table tfoot th {
    padding: 13px 14px;
    font-size: 0.85rem;
    border-top: 1px solid var(--line-2);
    background: var(--surface-2);
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.table tfoot th:first-child {
    border-bottom-left-radius: 11px;
}

.table tfoot th:last-child {
    border-bottom-right-radius: 11px;
}

.cell-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.cell-main strong {
    font-weight: 600;
    font-size: 0.88rem;
}

.cell-main small {
    font-size: 0.76rem;
}

.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}

.empty-row td {
    padding: 30px 14px;
    text-align: center;
    color: var(--muted);
    font-size: 0.86rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-2);
    background: var(--surface-3);
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-soft {
    color: var(--brand-ink);
    background: var(--brand-soft);
    border-color: color-mix(in srgb, var(--brand) 20%, transparent);
}

.badge[data-cat='General'] {
    color: var(--text-2);
    background: var(--surface-3);
}

.badge[data-cat='Insumos'] {
    color: #0b6b60;
    background: #d9f7f1;
}

.badge[data-cat='Renta'] {
    color: #4338ca;
    background: #e8e7fd;
}

.badge[data-cat='Servicios'] {
    color: #96610a;
    background: #fdf1da;
}

.badge[data-cat='Transporte'] {
    color: #0369a1;
    background: #e0f2fe;
}

.badge[data-cat='Otros'] {
    color: #b02a4a;
    background: #fde8ee;
}

[data-theme='dark'] .badge[data-cat='General'] {
    background: var(--surface-3);
    color: var(--text-2);
}

[data-theme='dark'] .badge[data-cat='Insumos'] {
    background: #0d3b36;
    color: #7ee7d8;
}

[data-theme='dark'] .badge[data-cat='Renta'] {
    background: #232456;
    color: #c3c2fb;
}

[data-theme='dark'] .badge[data-cat='Servicios'] {
    background: #3a2c12;
    color: #fbd38d;
}

[data-theme='dark'] .badge[data-cat='Transporte'] {
    background: #0c2d43;
    color: #8ed4f8;
}

[data-theme='dark'] .badge[data-cat='Otros'] {
    background: #3a1522;
    color: #f9a3b6;
}

/* ---------- Calendario ---------- */
.grid-calendario {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.month-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.month-nav strong {
    min-width: 136px;
    text-align: center;
    font-size: 0.86rem;
    font-weight: 600;
    text-transform: capitalize;
}

.calendar {
    width: 100%;
}

.calendar-head,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.calendar-head {
    margin-bottom: 6px;
}

.calendar-head span {
    padding: 4px 0;
    text-align: center;
    font-size: 0.68rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.cal-day {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-height: 62px;
    padding: 7px 8px;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.cal-day:hover {
    border-color: var(--line-2);
    background: var(--surface-2);
}

.cal-day:active {
    transform: translateY(1px);
}

.cal-day.is-blank {
    min-height: 0;
    border: 0;
    background: transparent;
    cursor: default;
}

.cal-num {
    font-size: 0.8rem;
    font-weight: 650;
}

.cal-monto {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--good);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cal-day.has-data {
    background: color-mix(in srgb, var(--brand) 6%, var(--surface));
    border-color: color-mix(in srgb, var(--brand) 22%, var(--line));
}

.cal-day.is-today .cal-num {
    color: var(--brand);
}

.cal-day.is-today::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--brand);
}

.cal-day.is-selected {
    border-color: var(--brand);
    background: var(--surface);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 26%, transparent);
}

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    font-size: 0.74rem;
    color: var(--muted);
}

.calendar-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--line-2);
}

.dot-ok {
    background: var(--good);
}

.dot-today {
    background: var(--brand);
}

.dia-totales {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.dia-totales > div {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 10px 12px;
    border-radius: 11px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.dia-totales span {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.dia-totales strong {
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

#diaIngresos {
    color: var(--good);
}

#diaGastos {
    color: var(--bad);
}

@media (max-width: 1080px) {
    .grid-calendario {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 620px) {
    .cal-day {
        min-height: 52px;
        padding: 5px 6px;
    }

    .cal-monto {
        font-size: 0.62rem;
    }

    .month-nav strong {
        min-width: 106px;
    }

    .dia-totales {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------- Modales ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.modal.is-open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 20, 19, 0.55);
    animation: fade-in 0.18s ease;
}

.modal-card {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: modal-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.modal-card-sm {
    max-width: 420px;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 20px 22px 14px;
    border-bottom: 1px solid var(--line);
}

.modal-head h2 {
    font-size: 1.06rem;
}

.modal-head p {
    margin-top: 2px;
}

.modal-dia-totales {
    margin: 16px 22px 0;
}

.modal-dia-ingresos {
    color: var(--good);
}

.modal-dia-gastos {
    color: var(--bad);
}

.modal-dia-detalle {
    padding: 10px 16px 18px;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 22px 20px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 18px 22px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field > span {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: 0.01em;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line-2);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.89rem;
    transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.field textarea {
    resize: vertical;
    min-height: 62px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.field input::placeholder,
.field textarea::placeholder {
    color: var(--muted);
}

.span-2 {
    grid-column: span 2;
}

/* ---------- Avisos ---------- */
.toast-stack {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(360px, calc(100vw - 32px));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 11px 14px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    font-size: 0.86rem;
    color: var(--text);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-in {
    opacity: 1;
    transform: none;
}

.toast-dot {
    width: 8px;
    height: 8px;
    margin-top: 6px;
    border-radius: 999px;
    background: var(--brand);
    flex-shrink: 0;
}

.toast-ok .toast-dot { background: var(--good); }
.toast-error .toast-dot { background: var(--bad); }

/* ---------- Estados ---------- */
.alert {
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 0.86rem;
    border: 1px solid var(--line);
    background: var(--surface-2);
    margin: 14px 0;
}

.alert-bad {
    color: var(--bad);
    background: var(--bad-soft);
    border-color: color-mix(in srgb, var(--bad) 25%, transparent);
}

.alert-good {
    color: var(--good);
    background: var(--good-soft);
    border-color: color-mix(in srgb, var(--good) 25%, transparent);
}

.setup {
    max-width: 560px;
    margin: 40px auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 34px 28px;
}

.setup-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    font-size: 1.5rem;
    background: var(--brand-soft);
    color: var(--brand);
}

.setup p {
    font-size: 0.88rem;
}

.setup .alert {
    width: 100%;
    text-align: left;
}

.setup-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 6px;
}

/* ---------- Instalador ---------- */
.install-body {
    display: grid;
    place-items: center;
    padding: 40px 18px;
}

.install {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.install-brand {
    justify-content: center;
    color: var(--text);
}

.install-brand .brand-text small {
    color: var(--muted);
}

.install-card {
    padding: 26px;
}

.install-card h1 {
    font-size: 1.35rem;
    margin-bottom: 6px;
}

.install-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 18px 0;
}

.install-meta > div {
    padding: 10px 12px;
    border-radius: 11px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.install-meta dt {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.install-meta dd {
    margin: 2px 0 0;
    font-size: 0.85rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.steps {
    margin: 14px 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
}

.steps li {
    position: relative;
    padding-left: 24px;
    color: var(--text-2);
}

.steps li::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 7px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--good);
    box-shadow: 0 0 0 3px var(--good-soft);
}

.install-counts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0;
}

.install-counts > div {
    padding: 14px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
}

.install-counts span {
    font-size: 0.75rem;
    color: var(--muted);
}

.install-counts strong {
    font-size: 1.4rem;
    letter-spacing: -0.02em;
}

.install-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.hint {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 0.78rem;
    color: var(--muted);
}

/* ---------- Registro rápido de consulta ---------- */
.money-input {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    border-radius: 12px;
    border: 1px solid var(--line-2);
    background: var(--surface);
    transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.money-input:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.money-prefix {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--muted);
}

.field .money-input input {
    border: 0;
    background: transparent;
    padding: 8px 0;
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.field .money-input input:focus {
    outline: none;
    box-shadow: none;
}

.field .money-input input::-webkit-outer-spin-button,
.field .money-input input::-webkit-inner-spin-button {
    margin: 0;
}

.hint-inline {
    margin-top: 2px;
}

.extra-data {
    margin: 0 22px 18px;
    border: 1px dashed var(--line-2);
    border-radius: 12px;
    background: var(--surface-2);
    overflow: hidden;
}

.extra-data > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    list-style: none;
}

.extra-data > summary::-webkit-details-marker {
    display: none;
}

.extra-data > summary::after {
    content: '+';
    font-size: 1rem;
    font-weight: 500;
    color: var(--muted);
}

.extra-data[open] > summary::after {
    content: '−';
}

.extra-data .form-grid {
    padding: 4px 14px 16px;
}

/* ---------- Usuario en la barra lateral ---------- */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    border-top: 1px solid var(--sidebar-line);
}

.sidebar-user-avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #04201d;
    background: #2dd4bf;
}

.sidebar-user-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    line-height: 1.25;
}

.sidebar-user-text strong {
    font-size: 0.84rem;
    color: #f2fbfa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-text small {
    font-size: 0.7rem;
    color: rgba(216, 233, 231, 0.55);
}

.sidebar-user-out {
    color: #d8e9e7;
    background: rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.sidebar-user-out:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

/* ---------- Login ---------- */
.auth-body {
    display: grid;
    place-items: center;
    padding: 32px 18px;
}

.auth-shell {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-brand {
    justify-content: center;
    color: var(--text);
}

.auth-brand .brand-text small {
    color: var(--muted);
}

.auth-card {
    padding: 28px;
}

.auth-card h1 {
    font-size: 1.35rem;
    margin-bottom: 4px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 18px;
}

.auth-submit {
    width: 100%;
    margin-top: 4px;
}

.auth-foot {
    margin-top: 16px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--muted);
}

.auth-legal {
    text-align: center;
    font-size: 0.76rem;
    color: var(--muted);
}

/* ---------- Configuración ---------- */
.config-section-title {
    padding: 16px 22px 0;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
}

.config-reset {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 22px;
    padding: 14px 0;
    border-top: 1px solid var(--line);
}

.config-account {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 16px 22px 20px;
}

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
    .extra-data {
        margin: 0 16px 16px;
    }
}

@media (max-width: 1180px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-charts {
        grid-template-columns: minmax(0, 1fr);
    }

    .chart-box {
        height: 240px;
    }
}

@media (max-width: 1024px) {
    .app {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        height: 100vh;
        width: 268px;
        transform: translateX(-104%);
        transition: transform 0.26s cubic-bezier(0.3, 0.8, 0.3, 1);
        border-right-color: rgba(255, 255, 255, 0.12);
    }

    .app.is-menu-open .sidebar {
        transform: none;
    }

    .menu-btn {
        display: inline-grid;
    }

    .topbar {
        padding: 12px 18px;
        gap: 12px;
        flex-wrap: wrap;
    }

    .content {
        padding: 20px 18px 16px;
    }

    .page-foot {
        padding: 16px 18px 22px;
    }
}

@media (max-width: 820px) {
    .topbar-heading {
        order: 1;
        flex: 1 1 100%;
    }

    .week-nav {
        order: 3;
        flex: 1 1 auto;
        justify-content: space-between;
    }

    .topbar-actions {
        order: 2;
    }

    .menu-btn {
        order: 0;
    }
}

@media (max-width: 700px) {
    .kpi-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .page-head {
        align-items: flex-start;
    }

    .page-head-actions {
        width: 100%;
    }

    .search {
        min-width: 0;
        flex: 1 1 100%;
    }

    .col-hide-sm {
        display: none;
    }

    .table thead th,
    .table tbody td {
        padding: 10px 11px;
    }

    .form-grid {
        grid-template-columns: minmax(0, 1fr);
        padding: 16px 16px;
    }

    .span-2 {
        grid-column: auto;
    }

    .modal-head,
    .modal-foot {
        padding-left: 16px;
        padding-right: 16px;
    }

    .install-meta {
        grid-template-columns: minmax(0, 1fr);
    }

    .install-counts {
        grid-template-columns: minmax(0, 1fr);
    }

    .page-foot {
        flex-direction: column;
        gap: 4px;
    }
}

@media (max-width: 480px) {
    .topbar {
        padding: 10px 12px;
        gap: 10px;
    }

    .content {
        padding: 16px 12px 12px;
    }

    .page-foot {
        padding: 14px 12px 18px;
    }

    .week-nav {
        flex-wrap: wrap;
    }

    .week-nav input[type='date'] {
        flex: 1 1 120px;
        min-width: 0;
    }

    .topbar-actions {
        margin-left: auto;
    }

    .modal {
        padding: 10px;
    }

    .modal-card {
        max-height: calc(100vh - 20px);
    }

    .auth-card {
        padding: 20px;
    }

    .config-section-title {
        padding-left: 16px;
        padding-right: 16px;
    }

    .config-account {
        padding-left: 16px;
        padding-right: 16px;
    }
}

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