:root {
    color-scheme: dark;
    font-family: Inter, Arial, Helvetica, sans-serif;
    --bg: #161a1d;
    --panel: #23272c;
    --sidebar: #12142d;
    --border: rgba(255, 255, 255, 0.07);
    --text: #f5f7fb;
    --muted: #99a2b5;
    --purple: #6d63ff;
    --pink: #db4df5;
    --yellow: #f7c74a;
    --green: #4ad07b;
    --danger: #ff6b6b;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { background: linear-gradient(180deg, #1a1d22 0%, #14171b 100%); }
button, input, select { font: inherit; }
.is-hidden { display: none !important; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel, .panel { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; }
.login-panel { width: min(100%, 420px); padding: 28px; box-shadow: 0 24px 60px rgba(0,0,0,.35); display: grid; gap: 14px; }
.login-stage { display: grid; gap: 14px; }
.password-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}
.password-toggle {
    min-width: 90px;
    padding-inline: 14px;
}
.verification-note {
    padding: 14px;
    border: 1px solid rgba(109,99,255,.2);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(109,99,255,.12) 0%, rgba(109,99,255,.05) 100%);
}
.verification-note strong {
    display: block;
    margin-bottom: 6px;
}
.verification-note p {
    margin: 0;
    color: var(--muted);
}

