* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, Poppins, Arial, sans-serif;
    background: #f8fafc;
    color: #0f172a;
    transition: background 0.25s ease, color 0.25s ease;
}

a {
    color: #16a34a;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.main-panel {
    flex: 1;
    min-width: 0;
}

.sidebar {
    width: 280px;
    background: #0f172a;
    color: #e2e8f0;
    padding: 1.5rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 18px 0 30px rgba(15, 23, 42, 0.08);
}

.sidebar-overlay {
    display: none;
}

.sidebar-brand {
    padding: 0.35rem 1rem 0.55rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    color: #ffffff;
    opacity: 0.96;
    transition: opacity 0.2s ease, filter 0.2s ease;
}

.brand:hover {
    text-decoration: none;
    opacity: 1;
    filter: brightness(1.05);
}

.brand-icon {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    flex: 0 0 26px;
}

.brand-icon svg {
    width: 100%;
    height: 100%;
}

.brand-text {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1;
    white-space: nowrap;
}

.brand-expense {
    color: #ffffff;
}

.brand-tracker {
    color: #22c55e;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem 2rem 0.5rem;
    color: #0f172a;
}

.subtitle {
    margin: 0.55rem 0 0;
    color: rgba(148, 163, 184, 0.6);
    font-size: 0.88rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    color: #cbd5e1;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.nav-item:hover {
    background: rgba(148, 163, 184, 0.14);
    color: #ffffff;
    text-decoration: none;
    transform: translateX(2px);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(22, 163, 74, 0.18));
    color: #dcfce7;
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.2);
}

.nav-item.disabled {
    opacity: 0.58;
    cursor: default;
}

.nav-item.disabled small {
    margin-left: auto;
    color: #86efac;
}

.nav-icon {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
}

.nav-icon svg,
.metric-icon svg,
.icon-button svg {
    width: 1.2rem;
    height: 1.2rem;
}

.sidebar-footer {
    margin-top: auto;
    padding: 0 0.6rem;
}

.sidebar-logout {
    width: 100%;
}

.topbar-left,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-action-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.eyebrow {
    margin: 0 0 0.25rem;
    color: #22c55e;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.topbar-title {
    margin: 0;
    font-size: 1.95rem;
    font-weight: 800;
}

.topbar-subtitle {
    margin: 0.35rem 0 0;
    color: #64748b;
    font-size: 0.98rem;
}

.menu-toggle,
.icon-button {
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border-radius: 14px;
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.menu-toggle {
    display: none;
}

.icon-button svg {
    color: #0f172a;
}

.profile-chip {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.5rem 0.8rem;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.profile-chip small {
    display: block;
    color: #64748b;
}

.profile-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dcfce7;
    color: #15803d;
    font-weight: 700;
}

.container {
    width: min(1180px, calc(100% - 2.5rem));
    margin: 1rem auto 2rem;
}

.grid {
    display: grid;
    gap: 1rem;
}

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

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

.card {
    background: #ffffff;
    border-radius: 24px;
    padding: 1.4rem;
    border: 1px solid rgba(148, 163, 184, 0.16);
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 26px 50px rgba(15, 23, 42, 0.08);
}

.card h2,
.card h3 {
    margin-top: 0;
}

.metric {
    font-size: 2.25rem;
    font-weight: 800;
    margin: 0.35rem 0 0;
    letter-spacing: -0.03em;
}

.negative-balance {
    color: #e53935;
    font-weight: 600;
}

.metric.negative-balance {
    color: #e53935;
}

body.theme-dark .metric.negative-balance {
    color: #f87171;
}

.hero-card,
.metric-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.hero-card h2 {
    margin: 0.4rem 0 0.6rem;
    font-size: 2.2rem;
    line-height: 1.2;
    letter-spacing: -0.03em;
}

.metric-card {
    align-items: flex-start;
}

.metric-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    color: #15803d;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.12);
}

.muted {
    color: #64748b;
}

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

.section-header h1,
.section-header h2 {
    margin: 0;
}

.card-header-block h2 {
    margin-bottom: 0.3rem;
}

.card-header-block p {
    margin-top: 0;
}

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

.field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.field.full {
    grid-column: 1 / -1;
}

label {
    font-weight: 600;
}

