:root {
    color-scheme: light dark;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #243138;
    background: #f5f7f9;
    --bg: #f5f7f9;
    --panel: #ffffff;
    --surface: #ffffff;
    --text: #243138;
    --muted: #7a8b96;
    --primary: #5FA58D;
    --secondary: #4A8B76;
    --accent: #FFC107;
    --danger: #EF5B5B;
    --success: #2D9C7C;
    --shadow: 0 24px 50px rgba(52, 67, 88, 0.08);
    --radius: 28px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
}

body {
    font-size: 16px;
    line-height: 1.5;
}

button, input {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

.app-shell {
    min-height: 100vh;
    position: relative;
}

.page {
    padding: 1rem;
    max-width: 960px;
    margin: 0 auto;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 2rem 1rem;
}

.card {
    background: var(--panel);
    border-radius: 32px;
    box-shadow: var(--shadow);
    padding: 1.75rem;
}

.auth-card {
    width: min(100%, 420px);
}

.auth-brand {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.75rem;
}

.brand-badge {
    width: 3.125rem;
    height: 3.125rem;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 14px 32px rgba(95, 165, 141, 0.22);
}

.auth-brand h1 {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
}

.auth-brand p {
    margin: 0;
    color: var(--muted);
}

.form-group {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.form-group span {
    font-size: 0.95rem;
    color: var(--muted);
}

input[type='email'],
input[type='password'],
input[type='text'],
input[type='email'],
input[type='password'],
select,
textarea {
    width: 100%;
    border-radius: 18px;
    border: 1px solid #e0e6eb;
    background: #f7f9fb;
    padding: 1rem 1rem;
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-card input[type='text'],
.auth-card input[type='email'],
.auth-card input[type='password'],
.auth-card select,
.auth-card textarea {
    color: #243138 !important;
    background: #f7f9fb !important;
    caret-color: #243138;
}

input[type='text']:focus,
input[type='email']:focus,
input[type='password']:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(95, 165, 141, 0.12);
}

.btn {
    border: none;
    border-radius: 18px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3.4rem;
    padding: 0 1.4rem;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    box-shadow: 0 14px 32px rgba(95, 165, 141, 0.24);
}

.btn-block {
    width: 100%;
}

.alert {
    border-radius: 20px;
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.alert-danger {
    background: #ffe7e6;
    color: #8a1f1f;
}

.small-text {
    color: var(--muted);
    font-size: 0.95rem;
    margin-top: 1rem;
}

.dashboard-page,
.admin-page {
    padding-bottom: 5rem;
}

.app-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.btn-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid #e6ebf0;
    color: var(--text);
    cursor: pointer;
}

.admin-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-top: 1.25rem;
}

.admin-card {
    background: var(--surface);
    border-radius: 28px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: grid;
    gap: 1rem;
}

.admin-card h2 {
    margin: 0;
    font-size: 1.15rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 0.95rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e9eef2;
}

.admin-table th {
    font-weight: 700;
    color: var(--muted);
}

.table-responsive {
    overflow-x: auto;
}

.drawer-section-title {
    margin: 1.25rem 0 0.75rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
}

.admin-card-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: rgba(95, 165, 141, 0.12);
    color: var(--primary);
    font-size: 1.3rem;
}

.global-menu-toggle {
    display: grid;
}

@media (min-width: 900px) {
    .global-menu-toggle {
        display: none;
    }
}

.dashboard-inner {
    display: grid;
    gap: 1.25rem;
}

.balance-card {
    background: linear-gradient(180deg, #5FA58D 0%, #4A8B76 100%);
    border-radius: 32px;
    padding: 1.5rem;
    color: #fff;
    box-shadow: 0 26px 60px rgba(41, 118, 81, 0.18);
}

.balance-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.balance-card h1 {
    margin: 0.5rem 0 0;
    font-size: clamp(2rem, 4vw, 3rem);
}

.balance-label {
    text-transform: uppercase;
    letter-spacing: 0.22em;
    opacity: 0.9;
    font-size: 0.85rem;
    margin: 0;
}

.balance-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: rgba(255,255,255,0.12);
    border-radius: 24px;
    padding: 1rem;
    margin-top: 1.25rem;
}

