:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-alt: #eef4ff;
    --border: #d9e3f0;
    --text: #162033;
    --muted: #61708a;
    --primary: #3b82f6;
    --primary-dark: #1d4ed8;
    --shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
    --radius: 20px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, Segoe UI, Arial, sans-serif;
    background: linear-gradient(180deg, #eff5ff 0%, var(--bg) 100%);
    color: var(--text);
}

body {
    min-height: 100vh;
}

a {
    color: inherit;
}

h1,
h2,
h3,
p {
    margin: 0;
}

.eyebrow {
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--primary-dark);
}

.muted {
    color: var(--muted);
}

.stack {
    display: grid;
    gap: 1rem;
}

.card {
    background: var(--surface);
    border: 1px solid rgba(217, 227, 240, 0.85);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card--narrow {
    width: min(100%, 420px);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.login-layout {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 1.5rem;
    width: min(1100px, 100%);
}

.login-panel {
    border-radius: 28px;
    padding: 2.25rem;
}

.login-panel--brand {
    background: radial-gradient(circle at top left, #60a5fa 0%, #1d4ed8 55%, #172554 100%);
    color: white;
    display: grid;
    align-content: end;
    min-height: 580px;
    box-shadow: var(--shadow);
}

.login-panel--brand .eyebrow,
.login-panel--brand .muted,
.login-panel--brand li {
    color: rgba(255, 255, 255, 0.88);
}

.login-panel--brand h1 {
    font-size: clamp(2rem, 4vw, 3.4rem);
    line-height: 1.05;
    margin-bottom: 1rem;
}

.feature-list {
    margin: 1.5rem 0 0;
    padding-left: 1.2rem;
    display: grid;
    gap: 0.75rem;
}

.login-panel--form {
    display: grid;
    place-items: center;
}

.app-shell {
    padding: 1.5rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin: 0 auto 1.5rem;
    width: min(1380px, 100%);
}

.topbar h1 {
    font-size: clamp(1.8rem, 2.5vw, 2.6rem);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-nav {
    display: flex;
    gap: 0.75rem;
}

.user-badge {
    padding: 0.9rem 2rem;
    border-radius: 200px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--border);
}

.user-badge__label {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
}

.page-shell {
    width: min(1380px, 100%);
    margin: 0 auto;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.filters-panel {
    position: sticky;
    top: 1.5rem;
}

.content-stack {
    display: grid;
    gap: 1.5rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.stat-card h3 {
    font-size: 1.8rem;
    margin-bottom: 0.35rem;
}

.field {
    display: grid;
    gap: 0.45rem;
}

.field span {
    font-weight: 600;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    background: #fbfdff;
    color: var(--text);
    font: inherit;
}

.input:focus {
    outline: 2px solid rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.45);
}

.button {
    border: 0;
    border-radius: 14px;
    padding: 0.95rem 1.2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.button--ghost {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
    text-decoration: none;
}

.group-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.group-card {
    padding: 1rem;
    border-radius: 16px;
    background: var(--surface-alt);
    border: 1px solid rgba(59, 130, 246, 0.12);
    display: grid;
    gap: 0.35rem;
}

.group-card span {
    font-size: 1.4rem;
    font-weight: 700;
}

.group-card small {
    color: var(--muted);
}

.table-wrapper {
    overflow: auto;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.report-table th,
.report-table td {
    padding: 0.95rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(217, 227, 240, 0.9);
}

.report-table thead th {
    position: sticky;
    top: 0;
    background: linear-gradient(180deg, #0f172a 0%, #334155 100%);
    color: white;
    font-size: 0.9rem;
}

.report-table tfoot td {
    font-weight: 700;
}

.month-chart {
    display: grid;
    gap: 0.75rem;
}

.month-chart__row {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr) 100px;
    gap: 0.75rem;
    align-items: center;
}

.month-chart__label {
    color: var(--muted);
    font-weight: 600;
}

.month-chart__bar-wrap {
    height: 16px;
    border-radius: 999px;
    background: #e5edf9;
    overflow: hidden;
}

.month-chart__bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.month-chart__value {
    text-align: right;
    font-weight: 700;
}

.numeric {
    text-align: right !important;
}

.empty-state {
    display: grid;
    gap: 0.4rem;
    place-items: center;
    min-height: 240px;
    text-align: center;
    color: var(--muted);
}

.validation {
    color: #b91c1c;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.toggle-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.toggle-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fbfdff;
    font-weight: 600;
}

.action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.action-row__left,
.action-row__right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.save-feedback {
    color: #166534;
    background: #ecfdf3;
    border: 1px solid #86efac;
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
    opacity: 1;
    transition: opacity 400ms ease;
}

.save-feedback--fade {
    opacity: 0;
}

.input--readonly {
    display: flex;
    align-items: center;
    min-height: 50px;
}

body.is-busy {
    overflow: hidden;
}

.sync-overlay[hidden] {
    display: none !important;
}

.sync-overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(8px);
    z-index: 1000;
}

.sync-popup {
    position: relative;
    width: min(460px, 100%);
    padding: 2rem;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(217, 227, 240, 0.95);
    box-shadow: 0 30px 70px rgba(15, 23, 42, 0.22);
    text-align: center;
    display: grid;
    gap: 0.9rem;
    animation: sync-popup-in 180ms ease-out;
}

.sync-popup__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: white;
    color: var(--text);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.sync-popup__close:hover {
    background: #f8fbff;
}

.sync-feedback--info {
    color: #1d4ed8;
}

.sync-spinner {
    width: 72px;
    height: 72px;
    margin: 0 auto 0.25rem;
    border-radius: 50%;
    border: 6px solid rgba(59, 130, 246, 0.16);
    border-top-color: var(--primary);
    border-right-color: var(--primary-dark);
    animation: sync-spin 0.9s linear infinite;
}

@keyframes sync-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes sync-popup-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 1100px) {
    .dashboard-grid,
    .login-layout,
    .summary-grid,
    .config-grid,
    .toggle-grid {
        grid-template-columns: 1fr;
    }

    .filters-panel {
        position: static;
    }
}

@media (max-width: 700px) {
    .month-chart__row {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }

    .month-chart__value {
        text-align: left;
    }

    .app-shell,
    .auth-shell {
        padding: 1rem;
    }

    .topbar,
    .topbar-actions,
    .field-grid {
        grid-template-columns: 1fr;
        display: grid;
    }

    .topbar {
        justify-content: stretch;
    }

    .topbar-nav,
    .action-row,
    .action-row__left,
    .action-row__right {
        flex-direction: column;
        align-items: stretch;
    }
}

.date-input-wrap {
    position: relative;
}

.date-input-wrap .input {
    padding-right: 3rem;
}

.date-picker-button {
    position: absolute;
    right: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    font-size: 1rem;
    cursor: pointer;
    color: var(--muted);
}

.date-input-native {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}

.admin-inline-form {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.admin-inline-form .input {
    min-width: 260px;
}

.admin-inline-form--right {
    justify-content: flex-end;
}
