/* ==========================================================================
   Blair Compass - PCP Chart Audit Tool (Enterprise Client-Side Edition)
   Single stylesheet. System fonts only; no external assets of any kind.
   Mirrors the Local Edition v2.0.1 Blair Compass look.
   ========================================================================== */

:root {
  --bg: #f7f6f2;
  --surface: #fdfcf9;
  --surface-2: #f1eee7;
  --border: #d8d4ca;
  --text: #232720;
  --muted: #6d6f66;
  --primary: #01696f;
  --primary-2: #0b4d52;
  --green-bg: #eef5e8;   --green-bd: #c3d9ad;  --green-tx: #2c5310;
  --amber-bg: #fdf1e4;   --amber-bd: #e5c49a;  --amber-tx: #7a4210;
  --blue-bg: #e9f1f6;    --blue-bd: #b9d2e2;   --blue-tx: #16465f;
  --purple-bg: #f1ecf5;  --purple-bd: #d0c2dd; --purple-tx: #4c3268;
  --danger-bg: #f9e9ef;  --danger-bd: #e0b7c8; --danger-tx: #7c1f47;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 5px 16px rgba(35, 39, 32, 0.05);
  --shadow-lg: 0 12px 32px rgba(35, 39, 32, 0.08);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(1, 105, 111, 0.07), transparent 30rem),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.bc-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.1rem 1rem 3rem;
}

.hidden { display: none !important; }

.bc-noscript {
  max-width: 42rem;
  margin: 3rem auto;
  padding: 1rem 1.2rem;
  background: #fff6ee;
  border: 1px solid #dcae94;
  border-radius: 16px;
  color: #59290f;
}

.bc-visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.bc-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--primary);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 50;
}
.bc-skip-link:focus { left: 0; }