input,
select,
button,
textarea {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border: 1px solid #dbe4ee;
    border-radius: 16px;
    background: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1rem;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(34, 197, 94, 0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.button-lg {
    padding: 0.95rem 1.35rem;
    font-size: 1rem;
}

.dashboard-cta {
    min-width: 148px;
}

button.secondary,
.button.secondary {
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #dbe4ee;
    box-shadow: none;
}

button.danger,
.button.danger {
    background: #dc2626;
    color: #ffffff;
    box-shadow: none;
}

button.warning,
.button.warning {
    background: #d97706;
    color: #ffffff;
    box-shadow: none;
}

.button:hover,
button:hover {
    opacity: 0.92;
    text-decoration: none;
    transform: translateY(-1px);
}

button:disabled,
.button:disabled,
.is-loading {
    cursor: wait;
    opacity: 0.8;
    transform: none;
}

.alert {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    font-weight: 600;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.toast-stack {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 60;
    display: grid;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    min-width: 260px;
    max-width: 360px;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    background: #0f172a;
    color: #ffffff;
    box-shadow: 0 22px 45px rgba(15, 23, 42, 0.2);
    transform: translateY(-8px);
    opacity: 0;
    transition: opacity 0.24s ease, transform 0.24s ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.toast-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.toast.toast-error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.toast.toast-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.55rem;
}

th,
td {
    padding: 1rem 0.9rem;
    text-align: left;
    vertical-align: middle;
}

th {
    color: #475569;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-bottom: 0.4rem;
}

tbody tr:hover {
    background: #f8fafc;
}

.categories-table tbody tr {
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.categories-table tbody td {
    background: #ffffff;
    border-top: 1px solid #eef2f7;
    border-bottom: 1px solid #eef2f7;
}

.categories-table tbody td:first-child {
    border-left: 1px solid #eef2f7;
    border-top-left-radius: 18px;
    border-bottom-left-radius: 18px;
}

.categories-table tbody td:last-child {
    border-right: 1px solid #eef2f7;
    border-top-right-radius: 18px;
    border-bottom-right-radius: 18px;
}

.categories-table tbody tr:hover td {
    background: #f8fafc;
    transform: translateY(-1px);
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 0.85rem;
    font-weight: 700;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-soft {
    background: #f1f5f9;
    color: #475569;
}

.badge-soft-green {
    background: #dcfce7;
    color: #16a34a;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.button-sm,
button.button-sm {
    padding: 0.55rem 0.8rem;
    border-radius: 12px;
    font-size: 0.92rem;
    box-shadow: none;
}

.category-icon-cell {
    width: 54px;
}

.category-icon {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #475569;
}

.category-icon svg {
    width: 20px;
    height: 20px;
}

.field-note {
    color: #94a3b8;
    font-size: 0.85rem;
}

.category-form-actions {
    margin-top: 1rem;
}

.category-form-actions .auth-submit {
    width: 100%;
}

.actions-heading {
    text-align: right;
}

.category-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.55rem;
}

.icon-outline-button {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid #dbe4ee;
    border-radius: 14px;
    background: #ffffff;
    color: #475569;
    box-shadow: none;
}

.icon-outline-button svg {
    width: 1rem;
    height: 1rem;
}

.icon-outline-button:hover {
    border-color: #22c55e;
    background: #f0fdf4;
    color: #15803d;
}

.icon-outline-danger:hover {
    border-color: #fecaca;
    background: #fef2f2;
    color: #dc2626;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(6px);
    z-index: 70;
    pointer-events: auto;
}

.modal-backdrop[hidden] {
    display: none !important;
}

.modal-card {
    width: min(100%, 520px);
    background: #ffffff;
    border-radius: 24px;
    padding: 1.4rem;
    box-shadow: 0 28px 70px rgba(15, 23, 42, 0.18);
    pointer-events: auto;
}

.modal-card-sm {
    width: min(100%, 440px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.modal-header h3 {
    margin: 0 0 0.3rem;
    font-size: 1.2rem;
}

.modal-header p {
    margin: 0;
}

.modal-close {
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    border-radius: 999px;
    background: #f8fafc;
    color: #475569;
    box-shadow: none;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.modal-highlight {
    margin: 0;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    background: #f8fafc;
    color: #0f172a;
    font-weight: 700;
}

.inline-form {
    display: inline;
}

.auth-card {
    max-width: 480px;
    width: 100%;
    margin: 0;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

.auth-card > * + * {
    margin-top: 14px;
}

.auth-logo-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 0;
}

.auth-logo-icon {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #0f172a;
    flex: 0 0 44px;
}

.auth-logo-icon svg {
    width: 100%;
    height: 100%;
}

.auth-logo-text {
    font-size: 1.8rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.03em;
    white-space: nowrap;
}

.auth-logo-expense {
    color: #0f172a;
}

.auth-logo-tracker {
    color: #22c55e;
}

.auth-header {
    text-align: center;
    margin-bottom: 0;
}

.auth-welcome {
    margin: 0 0 0.7rem;
    color: #16a34a;
    font-size: 14px;
    font-weight: 600;
}

.auth-title {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    color: #0f172a;
}

.auth-subtitle {
    margin: 0.55rem 0 0;
    color: #64748b;
    font-size: 0.96rem;
    line-height: 1.5;
}

.auth-card .form-grid {
    gap: 1.1rem;
}

.auth-card label {
    text-align: left;
}

.auth-link {
    margin: 1.15rem 0 1.2rem;
    text-align: center;
}

.auth-submit {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 8px 20px rgba(34, 197, 94, 0.25);
    transition: 0.2s;
}

.auth-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(34, 197, 94, 0.35);
}

.chart-card canvas {
    width: 100%;
    min-height: 260px;
    max-height: 260px;
}

.chart-card {
    position: relative;
    content-visibility: auto;
    contain-intrinsic-size: 340px;
}

.chart-empty-state {
    min-height: 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    border: 1px dashed #dbe4ee;
    border-radius: 20px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    text-align: center;
    padding: 1.5rem;
    color: #64748b;
}

.chart-skeleton {
    width: min(220px, 80%);
    height: 160px;
    border-radius: 18px;
    background: linear-gradient(90deg, #e2e8f0 25%, #f8fafc 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.6s infinite linear;
}

.metrics-grid,
.section-gap {
    margin-top: 1.25rem;
}

.expenses-layout {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr);
    gap: 1rem;
}

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

.settings-card {
    border-radius: 20px;
}

.settings-card-wide {
    grid-column: 1 / -1;
}

.settings-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.settings-card-header h2 {
    margin: 0.25rem 0 0.35rem;
}

.settings-eyebrow {
    margin: 0;
}

.settings-eyebrow-danger {
    color: #dc2626;
}

.settings-avatar-preview {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    color: #15803d;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    overflow: hidden;
    flex: 0 0 72px;
}

.settings-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-choice-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.avatar-choice-button.is-active {
    border-color: #22c55e;
    background: #f0fdf4;
    color: #15803d;
}

.avatar-upload-panel {
    display: none;
    margin-top: 0.85rem;
    gap: 0.85rem;
}

.avatar-upload-panel.is-visible {
    display: grid;
}

.settings-actions {
    margin-top: 1.1rem;
    display: flex;
    justify-content: flex-end;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 4.5rem;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 0.55rem;
    transform: translateY(-50%);
    padding: 0.45rem 0.7rem;
    border-radius: 10px;
    background: #f8fafc;
    color: #475569;
    box-shadow: none;
}

.password-toggle:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.settings-switch-list {
    display: grid;
    gap: 1rem;
}

.settings-switch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.05rem;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    background: #f8fafc;
}

.settings-switch-row strong,
.settings-switch-row small {
    display: block;
}

.switch {
    position: relative;
    display: inline-flex;
    width: 54px;
    height: 32px;
    flex: 0 0 54px;
}

.switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background 0.2s ease;
}

.switch-slider::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
    transition: transform 0.2s ease;
}

.switch input:checked + .switch-slider {
    background: #22c55e;
}

.switch input:checked + .switch-slider::before {
    transform: translateX(22px);
}

.danger-zone-card {
    border: 1px solid rgba(220, 38, 38, 0.15);
    background: linear-gradient(180deg, #ffffff 0%, #fff7f7 100%);
}

.settings-danger-banner {
    margin-top: 1rem;
    padding: 0.95rem 1rem;
    border-radius: 16px;
    background: #fee2e2;
    color: #991b1b;
}

body.theme-dark {
    background: #020617;
    color: #e2e8f0;
}

body.theme-dark .app-shell {
    background: linear-gradient(180deg, #020617 0%, #0f172a 100%);
}

body.theme-dark a {
    color: #4ade80;
}

body.theme-dark a:hover {
    color: #86efac;
}

body.theme-dark .topbar,
body.theme-dark .topbar-title,
body.theme-dark .modal-header h3,
body.theme-dark .modal-highlight,
body.theme-dark .settings-switch-row strong,
body.theme-dark .card h2,
body.theme-dark .card h3,
body.theme-dark .metric,
body.theme-dark th,
body.theme-dark td,
body.theme-dark strong,
body.theme-dark .auth-title,
body.theme-dark .auth-logo-expense,
body.theme-dark label {
    color: #f8fafc;
}

body.theme-dark .topbar-subtitle,
body.theme-dark .muted,
body.theme-dark .profile-chip small,
body.theme-dark .subtitle,
body.theme-dark .field-note,
body.theme-dark .settings-switch-row small {
    color: #94a3b8;
}

body.theme-dark .card,
body.theme-dark .profile-chip,
body.theme-dark .icon-button,
body.theme-dark .menu-toggle,
body.theme-dark .modal-card,
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea,
body.theme-dark .settings-switch-row,
body.theme-dark .category-icon,
body.theme-dark .quick-link,
body.theme-dark .auth-card,
body.theme-dark .radio-pill span,
body.theme-dark .nav-item.disabled,
body.theme-dark .table-wrap,
body.theme-dark .chart-empty-state {
    background: #0f172a;
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.2);
    box-shadow: 0 20px 45px rgba(2, 6, 23, 0.35);
}

body.theme-dark .table-card,
body.theme-dark .categories-table tbody td,
body.theme-dark table,
body.theme-dark .chart-card,
body.theme-dark .expense-form-card,
body.theme-dark .filter-card {
    background: #0f172a;
}

body.theme-dark .card,
body.theme-dark .auth-card,
body.theme-dark .chart-card,
body.theme-dark .table-card,
body.theme-dark .expense-form-card,
body.theme-dark .filter-card {
    border-color: rgba(148, 163, 184, 0.18);
    box-shadow: 0 22px 48px rgba(2, 6, 23, 0.42);
}

body.theme-dark .card:hover,
body.theme-dark .quick-link:hover,
body.theme-dark .categories-table tbody tr:hover td {
    box-shadow: 0 26px 52px rgba(2, 6, 23, 0.48);
}

body.theme-dark .icon-button svg,
body.theme-dark .menu-toggle,
body.theme-dark .password-toggle,
body.theme-dark .modal-close,
body.theme-dark .button.secondary,
body.theme-dark button.secondary {
    color: #e2e8f0;
}

body.theme-dark .button.secondary,
body.theme-dark button.secondary,
body.theme-dark .password-toggle,
body.theme-dark .modal-close {
    background: #111c30;
    border-color: rgba(148, 163, 184, 0.22);
}

body.theme-dark .button.secondary:hover,
body.theme-dark button.secondary:hover,
body.theme-dark .password-toggle:hover,
body.theme-dark .modal-close:hover,
body.theme-dark .icon-outline-button:hover {
    background: #162338;
}

body.theme-dark .nav-item.active {
    color: #dcfce7;
}

body.theme-dark .profile-avatar,
body.theme-dark .settings-avatar-preview {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.22), rgba(22, 163, 74, 0.22));
    color: #bbf7d0;
}

body.theme-dark .metric-icon {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.18), rgba(22, 163, 74, 0.22));
    color: #86efac;
    box-shadow: inset 0 0 0 1px rgba(74, 222, 128, 0.18);
}

body.theme-dark .hero-card,
body.theme-dark .metric-card {
    background: #0f172a;
}

body.theme-dark th {
    color: #94a3b8;
}

body.theme-dark td {
    border-color: rgba(148, 163, 184, 0.14);
}

body.theme-dark tbody tr:hover {
    background: rgba(148, 163, 184, 0.06);
}

body.theme-dark .categories-table tbody td,
body.theme-dark .categories-table tbody td:first-child,
body.theme-dark .categories-table tbody td:last-child {
    border-color: rgba(148, 163, 184, 0.14);
}

body.theme-dark .categories-table tbody tr:hover td {
    background: #111c30;
}

body.theme-dark .quick-link {
    background: #111827;
    border-color: rgba(148, 163, 184, 0.18);
}

body.theme-dark .quick-link:hover {
    border-color: rgba(74, 222, 128, 0.32);
    background: #162033;
}

body.theme-dark .chart-empty-state {
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    border-color: rgba(148, 163, 184, 0.18);
    color: #94a3b8;
}

body.theme-dark .chart-skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #0f172a 50%, #1e293b 75%);
    background-size: 200% 100%;
}

