: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 button,
.toolbar .button {
    flex: 0 0 auto;
}

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

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;
}

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

.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);
}

.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(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.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,
    .metric-grid,
    .admin-actions {
        grid-template-columns: 1fr;
    }

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

    .table-panel {
        overflow-x: auto;
    }

    th,
    td {
        white-space: nowrap;
    }
}

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