/* ---------- focus ---------- */
:focus-visible {
  outline: 3px solid rgba(1, 105, 111, 0.55);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- hero ---------- */
.bc-hero {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.2rem 1.4rem;
  box-shadow: var(--shadow-lg);
  margin-bottom: 0.9rem;
}
.bc-brand-row { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.bc-logo {
  width: 52px; height: 52px; border-radius: 15px; flex: 0 0 auto;
  background: conic-gradient(from 210deg, var(--primary), #0d8a91, var(--primary-2), var(--primary));
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 1.25rem; letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.28), 0 6px 14px rgba(1, 105, 111, 0.35);
  position: relative;
}
.bc-logo::after {
  content: ""; position: absolute; inset: 4px; border-radius: 11px;
  border: 1.5px dashed rgba(255, 255, 255, 0.4); pointer-events: none;
}
.bc-brand-name {
  font-size: 0.82rem; font-weight: 800; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--primary);
}
.bc-hero h1 { font-size: clamp(1.35rem, 2.3vw, 1.95rem); margin: 0; letter-spacing: -0.03em; }
.bc-purpose { color: var(--muted); margin: 0.3rem 0 0; max-width: 62rem; }
.bc-scope { color: var(--muted); font-size: 0.84rem; margin-top: 0.55rem; }
.bc-version {
  display: inline-block; margin-left: 0.6rem;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 0.74rem;
  padding: 0.18rem 0.6rem; border-radius: 999px; vertical-align: middle;
}

/* ---------- notice ---------- */
.bc-notice {
  border: 1px solid #dcae94; background: #fff6ee; color: #59290f;
  border-radius: var(--radius); padding: 0.85rem 1.05rem; margin: 0.3rem 0 0.8rem;
}

/* ---------- workflow strip ---------- */
.bc-steps {
  display: flex; gap: 0.6rem; flex-wrap: wrap;
  margin: 0.35rem 0 0.9rem; padding: 0; list-style: none;
}
.bc-step {
  flex: 1 1 10rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 0.6rem 0.75rem;
  display: flex; gap: 0.55rem; align-items: center;
}
.bc-step-num {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
  background: var(--primary); color: #fff; font-weight: 800; font-size: 0.82rem;
  display: grid; place-items: center;
}
.bc-step-label { font-size: 0.85rem; font-weight: 600; line-height: 1.25; }

/* ---------- layout ---------- */
.bc-body {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.bc-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0.75rem;
}
.bc-sidebar-title { margin: 0 0 0.5rem; font-size: 1rem; letter-spacing: -0.01em; }
.bc-sidebar-steps { margin: 0; padding-left: 1.15rem; }
.bc-sidebar-steps li { font-size: 0.86rem; margin-bottom: 0.35rem; }
.bc-sidebar-actions { display: flex; flex-direction: column; gap: 0.5rem; }
.bc-main { min-width: 0; }
.bc-divider { border: 0; border-top: 1px solid var(--border); margin: 1.1rem 0; }

/* ---------- typography helpers ---------- */
.bc-section-title {
  margin: 1.2rem 0 0.35rem; font-size: 1.06rem; font-weight: 800;
  letter-spacing: -0.02em;
}
h4.bc-section-title { font-size: 0.98rem; }
.bc-caption { color: var(--muted); font-size: 0.85rem; margin: 0.3rem 0 0.7rem; }
.bc-help { color: var(--muted); font-size: 0.8rem; margin: 0.25rem 0 0; }
.bc-muted { color: var(--muted); font-size: 0.88rem; }
.bc-none { opacity: 0.75; font-size: 0.88rem; }
.bc-strong-line { margin: 0.7rem 0 0.35rem; }

/* ---------- mode selector cards ---------- */
.bc-mode-cards {
  border: 0; padding: 0; margin: 0 0 0.2rem;
  display: flex; gap: 0.6rem; flex-wrap: wrap;
}
.bc-mode-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 0.8rem 1rem;
  min-width: 16rem;
  flex: 1 1 16rem;
  display: flex; align-items: center; gap: 0.6rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  min-height: 44px;
}
.bc-mode-card input { accent-color: var(--primary); width: 1.1rem; height: 1.1rem; flex: 0 0 auto; }
.bc-mode-card-checked {
  border-color: var(--primary);
  background: #eaf4f4;
  box-shadow: 0 0 0 1px var(--primary);
}

/* ---------- tabs ---------- */
.bc-tablist {
  display: flex; gap: 0.4rem; flex-wrap: wrap;
  border-bottom: 2px solid var(--border);
  margin: 1rem 0 0.8rem;
}
.bc-tab {
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 0.6rem 0.9rem;
  min-height: 44px;
  font: inherit;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  margin-bottom: -2px;
}
.bc-tab:hover { color: var(--text); background: var(--surface-2); }
.bc-tab-active { color: var(--primary); border-bottom-color: var(--primary); }
.bc-tabpanel { padding: 0.2rem 0 0; }

/* ---------- form fields ---------- */
.bc-field { margin: 0 0 0.85rem; }
.bc-label { display: block; font-weight: 700; font-size: 0.9rem; margin-bottom: 0.3rem; }
.bc-textarea, .bc-input, .bc-select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem;
}
.bc-textarea { resize: vertical; min-height: 5.5rem; }
.bc-textarea-note { min-height: 15rem; }
.bc-textarea-billing { min-height: 6.5rem; }
.bc-input, .bc-select { min-height: 44px; }
.bc-textarea:focus, .bc-input:focus, .bc-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  outline: none;
}
.bc-file { font: inherit; max-width: 100%; }
.bc-field-grid { display: grid; gap: 0 0.8rem; }
.bc-field-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bc-field-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.bc-billing-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0 0 0.85rem;
}
.bc-ocr-image {
  display: block;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0 0 0.6rem;
}
.bc-ocr-status { min-height: 1.1em; }
.bc-preview { font-variant-numeric: tabular-nums; }

