:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #eef4f7;
    --text: #17202a;
    --muted: #697586;
    --line: #d9e1ea;
    --accent: #0f766e;
    --accent-strong: #0b5f59;
    --blue: #175cd3;
    --danger: #b42318;
    --success: #067647;
    --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    width: min(1480px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 40px;
}

.app-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 44px);
    line-height: 1.05;
    font-weight: 800;
    letter-spacing: 0;
}

.header-meta {
    display: grid;
    gap: 4px;
    min-width: 180px;
    color: var(--muted);
    text-align: right;
}

.header-meta strong {
    color: var(--text);
    font-size: 28px;
    line-height: 1;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1.3fr) minmax(150px, 0.75fr) minmax(140px, 0.6fr) auto auto minmax(94px, 0.4fr) minmax(94px, 0.4fr) auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.field {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.field input,
.field select {
    width: 100%;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 0 12px;
    outline: none;
}

.field input:focus,
.field select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.field-small {
    min-width: 94px;
}

.segmented {
    display: flex;
    align-items: center;
    height: 42px;
    margin: 0;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
}

.segmented legend {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.segmented label {
    height: 34px;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented span {
    display: grid;
    min-width: 42px;
    height: 34px;
    place-items: center;
    border-radius: 5px;
    color: var(--muted);
    font-weight: 800;
    cursor: pointer;
}

.segmented input:checked + span {
    background: var(--surface);
    color: var(--accent);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.check-field {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    color: var(--text);
    font-weight: 700;
    white-space: nowrap;
}

.check-field input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.button {
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    padding: 0 14px;
    font-weight: 800;
    cursor: pointer;
}

.button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.button-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.button-primary:hover {
    border-color: var(--accent-strong);
    background: var(--accent-strong);
    color: #fff;
}

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

.summary > div {
    min-height: 74px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.summary-label {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.summary strong {
    font-size: 26px;
    line-height: 1;
}

.table-section {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.status {
    margin: 16px;
    padding: 12px 14px;
    border-radius: 6px;
    background: #e7f6f3;
    color: var(--accent-strong);
    font-weight: 700;
}

.status.is-error {
    background: #fee4e2;
    color: var(--danger);
}

.table-scroll {
    max-height: calc(100vh - 290px);
    min-height: 380px;
    overflow: auto;
}

table {
    width: 100%;
    min-width: 1160px;
    border-collapse: separate;
    border-spacing: 0;
}

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

th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

th button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    font-weight: 900;
    text-transform: uppercase;
    cursor: pointer;
}

th button.is-active {
    color: var(--accent);
}

th button.is-active::after {
    content: "";
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

th button.is-active[data-direction="asc"]::after {
    border-bottom: 6px solid currentColor;
}

th button.is-active[data-direction="desc"]::after {
    border-top: 6px solid currentColor;
}

tbody tr:hover {
    background: #f6fbfb;
}

tbody tr.is-inactive {
    background: #fbf7f2;
}

tbody tr.is-inactive:hover {
    background: #f7eee4;
}

.col-num {
    width: 64px;
    color: var(--muted);
    text-align: right;
}

.name-link {
    color: var(--blue);
    font-weight: 800;
    text-decoration: none;
}

.name-link:hover {
    text-decoration: underline;
}

.rating-cell {
    font-weight: 900;
}

.is-positive {
    color: var(--success);
    font-weight: 800;
}

.is-negative {
    color: var(--danger);
    font-weight: 800;
}

.active-badge {
    display: inline-grid;
    min-width: 42px;
    height: 24px;
    place-items: center;
    border-radius: 999px;
    padding: 0 9px;
    font-size: 12px;
    font-weight: 900;
}

.active-badge.is-active-row {
    background: #dff7ea;
    color: var(--success);
}

.active-badge.is-inactive-row {
    background: #fee4e2;
    color: var(--danger);
}

@media (max-width: 1180px) {
    .toolbar {
        grid-template-columns: minmax(220px, 1fr) minmax(160px, 1fr) auto auto;
    }

    .actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
}

@media (max-width: 760px) {
    .app-shell {
        width: min(100% - 20px, 1480px);
        padding-top: 18px;
    }

    .app-header {
        display: grid;
        gap: 12px;
    }

    .header-meta {
        text-align: left;
    }

    .toolbar {
        grid-template-columns: 1fr 1fr;
        padding: 12px;
    }

    .field-search,
    .actions {
        grid-column: 1 / -1;
    }

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

    .button {
        padding: 0 8px;
    }

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

    .hide-md {
        display: none;
    }

    .table-scroll {
        max-height: none;
    }

    table {
        min-width: 840px;
    }
}

@media (max-width: 560px) {
    body {
        font-size: 14px;
    }

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

    .field-search,
    .actions {
        grid-column: auto;
    }

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

    .hide-sm {
        display: none;
    }

    table {
        min-width: 620px;
    }

    th,
    td {
        padding: 10px 12px;
    }
}
