:root {
    color-scheme: light dark;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #eef1f4;
    --text: #17202a;
    --muted: #64707d;
    --border: #d8dee5;
    --primary: #2457a6;
    --primary-strong: #183f7b;
    --keep: #e7f6ed;
    --keep-text: #17663a;
    --remove: #fdecec;
    --remove-text: #9b1c1c;
    --unsure: #fff7db;
    --unsure-text: #7a5400;
    --pending: #eef1f4;
    --pending-text: #4c5864;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111418;
        --surface: #191e24;
        --surface-2: #242b33;
        --text: #f0f3f6;
        --muted: #a8b1bc;
        --border: #303945;
        --primary: #7aa7ff;
        --primary-strong: #a8c4ff;
        --keep: #143a28;
        --keep-text: #8ae0ad;
        --remove: #481d1d;
        --remove-text: #ff9f9f;
        --unsure: #443814;
        --unsure-text: #ffe08a;
        --pending: #29303a;
        --pending-text: #c0c8d2;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem clamp(1rem, 4vw, 2rem);
}

.topbar h1, .brand-block h1 {
    font-size: clamp(1.6rem, 3vw, 2.35rem);
    line-height: 1.1;
    margin: 0;
}

.topbar nav, .actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}

.eyebrow {
    color: var(--muted);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .08em;
    margin: 0 0 .25rem;
    text-transform: uppercase;
}

.page {
    margin: 0 auto;
    max-width: 1240px;
    padding: 1.25rem clamp(1rem, 4vw, 2rem) 3rem;
}

.login-page {
    align-items: center;
    display: flex;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .12);
    margin: 0 auto;
    max-width: 430px;
    padding: 2rem;
    width: 100%;
}

.brand-block p:last-child { color: var(--muted); margin-bottom: 1.5rem; }
.stack { display: grid; gap: .75rem; }

label {
    color: var(--muted);
    display: block;
    font-size: .9rem;
    font-weight: 700;
}

input, select, textarea {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    padding: .7rem .8rem;
    width: 100%;
}

textarea { min-width: 220px; resize: vertical; }

button, .button {
    background: var(--primary);
    border: 0;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    justify-content: center;
    padding: .72rem 1rem;
    text-decoration: none;
}

button:hover, .button:hover { background: var(--primary-strong); text-decoration: none; }
.button.secondary { background: var(--surface-2); color: var(--text); }

.alert {
    border-radius: 6px;
    margin-bottom: 1rem;
    padding: .85rem 1rem;
}
.alert.error { background: var(--remove); color: var(--remove-text); }
.alert.success { background: var(--keep); color: var(--keep-text); }

.stats-grid {
    display: grid;
    gap: .8rem;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin-bottom: 1rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.stat span { color: var(--muted); display: block; font-size: .85rem; font-weight: 700; }
.stat strong { display: block; font-size: 1.9rem; line-height: 1.1; margin-top: .35rem; }

.toolbar {
    align-items: end;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
}

.toolbar.split { justify-content: space-between; }
.search-form { align-items: end; display: flex; flex: 1; gap: .75rem; }
.search-form label { min-width: 130px; }
.search-form.compact { flex: 0 1 480px; }

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-x: auto;
}

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

th, td {
    border-bottom: 1px solid var(--border);
    padding: .85rem;
    text-align: left;
    vertical-align: top;
}

th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: .78rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

tr:last-child td { border-bottom: 0; }
.decision-keep { background: var(--keep); }
.decision-remove { background: var(--remove); }
.decision-unsure { background: var(--unsure); }
.decision-pending { background: var(--pending); }

.badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: .85rem;
    font-weight: 800;
    padding: .25rem .65rem;
}
.badge-keep { background: var(--keep); color: var(--keep-text); }
.badge-remove { background: var(--remove); color: var(--remove-text); }
.badge-unsure { background: var(--unsure); color: var(--unsure-text); }
.badge-pending { background: var(--pending); color: var(--pending-text); }

.form-footer {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
}
.form-footer p { color: var(--muted); margin: 0; }

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: 1rem;
}
.pagination a {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    min-width: 2.4rem;
    padding: .5rem .75rem;
    text-align: center;
}
.pagination a.active { background: var(--primary); color: #fff; }

@media (max-width: 760px) {
    .topbar, .toolbar, .toolbar.split, .search-form, .form-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat:first-child { grid-column: 1 / -1; }

    table { min-width: 0; }
    thead { display: none; }
    tr {
        display: block;
        padding: .75rem;
    }
    td {
        border: 0;
        display: grid;
        gap: .35rem;
        padding: .45rem 0;
    }
    td::before {
        color: var(--muted);
        content: attr(data-label);
        font-size: .78rem;
        font-weight: 800;
        text-transform: uppercase;
    }
    textarea { min-width: 0; }
}