.balance-meta span {
    font-size: 0.9rem;
    opacity: 0.9;
}

.balance-meta strong {
    font-size: 1.5rem;
}

.segment-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.segment {
    border: none;
    border-radius: 999px;
    padding: 0.9rem 1rem;
    background: rgba(255,255,255,0.15);
    color: #f7f9fb;
    font-weight: 700;
    transition: background 0.2s ease, color 0.2s ease;
}

.segment.active {
    background: #fff;
    color: #243138;
}

.chart-summary {
    display: grid;
    gap: 1rem;
}

.modern-chart-card {
    background: var(--surface);
    border-radius: 32px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.chart-card-title {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.chart-card-title h2 {
    margin: 0;
    font-size: 1.2rem;
}

.chart-wrapper {
    position: relative;
    min-height: 280px;
}

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

.chart-value {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    font-size: 1.75rem;
    font-weight: 700;
    color: #243138;
}

.stats-row {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
}

.stats-badge {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f5f7f9;
    border-radius: 20px;
    padding: 0.9rem 1rem;
}

.stats-badge strong {
    display: block;
}

.stats-badge span {
    color: var(--muted);
}

.category-list {
    display: grid;
    gap: 0.95rem;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--surface);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.category-meta {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.category-icon {
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 16px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.15rem;
}

.category-label strong {
    display: block;
    font-size: 1rem;
}

.category-label small {
    color: var(--muted);
}

.category-value {
    text-align: right;
}

.category-value strong {
    display: block;
}

.category-value span {
    color: var(--muted);
    font-size: 0.9rem;
}

.tag {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    font-size: 0.9rem;
    color: #fff;
}

.tag.positive { background: #4aaf80; }
.tag.negative { background: #ef5b5b; }
.tag.accent { background: #ffc107; color: #243138; }
.tag.neutral { background: #6c7b8a; }

.overview-panel {
    margin-top: 1.5rem;
    display: grid;
    gap: 1rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.panel-header h2 {
    margin: 0;
}

.panel-header p {
    margin: 0.5rem 0 0;
    color: var(--muted);
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.tab {
    border: none;
    background: #fff;
    color: var(--muted);
    border-radius: 999px;
    padding: 0.8rem 1rem;
    font-weight: 600;
    cursor: pointer;
}

.tab.active {
    background: var(--primary);
    color: #fff;
}

.charts-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.section-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-header h1 {
    margin: 0;
    font-size: clamp(1.5rem, 2vw, 2.25rem);
}

.section-header .eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    font-size: 0.8rem;
}

.cards-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.settings-panel,
.category-card,
.account-card,
.budget-card,
.goal-card,
.recurring-card,
.reminder-card {
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.category-card,
.account-card,
.budget-card,
.goal-card,
.recurring-card,
.reminder-card {
    padding: 1.25rem;
}

.category-icon,
.account-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 18px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.account-header,
.goal-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.account-balance {
    font-size: 1.75rem;
    font-weight: 700;
}

.budget-progress,
.progress-bar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-bar {
    background: rgba(95, 165, 141, 0.12);
    border-radius: 999px;
    height: 0.85rem;
    overflow: hidden;
}

.progress-bar div {
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.budget-description,
.goal-card p {
    margin: 0.75rem 0 0;
    color: var(--muted);
}

.panel-header {
    flex-wrap: wrap;
}

.panel-header > * {
    flex: 1;
}

@media (min-width: 900px) {
    .section-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.chart-card,
.transactions-card,
.form-card,
.import-panel,
.document-card,
.export-card {
    background: var(--surface);
    border-radius: 32px;
    padding: 1.4rem;
    box-shadow: var(--shadow);
}

.form-card {
    margin-bottom: 1rem;
}

.transaction-form,
.form-card form {
    display: grid;
    gap: 1rem;
}

.form-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.form-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    color: var(--muted);
}

.form-checkbox input {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--primary);
}

.document-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.document-meta h3,
.export-card h3 {
    margin: 0 0 0.35rem;
}

.export-card {
    display: grid;
    gap: 1rem;
}

.export-card button {
    justify-self: start;
}

.calendar-card,
.profile-card,
.settings-panel {
    padding: 1.4rem;
}

.chart-card header,
.transactions-card header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.chart-card h3,
.transactions-card h3 {
    margin: 0;
    font-size: 1.05rem;
}

.link-button {
    color: var(--primary);
    font-weight: 700;
}

.transaction-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.85rem;
}

.transaction-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 22px;
    background: #f8fbfd;
}

.drawer-nav a {
    transition: background 0.2s ease, border-color 0.2s ease;
}

.drawer-nav a.active {
    background: rgba(95, 165, 141, 0.18);
    color: var(--primary);
    border-color: rgba(95, 165, 141, 0.3);
}

.transaction-list strong {
    display: block;
    margin-bottom: 0.35rem;
}

.amount {
    font-weight: 700;
}

.amount.negative {
    color: var(--danger);
}

.amount.positive {
    color: var(--success);
}

.global-menu-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 18px;
    border: none;
    background: var(--surface);
    color: var(--text);
    display: grid;
    place-items: center;
    box-shadow: var(--shadow);
    z-index: 1100;
    cursor: pointer;
}

.fab {
    position: fixed;
    right: 1.25rem;
    bottom: 1.75rem;
    width: 4.25rem;
    height: 4.25rem;
    border-radius: 50%;
    background: var(--accent);
    color: #243138;
    border: none;
    display: grid;
    place-items: center;
    box-shadow: 0 18px 42px rgba(255, 193, 7, 0.28);
    cursor: pointer;
}

.drawer {
    position: fixed;
    inset: 0 auto auto 0;
    z-index: 1000;
    width: min(88vw, 320px);
    max-width: 100%;
    height: 100vh;
    background: var(--surface);
    border-radius: 0 32px 32px 0;
    transform: translateX(-110%);
    transition: transform 0.25s ease;
    box-shadow: 24px 0 72px rgba(0, 0, 0, 0.12);
    overflow-y: auto;
    padding: 1rem;
}

.drawer.open {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.drawer-header h2 {
    margin: 0;
}

.drawer-close {
    border: none;
    background: transparent;
    font-size: 1.2rem;
    color: var(--text);
    cursor: pointer;
}

.drawer-nav {
    display: grid;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.95rem 1rem;
    border-radius: 22px;
    color: var(--text);
    background: #f6f8fa;
    border: 1px solid transparent;
}

.nav-link.active,
.nav-link:hover {
    background: rgba(95, 165, 141, 0.12);
    border-color: rgba(95, 165, 141, 0.2);
}

.nav-logout {
    margin-top: 1rem;
    color: var(--danger);
}

@media (max-width: 800px) {
    .dashboard-inner {
        gap: 1rem;
    }

    .balance-card,
    .modern-chart-card,
    .category-item {
        padding: 1.25rem;
    }

    .chart-card-title {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .chart-value {
        font-size: 1.35rem;
    }
}

@media (max-width: 620px) {
    .balance-card {
        border-radius: 28px;
    }

    .balance-top-row,
    .stats-row,
    .category-item {
        gap: 0.75rem;
    }

    .segment-tabs {
        grid-template-columns: 1fr;
    }

    .category-item {
        flex-direction: column;
        align-items: stretch;
        text-align: left;
    }

    .category-value {
        text-align: left;
        margin-top: 0.75rem;
    }
}

@media (min-width: 900px) {
    .page {
        padding: 2rem;
    }
    .drawer {
        position: static;
        transform: none;
        width: 280px;
        height: auto;
        border-radius: 32px;
        box-shadow: var(--shadow);
        margin-bottom: 1rem;
    }
    .dashboard-page {
        display: grid;
        grid-template-columns: 280px 1fr;
        gap: 1rem;
    }
    .app-bar {
        grid-column: 2;
    }
    .overview-panel {
        grid-column: 2;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        color: #f1f5f8;
        background: #121b22;
        --bg: #121b22;
        --panel: #16212a;
        --surface: #192834;
        --text: #f1f5f8;
        --muted: #8ea3b4;
        --shadow: 0 24px 50px rgba(0, 0, 0, 0.45);
    }
    input, textarea, select {
        background: #0f1720;
        border-color: #253344;
        color: #f1f5f8;
    }
    .nav-link,
    .chart-card,
    .transactions-card,
    .stat-card,
    .auth-card {
        background: var(--surface);
    }
}