body.theme-dark .radio-pill span {
    background: #0f172a;
    border-color: rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
}

body.theme-dark .radio-pill input:checked + span {
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
    border-color: rgba(74, 222, 128, 0.4);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}

body.theme-dark .badge-soft {
    background: #1e293b;
    color: #cbd5e1;
}

body.theme-dark .badge-soft-green,
body.theme-dark .badge-success {
    background: rgba(34, 197, 94, 0.16);
    color: #86efac;
}

body.theme-dark .badge-warning {
    background: rgba(245, 158, 11, 0.18);
    color: #fcd34d;
}

body.theme-dark .icon-outline-button {
    background: #111827;
    color: #cbd5e1;
    border-color: rgba(148, 163, 184, 0.18);
}

body.theme-dark .icon-outline-button:hover {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(74, 222, 128, 0.3);
    color: #86efac;
}

body.theme-dark .icon-outline-danger:hover {
    background: rgba(220, 38, 38, 0.14);
    border-color: rgba(248, 113, 113, 0.24);
    color: #fca5a5;
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
    background: #111827;
    color: #f8fafc;
    border-color: rgba(148, 163, 184, 0.18);
}

body.theme-dark input::placeholder,
body.theme-dark textarea::placeholder {
    color: #64748b;
}

body.theme-dark input:focus,
body.theme-dark select:focus,
body.theme-dark textarea:focus {
    border-color: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16);
}

