:root {
  --bg: #f6f7f9; --surface: #fff; --text: #1d2330; --muted: #6a7282; --line: #e3e6eb;
  --accent: #2f5bd3; --accent-soft: #e8eefc; --good: #1f7a4d; --good-soft: #e4f4ec;
  --warn: #a65d00; --warn-soft: #fbf0e1; --bad: #b3261e; --bad-soft: #fbe9e8; --grey-soft: #eef0f3;
  --radius: 10px; color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b; --surface: #1c1f26; --text: #e6e8ec; --muted: #9aa1ae; --line: #2c313b;
    --accent: #7c9cf5; --accent-soft: #24304d; --good: #6fd19f; --good-soft: #1b3428;
    --warn: #f0b061; --warn-soft: #3a2c17; --bad: #f08a83; --bad-soft: #3b1f1d; --grey-soft: #262a33;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1.02rem; margin: 0; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { font-weight: 700; color: var(--text); }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.tabs a:hover { background: var(--grey-soft); text-decoration: none; }
.tabs a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--surface); font-size: .75rem; text-align: center; font-weight: 600; }
.logout { display: flex; gap: 10px; align-items: center; }
.runline { font-size: .82rem; padding-bottom: 8px; }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

main { padding: 28px 20px 60px; }
.page-head { margin-bottom: 20px; }
.page-head p { margin: .25rem 0 0; max-width: 70ch; }
.notice, .error { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 18px; }
.notice { background: var(--accent-soft); }
.error { background: var(--bad-soft); color: var(--bad); }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 32px; text-align: center; }
.empty p { margin: .3rem 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #10131a; } }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; justify-content: center; padding: 9px; }
.btn:disabled { opacity: .5; cursor: wait; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

/* offer cards */
.day h2 { margin-top: 28px; }
.cards { display: grid; gap: 12px; }
.card, .detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  transition: opacity .25s, transform .25s; }
.card.leaving { opacity: 0; transform: translateX(16px); }
.card-head { display: flex; gap: 14px; align-items: flex-start; }
.card-title { flex: 1; min-width: 0; }
.card-title h3 a, .card-title h1 { color: var(--text); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: .86rem; margin-top: 2px; }
.summary { margin: 10px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; background: var(--grey-soft); color: var(--text); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.gap { background: var(--warn-soft); color: var(--warn); }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.actions { display: flex; gap: 6px; }
.score { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; font-weight: 700; font-size: .95rem; }
.score.hi { background: var(--good-soft); color: var(--good); }
.score.mid { background: var(--warn-soft); color: var(--warn); }
.score.lo { background: var(--grey-soft); color: var(--muted); }
td .score { width: 34px; height: 34px; font-size: .85rem; }

/* detail */
.detail h1 { font-size: 1.35rem; }
.detail-status { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 20px 0 0; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.description { white-space: pre-wrap; line-height: 1.6; max-width: 80ch; }

/* status badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.match, .chip.match.on { background: var(--accent-soft); color: var(--accent); }
.badge.apply, .chip.apply.on { background: var(--good-soft); color: var(--good); }
.badge.userdiscard, .chip.userdiscard.on, .badge.discard, .chip.discard.on { background: var(--bad-soft); color: var(--bad); }
.badge.rejected, .badge.pending { background: var(--grey-soft); color: var(--muted); }

/* all offers */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type=search] { flex: 1; min-width: 220px; }
.status-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.status-chips .chip { border: 1px solid var(--line); background: var(--surface); color: var(--muted); padding: 4px 11px; }
.status-chips .chip:hover { text-decoration: none; border-color: var(--muted); }
.status-chips .chip.on { border-color: transparent; background: var(--text); color: var(--surface); }
.status-chips b { font-weight: 600; margin-left: 3px; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.offers { width: 100%; border-collapse: collapse; }
.offers th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.offers td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.offers tr:last-child td { border-bottom: 0; }
.offers tr.closed .title { color: var(--muted); }
.offers .title { color: var(--text); font-weight: 600; }
.offers .reason { font-size: .8rem; margin-top: 3px; max-width: 32ch; }
.offers .actions .btn { padding: 4px 9px; font-size: .8rem; }
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 16px; }

/* forms */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; resize: vertical; }
.form label { display: block; margin-bottom: 12px; font-weight: 500; font-size: .92rem; }
.form label > input:not([type=checkbox]), .form label > select { display: block; width: 100%; margin-top: 4px; font-weight: 400; }
.form label.inline, .form label.check { font-weight: 400; }
.form label.inline input { display: inline-block; width: auto; margin: 0 4px; }
.narrow { width: 80px !important; }
.row { display: flex; gap: 6px; margin-top: 4px; font-weight: 400; align-items: center; }
.row input:first-child { flex: 1; }
.auth { max-width: 380px; margin: 8vh auto 0; }
.auth .form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 18px 0; }
.settings { max-width: 820px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 20px 16px; margin-bottom: 18px; }
.panel > p.muted { margin-top: -4px; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; }
legend { font-weight: 500; font-size: .92rem; margin-bottom: 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.check { display: flex !important; gap: 8px; align-items: baseline; }
.check > span { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } .topbar-inner { gap: 12px; } .logout .muted { display: none; } }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface);
  padding: 10px 14px; border-radius: 10px; display: flex; gap: 14px; align-items: center; box-shadow: 0 6px 24px rgba(0,0,0,.2); z-index: 10; }
.toast[hidden] { display: none; }
.toast button { background: none; border: 0; color: var(--accent-soft); font: inherit; font-weight: 600; cursor: pointer; }