.bc-confirm { margin: 0.9rem 0 0.6rem; }
.bc-checkbox-row {
  display: flex; gap: 0.55rem; align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem;
  margin-bottom: 0.5rem;
}
.bc-checkbox-row input {
  width: 1.15rem; height: 1.15rem; margin-top: 0.15rem;
  flex: 0 0 auto; accent-color: var(--primary);
}
.bc-checkbox-row label { font-size: 0.88rem; cursor: pointer; }

/* ---------- buttons ---------- */
.bc-btn {
  min-height: 44px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  padding: 0.55rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.bc-btn:hover { border-color: var(--primary); color: var(--primary); }
.bc-btn:disabled {
  opacity: 0.55; cursor: not-allowed;
  border-color: var(--border); color: var(--muted);
}
.bc-btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.bc-btn-primary:hover:not(:disabled) { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.bc-btn-block { display: block; width: 100%; margin: 0.35rem 0; }

/* ---------- alerts ---------- */
.bc-alert {
  border-radius: var(--radius-sm);
  border: 1px solid;
  padding: 0.65rem 0.85rem;
  margin: 0.45rem 0;
  font-size: 0.9rem;
}
.bc-alert-info  { background: var(--blue-bg);   border-color: var(--blue-bd);   color: var(--blue-tx); }
.bc-alert-warn  { background: var(--amber-bg);  border-color: var(--amber-bd);  color: var(--amber-tx); }
.bc-alert-error { background: var(--danger-bg); border-color: var(--danger-bd); color: var(--danger-tx); }

/* ---------- results: buckets ---------- */
.bc-results { min-height: 6rem; }
.bc-buckets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0 0.75rem;
}
.bc-bucket {
  border-radius: var(--radius);
  padding: 0.95rem 1.05rem;
  border: 1px solid;
  min-height: 8.5rem;
}
.bc-bucket h4 { margin: 0 0 0.45rem; font-size: 0.95rem; letter-spacing: -0.01em; }
.bc-bucket ul { margin: 0; padding-left: 1.1rem; }
.bc-bucket li { font-size: 0.88rem; margin-bottom: 0.3rem; line-height: 1.4; }
.bc-bucket-green  { background: var(--green-bg);  border-color: var(--green-bd);  color: var(--green-tx); }
.bc-bucket-amber  { background: var(--amber-bg);  border-color: var(--amber-bd);  color: var(--amber-tx); }
.bc-bucket-blue   { background: var(--blue-bg);   border-color: var(--blue-bd);   color: var(--blue-tx); }
.bc-bucket-purple { background: var(--purple-bg); border-color: var(--purple-bd); color: var(--purple-tx); }

/* ---------- badges ---------- */
.bc-badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  border-radius: 999px;
  padding: 0.32rem 0.75rem;
  font-size: 0.84rem; font-weight: 700;
  border: 1px solid transparent;
}
.bc-badge-green  { background: var(--green-bg);  color: var(--green-tx);  border-color: var(--green-bd); }
.bc-badge-amber  { background: var(--amber-bg);  color: var(--amber-tx);  border-color: var(--amber-bd); }
.bc-badge-blue   { background: var(--blue-bg);   color: var(--blue-tx);   border-color: var(--blue-bd); }
.bc-badge-purple { background: var(--purple-bg); color: var(--purple-tx); border-color: var(--purple-bd); }
.bc-badge-danger { background: var(--danger-bg); color: var(--danger-tx); border-color: var(--danger-bd); }
.bc-classification { margin: 0.4rem 0 0.8rem; }

/* ---------- metric cards ---------- */
.bc-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0 0.75rem;
}
.bc-metrics-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bc-metric {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.9rem 1rem; min-height: 6.2rem;
  box-shadow: var(--shadow);
}
.bc-metric-label {
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); font-weight: 700; margin-bottom: 0.35rem;
}
.bc-metric-value { font-size: 1rem; line-height: 1.35; font-weight: 700; }
.bc-metric-big { font-size: 1.7rem; font-weight: 800; color: var(--primary); }
.bc-metric-gap { margin-top: 0.4rem; }

