@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("/static/fonts/manrope-variable.ttf") format("truetype");
}

:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #1d2433;
    --muted: #677085;
    --line: #dde3ee;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #15803d;
    --warning: #b7791f;
    --danger: #c2410c;
    --shadow: 0 10px 28px rgba(20, 31, 53, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: "Manrope", "Segoe UI", sans-serif;
    font-size: 15px;
}

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

.topbar {
    display: flex;
    align-items: center;
    gap: 26px;
    padding: 14px 28px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-weight: 700;
    font-size: 20px;
}

.nav {
    display: flex;
    gap: 18px;
    color: var(--muted);
    flex: 1;
}

.nav a:hover {
    color: var(--text);
}

.logout {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
}

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

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 18px;
}

.page-head h1 {
    margin: 0;
    font-size: 30px;
}

.page-head p,
.panel-head p {
    margin: 6px 0 0;
    color: var(--muted);
}

.panel,
.table-panel,
.form-panel,
.toolbar,
.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 22px;
    margin-bottom: 18px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px;
    margin-bottom: 18px;
}

.toolbar input,
.toolbar select {
    flex: 1 1 220px;
    min-width: 0;
    width: auto;
}

.toolbar-field {
    flex: 1 1 220px;
    min-width: 0;
    gap: 5px;
}