body.theme-dark .auth-subtitle,
body.theme-dark .auth-link,
body.theme-dark .auth-logo-text,
body.theme-dark .auth-logo-icon,
body.theme-dark .auth-card label {
    color: #e2e8f0;
}

body.theme-dark .auth-card {
    background: #0f172a;
}

body.theme-dark .auth-logo-expense {
    color: #f8fafc;
}

body.theme-dark .auth-submit {
    box-shadow: 0 10px 25px rgba(34, 197, 94, 0.2);
}

body.theme-dark .alert-success {
    background: rgba(34, 197, 94, 0.16);
    color: #86efac;
}

body.theme-dark .alert-error {
    background: rgba(220, 38, 38, 0.18);
    color: #fecaca;
}

body.theme-dark .settings-danger-banner {
    background: rgba(127, 29, 29, 0.28);
    color: #fecaca;
}

body.theme-dark .danger-zone-card {
    background: linear-gradient(180deg, #0f172a 0%, #1f2937 100%);
    border-color: rgba(248, 113, 113, 0.2);
}

body.theme-dark .switch-slider {
    background: #334155;
}

body.theme-dark .toast {
    box-shadow: 0 22px 45px rgba(2, 6, 23, 0.55);
}

.expense-summary-card {
    border-top: 4px solid #22c55e;
}

.expense-form-card,
.filter-card,
.table-card {
    overflow: hidden;
}

.radio-group {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    padding-top: 0.1rem;
}

.radio-pill {
    position: relative;
    cursor: pointer;
}

.radio-pill input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.radio-pill span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    padding: 0.85rem 1rem;
    border-radius: 16px;
    border: 1px solid #dbe4ee;
    background: #ffffff;
    color: #0f172a;
    font-weight: 600;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.radio-pill input:checked + span {
    border-color: #22c55e;
    background: #f0fdf4;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
    color: #15803d;
}

.table-meta {
    margin-top: 0.45rem;
}

.table-actions-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.7rem;
}