/* ---------- panels ---------- */
.bc-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: 0.75rem;
}
.bc-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
.bc-panel-grid .bc-panel { margin-bottom: 0; }

/* ---------- tables ---------- */
.bc-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin: 0.4rem 0 0.7rem;
  max-width: 100%;
}
.bc-table { border-collapse: collapse; width: 100%; font-size: 0.86rem; }
.bc-table th, .bc-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  min-width: 6rem;
}
.bc-table th {
  background: var(--surface-2);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  position: sticky;
  top: 0;
}
.bc-table tbody tr:last-child td { border-bottom: 0; }
.bc-table tbody tr:nth-child(even) td { background: rgba(241, 238, 231, 0.45); }

/* ---------- collapsible details ---------- */
.bc-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 0.6rem;
  box-shadow: var(--shadow);
}
.bc-details summary {
  cursor: pointer;
  font-weight: 700;
  padding: 0.75rem 1rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  border-radius: var(--radius);
  list-style-position: inside;
}
.bc-details summary:hover { color: var(--primary); }
.bc-details[open] > summary { border-bottom: 1px solid var(--border); }
.bc-details-body { padding: 0.75rem 1rem 0.9rem; }
.bc-details-sub { box-shadow: none; }

/* ---------- copy-ready blocks ---------- */
.bc-copy-wrap { margin: 0 0 1rem; }
.bc-copy-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.6rem; margin-bottom: 0.35rem; flex-wrap: wrap;
}
.bc-copy-btn { min-height: 36px; padding: 0.3rem 0.9rem; box-shadow: none; }
.bc-pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.95rem;
  margin: 0;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 26rem;
  overflow-y: auto;
}
.bc-pre-json { white-space: pre; overflow-wrap: normal; }

.bc-downloads {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 0.4rem 0 0.6rem;
}
.bc-downloads .bc-btn-block { margin: 0; }

/* ---------- about panel ---------- */
.bc-about { margin-top: 0.6rem; }
.bc-about summary { font-size: 0.88rem; }
.bc-about-list { margin: 0 0 0.5rem; padding-left: 1.05rem; }
.bc-about-list li {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  overflow-wrap: anywhere;
}

/* ---------- footer ---------- */
.bc-footer {
  border-top: 1px solid var(--border);
  margin-top: 1.4rem;
  padding-top: 1rem;
}

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .bc-body { grid-template-columns: 1fr; }
  .bc-sidebar { position: static; }
  .bc-metrics-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bc-field-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .bc-shell { padding: 0.7rem 0.7rem 2rem; }
  .bc-buckets,
  .bc-metrics,
  .bc-metrics-3,
  .bc-panel-grid,
  .bc-field-grid-2,
  .bc-field-grid-3,
  .bc-downloads { grid-template-columns: 1fr; }
  .bc-hero { padding: 1rem 1.05rem; }
  .bc-mode-card { min-width: 0; }
}

/* ---------- print ---------- */
@media print {
  body { background: #fff; }
  .bc-shell { max-width: 100%; padding: 0; }
  .bc-skip-link,
  .bc-sidebar,
  .bc-notice,
  .bc-steps,
  .bc-forms,
  .bc-btn,
  .bc-downloads,
  .bc-copy-btn,
  .bc-divider,
  .no-print { display: none !important; }
  .bc-body { display: block; }
  .bc-hero, .bc-panel, .bc-metric, .bc-bucket, .bc-details, .bc-table-wrap, .bc-pre {
    box-shadow: none;
    break-inside: avoid;
  }
  .bc-details { border: 1px solid #bbb; }
  .bc-details:not([open]) > summary { display: flex; }
  .bc-table-wrap { overflow: visible; }
  .bc-pre { max-height: none; overflow: visible; }
}
