:root {
    color-scheme: light;
    --bg: #eef4ff;
    --panel: #ffffff;
    --text: #14213d;
    --muted: #5f6f8f;
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.1);
    --border: #dfe7f3;
    --danger: #dc2626;
    --success: #16a34a;
    --shadow: 0 16px 35px rgba(15, 23, 42, 0.08);
}

body.dark {
    color-scheme: dark;
    --bg: #07111f;
    --panel: #111c2e;
    --text: #f5f7fb;
    --muted: #95a3b8;
    --accent: #70b3ff;
    --accent-soft: rgba(112, 179, 255, 0.16);
    --border: #2e3d53;
    --danger: #f87171;
    --success: #4ade80;
    --shadow: 0 16px 35px rgba(0, 0, 0, 0.3);
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg), #f8fbff);
    color: var(--text);
    transition: background 0.2s ease, color 0.2s ease;
}

body.dark {
    background: linear-gradient(135deg, var(--bg), #0f172a);
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px;
}

.navbar,
.card,
.table-wrap,
.hero {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.navbar {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 22px;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    display: block;
    position: absolute;
    top: 16px;
    right: 22px;
    z-index: 30;
    width: 42px;
    height: 38px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--accent-soft);
    cursor: pointer;
    pointer-events: auto;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    margin: 4px auto;
    border-radius: 4px;
    background: var(--accent);
    transition: transform 0.25s ease, opacity 0.2s ease;
}

.menu-toggle.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.nav-links {
    display: none;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-links a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.nav-links a:hover {
    text-decoration: underline;
}

.navbar .nav-links.open {
    position: absolute;
    top: calc(100% - 8px);
    right: 22px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 190px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: var(--shadow);
    visibility: visible;
    max-height: 500px;
    animation: menuReveal 0.25s ease both;
}

@keyframes menuReveal {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    padding: 20px;
    margin-bottom: 18px;
}

.hero {
    padding: 14px 20px;
}

.hero-compact {
    padding: 12px 20px;
    margin-bottom: 14px;
}

.hero-title {
    margin: 0 0 2px;
    font-size: 16px;
    font-weight: 700;
}

.hero-subtitle {
    margin: 0;
    font-size: 13px;
}

.hero-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hero-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.hero-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.hero-actions .button {
    width: auto;
    margin-top: 0;
    padding: 7px 16px;
    font-size: 13px;
    white-space: nowrap;
}


/* Action buttons in hero */

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
    white-space: nowrap;
}

.btn-action:hover {
    transform: translateY(-1px);
    opacity: 0.92;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
}

.btn-secondary {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--border);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.stats {
    padding: 18px;
    border-left: 5px solid var(--accent);
    background: var(--accent-soft);
    border-radius: 12px;
}

form input,
form select,
form textarea,
form button,
.theme-toggle button,
.button {
    width: 100%;
    padding: 10px 12px;
    margin-top: 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
    box-sizing: border-box;
    font-size: 14px;
    transition: transform 0.2s ease, background 0.2s ease;
}

form input,
form select,
form textarea {
    background: var(--panel);
    color: var(--text);
}

form button,
.theme-toggle button,
.button {
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

form button:hover,
.theme-toggle button:hover,
.button:hover {
    transform: translateY(-1px);
    opacity: 0.95;
}

.button.secondary {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--border);
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.table-wrap {
    overflow-x: auto;
    padding: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.muted {
    color: var(--muted);
}

.badge {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge.income {
    background: rgba(22, 163, 74, 0.14);
    color: var(--success);
}

.badge.expense {
    background: rgba(220, 38, 38, 0.14);
    color: var(--danger);
}

.auth-box {
    max-width: 440px;
    margin: 50px auto;
    padding: 24px;
    background: var(--panel);
    border-radius: 18px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.auth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 12px;
}

.alert.success {
    background: rgba(22, 163, 74, 0.12);
    color: var(--success);
}

.alert.danger {
    background: rgba(220, 38, 38, 0.12);
    color: var(--danger);
}

.empty-state {
    padding: 16px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    color: var(--muted);
    text-align: center;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.budget-card {
    display: grid;
    gap: 10px;
}

.budget-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.budget-form input {
    max-width: 240px;
}

.budget-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    color: var(--muted);
}

.progress-bar {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.progress-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), #22c55e);
}

.filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.hint {
    margin-top: 10px;
    color: var(--muted);
    font-size: 14px;
}

.action-group {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.action-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.inline-form {
    display: inline-block;
}

.danger-button {
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}

.chart-card {
    min-height: 220px;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, var(--accent-soft), transparent);
}

.trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    min-height: 180px;
}

.trend-month {
    flex: 1;
    display: grid;
    gap: 8px;
    justify-items: center;
}

.trend-bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 140px;
    width: 100%;
    justify-content: center;
}

.trend-bar {
    width: 22px;
    border-radius: 8px 8px 0 0;
    min-height: 8px;
    transition: transform 0.2s ease, opacity 0.2s ease;
    cursor: pointer;
}

.trend-bar:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

.trend-bar.income {
    background: linear-gradient(180deg, #22c55e, #16a34a);
}

.trend-bar.expense {
    background: linear-gradient(180deg, #f59e0b, #dc2626);
}

.trend-label {
    font-size: 12px;
    color: var(--muted);
}

.toggle-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 600;
}

.toggle-row input {
    width: auto;
    margin: 0;
}

.chart-labels {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
}

.chart-caption {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
}

.profile-photo {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 50%;
    margin-bottom: 10px;
    border: 2px solid var(--border);
}

.reminder-card {
    display: grid;
    gap: 10px;
}

.insight-list {
    display: grid;
    gap: 8px;
}

.insight-item {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--accent-soft);
    color: var(--text);
}

.reminder-list {
    display: grid;
    gap: 8px;
}

.reminder-item {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--accent-soft);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.kpi-card {
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel);
}

