/* ScrubCheck — clinical instrument panel.
   Light, CMS-aligned surfaces matched to SourceFetch; color appears only to
   carry a verdict (deny / modifier / review / clean / info). Codes are set in
   mono throughout, because in this subject the code IS the noun. */

:root {
  /* clinical light surfaces (matched to SourceFetch) */
  --ink:        #F1F5F9;   /* page */
  --ink-2:      #FFFFFF;
  --surface:    #FFFFFF;   /* cards */
  --surface-2:  #F8FAFC;   /* insets: textarea, rule tags */
  --line:       #E2E8F0;
  --line-soft:  #EDF1F6;

  --text:       #1B2733;
  --text-dim:   #51637A;
  --text-faint: #8595A6;

  /* brand accent = CMS blue */
  --brand:      #0071BC;
  --brand-deep: #004F84;

  /* severity = meaning. tinted background + saturated foreground. */
  --deny:       #C8102E;  --deny-bg:    #FBEAEC;
  --modifier:   #B45309;  --modifier-bg:#FBF1E0;
  --review:     #245C92;  --review-bg:  #E8F0F8;
  --ok:         #12890E;  --ok-bg:      #E7F3E7;
  --info:       #51637A;  --info-bg:    #EEF2F7;

  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 1px 2px rgba(16,40,70,0.05), 0 8px 24px rgba(16,40,70,0.06);

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body:    'IBM Plex Sans', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

/* the hidden attribute must always win over the display rules below
   (this is what was leaving the "Nothing scrubbed yet" panel on screen) */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }

.brand-mark {
  width: 11px; height: 11px;
  border-radius: 3px;
  background: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,113,188,0.16);
  align-self: center;
  flex: none;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.brand-tag {
  color: var(--text-faint);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status { display: flex; gap: 8px; flex: none; }

.status-chip {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}
.status-chip.on   { color: var(--ok);   border-color: rgba(18,137,14,0.35); }
.status-chip.off  { color: var(--text-faint); }

/* ---------- workbench ---------- */
.workbench {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(320px, 5fr) minmax(0, 7fr);
  gap: 0;
  min-height: 0;
}

.panel { padding: 26px 28px; min-width: 0; }

.panel-input {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.panel-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 4px;
}

.panel-sub {
  margin: 0 0 16px;
  color: var(--text-faint);
  font-size: 13px;
}

.claim-input {
  flex: 1;
  min-height: 220px;
  resize: vertical;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.9;
  padding: 16px 18px;
  letter-spacing: 0.02em;
}
.claim-input::placeholder { color: var(--text-faint); }
.claim-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,113,188,0.15);
}

.input-row { display: flex; gap: 10px; margin-top: 14px; }

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn-primary { background: var(--brand); color: #FFFFFF; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }

.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-ai {
  background: transparent;
  color: var(--brand);
  border-color: var(--brand);
  font-size: 13px;
  padding: 7px 14px;
}
.btn-ai:hover { background: rgba(0,113,188,0.08); }
.btn-ai:disabled { opacity: .55; cursor: default; }

/* sample chips */
.samples { margin-top: 22px; }
.samples-label {
  display: block;
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 9px;
}
.samples-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sample {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.sample:hover { border-color: var(--brand); color: var(--text); }
.sample:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- output ---------- */
.panel-output { overflow: auto; }

.empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--text-faint);
}
.empty-mark {
  width: 46px; height: 46px;
  border-radius: 12px;
  border: 1.5px dashed var(--line);
  margin-bottom: 18px;
  position: relative;
}
.empty-mark::after {
  content: "";
  position: absolute; inset: 13px;
  border-left: 1.5px dashed var(--line);
  border-bottom: 1.5px dashed var(--line);
}
.empty-head { font-family: var(--font-display); font-weight: 600; color: var(--text-dim); font-size: 16px; margin: 0 0 6px; }
.empty-body { max-width: 360px; font-size: 13.5px; margin: 0; }

.results { display: flex; flex-direction: column; gap: 22px; }

/* verdict banner */
.verdict {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 14px;
}
.verdict-icon {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 18px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  flex: none;
  color: #FFFFFF;
}
.verdict-text { min-width: 0; }
.verdict-head { font-family: var(--font-display); font-weight: 600; font-size: 16px; margin: 0; }
.verdict-meta { color: var(--text-dim); font-size: 13px; margin: 2px 0 0; }

