* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #f6f7fb;
    --bg-soft: #eef4ff;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #dbeafe;
    --green: #16a34a;
    --green-soft: #dcfce7;
    --red: #dc2626;
    --red-soft: #fee2e2;
    --yellow-soft: #fef3c7;
    --yellow-text: #92400e;
    --border: #e5e7eb;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 10px 24px rgba(15, 23, 42, 0.06);
    --radius: 18px;
    --transition: 0.22s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 28%),
        linear-gradient(135deg, #f8fafc 0%, var(--bg) 100%);
    color: var(--text);
    line-height: 1.6;
}

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

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

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 24px;
    padding: 30px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    animation: fadeUp 0.55s ease both;
}

.auth-card h1 {
    font-size: 30px;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
}

.auth-card p {
    color: var(--muted);
    margin-bottom: 22px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 7px;
    font-size: 14px;
}

.form-control,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 15px;
    outline: none;
    background: #fff;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

textarea {
    min-height: 92px;
    resize: vertical;
}

.form-control:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
    transform: translateY(-1px);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 14px;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition);
    min-height: 44px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

.btn:active {
    transform: translateY(0);
}

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

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

.btn-secondary {
    background: #eef2ff;
    color: #1e40af;
}

.btn-secondary:hover {
    background: #dbeafe;
}

.btn-warning {
    background: var(--yellow-soft);
    color: var(--yellow-text);
}

.btn-danger {
    background: var(--red-soft);
    color: #991b1b;
}

.btn-success {
    background: var(--green-soft);
    color: #166534;
}

.btn-block {
    width: 100%;
}

.auth-link {
    text-align: center;
    margin-top: 18px;
    color: var(--muted);
}

.auth-link a {
    color: var(--primary);
    font-weight: 800;
}

.demo-box {
    margin-top: 18px;
    padding: 14px;
    border: 1px dashed #bfdbfe;
    border-radius: 16px;
    background: #f8fbff;
}

.demo-box h3 {
    font-size: 15px;
    margin-bottom: 6px;
}

.demo-box p {
    margin-bottom: 10px;
    font-size: 14px;
}

.demo-credentials {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 14px;
}

.demo-credentials strong {
    color: var(--text);
}

.alert {
    padding: 12px 14px;
    border-radius: 14px;
    margin-bottom: 16px;
    font-size: 14px;
    animation: fadeIn 0.35s ease both;
}

.alert-danger {
    background: var(--red-soft);
    color: #991b1b;
}

.alert-success {
    background: var(--green-soft);
    color: #166534;
}

.layout {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 270px;
    background: rgba(255, 255, 255, 0.9);
    border-right: 1px solid var(--border);
    padding: 22px;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    backdrop-filter: blur(12px);
    z-index: 10;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 26px;
}

.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.brand h2 {
    font-size: 18px;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.brand p {
    font-size: 13px;
    color: var(--muted);
}

.menu {
    display: grid;
    gap: 10px;
}

.menu-link {
    padding: 12px 14px;
    border-radius: 14px;
    color: #374151;
    font-weight: 700;
    transition: background var(--transition), color var(--transition), transform var(--transition);
}

.menu-link:hover,
.menu-link.active {
    background: #f3f7ff;
    color: var(--primary-dark);
    transform: translateX(3px);
}

.menu-link.logout {
    color: var(--red);
}

.main-content {
    width: 100%;
    margin-left: 270px;
    padding: 28px;
    animation: fadeUp 0.45s ease both;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.topbar h1 {
    font-size: 30px;
    letter-spacing: -0.03em;
}

.topbar p {
    color: var(--muted);
}

.card,
.stat-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(229, 231, 235, 0.75);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    transition: transform var(--transition), box-shadow var(--transition);
}

.card {
    padding: 22px;
    margin-bottom: 20px;
}

.card:hover,
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 20px;
}

.stat-card {
    padding: 22px;
    overflow: hidden;
    position: relative;
}

.stat-card::after {
    content: "";
    position: absolute;
    right: -32px;
    top: -32px;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.08);
}

.stat-card span {
    color: var(--muted);
    font-size: 14px;
}

.stat-card h2 {
    margin-top: 8px;
    font-size: clamp(21px, 3vw, 28px);
    letter-spacing: -0.03em;
}

.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-blue { color: var(--primary); }
.text-muted { color: var(--muted); }

.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: 14px;
}

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

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    background: #f9fafb;
}

tbody tr {
    transition: background var(--transition);
}

tbody tr:hover {
    background: #f8fafc;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 800;
}

.badge-income {
    background: var(--green-soft);
    color: #166534;
}

.badge-expense {
    background: var(--red-soft);
    color: #991b1b;
}

.action-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

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

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

.empty-state {
    padding: 24px;
    text-align: center;
    color: var(--muted);
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 900px) {
    body {
        background: #f8fafc;
    }

    .layout {
        display: block;
    }

    .sidebar {
        position: sticky;
        width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 16px;
    }

    .brand {
        margin-bottom: 14px;
    }

    .menu {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .menu-link {
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .menu-link:hover,
    .menu-link.active {
        transform: translateY(-1px);
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .stats-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

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

    .topbar .btn {
        width: 100%;
    }
}

@media (max-width: 620px) {
    .auth-page {
        align-items: flex-start;
        padding: 18px;
    }

    .auth-card,
    .card,
    .stat-card {
        border-radius: 16px;
        padding: 18px;
    }

    .auth-card h1,
    .topbar h1 {
        font-size: 24px;
    }

    .brand-icon {
        width: 42px;
        height: 42px;
    }

    .brand h2 {
        font-size: 16px;
    }

    .main-content {
        padding: 16px;
    }

    .btn {
        width: 100%;
    }

    .action-group {
        width: 100%;
    }

    .action-group .btn {
        flex: 1 1 120px;
    }

    th,
    td {
        padding: 12px 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
