:root {
  --ink: #17212b;
  --ink-2: #4a5866;
  --muted: #7b8794;
  --line: #e2e6ea;
  --line-2: #eef1f3;
  --bg: #f6f7f5;
  --card: #ffffff;
  --brand: #0f4c5c;
  --brand-2: #e6f0f1;
  --red: #b42318;
  --red-bg: #fdecea;
  --amber: #93630b;
  --amber-bg: #fdf3dc;
  --green: #1d6b3c;
  --green-bg: #e6f4eb;
  --blue: #1f5aa6;
  --blue-bg: #e8f0fb;
  --radius: 8px;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
.sub, .muted { color: var(--muted); }
.sub { margin: 0; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand strong { display: block; font-size: 14px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.mark { width: 30px; height: 30px; border-radius: 7px; background: var(--brand); color: #fff; display: grid;
  place-items: center; font-weight: 700; }
.topbar nav { display: flex; gap: 18px; flex: 1; }
.topbar nav a { text-decoration: none; color: var(--ink-2); font-weight: 500; }
.who { display: flex; gap: 12px; align-items: center; color: var(--ink-2); }
.who form { margin: 0; }
button.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font: inherit; }

.page { max-width: 1280px; margin: 0 auto; padding: 24px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 500;
  cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #c7ced5; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0b3c49; }
.btn.danger-outline { color: var(--red); }
.btn.wide { width: 100%; justify-content: center; padding: 10px; }

/* alerts */
.alert { padding: 10px 12px; border-radius: 6px; margin: 0 0 12px; }
.alert p { margin: 0 0 6px; }
.alert.error { background: var(--red-bg); color: var(--red); }
.alert.ok { background: var(--green-bg); color: var(--green); }
.alert.info { background: var(--blue-bg); color: var(--blue); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }

/* login */
.login-body { background: linear-gradient(160deg, #e6f0f1, #f6f7f5 60%); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); padding: 28px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 76, 92, .08); border: 1px solid var(--line); }
.login-card .brand { margin-bottom: 20px; }
.login-card label { display: block; font-weight: 500; margin-bottom: 14px; color: var(--ink-2); }
.login-card input { display: block; width: 100%; margin-top: 6px; }
.fineprint { color: var(--muted); font-size: 12px; margin: 16px 0 0; }

input, select, textarea { font: inherit; color: var(--ink); padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 76, 92, .25); border-color: var(--brand); }

/* queue */
.queue-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; gap: 16px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; }
.head-actions form { margin: 0; }
.due-text { color: var(--red); font-weight: 600; }
.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; background: var(--line-2); padding: 3px; border-radius: 8px; margin-right: auto; }
.tab { padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--ink-2); font-weight: 500; }
.tab.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.tab .count { color: var(--muted); font-weight: 400; margin-left: 2px; }
.filters input[type=search] { width: 240px; }

table.queue { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.queue th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fbfbfa; }
.queue td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.queue tr:last-child td { border-bottom: 0; }
.queue tr.row { cursor: pointer; }
.queue tr.row:hover td { background: #fafbfa; }
.queue tr.urgent td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.pt { font-weight: 600; text-decoration: none; color: var(--ink); display: block; }
.queue small { display: block; color: var(--muted); margin-top: 2px; }
.queue td.from { color: var(--ink-2); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue small.chip, .chip { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px;
  background: var(--line-2); color: var(--ink-2); margin: 0 0 0 4px; }
.svc { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.svc-tcm { background: var(--blue-bg); color: var(--blue); }
.svc-wound_care { background: #f3eafa; color: #6b3e91; }
.svc-unknown { background: var(--line-2); color: var(--ink-2); }
.deadline { font-weight: 500; white-space: nowrap; }
.deadline.overdue, .deadline.due-today { color: var(--red); font-weight: 600; }
.badge { font-weight: 600; text-transform: uppercase; font-size: 10px !important; letter-spacing: .05em; }
.badge.overdue, .badge.due-today { color: var(--red) !important; }
.badge.due-tomorrow { color: var(--amber) !important; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; margin: 0 4px 2px 0; white-space: nowrap; }
.pill.err { background: var(--red-bg); color: var(--red); }
.pill.warn { background: var(--amber-bg); color: var(--amber); }
.pill.ok { background: var(--green-bg); color: var(--green); }
.status { font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-new { color: var(--blue); }
.st-needs_info { color: var(--amber); }
.st-accepted { color: var(--green); }
.st-declined { color: var(--muted); }
.st-error { color: var(--red); }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 48px; text-align: center; }

/* review screen */
main.review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(460px, 560px); height: calc(100vh - 51px); }
.pdf-pane { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #525659; }
.pdf-bar { display: flex; justify-content: space-between; padding: 8px 14px; background: var(--card);
  border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: 13px; }
.pdf-pane iframe { flex: 1; width: 100%; border: 0; }
.form-pane { overflow-y: auto; padding: 18px 22px 0; background: var(--card); }
.form-head { margin-bottom: 14px; }
.back { text-decoration: none; font-size: 13px; color: var(--muted); }
.form-head h1 { margin-top: 6px; }
.meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 13px; align-items: center; }
.meta.from { margin-top: 4px; }
.service-pick { display: flex; align-items: center; gap: 6px; margin: 4px 0 14px; }
.service-pick .lbl { font-weight: 600; margin-right: 6px; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.seg input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid rgba(15, 76, 92, .4); }

.deadlines { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.dl { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.dl span, .dl small { display: block; color: var(--muted); font-size: 12px; }
.dl strong { display: block; font-size: 16px; margin: 2px 0; }
.dl.now { border-color: var(--amber); background: var(--amber-bg); }
.dl.past { border-color: var(--red); background: var(--red-bg); }
.dl.past strong { color: var(--red); }

.issues { list-style: none; padding: 0; margin: 0 0 14px; }
.iss { padding: 7px 10px; border-radius: 6px; margin-bottom: 4px; font-size: 13px; }
.iss.error { background: var(--red-bg); color: var(--red); }
.iss.warning { background: var(--amber-bg); color: var(--amber); }
.iss.info { background: var(--blue-bg); color: var(--blue); }

fieldset.section { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 14px 0 6px; }
fieldset.section legend { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--brand); padding: 0 8px 0 0; }
fieldset.section > textarea { width: 100%; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.field { display: flex; flex-direction: column; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.field input, .field select, .field textarea { width: 100%; }
.field.error input, .field.error select, .field.error textarea { border-color: #e5a29b; background: #fffafa; }
.field.warning input, .field.warning select, .field.warning textarea { border-color: #e6c37d; background: #fffdf6; }
.req { color: var(--red); }
.lowconf { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; background: var(--amber-bg);
  color: var(--amber); padding: 1px 5px; border-radius: 4px; font-weight: 700; }
.msg, .hint { font-size: 12px; margin-top: 3px; }
.msg.error { color: var(--red); }
.msg.warning { color: var(--amber); }
.msg.info { color: var(--blue); }
.hint { color: var(--muted); }

.history { margin: 6px 0 12px; color: var(--ink-2); }
.history summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.history ul { list-style: none; padding: 0; margin: 8px 0 0; font-size: 12px; }
.history li { padding: 3px 0; border-bottom: 1px solid var(--line-2); }
.history li span { color: var(--muted); margin-right: 6px; }

.actions { position: sticky; bottom: 0; display: flex; gap: 8px; justify-content: flex-end; padding: 12px 0 16px;
  background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 30%); margin-top: 8px; }

@media (max-width: 1000px) {
  main.review { grid-template-columns: 1fr; height: auto; }
  .pdf-pane { height: 70vh; }
  .grid, .deadlines { grid-template-columns: 1fr; }
  .queue td.from, .queue th:nth-child(5) { display: none; }
}

/* ---------- eligibility (phase 2) ---------- */
.btn.small { padding: 5px 10px; font-size: 13px; }
.pill.info { background: var(--blue-bg); color: var(--blue); }
.elig { border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.elig-active { border-left-color: var(--green); }
.elig-inactive { border-left-color: var(--red); background: #fffafa; }
.elig-error, .elig-not_checked { border-left-color: var(--amber); }
.elig-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.elig-head > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.elig-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); }
.elig-status { font-size: 16px; }
.elig-active .elig-status { color: var(--green); }
.elig-inactive .elig-status { color: var(--red); }
.elig-error .elig-status, .elig-not_checked .elig-status { color: var(--amber); }
.elig-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 10px 0 4px; }
.elig-facts dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.elig-facts dd { margin: 2px 0 0; font-weight: 500; }
.elig-facts small { color: var(--muted); font-weight: 400; }
.elig p.iss { margin: 8px 0 0; }
.elig-meta { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.benefits { margin-top: 8px; font-size: 13px; }
.benefits summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
.benefits table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 12px; }
.benefits th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.benefits td { padding: 4px 6px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.benefits td small { color: var(--muted); display: block; }
.benefits ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); }
.elig-pill { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.ep-active { background: var(--green-bg); color: var(--green); }
.ep-inactive { background: var(--red-bg); color: var(--red); }
.ep-error, .ep-not_checked { background: var(--amber-bg); color: var(--amber); }
.payer-row { padding: 8px 12px !important; }
.payer-form { display: grid; grid-template-columns: 1.3fr .7fr 2fr 1.1fr .6fr .5fr auto; gap: 8px; align-items: center; margin: 0; }
.payer-form input, .payer-form select { width: 100%; }
.payer-row.new { background: #fbfbfa; }
@media (max-width: 1000px) { .payer-form { grid-template-columns: 1fr 1fr; } .elig-facts { grid-template-columns: 1fr; } }
.default-submit { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.payer-head span { font-size: 12px; } .payer-head { min-height: 0; } .payers-sub { margin-bottom: 16px; max-width: 900px; }
.payer-form > :last-child { justify-self: end; min-width: 58px; }
