:root {
  --navy: #0E3A53;
  --navy-light: #14506f;
  --clay: #C2410C;
  --ink: #1E293B;
  --muted: #64748B;
  --border: #E2E8F0;
  --bg: #F7F5F1;
  --card: #FFFFFF;
  --red: #B91C1C;
  --amber: #A16207;
  --blue: #1D4ED8;
  --green: #15803D;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Public Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* ---------- App header / top-level nav (Dashboard / Review worklist) ---------- */

.app-header {
  background: var(--navy);
  border-bottom: 1px solid #092A3D;
}
.app-header-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}
.brand-logo { height: 34px; width: auto; display: block; }
.brand-text { line-height: 1.15; }
.brand-name { color: #fff; font-size: 14.5px; font-weight: 700; }
.brand-sub { color: #9FB4C4; font-size: 10.5px; }

.app-nav { display: flex; align-items: center; gap: 28px; }
.nav-link {
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: #AFC3D2;
  border-bottom: 2px solid transparent;
  padding: 21px 0 20px;
}
.nav-link:hover { color: #fff; }
.nav-link.active { color: #fff; border-bottom-color: var(--clay); }

.nav-user {
  display: flex; align-items: center; gap: 8px;
  padding-left: 20px; border-left: 1px solid #1B4C68;
}
.nav-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--navy-light); color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.nav-user-name { color: #CBD5E1; font-size: 12px; }
.btn-signout {
  background: none; border: 1px solid #2B5D7A; color: #CBD5E1;
  border-radius: 6px; padding: 4px 10px; font-size: 11px; font-weight: 600;
  cursor: pointer; margin-left: 4px; font-family: inherit;
}
.btn-signout:hover { background: #1B4C68; color: #fff; }

main { max-width: 1360px; margin: 0 auto; padding: 0 28px 28px; }

/* ---------- Dashboard view ---------- */

.dashboard { padding-top: 22px; }

.stat-cards { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-card {
  flex: 1 1 150px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-value { font-size: 24px; font-weight: 800; color: var(--navy); }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

.dashboard-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; margin-bottom: 16px; align-items: start; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px 18px;
  margin-bottom: 16px;
}
.dashboard-grid .panel { margin-bottom: 0; }
.panel h3 { margin-top: 0; }
.panel h3:not(:first-child) { margin-top: 20px; }

.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 190px 1fr 30px; align-items: center; gap: 10px; }
.funnel-label { font-size: 12px; color: var(--muted); }
.funnel-bar-track, .breakdown-bar-track {
  background: #F1F5F9; border-radius: 6px; height: 14px; overflow: hidden;
}
.funnel-bar { display: block; height: 100%; background: var(--navy); border-radius: 6px; }
.funnel-count { font-size: 12.5px; font-weight: 700; text-align: right; color: var(--ink); }

.breakdown { display: flex; flex-direction: column; gap: 8px; }
.breakdown-row { display: grid; grid-template-columns: 150px 1fr 26px; align-items: center; gap: 10px; }
.breakdown-label { font-size: 12px; color: var(--muted); }
.breakdown-bar { display: block; height: 100%; background: var(--clay); border-radius: 6px; }
.breakdown-count { font-size: 12.5px; font-weight: 700; text-align: right; color: var(--ink); }

.attention-list { display: flex; flex-direction: column; gap: 8px; }
.attention-item {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; cursor: pointer; gap: 10px; flex-wrap: wrap;
}
.attention-item:hover { background: #F8FAFC; border-color: #CBD5E1; }
.attention-main { display: flex; align-items: baseline; gap: 8px; }
.attention-id { font-weight: 700; font-size: 12.5px; color: var(--navy); }
.attention-patient { font-size: 12px; color: var(--ink); }
.attention-meta { display: flex; gap: 12px; font-size: 11px; color: var(--muted); }
.attention-reason { font-weight: 600; }

.tabs { display: flex; gap: 4px; padding: 22px 0 0; }
.tab {
  background: none;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tab.active { background: var(--card); color: var(--navy); }

.layout {
  display: grid;
  grid-template-columns: 1.1fr 1.4fr;
  gap: 0;
  padding: 0 0 28px;
  align-items: start;
}

.list-pane {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0 8px 8px 8px;
  overflow: hidden;
  margin-right: 16px;
}
table.worklist { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.worklist th {
  text-align: left;
  padding: 8px 10px;
  background: #F1F5F9;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
}
table.worklist td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.worklist tr { cursor: pointer; }
table.worklist tr:hover td { background: #F8FAFC; }
table.worklist tr.selected td { background: #FEF3E7; }
.empty-state { padding: 20px; color: var(--muted); font-size: 13px; }

.flag-count { display: inline-block; min-width: 18px; text-align: center; background: #FEF3C7; color: #78350F; border-radius: 8px; padding: 1px 6px; font-size: 10.5px; font-weight: 700; }
.flag-count.zero { background: transparent; color: var(--border); }

.detail-pane {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px 26px;
  min-height: 300px;
}
.placeholder { color: var(--muted); font-size: 13px; }

.detail-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.detail-head h2 { margin: 0; font-size: 18px; color: var(--navy); }
.detail-head .d-patient { font-size: 12px; color: var(--muted); }
.badge { font-size: 10.5px; font-weight: 700; padding: 3px 10px; border-radius: 12px; background: var(--navy); color: #fff; text-transform: uppercase; letter-spacing: .02em; }
.badge.FINAL_PCRL { background: var(--clay); }

.d-terminated-note {
  background: #FEE2E2; color: #7F1D1D; border: 1px solid #FCA5A5;
  border-radius: 8px; padding: 8px 12px; font-size: 12px; margin: 0 0 14px;
}

h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--navy); margin: 18px 0 6px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
h3 .hint { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; font-size: 11px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
dl { margin: 0; }
dt { font-size: 10.5px; color: var(--muted); margin-top: 8px; }
dt:first-child { margin-top: 0; }
dd { margin: 1px 0 0; font-size: 12.5px; }

.d-escalations, .d-candidates-body ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.d-escalations li, .cand-item {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px;
}
.cand-item .cand-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; margin-bottom: 3px; }
.cand-item .cand-priority { font-weight: 700; }
.cand-item .cand-flag { color: var(--muted); font-style: italic; font-size: 10.5px; }
.cand-item .cand-text { color: var(--muted); font-size: 11px; max-height: 4.5em; overflow: hidden; }

.hitl-row { display: flex; gap: 8px; font-size: 12px; margin-bottom: 4px; }
.hitl-row b { min-width: 130px; display: inline-block; color: var(--muted); font-weight: 600; }

.d-rationale-wrap { background: #F8FAFC; border: 1px solid var(--border); border-radius: 8px; padding: 4px 14px 12px; }
.d-rationale-wrap h3 { border-bottom: none; margin-top: 12px; }
.rationale-row { font-size: 12.5px; margin-bottom: 8px; }
.rationale-row b { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 2px; font-weight: 700; }
.rationale-recommendation { background: #FEF3E7; border: 1px solid #FCD9B8; border-radius: 8px; padding: 8px 10px; }
.rationale-disclaimer { font-size: 10.5px; color: var(--muted); font-style: italic; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); }

.form-field { margin-bottom: 12px; }
.form-field label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.form-field select, .form-field textarea, .form-field input {
  width: 100%; font-family: inherit; font-size: 12.5px; padding: 7px 9px;
  border: 1px solid var(--border); border-radius: 6px; box-sizing: border-box;
}
.form-field textarea { min-height: 70px; resize: vertical; }
.kb-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.kb-checks label { display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 400; color: var(--ink); border: 1px solid var(--border); border-radius: 12px; padding: 3px 10px; }

.btn {
  background: var(--navy); color: #fff; border: none; border-radius: 8px;
  padding: 9px 18px; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.btn:hover { background: var(--navy-light); }
.btn-disabled { background: #E2E8F0; color: var(--muted); cursor: not-allowed; }
.btn-disabled:hover { background: #E2E8F0; }

.form-error {
  background: #FEE2E2; color: #7F1D1D; border: 1px solid #FCA5A5;
  border-radius: 8px; padding: 8px 12px; font-size: 12px; margin-bottom: 10px;
}
.form-success {
  background: #DCFCE7; color: #14532D; border: 1px solid #86EFAC;
  border-radius: 8px; padding: 8px 12px; font-size: 12px; margin-bottom: 10px;
}
