* {
    box-sizing: border-box;
}

:root {
    --bg: #f3f6fb;
    --card: #ffffff;
    --card-soft: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --secondary: #475569;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at top left, #e0ecff 0%, transparent 30%),
        radial-gradient(circle at top right, #eafbf4 0%, transparent 25%),
        var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* LOGIN */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 430px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 32px 24px;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.brand-badge {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    background: #eff6ff;
    color: var(--primary);
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 14px;
}

.login-card h1 {
    margin: 0 0 8px;
    font-size: 28px;
    line-height: 1.2;
}

.login-subtitle {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 15px;
}

.demo-box {
    margin-top: 18px;
    background: var(--card-soft);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    font-size: 14px;
    color: var(--muted);
}

.demo-box strong {
    color: var(--text);
}

h1, h2, h3 {
    margin-top: 0;
}

.muted {
    color: var(--muted);
}

/* LAYOUT */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(10px);
    color: #fff;
    padding: 18px 16px;
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.22);
}

.topbar-left h1 {
    margin: 0 0 4px;
    font-size: 22px;
    line-height: 1.2;
}

.topbar .muted {
    color: #cbd5e1;
    margin: 0;
    font-size: 14px;
}

.topbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px 14px 40px;
}

.page-intro {
    margin-bottom: 18px;
}

.page-intro h2 {
    margin-bottom: 6px;
    font-size: 24px;
}

.page-intro p {
    margin: 0;
    color: var(--muted);
}

/* CARDS */

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 18px;
    border: 1px solid rgba(226, 232, 240, 0.9);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.card-header h2 {
    margin: 0;
    font-size: 20px;
}

.card-subtitle {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border-radius: 20px;
    padding: 18px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-card h3 {
    margin: 0 0 10px;
    font-size: 14px;
    color: var(--muted);
    font-weight: bold;
}

.stat-card p {
    margin: 0;
    font-size: 28px;
    font-weight: bold;
    line-height: 1.1;
    word-break: break-word;
}

.stat-card.highlight {
    background: linear-gradient(180deg, #ecfdf5 0%, #f0fdf4 100%);
    border: 1px solid #a7f3d0;
}

.stat-card.highlight p {
    color: #047857;
}

/* FORM */

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 14px;
}

input,
select,
button,
.btn {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 16px;
    transition: 0.2s ease;
}

input,
select {
    border: 1px solid var(--border);
    background: #fff;
    margin-bottom: 16px;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

button,
.btn {
    border: none;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: bold;
}

button:hover,
.btn:hover {
    background: var(--primary-dark);
}

.btn.secondary {
    background: var(--secondary);
}

.btn.secondary:hover {
    background: #334155;
}

.btn.danger {
    background: var(--danger);
}

.btn.danger:hover {
    background: var(--danger-dark);
}

.btn.small {
    width: auto;
    min-height: 38px;
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 10px;
}

/* ALERTS */

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-size: 15px;
}

.alert.success {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.alert.error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* MONTH FORM */

.month-form {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
}

.month-field {
    flex: 1 1 220px;
}

.month-form button {
    width: auto;
    min-width: 140px;
}

/* TABLE */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead th {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    background: #f8fafc;
}

table th,
table td {
    border-bottom: 1px solid var(--border);
    padding: 14px 10px;
    text-align: left;
    vertical-align: middle;
}

table tbody tr:hover {
    background: #fafcff;
}

/* EXPORT */

.export-card {
    box-shadow: none;
    border: 1px solid #ddd;
}

/* MOBILE TABLE TO CARDS */

@media (max-width: 760px) {
    .table-mobile table,
    .table-mobile thead,
    .table-mobile tbody,
    .table-mobile th,
    .table-mobile td,
    .table-mobile tr {
        display: block;
        width: 100%;
    }

    .table-mobile thead {
        display: none;
    }

    .table-mobile tr {
        margin-bottom: 14px;
        padding: 14px;
        border: 1px solid var(--border);
        border-radius: 16px;
        background: #fff;
        box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
    }

    .table-mobile td {
        border: none;
        padding: 8px 0;
        text-align: left;
    }

    .table-mobile td::before {
        content: attr(data-label);
        display: block;
        font-size: 12px;
        color: var(--muted);
        margin-bottom: 3px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        font-weight: bold;
    }

    .table-mobile td:last-child {
        padding-top: 12px;
    }

    .table-mobile .btn.small {
        width: 100%;
    }
}

/* RESPONSIVE */

@media (max-width: 1100px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
    }

    .topbar-actions .btn {
        flex: 1 1 160px;
    }
}

@media (max-width: 560px) {
    .login-card {
        padding: 24px 18px;
        border-radius: 20px;
    }

    .login-card h1 {
        font-size: 24px;
    }

    .container {
        padding: 16px 12px 34px;
    }

    .card {
        padding: 16px;
        border-radius: 16px;
    }

    .page-intro h2 {
        font-size: 22px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        min-height: auto;
    }

    .stat-card p {
        font-size: 24px;
    }

    .month-form {
        flex-direction: column;
        align-items: stretch;
    }

    .month-field {
        width: 100%;
    }

    .month-form button {
        width: 100%;
    }

    .topbar-actions .btn {
        width: 100%;
    }
}

@media print {
    .topbar,
    .btn,
    button {
        box-shadow: none !important;
    }
}