.workspace { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, #12142d 0%, #13132c 100%); padding: 28px 18px; display: flex; flex-direction: column; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 34px; height: 34px; border-radius: 50%; background: conic-gradient(from 0deg, var(--purple) 0 74%, transparent 74% 100%), radial-gradient(circle at center, rgba(255,255,255,.12) 0 35%, transparent 37%); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.brand-title, .brand-subtitle { font-weight: 800; line-height: 1.05; }
.sidebar-label, .eyebrow, .field span { color: var(--muted); font-size: .76rem; font-weight: 800; text-transform: uppercase; }

.sidebar-nav, .sidebar-list, .stack-list, .table-list, .category-list, .quick-hints, .inline-actions, .form-actions { display: grid; gap: 10px; }
.sidebar-section {
    padding-top: 4px;
}
.sidebar-list-years { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sidebar-list-months { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.menu-button, .sidebar-chip, .switch-button {
    border: 1px solid rgba(255,255,255,.06);
    background: rgba(255,255,255,.02);
    color: #cfd5e5;
    cursor: pointer;
}
.menu-button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 0 14px; border-radius: 12px; text-align: left; }
.menu-button strong, .menu-button small { display: block; }
.menu-button small { color: var(--muted); }
.menu-button.is-active, .switch-button.is-active, .sidebar-chip.is-active { background: linear-gradient(90deg, rgba(109,99,255,.28), rgba(109,99,255,.08)); border-color: rgba(109,99,255,.45); color: #fff; }
.menu-icon { width: 16px; height: 16px; border-radius: 5px; background: linear-gradient(180deg, #8b82ff, #5a50ff); }
.menu-icon.analytics { border-radius: 50%; background: conic-gradient(from 0deg, #db4df5 0 30%, #6d63ff 30% 72%, #f7c74a 72% 100%); }
.sidebar-chip {
    min-height: 40px;
    border-radius: 12px;
    padding: 0 12px;
    text-align: left;
    color: #8c93b5;
    font-weight: 600;
    transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease;
}
.sidebar-chip:hover {
    border-color: rgba(109,99,255,.22);
    background: rgba(255,255,255,.04);
    color: #d7dcf2;
}
.sidebar-actions { margin-top: auto; padding-top: 10px; }
.sidebar-button { width: 100%; }

.dashboard { padding: 20px; }
.dashboard-header, .panel-heading, .transaction-main, .transaction-meta, .list-card-top, .category-row, .header-tools, .quick-form { display: flex; gap: 12px; }
.dashboard-header, .panel-heading, .transaction-main, .transaction-meta, .list-card-top, .category-row { justify-content: space-between; align-items: flex-start; }
.dashboard-header { align-items: end; margin-bottom: 18px; }
.dashboard-header h1, .panel-heading h2, .login-panel h1 { margin: 0; }
.dashboard-header p, .panel-heading p, .login-panel p, .form-message, .muted-text, .metric-footnote { color: var(--muted); }

.hero-grid, .content-grid, .form-grid, .filters, .form-switcher { display: grid; gap: 16px; }
.hero-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.content-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.panel { padding: 18px; background: linear-gradient(180deg, rgba(41,45,50,.96) 0%, rgba(34,38,43,.96) 100%); }
.panel-span-8 { grid-column: span 8; }
.panel-span-12 { grid-column: span 12; }
.panel-span-6 { grid-column: span 6; }
.panel-span-7 { grid-column: span 7; }
.panel-span-5 { grid-column: span 5; }
.panel-span-4 { grid-column: span 4; }
.metric-panel { display: flex; flex-direction: column; min-height: 126px; }
.metric-heading { color: #d6d9e4; font-size: .95rem; font-weight: 700; }
.metric-big { margin-top: 6px; font-size: clamp(1.7rem, 2vw, 2.3rem); font-weight: 800; }
.sparkline { margin-top: auto; height: 54px; }
.sparkline svg, .bar-chart svg, .line-chart svg, .donut-chart svg, .ring-summary svg { width: 100%; height: 100%; display: block; }

.form-switcher { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 16px; }
.switch-button { min-height: 42px; border-radius: 10px; padding: 0 10px; }
.entry-panel { min-height: 380px; }

.donut-panel { min-height: 166px; }
.donut-wrap { display: flex; gap: 16px; align-items: center; }
.donut-chart { width: 160px; height: 120px; flex: 0 0 auto; }
.donut-legend { display: grid; gap: 8px; flex: 1; }
.legend-item, .ring-card, .list-card, .transaction-card, .category-row {
    border: 1px solid rgba(255,255,255,.05);
    border-radius: 12px;
    background: rgba(255,255,255,.02);
}
.legend-item { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; font-size: .85rem; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 8px; }

.bar-chart { height: 245px; }
.ring-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ring-card { padding: 12px; text-align: center; }
.ring-card .ring-svg { width: 76px; height: 76px; margin: 0 auto 8px; }
.expense-breakdown { display: grid; gap: 10px; }
.expense-bar-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; font-size: .92rem; }
.expense-track { height: 14px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden; }
.expense-fill { display: block; height: 100%; border-radius: inherit; }
.line-chart { height: 220px; }
.analytics-list,
.analytics-ranking,
.analytics-month-table { display: grid; gap: 12px; }
.analytics-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.analytics-summary-item,
.analytics-rank-row,
.analytics-month-table-head,
.analytics-month-row {
    border: 1px solid rgba(255,255,255,.05);
    border-radius: 12px;
    background: rgba(255,255,255,.02);
}
.analytics-summary-item {
    padding: 14px;
    display: grid;
    gap: 8px;
}
.analytics-summary-item span {
    color: var(--muted);
    font-size: .84rem;
}
.analytics-summary-item strong {
    font-size: 1rem;
    line-height: 1.4;
}
.analytics-rank-row {
    padding: 14px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}
.analytics-rank-label,
.analytics-rank-values {
    display: flex;
    align-items: center;
    gap: 10px;
}
.analytics-rank-values {
    flex-direction: column;
    align-items: end;
    gap: 2px;
}
.analytics-rank-values small { color: var(--muted); }
.analytics-rank-index {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    background: rgba(109,99,255,.14);
    color: #dcd9ff;
    font-size: .78rem;
    font-weight: 800;
}
.analytics-month-table-head,
.analytics-month-row {
    display: grid;
    grid-template-columns: 1.1fr 1fr 1fr 1fr;
    gap: 12px;
    padding: 14px;
    align-items: center;
}
.analytics-month-table-head {
    color: var(--muted);
    font-size: .82rem;
    font-weight: 800;
    text-transform: uppercase;
}
.text-danger { color: #ff9a9a; }
.text-success { color: #82e6a8; }

.field { display: grid; gap: 8px; }
.compact-field { min-width: 180px; }
.field-grow { flex: 1; }
.field-full { grid-column: 1 / -1; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.filters { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.filters-wide { align-items: end; }

input, select, .primary-button, .ghost-button, .inline-button {
    min-height: 42px;
    border-radius: 8px;
}
input, select {
    width: 100%;
    border: 1px solid rgba(255,255,255,.08);
    background: rgba(16,18,23,.9);
    color: var(--text);
    padding: 0 12px;
}
input[type="color"] { padding: 4px; }
.primary-button, .ghost-button, .inline-button {
    border: 1px solid rgba(255,255,255,.08);
    color: var(--text);
    background: rgba(255,255,255,.04);
    cursor: pointer;
}
.primary-button { background: linear-gradient(90deg, var(--purple), #8077ff); font-weight: 700; padding: 0 14px; }
.ghost-button, .inline-button { padding: 0 12px; }

.day-input-shell {
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 8px;
    align-items: center;
}

.day-prefix {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    background: rgba(16,18,23,.9);
    color: var(--muted);
    font-weight: 700;
}

.toggle-field {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 12px;
    align-items: start;
    padding: 12px;
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 12px;
    background: rgba(255,255,255,.02);
}

.toggle-field input {
    appearance: none;
    -webkit-appearance: none;
    min-height: auto;
    width: 44px;
    height: 26px;
    margin: 0;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.08);
    position: relative;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease;
}

.toggle-field input::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    transition: transform .18s ease;
}

.toggle-field input:checked {
    background: linear-gradient(90deg, rgba(109,99,255,.95), rgba(109,99,255,.65));
    border-color: rgba(109,99,255,.7);
}

.toggle-field input:checked::after {
    transform: translateX(18px);
}

.toggle-field strong,
.toggle-field small {
    display: block;
}

.toggle-field small {
    margin-top: 4px;
    color: var(--muted);
}

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

.transaction-summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.summary-chip { padding: 12px; border: 1px solid rgba(255,255,255,.05); border-radius: 12px; background: rgba(255,255,255,.02); }
.summary-chip strong, .summary-chip span { display: block; }
.summary-chip span { color: var(--muted); font-size: .82rem; margin-bottom: 4px; }

.transaction-list { gap: 12px; }
.transaction-card { padding: 14px; }
.transaction-topline { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.transaction-title { font-weight: 800; font-size: 1rem; }
.transaction-secondary { margin-top: 4px; color: var(--muted); font-size: .9rem; }
.transaction-footer { margin-top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.list-card, .category-row { padding: 12px; }
.badge, .status-pill {
    display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px;
    border-radius: 999px; font-size: .8rem; font-weight: 700;
}
.badge { background: rgba(255,255,255,.05); color: var(--muted); }
.status-paid { background: rgba(74,208,123,.15); color: #78e39d; }
.status-pending { background: rgba(247,199,74,.15); color: var(--yellow); }
.status-overdue { background: rgba(255,107,107,.15); color: #ff9a9a; }
.amount { font-weight: 800; white-space: nowrap; }
.amount-expense { color: #f2a6ff; }
.amount-income { color: #9bc1ff; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-button { min-height: 30px; border-radius: 999px; }

.empty-state {
    padding: 18px;
    border: 1px dashed rgba(255,255,255,.08);
    border-radius: 12px;
    color: var(--muted);
    text-align: center;
}

.modal-shell {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 40;
    padding: 24px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 7, 12, 0.72);
    backdrop-filter: blur(6px);
}

.modal-card {
    position: relative;
    width: min(100%, 420px);
    padding: 22px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,.08);
    background: linear-gradient(180deg, rgba(36,40,47,.98) 0%, rgba(28,31,38,.98) 100%);
    box-shadow: 0 24px 60px rgba(0,0,0,.42);
}

.modal-eyebrow {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.modal-card h2 {
    margin: 0 0 8px;
}

.modal-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: end;
    gap: 10px;
    margin-top: 18px;
}

@media (max-width: 1280px) {
    .hero-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .panel-span-12, .panel-span-8, .panel-span-7, .panel-span-6, .panel-span-5, .panel-span-4 { grid-column: span 12; }
}
@media (max-width: 920px) {
    .workspace { grid-template-columns: 1fr; }
    .sidebar-list-years { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .sidebar-list-months { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .filters, .transaction-summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .analytics-list { grid-template-columns: 1fr; }
    .analytics-month-table-head,
    .analytics-month-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .dashboard { padding: 14px; }
    .hero-grid, .form-grid, .filters, .ring-summary, .form-switcher, .transaction-summary-strip { grid-template-columns: 1fr; }
    .dashboard-header, .quick-form, .donut-wrap, .panel-heading, .transaction-topline, .transaction-footer, .header-tools { flex-direction: column; }
    .sidebar-list-years { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .sidebar-list-months { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .donut-chart { width: 100%; height: 180px; }
    .expense-bar-row { grid-template-columns: 1fr; }
    .analytics-rank-row,
    .analytics-rank-label,
    .analytics-rank-values { align-items: start; }
    .analytics-rank-row,
    .analytics-month-table-head,
    .analytics-month-row { grid-template-columns: 1fr; }
}