.kpi-efficiency {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.kpi-card h4 {
    margin: 0 0 6px;
}

.kpi-card p {
    margin: 0;
    font-weight: 700;
}

.kpi-value {
    font-size: 22px;
    color: var(--accent);
}

.kpi-note {
    margin-top: 5px;
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
    line-height: 1.4;
}

.history-list {
    display: grid;
    gap: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--accent-soft);
}

.management-summary {
    display: grid;
    gap: 14px;
}

.management-highlight {
    padding: 16px;
    border-radius: 12px;
    background: var(--accent-soft);
    border: 1px solid var(--border);
}

.management-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.management-card {
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel);
}

.management-card h4 {
    margin: 0 0 6px;
}

.management-card p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.status-pill {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--accent);
    color: white;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
}

.link {
    color: var(--accent);
    text-decoration: none;
}

.toast-container {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 9999;
    display: grid;
    gap: 10px;
    max-width: min(360px, calc(100vw - 32px));
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 16px;
    color: white;
    font-weight: 700;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transform: translateX(18px);
    transition: transform 0.28s ease, opacity 0.28s ease;
    position: relative;
    overflow: hidden;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.toast.danger {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
}

.toast.warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: rgba(255, 255, 255, 0.35);
}

.toast.hidden {
    display: none !important;
}

.pagination {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.pagination a {
    min-width: 34px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--accent);
    text-align: center;
    text-decoration: none;
}

.pagination a.active,
.pagination a:hover {
    background: var(--accent);
    color: white;
}

@media (max-width: 700px) {
    .container {
        padding: 16px;
    }
    .navbar {
        padding: 14px;
    }
    .nav-links {
        display: grid;
        grid-template-rows: 0fr;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transform: translateY(-8px);
        transition: grid-template-rows 0.3s ease, max-height 0.3s ease, opacity 0.25s ease, transform 0.3s ease;
    }
    .brand-row {
        width: 100%;
        justify-content: space-between;
    }
    .menu-toggle {
        position: static;
        display: block;
    }
    .navbar .nav-links.open {
        position: static;
        display: grid;
        grid-template-rows: 1fr;
        max-height: 280px;
        opacity: 1;
        transform: translateY(0);
        padding-top: 10px;
        min-width: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }
    .navbar .nav-links>* {
        min-height: 0;
    }
    .navbar .nav-links a,
    .navbar .nav-links form {
        width: 100%;
    }
}

.chart-list {
    display: grid;
    gap: 16px;
}

.chart-row {
    display: grid;
    gap: 6px;
}

.chart-row small,
.net-column small {
    color: var(--muted);
}

.chart-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--border);
}

.chart-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
}

.chart-income,
.legend-income {
    background: #16a34a;
}

.chart-expense,
.legend-expense {
    background: #dc2626;
}

.legend-income,
.legend-expense {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 5px;
    border-radius: 50%;
}

.net-chart {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    min-height: 220px;
    overflow-x: auto;
    padding: 16px 8px 4px;
}

.net-column {
    display: flex;
    flex: 1 0 72px;
    min-width: 72px;
    height: 190px;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    text-align: center;
}

.net-bar {
    width: 30px;
    min-height: 8px;
    border-radius: 8px 8px 2px 2px;
}

.net-bar.positive {
    background: #16a34a;
}

.net-bar.negative {
    background: #dc2626;
}