/* =====================================================================
   PA Decision Demo — Clean professional styling (matches deck theme)
   ===================================================================== */

:root {
  --deck-blue:      #619DD1;
  --deck-blue-d:    #3F7CAE;
  --deck-blue-bg:   #F4F8FC;
  --navy:           #0F2A52;
  --teal:           #0D7C8A;
  --coral:          #E2725B;
  --green:          #059669;
  --red:            #DC2626;
  --amber:          #B45309;
  --ink:            #1F2937;
  --slate:          #475569;
  --muted:          #94A3B8;
  --soft:           #E2E8F0;
  --white:          #FFFFFF;
  --sand:           #F4F1EB;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'Segoe UI', Calibri, Arial, sans-serif;
  background: #FAFAFA;
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ============== App shell: sidebar + main column ============== */
.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 4px solid var(--deck-blue);
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.brand-mark {
  width: 14px; height: 14px; background: var(--coral);
  display: inline-block; border-radius: 3px; flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-name {
  font-family: Georgia, serif; font-size: 16.5px; font-weight: 600;
  letter-spacing: 0.3px; line-height: 1.2;
}
.brand-sub {
  font-size: 10.5px; color: rgba(255,255,255,0.55);
  letter-spacing: 0.2px;
}

.sidebar .nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px;
  flex: 1;
}
.sidebar .nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: background 0.15s, color 0.15s;
}
.sidebar .nav a i { font-size: 16px; width: 18px; text-align: center; opacity: 0.9; }
.sidebar .nav a:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.sidebar .nav a.active {
  background: var(--deck-blue-d); color: var(--white); font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.sidebar-footer {
  padding: 16px 20px 20px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-footer .tagline {
  font-size: 10.5px; color: rgba(255,255,255,0.5);
  line-height: 1.5; margin-bottom: 8px;
}
.sidebar-footer .credit {
  font-size: 10px; color: rgba(255,255,255,0.35);
  letter-spacing: 0.3px; text-transform: uppercase;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 1100;
  width: 40px; height: 40px;
  border-radius: 6px;
  border: none;
  background: var(--navy);
  color: var(--white);
  font-size: 18px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ============== Bottom bar (matches deck) ============== */
.bottom-bar {
  height: 10px; background: var(--deck-blue);
  margin-top: auto;
}

main { padding: 32px 0 50px 0; }

@media (max-width: 900px) {
  .sidebar-toggle { display: flex; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 1050;
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }
  .sidebar.open { transform: translateX(0); }
  .container { padding: 0 18px; }
  main { padding-top: 64px; }
}

/* ============== Headings ============== */
h1 {
  font-family: Georgia, serif;
  font-size: 28px; font-weight: 400;
  color: var(--ink); margin: 0 0 4px 0;
}
h1 + .subtitle {
  color: var(--slate); font-style: italic; margin: 0 0 18px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--soft);
  padding-bottom: 14px;
}
h2 {
  font-family: Georgia, serif;
  font-size: 18px; font-weight: 600;
  color: var(--ink); margin: 24px 0 10px 0;
}
h3 {
  font-size: 14px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--deck-blue-d);
  margin: 18px 0 8px 0;
}

/* ============== Cards / sections ============== */
.card {
  background: var(--white);
  border: 1px solid var(--soft);
  border-radius: 6px;
  padding: 20px 24px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.card.accent-blue  { border-left: 4px solid var(--deck-blue); }
.card.accent-coral { border-left: 4px solid var(--coral); }
.card.accent-teal  { border-left: 4px solid var(--teal); }
.card.accent-navy  { border-left: 4px solid var(--navy); }

/* ============== Stat tiles (dashboard) ============== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 20px 0 30px 0;
}
.stat {
  background: var(--white);
  border: 1px solid var(--soft);
  border-top: 3px solid var(--deck-blue);
  padding: 18px 20px;
  border-radius: 4px;
}
.stat .num {
  font-family: Georgia, serif;
  font-size: 32px; font-weight: 600;
  color: var(--navy);
  display: block;
  line-height: 1;
}
.stat .label {
  display: block;
  margin-top: 6px;
  font-size: 12px; color: var(--slate);
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* ============== Tables ============== */
table.data {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13.5px;
  background: var(--white);
}
table.data thead th {
  background: var(--deck-blue-d);
  color: var(--white);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
table.data tbody td {
  padding: 9px 12px;
  border-top: 1px solid var(--soft);
  vertical-align: top;
}
table.data tbody tr:nth-child(even) { background: var(--deck-blue-bg); }
table.data tbody tr:hover { background: #EDF3F9; }
table.data a { color: var(--deck-blue-d); text-decoration: none; font-weight: 500; }
table.data a:hover { text-decoration: underline; }

/* ============== Filters / search bar ============== */
.filters {
  background: var(--white);
  border: 1px solid var(--soft);
  border-radius: 6px;
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.filters input[type=text],
.filters select {
  font-family: inherit;
  font-size: 13.5px;
  padding: 7px 10px;
  border: 1px solid var(--soft);
  border-radius: 4px;
  min-width: 200px;
  background: var(--white);
}
.filters input[type=text]:focus,
.filters select:focus {
  outline: none; border-color: var(--deck-blue);
  box-shadow: 0 0 0 2px rgba(97,157,209,0.15);
}
.filters .small-text { font-size: 12px; color: var(--muted); margin-left: auto; }

/* ============== Buttons ============== */
.btn {
  display: inline-block;
  padding: 9px 20px;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.15s;
}
.btn-primary { background: var(--deck-blue-d); color: var(--white); }
.btn-primary:hover { background: var(--navy); }
.btn-secondary { background: var(--white); color: var(--deck-blue-d); border: 1px solid var(--soft); }
.btn-secondary:hover { background: var(--deck-blue-bg); }
.btn-coral { background: var(--coral); color: var(--white); }
.btn-coral:hover { background: #C5604F; }

/* ============== Forms ============== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 22px;
  margin: 12px 0;
}
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label {
  font-size: 12px; font-weight: 600; color: var(--slate);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.form-row input,
.form-row select,
.form-row textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--soft);
  border-radius: 4px;
  background: var(--white);
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none; border-color: var(--deck-blue);
  box-shadow: 0 0 0 2px rgba(97,157,209,0.15);
}
.form-row .hint { font-size: 11px; color: var(--muted); }

/* ============== Decision badge ============== */
.decision-banner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 28px;
  border-radius: 6px;
  margin: 20px 0 24px 0;
  color: var(--white);
}
.decision-banner.approved { background: linear-gradient(135deg, #059669, #047857); }
.decision-banner.denied   { background: linear-gradient(135deg, #DC2626, #991B1B); }
.decision-banner.review   { background: linear-gradient(135deg, #B45309, #92400E); }
.decision-banner .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px;
  opacity: 0.85;
}
.decision-banner .verdict {
  font-family: Georgia, serif; font-size: 26px; font-weight: 600;
  margin-top: 4px;
}
.decision-banner .score {
  font-family: Georgia, serif; font-size: 36px; font-weight: 700;
  text-align: right; line-height: 1;
}
.decision-banner .score-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px;
  opacity: 0.85; text-align: right;
}

/* ============== Criteria lists ============== */
.criteria-list {
  list-style: none; margin: 0; padding: 0;
}
.criteria-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--soft);
  font-size: 13.5px;
  display: flex; gap: 12px; align-items: flex-start;
}
.criteria-list li:last-child { border-bottom: none; }
.criteria-list .weight {
  font-family: 'SF Mono', Consolas, monospace;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
  min-width: 50px;
}
.criteria-list .matched .weight { color: var(--green); }
.criteria-list .missing .weight { color: var(--red); }
.criteria-list .matched .desc   { color: var(--ink); }
.criteria-list .missing .desc   { color: var(--slate); }

/* ============== Chunk evidence cards ============== */
.chunk-card {
  background: var(--deck-blue-bg);
  border: 1px solid var(--soft);
  border-left: 3px solid var(--deck-blue);
  border-radius: 4px;
  padding: 14px 18px;
  margin-bottom: 12px;
  font-size: 13px;
}
.chunk-card .chunk-id {
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 11px;
  color: var(--deck-blue-d);
  background: var(--white);
  padding: 2px 7px;
  border-radius: 3px;
  margin-bottom: 6px;
  display: inline-block;
}
.chunk-card .meta {
  font-size: 11px; color: var(--muted);
  margin-bottom: 6px;
}
.chunk-card .content {
  color: var(--slate);
  white-space: pre-wrap;
  font-size: 12.5px;
  line-height: 1.5;
}

/* ============== LLM explanation styling ============== */
.llm-section {
  margin-bottom: 18px;
}
.llm-section .heading {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--coral); margin-bottom: 6px;
}
.llm-section .body {
  white-space: pre-wrap;
  color: var(--ink); font-size: 13.5px; line-height: 1.6;
}

/* ============== Tags / chips ============== */
.tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 3px;
  background: var(--deck-blue-bg);
  color: var(--deck-blue-d);
  font-weight: 500;
  margin: 2px 3px 2px 0;
}
.tag.icd { background: #FEF3C7; color: #92400E; }
.tag.proc { background: #DBEAFE; color: #1E40AF; }
.tag.muted { background: var(--soft); color: var(--slate); }

/* ============== Diagnosis / detail rows ============== */
.detail-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 12px;
  padding: 7px 0;
  font-size: 13.5px;
  border-bottom: 1px solid var(--soft);
}
.detail-row:last-child { border-bottom: none; }
.detail-row .key {
  color: var(--slate); font-weight: 600;
  text-transform: uppercase; font-size: 11px; letter-spacing: 0.4px;
  padding-top: 2px;
}
.detail-row .val { color: var(--ink); }

/* ============== Loading state ============== */
.loading-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 42, 82, 0.55);
  display: none; align-items: center; justify-content: center;
  z-index: 1000;
}
.loading-overlay.active { display: flex; }
.loading-card {
  background: var(--white);
  padding: 30px 50px; border-radius: 8px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.loading-card .spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--soft);
  border-top-color: var(--deck-blue);
  border-radius: 50%;
  margin: 0 auto 14px auto;
  animation: spin 0.8s linear infinite;
}
.loading-card .text {
  font-size: 14px; color: var(--ink); font-weight: 500;
}
.loading-card .sub {
  font-size: 12px; color: var(--muted); margin-top: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============== Note view (raw text) ============== */
.note-text {
  white-space: pre-wrap;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 12px;
  background: #F8F9FA;
  border: 1px solid var(--soft);
  padding: 16px;
  border-radius: 4px;
  max-height: 500px;
  overflow-y: auto;
  color: var(--slate);
}

/* ============== Two / three-column layout ============== */
.col2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.col3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) {
  .col2 { grid-template-columns: 1fr; }
  .col3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ============== Status pill (system health) ============== */
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 14px; border-radius: 20px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.2px;
  background: var(--soft); color: var(--slate);
}
.status-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); flex-shrink: 0;
}
.status-pill.ok { background: #DCFCE7; color: #166534; }
.status-pill.ok .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(5,150,105,0.2); }
.status-pill.fail { background: #FEE2E2; color: #991B1B; }
.status-pill.fail .dot { background: var(--red); box-shadow: 0 0 0 3px rgba(220,38,38,0.2); }
.status-pill.checking .dot { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* =====================================================================
   Phase II — Agent Pipeline trace
   ===================================================================== */
.agent-trace {
  display: flex; flex-direction: column; gap: 0;
  margin-top: 8px;
}
.agent-step {
  border: 1px solid var(--soft);
  border-radius: 6px;
  margin-bottom: 8px;
  background: var(--white);
  overflow: hidden;
}
.agent-step-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}
.agent-step-header:hover { background: var(--deck-blue-bg); }
.agent-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--deck-blue-d); color: var(--white);
  font-size: 11.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.agent-name {
  font-weight: 600; font-size: 13.5px; color: var(--ink);
  min-width: 150px; flex-shrink: 0;
}
.agent-summary {
  color: var(--slate); font-size: 13px; flex: 1;
}
.agent-duration {
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 11px; color: var(--muted);
  flex-shrink: 0;
}
.agent-caret {
  color: var(--muted); font-size: 12px;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.agent-step.open .agent-caret { transform: rotate(90deg); }
.agent-detail {
  display: none;
  padding: 4px 16px 16px 52px;
  font-size: 12.5px;
  color: var(--slate);
}
.agent-step.open .agent-detail { display: block; }
.agent-detail pre {
  background: #F8F9FA;
  border: 1px solid var(--soft);
  border-radius: 4px;
  padding: 10px 12px;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 11.5px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
  margin: 0;
}
.agent-arrow {
  text-align: center;
  color: var(--muted);
  font-size: 16px;
  margin: -4px 0 -2px 0;
}

/* =====================================================================
   Phase II — Knowledge graph canvas / legend
   ===================================================================== */
.graph-canvas {
  width: 100%;
  border: 1px solid var(--soft);
  border-radius: 6px;
  background: #0F2A3A;
  overflow: hidden;
}
.graph-legend {
  display: flex; flex-wrap: wrap; gap: 16px;
  margin: 10px 0 16px 0;
  font-size: 12px; color: var(--slate);
}
.legend-item {
  display: inline-flex; align-items: center; gap: 6px;
}
.legend-dot {
  width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0;
}
.legend-dot.payer     { background: #2b6cb0; border-radius: 2px; }
.legend-dot.topic     { background: #38a169; }
.legend-dot.icd       { background: #dd6b20; }
.legend-dot.procedure { background: #805ad5; transform: rotate(45deg); border-radius: 2px; }
.legend-dot.highlight { background: #e53e3e; }

.graph-detail-panel {
  background: var(--deck-blue-bg);
  border: 1px solid var(--soft);
  border-radius: 6px;
  padding: 14px 18px;
  margin-top: 12px;
  font-size: 13px;
  min-height: 44px;
}
.graph-detail-panel .placeholder { color: var(--muted); }
.graph-detail-panel .node-title {
  font-weight: 700; color: var(--ink); margin-bottom: 4px;
}
.graph-detail-panel .node-type {
  display: inline-block;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--deck-blue-d); font-weight: 600;
}

/* =====================================================================
   Phase II — Dynamic prompt viewer
   ===================================================================== */
.prompt-block {
  white-space: pre-wrap;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.6;
  background: #F8F9FA;
  border: 1px solid var(--soft);
  border-radius: 4px;
  padding: 14px 16px;
  max-height: 420px;
  overflow-y: auto;
  color: var(--ink);
}
.prompt-viewer summary {
  cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--deck-blue-d);
  padding: 8px 0;
}
.prompt-viewer summary:hover { color: var(--navy); }
.prompt-viewer .prompt-meta {
  font-size: 11px; color: var(--muted); margin-bottom: 8px;
}
