:root {
  --bg: #f5f6f8; --card: #fff; --text: #1d2330; --muted: #6b7385; --line: #e3e6ec;
  --brand: #1f4fd1; --brand-soft: #e8eefc; --ok: #13804b; --ok-soft: #e3f5ea; --warn: #a15c00; --warn-soft: #fff2dc;
  --bad: #b42318; --bad-soft: #fde8e6; --info-soft: #eef0f4;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
small, .muted { color: var(--muted); }

.topbar { display: flex; align-items: center; gap: 24px; background: #111a2e; color: #fff; padding: 0 20px; height: 52px; position: sticky; top: 0; z-index: 10; }
.topbar .brand { color: #fff; font-weight: 700; font-size: 16px; }
.topbar nav { display: flex; gap: 4px; flex: 1; align-items: center; }
.topbar nav > a, .dd > span { color: #c9d1e3; padding: 8px 10px; border-radius: 6px; cursor: pointer; display: inline-block; }
.topbar nav > a.active, .dd > span.active, .topbar nav > a:hover, .dd:hover > span { background: #22305a; color: #fff; text-decoration: none; }
.dd { position: relative; }
.dd-menu { display: none; position: absolute; top: 100%; left: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 240px; padding: 6px; }
.dd:hover .dd-menu { display: block; }
.dd-menu a { display: block; padding: 8px 10px; color: var(--text); border-radius: 6px; }
.dd-menu a:hover { background: var(--brand-soft); text-decoration: none; }
.who { display: flex; gap: 12px; align-items: center; color: #c9d1e3; }
.who small { color: #8d97ad; }
button.link { background: none; border: 0; color: #9db6ff; cursor: pointer; padding: 0; font: inherit; }

main { max-width: 1320px; margin: 0 auto; padding: 20px; }
main.narrow { max-width: 420px; padding-top: 80px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 900px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; } }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat .sub { color: var(--muted); font-size: 12px; }
a.stat:hover { border-color: var(--brand); text-decoration: none; }

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfc; white-space: nowrap; }
tr:hover td { background: #fafcff; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; background: #fafbfc; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 16px; }
.tablewrap table { border: 0; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

form.inline { display: inline; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #cfd4de; border-radius: 6px; font: inherit; background: #fff; color: var(--text); }
input[type=checkbox] { width: auto; }
textarea { min-height: 70px; }
.field { margin-bottom: 12px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { margin: 0; min-width: 150px; }
.btn { display: inline-block; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--bad-soft); color: var(--bad); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--info-soft); color: #39425a; white-space: nowrap; }
.st-enrolled, .st-paid, .st-unconditional-offer, .st-offer-accepted, .st-interview-passed, .st-payable, .st-settled { background: var(--ok-soft); color: var(--ok); }
.st-conditional-offer, .st-interview-scheduled, .st-invoiced, .st-unpaid, .st-on-hold, .st-due { background: var(--warn-soft); color: var(--warn); }
.st-interview-failed, .st-interview-no-show, .st-rejected, .st-withdrawn, .st-overdue, .st-recoverable, .st-clawback-due, .st-void, .st-cancelled { background: var(--bad-soft); color: var(--bad); }
.st-application-submitted, .st-new-lead, .st-documents-pending, .st-scheduled, .st-deferred, .st-recovered, .st-credited { background: var(--brand-soft); color: var(--brand); }

.doclist { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.doc { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.doc.missing { border-style: dashed; color: var(--muted); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; }
.kv div:nth-child(odd) { color: var(--muted); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); }

/* Invoice print */
.invoice { background: #fff; max-width: 860px; margin: 0 auto; padding: 40px; border: 1px solid var(--line); }
.invoice h1 { font-size: 28px; }
.invoice .head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
@media print {
  .topbar, .noprint, .flash { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .invoice { border: 0; padding: 0; }
}

.wrap-head th { white-space: normal; vertical-align: bottom; }

/* Logo */
.topbar .brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.topbar .brand:hover { text-decoration: none; }
.logo-tile { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; overflow: hidden; flex: none; }
.logo-tile img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.logo-tile.big { width: 56px; height: 56px; border-radius: 12px; }
.login-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.login-logo h1 { margin: 0; }