.amount-positive {
    color: #15803d;
    font-weight: 700;
}

.amount-negative {
    color: #dc2626;
    font-weight: 700;
}

.quick-links {
    display: grid;
    gap: 0.9rem;
}

.quick-link {
    display: block;
    padding: 1rem 1.1rem;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.quick-link:hover {
    text-decoration: none;
    transform: translateY(-2px);
    border-color: rgba(34, 197, 94, 0.28);
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.06);
}

.quick-link span {
    display: block;
    margin-top: 0.25rem;
    color: #64748b;
}

.topbar-actions > * {
    flex-shrink: 0;
}

.guest-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.guest-container > * {
    width: min(100%, 480px);
}

.guest-container .alert {
    margin-bottom: 0;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

@media (max-width: 900px) {
    .grid-3,
    .grid-2,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .expenses-layout {
        grid-template-columns: 1fr;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .topbar,
    .section-header,
    .hero-card,
    .metric-card,
    .settings-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(82vw, 300px);
        max-width: 300px;
        transform: translateX(-100%);
        transition: transform 0.24s ease;
        z-index: 40;
        overflow-y: auto;
    }

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

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        border: 0;
        padding: 0;
        margin: 0;
        background: rgba(15, 23, 42, 0.48);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 30;
    }

    .sidebar-overlay.open {
        opacity: 1;
        pointer-events: auto;
    }

    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .container {
        width: min(1180px, calc(100% - 1.2rem));
        margin: 0.75rem auto 1.5rem;
    }

    .topbar {
        padding: 1rem 0.75rem 0.5rem;
    }

    .profile-chip {
        width: 100%;
    }

    .topbar-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .topbar-actions .button,
    .topbar-actions .button-lg,
    .topbar-actions .icon-button,
    .sidebar-logout,
    .actions .button,
    .actions button,
    .table-actions-inline .button,
    .table-actions-inline button,
    .settings-actions .button,
    .category-form-actions .auth-submit {
        width: 100%;
    }

    .topbar-title {
        font-size: 1.55rem;
        line-height: 1.15;
    }

    .topbar-subtitle,
    .auth-subtitle,
    .muted,
    .subtitle {
        font-size: 0.92rem;
    }

    .metric {
        font-size: 1.75rem;
        word-break: break-word;
    }

    .card,
    .auth-card {
        padding: 1rem;
        border-radius: 18px;
        box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
    }

    .card:hover,
    .auth-card:hover {
        transform: none;
    }

    .hero-card h2 {
        font-size: 1.7rem;
    }

    .metric-icon {
        width: 2.7rem;
        height: 2.7rem;
    }

    .settings-avatar-preview {
        width: 60px;
        height: 60px;
        border-radius: 16px;
        flex-basis: 60px;
    }

    .table-wrap {
        margin: 0 -0.2rem;
    }

    table {
        min-width: 620px;
    }

    th,
    td {
        padding: 0.85rem 0.75rem;
        font-size: 0.94rem;
    }

    .toast-stack {
        top: 0.85rem;
        right: 0.85rem;
        left: 0.85rem;
    }

    .toast {
        max-width: none;
        min-width: 0;
    }

    .category-actions {
        justify-content: flex-start;
    }

    .settings-switch-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .settings-switch-row .switch {
        align-self: center;
    }

    .modal-card,
    .modal-card-sm {
        width: min(100%, 94vw);
        padding: 1rem;
        border-radius: 20px;
    }

    .modal-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .brand-text {
        display: none;
    }
}

@media (max-width: 768px) {
    .grid-3,
    .grid-2,
    .settings-grid,
    .expenses-layout,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .section-gap,
    .metrics-grid {
        margin-top: 1rem;
    }

    .radio-group,
    .actions,
    .table-actions-inline,
    .avatar-choice-row {
        flex-direction: column;
        align-items: stretch;
    }

    .settings-switch-row {
        flex-direction: row;
        align-items: center;
        gap: 0.85rem;
    }

    .settings-switch-row span:first-child {
        flex: 1;
        min-width: 0;
    }

    .radio-pill span {
        width: 100%;
        min-width: 0;
    }

    input,
    select,
    textarea,
    button,
    .button {
        min-height: 48px;
    }

    .nav-item {
        padding: 0.85rem 0.9rem;
    }

    .quick-link {
        padding: 0.95rem 1rem;
    }
}