.verdict.v-deny     { border-left-color: var(--deny);     background: var(--deny-bg); }
.verdict.v-deny     .verdict-icon { background: var(--deny); }
.verdict.v-modifier { border-left-color: var(--modifier); background: var(--modifier-bg); }
.verdict.v-modifier .verdict-icon { background: var(--modifier); }
.verdict.v-review   { border-left-color: var(--review);   background: var(--review-bg); }
.verdict.v-review   .verdict-icon { background: var(--review); }
.verdict.v-ok       { border-left-color: var(--ok);       background: var(--ok-bg); }
.verdict.v-ok       .verdict-icon { background: var(--ok); }
.verdict.v-info     { border-left-color: var(--info);     background: var(--info-bg); }
.verdict.v-info     .verdict-icon { background: var(--info); }

/* blocks */
.block-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 12px;
}
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.block-head .block-title { margin: 0; }

/* line items — the EOB ledger */
.lineitems {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.lineitem {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}
.lineitem:last-child { border-bottom: none; }
.li-code { font-family: var(--font-mono); font-weight: 600; font-size: 14px; color: var(--text); }
.li-mod {
  font-family: var(--font-mono); font-size: 11px; color: var(--brand-deep);
  background: rgba(0,113,188,0.08); border: 1px solid rgba(0,113,188,0.25);
  border-radius: 4px; padding: 1px 6px; margin-left: 6px;
}
.li-desc { color: var(--text-dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-units { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-faint); }
.li-chip {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.03em; text-transform: uppercase;
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.chip-deny     { color: var(--deny);     background: var(--deny-bg); }
.chip-modifier { color: var(--modifier); background: var(--modifier-bg); }
.chip-review   { color: var(--review);   background: var(--review-bg); }
.chip-ok       { color: var(--ok);       background: var(--ok-bg); }
.chip-info     { color: var(--info);     background: var(--info-bg); }

/* findings cards */
.findings { display: flex; flex-direction: column; gap: 12px; }
.finding {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
  padding: 15px 17px;
  box-shadow: var(--shadow);
}
.finding.f-deny     { border-left-color: var(--deny); }
.finding.f-modifier { border-left-color: var(--modifier); }
.finding.f-review   { border-left-color: var(--review); }
.finding.f-ok       { border-left-color: var(--ok); }
.finding.f-info     { border-left-color: var(--info); }

.f-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.f-badge {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  border-radius: 4px; padding: 2px 7px; flex: none;
}
.f-deny     .f-badge { color: var(--deny);     background: var(--deny-bg); }
.f-modifier .f-badge { color: var(--modifier); background: var(--modifier-bg); }
.f-review   .f-badge { color: var(--review);   background: var(--review-bg); }
.f-ok       .f-badge { color: var(--ok);       background: var(--ok-bg); }
.f-info     .f-badge { color: var(--info);     background: var(--info-bg); }
.f-title { font-weight: 600; font-size: 14.5px; font-family: var(--font-mono); letter-spacing: 0.01em; color: var(--text); }

.f-body { color: var(--text-dim); font-size: 13.5px; margin: 0 0 10px; }
.f-body.is-ai { color: var(--text); }
.f-ai-tag {
  font-family: var(--font-mono); font-size: 10px; color: var(--brand);
  text-transform: uppercase; letter-spacing: 0.05em; margin-left: 8px;
}

.f-rule {
  display: flex; flex-wrap: wrap; gap: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
}
.rule-tag {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-dim);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 3px 9px;
}
.rule-tag b { color: var(--text); font-weight: 600; }

.f-loading { color: var(--text-faint); font-size: 12.5px; font-style: italic; }

/* footnote */
.footnote {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 12px;
  text-align: center;
}

/* entrance motion */
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.results:not([hidden]) .verdict,
.results:not([hidden]) .block { animation: rise .28s ease both; }
.results:not([hidden]) .block:nth-child(2) { animation-delay: .04s; }
.results:not([hidden]) .block:nth-child(3) { animation-delay: .08s; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* responsive */
@media (max-width: 860px) {
  .workbench { grid-template-columns: 1fr; }
  .panel-input { border-right: none; border-bottom: 1px solid var(--line); }
  .panel-output { min-height: 50vh; }
  .brand-tag { display: none; }
}
