/* ERA enrollment operator UI (TOL-1928). Tolerance design tokens; one typeface. */

:root {
  --green: #10765B;
  --green-hover: #0C5E49;
  --green-soft: #E6F1ED;
  --bg: #F7F7F4;
  --surface: #FFFFFF;
  --surface-2: #F4F4F1;
  --border: #E7E7E4;
  --border-strong: #D6D6D2;
  --ink: #1B1B16;
  --muted: #57574F;
  --dim: #8A8A82;
  --warn: #B8770B;
  --warn-soft: #FBF1DD;
  --danger: #C0392B;
  --danger-soft: #FBEAE7;
  --info: #2E5C8A;
  --info-soft: #E9EFF6;
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --rail: 216px;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.skip {
  position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 6px 10px; border: 1px solid var(--border);
}
.skip:focus { left: 8px; z-index: 10; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; padding: 20px 16px; border-right: 1px solid var(--border);
  background: var(--surface); display: flex; flex-direction: column; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px; }
.brand-mark { width: 12px; height: 12px; border-radius: 3px; background: var(--green); }
.brand-name { font-weight: 600; letter-spacing: -0.01em; }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; justify-content: space-between; align-items: baseline; padding: 7px 8px; border-radius: 6px; color: var(--ink);
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--green-soft); color: var(--green-hover); font-weight: 500; }
.nav .count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.nav a.active .count { color: var(--green-hover); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; font-size: 13px; padding: 0 6px; }
.who { color: var(--muted); word-break: break-all; }
.who button { margin-left: 6px; }

