:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #667085;
    --border: #e3e6eb;
    --accent: #2f5bd3;
    --strong: #13795b;
    --strong-bg: #e3f4ec;
    --stretch: #9a6400;
    --stretch-bg: #fdf1d8;
    --skip: #5b6475;
    --skip-bg: #eceef2;
    --danger: #b42318;
    --danger-bg: #fdeceb;
    --accent-bg: #e8eefc;
    --radius: 8px;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    color: var(--text);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151b;
        --surface: #1a1f27;
        --text: #e6e8ec;
        --muted: #9aa3b2;
        --border: #2b323d;
        --accent: #7c9cff;
        --strong: #5fd0a4;
        --strong-bg: #173a2e;
        --stretch: #f3c46b;
        --stretch-bg: #3d3018;
        --skip: #b2bac7;
        --skip-bg: #2a303a;
        --danger: #ff8a80;
        --danger-bg: #3d1f1d;
        --accent-bg: #1e2a4a;
    }
}

* { box-sizing: border-box; }

body { margin: 0; background: var(--bg); color: var(--text); }

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

h1 { font-size: 1.5rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 0.6rem; }
h1:focus { outline: none; }

code { background: var(--skip-bg); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.9em; }

.topbar {
    display: flex; align-items: center; gap: 1.5rem;
    padding: 0.8rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.topbar nav a { color: var(--muted); }
.topbar nav a.active { color: var(--text); font-weight: 600; }

.page { max-width: 1240px; margin: 0 auto; padding: 1.5rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0.2rem 0.7rem; font-size: 0.85rem; color: var(--muted); }
.chip b { color: var(--text); margin-left: 0.2rem; }
.chip.sep { margin-left: 0.6rem; }

.filters { display: flex; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters label { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.9rem; }
select, textarea {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: 6px; padding: 0.35rem 0.5rem;
}
textarea { width: 100%; resize: vertical; }

table.matches { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.matches th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); background: var(--bg); }
.matches td { padding: 0.75rem 0.8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.matches tr:last-child td { border-bottom: none; }
.matches tr.row-rejected td { opacity: 0.6; }
.num { text-align: center; width: 5.5rem; }
.actions { white-space: nowrap; width: 11rem; }

.score { font-size: 1.5rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.score.big { font-size: 2.6rem; min-width: 4.5rem; text-align: center; }
.job-title { font-weight: 600; }
.company { font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 2rem; text-align: center; color: var(--muted); }
.alert { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius); padding: 0.8rem 1rem; }

.badge { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--skip-bg); color: var(--skip); margin-top: 0.2rem; }
.tier-strong, .status-approved { background: var(--strong-bg); color: var(--strong); }
.tier-stretch, .changed { background: var(--stretch-bg); color: var(--stretch); }
.status-rejected, .dealbreaker { background: var(--danger-bg); color: var(--danger); }
.changed { margin-left: 0.3rem; }

.matches td.small div { white-space: nowrap; }
.gap-dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-right: 0.4rem; background: var(--skip); }
.gap-dot.significant { background: var(--danger); }
.gap-dot.minor { background: var(--stretch); }

.doc-links { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; }

.btn {
    font: inherit; font-size: 0.85rem; cursor: pointer; padding: 0.3rem 0.75rem; border-radius: 6px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { cursor: default; opacity: 0.55; }
.btn.approve.active { background: var(--strong); border-color: var(--strong); color: #fff; }
.btn.reject.active { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn + .btn { margin-left: 0.35rem; }

.back { display: inline-block; margin-bottom: 1rem; }
.detail-head { display: flex; gap: 1.25rem; align-items: center; }
.meta { display: flex; gap: 0.5rem 1rem; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 0.9rem; margin-top: 0.35rem; }
.summary { font-size: 1.02rem; line-height: 1.5; max-width: 60rem; }

.review-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 1rem 0; }
.review-panel label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0.75rem 0 0.3rem; }
.decision { display: flex; gap: 0.5rem; align-items: center; }
.decision .btn + .btn { margin-left: 0; }
.row { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.5rem; }

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.reqs { list-style: none; padding: 0; margin: 0; }
.reqs li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 0.75rem; margin-bottom: 0.5rem; line-height: 1.45; }
.reqs li div { color: var(--muted); font-size: 0.9rem; margin-top: 0.2rem; }
.ok { color: var(--strong); font-weight: 700; }

