:root {
    --bg: #f4f7f8;
    --panel: #ffffff;
    --ink: #192226;
    --muted: #66727a;
    --line: #dbe3e7;
    --line-strong: #c7d2d8;
    --accent: #0f766e;
    --accent-dark: #115e59;
    --accent-soft: #e8f5f3;
    --control: #f9fbfb;
    --warn: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

a {
    color: var(--accent-dark);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px 28px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.topbar div {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.topbar span,
.section-title span,
.metrics span {
    color: var(--muted);
}

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

.metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.metrics article,
.table-section,
.login-box,
.setup-box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.metrics article,
.setup-box {
    padding: 18px;
}

.metrics strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}

.section-title > div:first-child {
    display: grid;
    gap: 4px;
}

.section-title h1 {
    margin: 0;
    font-size: 22px;
}

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

.filter-count {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid #d8c687;
    border-radius: 6px;
    color: #6f5715;
    background: #fff8dc;
    font-size: 13px;
    font-weight: 700;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 8px 12px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: #fff;
    background: var(--accent);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.button:hover {
    background: var(--accent-dark);
}

.button.secondary {
    border-color: var(--line-strong);
    color: var(--ink);
    background: #fff;
}

.button.secondary:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
    background: var(--accent-soft);
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) repeat(8, minmax(104px, 1fr)) auto;
    gap: 12px;
    align-items: end;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    background: #fbfcfc;
}

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

.filter-wide {
    min-width: 220px;
}

.filter-submit {
    display: flex;
    align-items: end;
}

.table-wrap {
    max-height: calc(100vh - 360px);
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th,
td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

th:first-child,
td:first-child {
    min-width: 320px;
    white-space: normal;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--muted);
    font-weight: 700;
    background: var(--control);
}

td strong,
td small {
    display: block;
}

td small {
    margin-top: 4px;
    color: var(--muted);
    line-height: 1.35;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.sort-link {
    display: inline-flex;
    color: inherit;
    text-decoration: none;
}

.sort-link:hover {
    color: var(--accent-dark);
}

.empty {
    padding: 28px 16px;
    color: var(--muted);
    text-align: center;
}

.status {
    display: inline-block;
    padding: 4px 8px;
    border: 1px solid #b7d8d4;
    border-radius: 6px;
    color: var(--accent-dark);
    background: var(--accent-soft);
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(420px, 100%);
}

.login-box {
    display: grid;
    gap: 16px;
    padding: 28px;
}

.login-box h1 {
    margin: 0 0 8px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 700;
}

input,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

select {
    min-height: 43px;
}

button {
    border: 0;
    border-radius: 6px;
    padding: 12px 16px;
    color: #fff;
    background: var(--accent);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button:hover {
    background: var(--accent-dark);
}

.alert {
    margin: 0;
    padding: 10px 12px;
    border: 1px solid #f2b8b5;
    border-radius: 6px;
    color: var(--warn);
    background: #fff1f0;
}

.setup-box {
    margin-top: 24px;
}

.setup-box code {
    display: block;
    overflow-x: auto;
    padding: 12px;
    border-radius: 6px;
    background: #edf2f4;
}

@media (max-width: 1180px) {
    .filter-bar {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .filter-wide {
        grid-column: span 2;
    }
}

@media (max-width: 820px) {
    .metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-wide,
    .filter-submit {
        grid-column: 1 / -1;
    }

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

@media (max-width: 560px) {
    .metrics {
        grid-template-columns: 1fr;
    }

    .topbar,
    .section-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .filter-bar {
        grid-template-columns: 1fr;
    }
}