.main { padding: 28px 36px 60px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 10px; }
.lede { color: var(--muted); margin: 4px 0 0; max-width: 64ch; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.mono, .id, td.num, .num { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.small { font-size: 13px; }

/* ---- controls ---- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field > input, .field > select, .field > textarea {
  padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--ink); min-width: 160px;
}
.field > textarea { min-width: 320px; min-height: 64px; resize: vertical; }
input:disabled, select:disabled, textarea:disabled, button:disabled { opacity: 0.55; cursor: not-allowed; }
.btn {
  padding: 7px 12px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-hover); }
.btn.danger { color: var(--danger); border-color: #E7B7B1; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.quiet { border-color: transparent; color: var(--green); padding-left: 6px; padding-right: 6px; }
.btn.quiet:hover { background: var(--green-soft); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- table (the ledger) ---- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.row-link { cursor: pointer; }
tbody tr.row-link:hover td { background: #FBFBF9; }
tbody tr.flash td { animation: flash 900ms ease-out; }
@keyframes flash { from { background: var(--green-soft); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { tbody tr.flash td { animation: none; } }
td.sel { width: 32px; padding-right: 0; }
.empty { padding: 36px 20px; color: var(--muted); text-align: center; }
.empty strong { display: block; color: var(--ink); font-weight: 500; margin-bottom: 4px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; color: var(--muted); font-size: 13px; }

/* ---- status pills: one vocabulary everywhere ---- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 6px; border-radius: 999px; font-size: 12.5px; font-weight: 500; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid transparent;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.pill.s-PendingSubmission, .pill.s-PendingEaseAction { background: var(--info-soft); color: var(--info); }
.pill.s-Submitted { background: var(--info-soft); color: var(--info); }
.pill.s-PendingClientAction { background: var(--warn-soft); color: var(--warn); }
.pill.s-Approved { background: var(--green-soft); color: var(--green-hover); }
.pill.s-Verified { background: var(--green); color: #fff; }
.pill.s-Verified::before { background: #fff; }
.pill.s-NeedsInvestigation { background: var(--danger-soft); color: var(--danger); }
.pill.s-Denied { background: var(--danger-soft); color: var(--danger); }
.pill.s-OnHold, .pill.s-NotSupported, .pill.s-Canceled { background: var(--surface-2); color: var(--muted); }
.pill.s-RequiresManualSubmission { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.pill.s-Unsupported { background: transparent; color: var(--danger); border-color: var(--danger); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 12px; background: var(--surface-2); color: var(--muted); margin-right: 4px; white-space: nowrap; }
.tag.reason-open_proposal { background: var(--green-soft); color: var(--green-hover); }
.tag.reason-human_submission, .tag.reason-ease_action { background: var(--warn-soft); color: var(--warn); }
.tag.reason-investigate, .tag.reason-denied, .tag.reason-unmapped_status { background: var(--danger-soft); color: var(--danger); }
.tag.reason-lane_needed, .tag.reason-lane_unavailable { background: var(--warn-soft); color: var(--warn); }
.tag.reason-scheduled { background: var(--surface-2); color: var(--ink); }
.tag.reason-pre_submission_check { background: var(--danger-soft); color: var(--danger); }
.tag.lane-agent, .tag.lane-availity_batch { background: var(--green-soft); color: var(--green-hover); }
.tag.lane-optum_api { background: var(--surface-2); color: var(--ink); }
.tag.lane-human, .tag.lane-human_wet_signature, .tag.lane-human_portal_access { background: var(--warn-soft); color: var(--warn); }
.tag.lane-not_supported { background: var(--danger-soft); color: var(--danger); }
.work-item .headline { font-size: 15px; font-weight: 500; margin: 4px 0 6px; }
.work-item .checklist { margin: 12px 0 0 20px; padding: 0; font-size: 13.5px; }
.work-item .checklist li { margin: 4px 0; }

/* ---- detail ---- */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.key { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.key .sep { color: var(--dim); font-weight: 400; margin: 0 6px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13.5px; margin-top: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.cols { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 24px; align-items: start; }
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; margin-bottom: 18px; }
.panel h2 { display: flex; justify-content: space-between; align-items: baseline; }
.panel h2 .muted { font-weight: 400; font-size: 13px; }
.proposal { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; padding: 10px 0; border-top: 1px solid var(--border); }
.proposal:first-of-type { border-top: none; padding-top: 0; }
.proposal .why { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.transitions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.reason-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.reason-row .field { flex: 1; min-width: 240px; }
.reason-row .field > textarea, .reason-row .field > input { min-width: 0; width: 100%; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 124px 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.timeline li:first-child { border-top: none; padding-top: 0; }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline .kind { font-weight: 500; }
.timeline .by { color: var(--muted); }
.timeline .detail { color: var(--muted); margin-top: 2px; white-space: pre-wrap; word-break: break-word; }

.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.source { border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; font-size: 13px; }
.source .name { font-weight: 500; margin-bottom: 4px; }
.source .asserted { margin: 4px 0; }
.evidence-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.evidence-list li { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; align-items: baseline; overflow-wrap: anywhere; }
.evidence-list img { max-width: 100%; border: 1px solid var(--border); border-radius: 6px; margin-top: 6px; display: block; }
details summary { cursor: pointer; color: var(--muted); font-size: 13.5px; }
pre.json { font-size: 12.5px; background: var(--surface-2); padding: 10px; border-radius: 6px; overflow: auto; max-height: 360px; white-space: pre-wrap; }

/* ---- metrics ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; }
.stat .n { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.stat .sub { color: var(--dim); font-size: 12.5px; margin-top: 6px; }
.bars { display: grid; grid-template-columns: max-content 1fr max-content; gap: 6px 12px; align-items: center; font-size: 13.5px; }
.bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--green); }
.bar.b-PendingClientAction > span, .bar.b-PendingEaseAction > span, .bar.b-RequiresManualSubmission > span { background: var(--warn); }
.bar.b-NeedsInvestigation > span, .bar.b-Denied > span, .bar.b-Unsupported > span { background: var(--danger); }
.bar.b-PendingSubmission > span, .bar.b-Submitted > span { background: var(--info); }
.bar.b-OnHold > span, .bar.b-NotSupported > span, .bar.b-Canceled > span { background: var(--border-strong); }

/* ---- digest ---- */
pre.digest { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 18px 20px; white-space: pre-wrap; font-family: var(--font); font-size: 14px; line-height: 1.5; }

/* ---- sign in ---- */
.signin { max-width: 520px; margin: 60px auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 28px 30px; }
.signin p { color: var(--muted); }
.signin .field > input { min-width: 0; width: 100%; }

/* ---- notices and toasts ---- */
.notice { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 13.5px; border: 1px solid var(--border); background: var(--surface); }
.notice.warn { background: var(--warn-soft); border-color: #EBD6A6; color: #6B4606; }
.notice.danger { background: var(--danger-soft); border-color: #E7B7B1; color: #7A231B; }
.notice.ok { background: var(--green-soft); border-color: #BFDCD1; color: var(--green-hover); }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13.5px; max-width: 420px; box-shadow: 0 6px 24px rgba(27, 27, 22, 0.18); }
.toast.error { background: var(--danger); }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 18px 16px 40px; }
}

/* Sortable queue headers (Demo 2 P1-4): the API orders the page; the header says by what. */
th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
th.th-sort:hover { color: var(--ink); text-decoration: underline; }
th.th-sort.on { color: var(--green); }
