* {
    box-sizing: border-box;
}

:root {
    --bg: #f3f6f4;
    --panel: #ffffff;
    --text: #17211a;
    --muted: #66736a;
    --line: #dfe7e1;
    --primary: #1f6f45;
    --primary-dark: #155434;
    --soft: #eaf4ed;
    --danger: #b42318;
    --warning: #9a6700;
    --shadow: 0 18px 45px rgba(24, 48, 32, 0.09);
    --radius: 18px;
}

html {
    color-scheme: light;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(31, 111, 69, 0.10), transparent 28rem),
        var(--bg);
}

a {
    color: inherit;
}

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

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.topbar {
    min-height: 96px;
    padding: 22px clamp(18px, 4vw, 56px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    color: white;
    background: linear-gradient(135deg, #184e32, #1f6f45);
    box-shadow: 0 14px 35px rgba(24, 78, 50, 0.22);
}

.topbar h1,
.section-heading h2,
.auth-card h1 {
    margin: 4px 0 0;
    line-height: 1.1;
}

.topbar h1 {
    font-size: clamp(1.45rem, 3vw, 2.15rem);
}

.eyebrow {
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    opacity: 0.76;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.top-actions form {
    margin: 0;
}

.user-chip {
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 999px;
    background: rgba(255,255,255,0.10);
    font-weight: 700;
}

.page-shell {
    width: min(1500px, calc(100% - 32px));
    margin: 28px auto 60px;
}

.page-shell.narrow {
    width: min(850px, calc(100% - 32px));
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(240px, 0.45fr);
    gap: 22px;
    align-items: start;
    margin-bottom: 22px;
}

.admin-grid {
    grid-template-columns: minmax(280px, 0.7fr) minmax(0, 1.3fr);
}

.panel,
.stat-card,
.auth-card {
    background: rgba(255,255,255,0.96);
    border: 1px solid rgba(223, 231, 225, 0.95);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel {
    padding: clamp(18px, 3vw, 30px);
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.section-heading h2 {
    font-size: clamp(1.25rem, 2vw, 1.65rem);
}

.section-heading.split {
    align-items: flex-end;
}

.stats-stack {
    display: grid;
    gap: 16px;
}

.stat-card {
    padding: 22px;
    display: grid;
    gap: 4px;
}

.stat-card span,
.stat-card small {
    color: var(--muted);
}

.stat-card strong {
    margin: 2px 0;
    font-size: clamp(1.7rem, 4vw, 2.4rem);
    line-height: 1;
    color: var(--primary-dark);
}

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

.stack {
    display: grid;
    gap: 16px;
}

label,
legend {
    color: #314039;
    font-size: 0.91rem;
    font-weight: 760;
}

label {
    display: grid;
    gap: 7px;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #cfd9d2;
    border-radius: 12px;
    background: #fbfdfb;
    color: var(--text);
    padding: 12px 13px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(31, 111, 69, 0.12);
    background: white;
}

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

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

.area-fieldset {
    margin: 0;
    border: 1px solid #cfd9d2;
    border-radius: 12px;
    padding: 10px 13px 12px;
    display: flex;
    gap: 18px;
    align-items: center;
    min-height: 72px;
}

.area-fieldset legend {
    padding: 0 6px;
}

.check-row {
    display: inline-flex;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.check-row input {
    width: 19px;
    height: 19px;
    padding: 0;
    accent-color: var(--primary);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 16px;
    border: 0;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

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

.button.primary {
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 10px 22px rgba(31, 111, 69, 0.20);
}

.button.secondary {
    color: var(--primary-dark);
    background: var(--soft);
}

.button.ghost {
    color: inherit;
    background: rgba(255,255,255,0.11);
    border: 1px solid rgba(255,255,255,0.22);
}

.button.full {
    width: 100%;
}

.button.small {
    min-height: 36px;
    padding: 7px 11px;
    font-size: 0.84rem;
}

.month-filter {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.month-filter label {
    min-width: 170px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

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

th {
    color: var(--muted);
    font-size: 0.76rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

td {
    font-size: 0.93rem;
}

td small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.notes-cell {
    max-width: 260px;
    white-space: normal;
}

.badge {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 999px;
    color: var(--primary-dark);
    background: var(--soft);
    font-weight: 800;
    white-space: nowrap;
}

.row-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    white-space: nowrap;
}

.row-actions form {
    margin: 0;
}

.icon-link,
.link-button {
    border: 0;
    padding: 0;
    color: var(--primary-dark);
    background: none;
    text-decoration: underline;
    font-weight: 760;
    cursor: pointer;
}

.link-button.danger {
    color: var(--danger);
}

.alert {
    margin-bottom: 18px;
    padding: 13px 15px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 700;
}

.alert.success {
    color: #166534;
    background: #ecfdf3;
    border-color: #bbf7d0;
}

.alert.error {
    color: #991b1b;
    background: #fff1f2;
    border-color: #fecdd3;
}

.alert.warning {
    color: #7a4b00;
    background: #fffbeb;
    border-color: #fde68a;
}

.empty-state {
    min-height: 180px;
    display: grid;
    place-content: center;
    text-align: center;
    gap: 6px;
    color: var(--muted);
    border: 1px dashed #cbd7ce;
    border-radius: 14px;
    background: #fbfdfb;
}

.empty-state strong {
    color: var(--text);
}

.auth-page {
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 10%, rgba(255,255,255,0.18), transparent 25rem),
        linear-gradient(135deg, #153f2a, #1f6f45 55%, #2f8b59);
}

.auth-card {
    width: min(460px, 100%);
    padding: clamp(24px, 5vw, 38px);
}

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

.brand-mark {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    margin-bottom: 18px;
    border-radius: 17px;
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 12px 24px rgba(31, 111, 69, 0.25);
    font-weight: 900;
    letter-spacing: 0.06em;
}

.muted {
    margin-top: 8px;
    margin-bottom: 24px;
    color: var(--muted);
}

.user-list {
    display: grid;
    gap: 12px;
}

.user-row {
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfdfb;
}

.user-row span,
.user-row small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.user-actions,
.password-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.password-inline input {
    min-width: 160px;
    padding: 8px 10px;
}

@media (max-width: 980px) {
    .dashboard-grid,
    .admin-grid {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

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

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

    .full-span {
        grid-column: auto;
    }

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

    .section-heading.split,
    .month-filter,
    .user-row,
    .user-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .month-filter label {
        min-width: 0;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
    }

    table {
        min-width: 0;
    }

    thead {
        display: none;
    }

    tr {
        margin-bottom: 16px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: #fbfdfb;
    }

    td {
        display: grid;
        grid-template-columns: 118px 1fr;
        gap: 10px;
        padding: 8px 4px;
        border-bottom: 1px dashed var(--line);
    }

    td:last-child {
        border-bottom: 0;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 800;
    }

    .row-actions {
        display: flex;
        padding-top: 12px;
    }

    .row-actions::before {
        display: none;
    }

    .notes-cell {
        max-width: none;
    }
}


.overall-stat {
    color: white;
    border-color: transparent;
    background: linear-gradient(135deg, #1f6f45, #12452c);
    box-shadow: 0 18px 38px rgba(24, 78, 50, 0.24);
}

.overall-stat span,
.overall-stat small,
.overall-stat strong {
    color: white;
}

.overall-stat small {
    opacity: 0.78;
}

.filter-actions {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 760px) {
    .filter-actions {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }

    .filter-actions .button {
        width: 100%;
    }
}