.package { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; margin-bottom: 0.6rem; }
.package-head { display: flex; gap: 0.75rem; align-items: baseline; flex-wrap: wrap; }
.note { color: var(--stretch); font-size: 0.85rem; margin-top: 0.3rem; }
details { margin-top: 0.5rem; }
details summary { cursor: pointer; color: var(--accent); }
pre.report { white-space: pre-wrap; font-family: inherit; font-size: 0.9rem; line-height: 1.5; background: var(--bg); border-radius: 6px; padding: 0.75rem 1rem; max-height: 32rem; overflow: auto; }
.posting { margin-top: 1.5rem; }

/* Application stages */
.stage-applied { background: var(--skip-bg); color: var(--skip); }
.stage-screen, .stage-interview { background: var(--accent-bg); color: var(--accent); }
.stage-offer { background: var(--strong-bg); color: var(--strong); }
.stage-rejected { background: var(--danger-bg); color: var(--danger); }
.matches tr.stage-row-rejected td { opacity: 0.7; }

.apply-panel { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 0.25rem 1rem 1rem; margin: 1rem 0; }
.apply-panel h2 { margin-top: 0.75rem; }
.apply-panel p { margin: 0.4rem 0; max-width: 60rem; }
pre.command { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.55rem 0.75rem; overflow-x: auto; font-size: 0.88rem; margin: 0.5rem 0; user-select: all; }

.stat-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; margin-bottom: 0.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.25rem 1rem 0.75rem; overflow-x: auto; }
.stat-card h2 { margin-top: 0.75rem; }
table.rates { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.rates th, .rates td { padding: 0.35rem 0.4rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.rates thead th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.rates tbody th { font-weight: 600; }
.rates tr:last-child th, .rates tr:last-child td { border-bottom: none; }
.rates .n { text-align: right; font-variant-numeric: tabular-nums; }
.bar-cell { display: flex; align-items: center; gap: 0.5rem; }
.bar { width: 4.5rem; height: 0.5rem; border-radius: 999px; background: var(--skip-bg); overflow: hidden; flex: none; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar.strong span { background: var(--strong); }
.bar-label { font-variant-numeric: tabular-nums; color: var(--muted); }

.stage-select { min-width: 8rem; }
ul.history { list-style: none; padding: 0; margin: 0.4rem 0 0; }
ul.history li { margin-bottom: 0.3rem; }

@media (max-width: 860px) {
    .columns { grid-template-columns: 1fr; }
    .matches thead { display: none; }
    .matches, .matches tbody, .matches tr, .matches td { display: block; width: 100%; }
    .matches tr { border-bottom: 1px solid var(--border); padding: 0.5rem 0; }
    .matches td { border: none; padding: 0.3rem 0.8rem; }
    .num { text-align: left; display: flex !important; gap: 0.6rem; align-items: center; }
    .page { padding: 1rem; }
}

#blazor-error-ui {
    background: lightyellow; color: #1d2330; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* Accounts and profile */
.topbar .account { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar .account form { margin: 0; }
.topbar .account .who { color: inherit; text-decoration: none; font-weight: 600; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
button.link:hover { text-decoration: underline; }
button.link.danger { color: var(--danger); }
button.primary, .card button.primary { background: var(--accent); color: #fff; border: 0; border-radius: var(--radius); padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer; }
button.primary:disabled { opacity: .6; cursor: default; }
.card button:not(.link):not(.primary) { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px; font: inherit; cursor: pointer; }
.signin-page { display: flex; justify-content: center; padding-top: 10vh; }
.signin { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.signin h1 { margin-top: 0; }
.signin label, .card label { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-weight: 600; }
.signin label.check, .card label.check { flex-direction: row; align-items: center; font-weight: 400; gap: 8px; }
.signin input:not([type=checkbox]), .card input:not([type=checkbox]):not([type=file]), .card select { font: inherit; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-weight: 400; }
.signin button.primary { width: 100%; margin-top: 8px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin: 16px 0; }
.card.narrow { max-width: 460px; }
.card h2 { margin-top: 0; }
.card textarea { width: 100%; box-sizing: border-box; font-weight: 400; }
.card .block { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; align-items: end; }
.tabs { display: flex; gap: 4px; margin: 12px 0 0; }
.tabs button { background: none; border: 1px solid transparent; border-bottom: 2px solid transparent; padding: 6px 12px; font: inherit; cursor: pointer; color: var(--muted); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
textarea.json { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }
.error { color: var(--danger); background: var(--danger-bg); border-radius: 6px; padding: 8px 10px; }
.ok { color: var(--strong); background: var(--strong-bg); border-radius: 6px; padding: 8px 10px; }
.validation-message { color: var(--danger); font-size: 13px; }
.actions.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--border); }