.toolbar-field span {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.toolbar button,
.toolbar .button {
    flex: 0 0 auto;
}

.table-panel {
    overflow: hidden;
    margin-bottom: 18px;
}

.mobile-scroll-hint {
    display: none;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    background: #f0f3f8;
    color: #3a4458;
    font-size: 12px;
    text-transform: uppercase;
}

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

.totals-row td {
    background: #f0f3f8;
    font-size: 14px;
}

.right {
    text-align: right;
    white-space: nowrap;
}

.muted,
.empty,
.cell-note {
    color: var(--muted);
}

.cell-title {
    font-weight: 700;
}

.cell-note {
    margin-top: 4px;
    font-size: 13px;
}

.button,
button {
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
}

.button.primary,
.login-panel button {
    color: #ffffff;
    background: var(--primary);
}

.form-panel button {
    color: #ffffff;
    background: var(--primary);
    min-height: 42px;
    justify-self: start;
    width: auto;
}

.login-panel button {
    min-height: 42px;
}

.button.primary:hover,
.login-panel button:hover {
    background: var(--primary-dark);
}

.form-panel button:hover {
    background: var(--primary-dark);
}

.button.secondary,
.logout button {
    color: var(--text);
    background: #ffffff;
    border-color: var(--line);
}

.button.danger {
    color: #ffffff;
    background: var(--danger);
}

.button.small {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 13px;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.badge,
.tag {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge {
    min-height: 26px;
    padding: 4px 9px;
}

.tag {
    padding: 4px 8px;
    margin: 2px 3px 2px 0;
    color: #344054;
    background: #eef2f7;
}

.badge.ok {
    color: #0f5132;
    background: #dcfce7;
}

.badge.warning {
    color: #7c4a03;
    background: #fef3c7;
}

.badge.error {
    color: #7c2d12;
    background: #ffedd5;
}

.badge.info {
    color: #1e3a8a;
    background: #dbeafe;
}

.alert {
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 16px;
}

.alert-info {
    background: #eff6ff;
    color: #1e3a8a;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
}

.alert-error {
    background: #fff1f2;
    color: #9f1239;
}

.narrow {
    max-width: 820px;
}

.form-panel {
    display: grid;
    gap: 16px;
    padding: 22px;
}

.reports-upload-panel {
    margin-bottom: 22px;
}

.reports-upload-grid,
.reports-filter-toolbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.reports-filter-toolbar {
    align-items: end;
    padding: 14px 0 22px;
    margin-bottom: 18px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.reports-filter-toolbar label {
    min-width: 0;
}

.reports-filter-toolbar select {
    flex: initial;
    width: 100%;
}

.field-note {
    color: var(--muted);
    font-size: 13px;
    font-weight: 400;
}

.field-status {
    min-height: 18px;
    margin-top: -6px;
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
}

.field-status.success {
    color: var(--success);
}

.field-status.error {
    color: var(--danger);
}

.form-actions {
    display: flex;
    gap: 10px;
}

.form-actions-right {
    justify-content: flex-end;
}

.report-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    white-space: nowrap;
}

.report-actions form {
    margin: 0;
}

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

.password-grid {
    align-items: start;
}

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

label {
    display: grid;
    gap: 7px;
    color: #344054;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid #cfd7e6;
    border-radius: 8px;
    color: var(--text);
    background: #ffffff;
    font: inherit;
}

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

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(37, 99, 235, 0.18);
    border-color: var(--primary);
}

.checkline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkline input {
    width: auto;
    min-height: auto;
}

.option-stack {
    display: grid;
    gap: 10px;
}

.login-shell {
    min-height: calc(100vh - 96px);
    display: grid;
    place-items: center;
}

.login-panel {
    width: min(420px, 100%);
    display: grid;
    gap: 18px;
    padding: 28px;
}

.login-panel h1 {
    margin: 0;
    font-size: 34px;
}

.login-panel p {
    margin: 6px 0 0;
    color: var(--muted);
}

.auth-form {
    display: grid;
    gap: 15px;
}

.auth-form button {
    width: 100%;
}

.login-panel .auth-switch {
    margin: 0;
    text-align: center;
}

.auth-switch a {
    color: var(--primary);
    font-weight: 700;
}

body:has(.auth-login-shell) .page {
    width: 100%;
    margin: 0;
}

.auth-login-shell {
    min-height: 100vh;
    padding: 76px 20px 48px;
    align-items: start;
}

.auth-login-panel {
    width: min(480px, 100%);
    gap: 0;
    padding: 40px;
    border-color: #dce3ef;
    border-radius: 18px;
    box-shadow: 0 22px 55px rgba(20, 31, 53, 0.1);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 42px;
}

.auth-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    color: #ffffff;
    background: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.auth-brand-name {
    color: #344054;
    font-size: 14px;
    font-weight: 800;
}

.auth-intro {
    margin-bottom: 30px;
}

.auth-login-panel .auth-eyebrow {
    margin: 0 0 14px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.auth-login-panel h1 {
    margin: 0;
    color: #202938;
    font-size: 34px;
    line-height: 1.15;
    letter-spacing: -0.045em;
}

.auth-login-panel .auth-description {
    max-width: 350px;
    margin: 14px 0 0;
    color: #6d7890;
    font-size: 15px;
    line-height: 1.55;
}

.auth-keycloak-button {
    width: 100%;
    min-height: 50px;
    justify-content: space-between;
    padding: 10px 17px;
    border-radius: 11px;
    color: #ffffff;
    background: var(--primary);
}

.auth-keycloak-button:hover {
    color: #ffffff;
    background: var(--primary-dark);
}

.auth-arrow {
    font-size: 24px;
    font-weight: 400;
    line-height: 1;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 32px 0 24px;
    color: #9aa5b8;
    font-size: 12px;
    white-space: nowrap;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    height: 1px;
    flex: 1;
    background: #dce3ef;
}

.auth-login-panel .auth-form {
    gap: 15px;
}

.auth-login-panel .auth-form label {
    gap: 8px;
    color: #344054;
    font-size: 13px;
}

.auth-login-panel .auth-form input {
    min-height: 48px;
    padding: 10px 13px;
    border-radius: 11px;
    border-color: #cfd7e6;
}

.auth-login-panel .auth-form input::placeholder {
    color: #9aa5b8;
}

.auth-login-panel .auth-form button {
    min-height: 48px;
    margin-top: 2px;
    border-radius: 11px;
}

.auth-login-panel .auth-help {
    margin: 24px 0 0;
    color: #9aa5b8;
    font-size: 12px;
    line-height: 1.5;
    text-align: left;
}

.office-list {
    display: grid;
    gap: 10px;
}

.office-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcff;
}

.note-text {
    white-space: pre-wrap;
}

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

@media (max-width: 1060px) and (min-width: 841px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.metric-card {
    min-height: 120px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.metric-card strong {
    display: block;
    margin-top: 10px;
    font-size: 32px;
    font-weight: 700;
}

.metric-card small {
    color: var(--muted);
}

.admin-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.admin-action {
    display: grid;
    gap: 6px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcff;
}

.admin-action strong {
    font-weight: 700;
}

.admin-action span {
    color: var(--muted);
    font-size: 13px;
}

.admin-action em {
    width: fit-content;
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    color: var(--primary);
    background: #eff6ff;
    font-style: normal;
    font-size: 13px;
    font-weight: 700;
}

.admin-action:hover {
    border-color: var(--primary);
}

@media (max-width: 840px) {
    .topbar,
    .page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .logout {
        justify-content: space-between;
    }

    .grid-2,
    .grid-3,
    .reports-upload-grid,
    .reports-filter-toolbar,
    .metric-grid,
    .admin-actions {
        grid-template-columns: 1fr;
    }

    .form-actions-right {
        justify-content: stretch;
    }

    .form-actions-right button {
        width: 100%;
    }

    .toolbar input,
    .toolbar select,
    .toolbar .toolbar-field,
    .toolbar button,
    .toolbar .button {
        width: 100%;
        flex-basis: 100%;
    }

    .table-panel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-color: var(--primary) transparent;
        scrollbar-width: thin;
        scroll-snap-type: x proximity;
    }

    .mobile-scroll-hint {
        display: flex;
        width: fit-content;
        margin: 10px 12px 0;
        padding: 5px 8px;
        color: var(--muted);
        font-size: 12px;
        font-weight: 600;
        line-height: 1.3;
        background: #f0f3f8;
        border-radius: 999px;
    }

    th,
    td {
        white-space: nowrap;
        scroll-snap-align: start;
    }
}

@media (max-width: 520px) {
    .page {
        width: min(100% - 20px, 1220px);
        margin-top: 18px;
    }
}
