/* ============================================================
   DESIGN TOKENS — "Optometric Ledger"
============================================================ */
:root {
  --paper:      #F5F6F2;
  --paper-2:    #EBEDE6;
  --ink:        #16233F;
  --ink-soft:   #4B5670;
  --line:       #D8D9CD;
  --brass:      #A8792B;
  --brass-soft: #EFE2C4;
  --wnl:        #2F6D4F;
  --wnl-bg:     #E4EFE7;
  --high:       #B4463C;
  --high-bg:    #F5E3E1;
  --low:        #3D6C93;
  --low-bg:     #E2ECF3;
  --amber:      #C68A2E;
  --amber-bg:   #F7EBD6;
  --font-serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono:  ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 3px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--brass-soft);
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

a {
  color: var(--brass);
}

/* ---------- Header / Nameplate ---------- */
header.nameplate {
  background: var(--ink);
  color: var(--paper);
  padding: 0;
  display: flex;
  flex-direction: column;
  border-bottom: 2px solid var(--brass);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.nameplate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px clamp(14px, 3vw, 32px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.manas-presets {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Framework Tabs Navigation ---------- */
.framework-nav {
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 0 clamp(14px, 3vw, 32px);
  background: #101B30;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: transparent;
  color: #A6B2CA;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.nav-tab:hover {
  color: #F5F6F2;
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  color: #FFFFFF;
  background: rgba(168, 121, 43, 0.12);
  border-bottom-color: var(--brass);
}

.nav-tab-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.6px;
  background: rgba(255, 255, 255, 0.1);
  color: #CFD6E4;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
  transition: all 0.16s ease;
}

.nav-tab.active .nav-tab-badge {
  background: var(--brass);
  color: #16233F;
  font-weight: 700;
}

.nav-tab-title {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.nav-tab-sub {
  font-size: 11px;
  color: #7E8DAA;
  font-weight: 400;
}

.nav-tab.active .nav-tab-sub {
  color: var(--brass-soft);
}

/* ---------- Tab Panels Container ---------- */
.tab-panel {
  display: grid;
  gap: 20px;
}

.tab-panel[hidden] {
  display: none !important;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  flex: none;
  border: 1.5px solid var(--brass);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--brass);
  position: relative;
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px dashed rgba(168, 121, 43, 0.55);
  border-radius: 50%;
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(16px, 2.4vw, 20px);
  letter-spacing: 0.2px;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: #B9C2D6;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pwa-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #CFE0D4;
  padding: 5px 9px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.pwa-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6FBF8B;
  box-shadow: 0 0 0 3px rgba(111, 191, 139, 0.18);
}

button {
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  padding: 8px 12px;
  letter-spacing: 0.2px;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}

button:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--brass);
  color: #231A0B;
  border-color: var(--brass);
}

.btn-primary:hover {
  background: #BC8B3E;
}

.btn-ghost {
  background: transparent;
  color: var(--paper);
  border-color: rgba(255, 255, 255, 0.35);
}

.btn-ghost:hover {
  border-color: var(--brass);
  color: var(--brass-soft);
}

.btn-preset {
  background: rgba(255, 255, 255, 0.06);
  color: var(--paper);
  border-color: rgba(255, 255, 255, 0.28);
}

.btn-preset:hover {
  border-color: var(--brass);
  background: rgba(168, 121, 43, 0.18);
}

.btn-reset {
  background: transparent;
  color: #E7B9B4;
  border-color: rgba(231, 185, 180, 0.4);
}

.btn-reset:hover {
  border-color: #E7B9B4;
  background: rgba(180, 70, 60, 0.15);
}

/* ---------- Layout shell ---------- */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px clamp(12px, 3vw, 28px) 80px;
  display: grid;
  gap: 20px;
}

.app-intro {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: -4px;
}

.app-intro p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  max-width: 62ch;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0;
}

/* ---------- Badge legend ---------- */
.legend-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.legend-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink);
  font-weight: 700;
  margin-right: 4px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* ---------- Record card ---------- */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #FBFBF8);
}

.card-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 17px;
  color: var(--ink);
}

.card-head .sub {
  font-size: 12px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
}

.field-table {
  width: 100%;
  border-collapse: collapse;
}

.field-table thead th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}

.field-table tbody tr {
  border-bottom: 1px solid var(--line);
}

.field-table tbody tr:last-child {
  border-bottom: none;
}

.field-table tbody tr:hover {
  background: #FBFAF4;
}

.field-table td {
  padding: 9px 18px;
  vertical-align: middle;
}

.oep-no {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--brass);
  white-space: nowrap;
}

.flabel {
  font-size: 13.5px;
  color: var(--ink);
}

.flabel small {
  display: block;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 400;
}

.entry {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

input[type=number] {
  width: 92px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #FCFCFA;
  color: var(--ink);
}

input[type=number].signed-input {
  width: 120px;
}

input[type=number]:focus {
  border-color: var(--brass);
  background: #fff;
}

.unit {
  font-size: 11.5px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
}

/* Live-translated clinical preview under signed phoria inputs */
.phoria-preview {
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--brass);
  min-height: 14px;
  letter-spacing: 0.2px;
}

.phoria-preview.eso {
  color: var(--low);
}

.phoria-preview.exo {
  color: var(--wnl);
}

.phoria-preview.ortho {
  color: var(--ink-soft);
}

.phoria-preview.empty {
  color: #B7BAC0;
}

.norm-text {
  font-size: 11.5px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Info icon (tooltip trigger) next to #4/#5/#6 labels */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--brass);
  background: transparent;
  color: var(--brass);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
  cursor: help;
  margin-left: 6px;
  padding: 0;
  vertical-align: middle;
  transition: background .15s ease, color .15s ease;
}

.info-icon:hover,
.info-icon:focus-visible {
  background: var(--brass);
  color: #fff;
  outline: none;
}

.info-icon[aria-expanded="true"] {
  background: var(--brass);
  color: #fff;
}

/* Shared tooltip popover — appended once at body level so a card's
   overflow:hidden can never clip it; positioned via JS as position:fixed. */
.tooltip-card {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  max-width: 300px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(22, 35, 63, 0.2);
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}

.tooltip-card.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.tooltip-card .tt-head {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}

.tooltip-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  align-items: start;
}

.tooltip-card dt {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--brass);
  white-space: nowrap;
  padding-top: 1px;
}

.tooltip-card dd {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-soft);
}

.tooltip-card dd.tt-high {
  color: var(--high);
}

.tooltip-card dd.tt-low {
  color: var(--low);
}

/* Real-time clinical interpretation caption under #4/#5/#6 inputs */
.interp-tag {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  min-height: 14px;
  letter-spacing: 0.1px;
}

.interp-tag.high {
  color: var(--high);
}

.interp-tag.low {
  color: var(--low);
}

.interp-tag.wnl {
  color: var(--wnl);
}

.interp-tag.amber {
  color: var(--amber);
}

.interp-tag.idle {
  color: #B7BAC0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.3px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge.wnl {
  color: var(--wnl);
  background: var(--wnl-bg);
  border-color: #CADFCE;
}

.badge.high {
  color: var(--high);
  background: var(--high-bg);
  border-color: #EBC8C3;
}

.badge.low {
  color: var(--low);
  background: var(--low-bg);
  border-color: #C6D8E6;
}

.badge.amber {
  color: var(--amber);
  background: var(--amber-bg);
  border-color: #E9D6A9;
}

.badge.idle {
  color: #9AA1AE;
  background: #F1F1EE;
  border-color: var(--line);
}

/* ---------- Diagnostics section ---------- */
.diag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px;
}

.gauge-value {
  font-family: var(--font-mono);
  font-size: 26px;
  color: var(--ink);
  font-weight: 700;
}

.gauge-label {
  font-size: 11.5px;
  color: var(--ink-soft);
  text-align: center;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}

.kv-row:last-child {
  border-bottom: none;
}

.kv-row .k {
  color: var(--ink-soft);
}

.kv-row .v {
  font-family: var(--font-mono);
  font-weight: 600;
}

.shift-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px;
}

.shift-track {
  position: relative;
  width: 100%;
  max-width: 280px;
  height: 10px;
  background: var(--paper-2);
  border-radius: 6px;
  border: 1px solid var(--line);
}

.shift-track .zero-mark {
  position: absolute;
  left: 50%;
  top: -4px;
  bottom: -4px;
  width: 1px;
  background: var(--ink-soft);
}

.shift-track .shift-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--brass);
  border-radius: 6px;
}

.shift-value {
  font-family: var(--font-mono);
  font-size: 22px;
  color: var(--ink);
  font-weight: 700;
}

/* ---------- Case chain fraction ---------- */
.chain-card {
  padding: 18px;
}

.chain-fraction {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: 560px;
  margin: 6px auto 14px;
}

.chain-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 4px;
  min-height: 38px;
  align-items: center;
}

.chain-rule {
  height: 2px;
  background: var(--ink);
  margin: 0 4px;
  border-radius: 1px;
}

.chain-chip {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 4px;
  border: 1px solid;
  white-space: nowrap;
}

.chain-chip.high {
  color: var(--high);
  background: var(--high-bg);
  border-color: #EBC8C3;
}

.chain-chip.low {
  color: var(--low);
  background: var(--low-bg);
  border-color: #C6D8E6;
}

.chain-empty {
  color: #A9AFB9;
  font-size: 12px;
  font-style: italic;
}

.syndrome-result {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px 16px;
  background: var(--paper-2);
  margin-top: 10px;
}

.syndrome-result h3 {
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--ink);
}

.syndrome-result .type-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #fff;
  background: var(--ink);
  padding: 2px 8px;
  border-radius: 3px;
  margin-bottom: 6px;
}

.syndrome-result p {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.mgmt-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.mgmt-list li {
  font-size: 13px;
  padding: 9px 12px;
  background: #fff;
  border-radius: 0 4px 4px 0;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
}

footer {
  text-align: center;
  padding: 18px;
  font-size: 11px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
}

/* ---------- Vertical Tests (VT #12) Section ---------- */
.card-vertical-section {
  border-left: 4px solid var(--brass);
  background: #FCFCFA;
}

.section-tagline {
  margin: 3px 0 0;
  font-size: 11.5px;
  color: var(--ink-soft);
  font-weight: normal;
}

.section-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--brass-soft);
  border: 1px solid rgba(168, 121, 43, 0.4);
  color: #5D3E0A;
  padding: 3px 8px;
  border-radius: 12px;
  letter-spacing: 0.5px;
  font-weight: 700;
  text-transform: uppercase;
}

.vertical-intro-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-soft);
}

.vertical-intro-banner p {
  margin: 0;
  line-height: 1.35;
}

.vt-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: var(--brass);
  color: #231A0B;
  padding: 2px 7px;
  border-radius: 3px;
  white-space: nowrap;
  flex: none;
}

.phoria-preview.r-hyper {
  color: var(--high);
  font-weight: 600;
}

.phoria-preview.l-hyper {
  color: var(--low);
  font-weight: 600;
}

/* Cross-Meridian Correlation Callout */
.cross-meridian-box {
  margin-top: 12px;
  padding: 12px 14px;
  background: #FFF8EB;
  border: 1px solid #E9D6A9;
  border-left: 4px solid var(--amber);
  border-radius: 4px;
}

.cross-meridian-box .cm-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 13.5px;
  color: #694406;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cross-meridian-box p {
  margin: 0;
  font-size: 12.5px;
  color: #4A3B1F;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .vertical-intro-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .field-table thead {
    display: none;
  }
  .field-table,
  .field-table tbody,
  .field-table tr,
  .field-table td {
    display: block;
    width: 100%;
  }
  .field-table tbody tr {
    padding: 10px 14px 12px;
  }
  .field-table td {
    padding: 3px 0;
  }
  .field-table td.cell-oep {
    display: none;
  }
  .flabel::before {
    content: attr(data-oep) " ";
    color: var(--brass);
    font-family: var(--font-mono);
    font-size: 11px;
  }
  .norm-text {
    display: block;
    margin-top: 2px;
  }
}

/* ---------- Mitchell Scheiman Framework & Reference Styles ---------- */
.scaffold-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 11px;
  border-radius: 20px;
  background: #FFF9E9;
  border: 1px solid #EBD59B;
  color: #7A530E;
  white-space: nowrap;
}

.scaffold-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 2.5px rgba(198, 138, 46, 0.22);
}

.scheiman-notice-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  background: #FCFAF4;
  border: 1px solid #E6DEC6;
  border-left: 4px solid var(--brass);
  border-radius: 6px;
}

.scheiman-notice-icon {
  font-size: 22px;
  line-height: 1;
  flex: none;
}

.scheiman-notice-body h3 {
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--ink);
}

.scheiman-notice-body p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.scheiman-table {
  width: 100%;
  border-collapse: collapse;
}

.scheiman-table thead th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 9px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}

.scheiman-table tbody tr {
  border-bottom: 1px solid var(--line);
}

.scheiman-table tbody tr:last-child {
  border-bottom: none;
}

.scheiman-table tbody tr:hover {
  background: #FBFAF4;
}

.scheiman-table td {
  padding: 9px 18px;
  font-size: 13px;
  vertical-align: middle;
}

.norm-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--wnl);
}

.scheiman-class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 14px;
  padding: 16px;
  background: var(--paper-2);
}

.scheiman-class-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.class-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.class-code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--brass);
  background: var(--brass-soft);
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

.class-card-header h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--ink);
}

.class-card-features {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.class-card-features li {
  margin-bottom: 4px;
}

.class-card-features strong {
  color: var(--ink);
}

.scheiman-formulas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  padding: 16px;
}

.formula-box {
  background: #FDFCF8;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.formula-badge {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 3px;
}

.formula-box h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 15.5px;
  color: var(--ink);
}

.formula-math {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--brass);
  background: #FFFDF7;
  border: 1px dashed #DFCBA3;
  padding: 8px 12px;
  border-radius: 4px;
  text-align: center;
}

.formula-desc {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.scheiman-custom-staging {
  background: linear-gradient(135deg, #FAF8F2 0%, #F5F1E6 100%);
  border: 1px dashed var(--brass);
}

.staging-inner {
  padding: 26px 20px;
  text-align: center;
  max-width: 650px;
  margin: 0 auto;
}

.staging-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--brass);
  background: var(--brass-soft);
  padding: 3px 9px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.staging-inner h3 {
  margin: 6px 0 8px;
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--ink);
}

.staging-inner p {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.staging-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.s-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
}

@media (max-width: 640px) {
  .nav-tab-sub {
    display: none;
  }
  .nav-tab {
    padding: 9px 12px;
  }
}

/* ---------- Scheiman Form & Collapsible Reference ---------- */
.scheiman-presets {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.scheiman-ref-details {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 4px;
}

.scheiman-ref-summary {
  padding: 13px 18px;
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  background: linear-gradient(180deg, #fff, #FBFBF8);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: background 0.15s ease;
}

.scheiman-ref-summary::-webkit-details-marker {
  display: none;
}

.scheiman-ref-summary:hover {
  background: #FAF8F2;
}

.scheiman-ref-details[open] .scheiman-ref-summary {
  border-bottom-color: var(--line);
}

.scheiman-ref-body {
  padding: 0;
}

/* ---------- Formula Legend Boxes (Sheard's, Percival's, 1:1 Rule) ---------- */
.formula-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--brass-soft);
  color: #5D3E0A;
  border: 1px solid rgba(168, 121, 43, 0.4);
  padding: 3px 8px;
  border-radius: 3px;
  font-weight: 700;
  white-space: nowrap;
}

.formula-legend-box {
  background: #FCFAF5;
  border: 1px solid #EBE4D2;
  border-left: 3px solid var(--brass);
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.fl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 7px;
  padding-bottom: 5px;
  border-bottom: 1px dashed #E2D9C2;
}

.fl-title {
  font-family: var(--font-serif);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}

.fl-code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--brass);
  background: #FFF;
  border: 1px solid #DFCBA3;
  padding: 2px 6px;
  border-radius: 3px;
}

.fl-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11.5px;
  color: var(--ink-soft);
}

.fl-list li {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.4;
}

.fl-term {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink);
  background: #EFE9D9;
  padding: 1px 5px;
  border-radius: 3px;
  flex: none;
  min-width: 16px;
  text-align: center;
}

.fl-def {
  flex: 1;
}

.fl-rule {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px dashed #E2D9C2;
  font-size: 11px;
  color: #554425;
  line-height: 1.4;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.fl-rule-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--brass);
  color: #FFF;
  padding: 1px 5px;
  border-radius: 2px;
  flex: none;
}

/* ---------- Clinical Diagnostic Summary Reference Table ---------- */
.clinical-summary-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: #FFF;
}

.clinical-summary-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1240px;
  font-size: 12px;
  line-height: 1.4;
}

.clinical-summary-table thead th {
  background: var(--paper-2);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 11px 13px;
  border-bottom: 2px solid var(--line);
  border-right: 1px solid var(--line-light);
  text-align: left;
  white-space: nowrap;
}

.clinical-summary-table thead th:last-child {
  border-right: none;
}

.clinical-summary-table thead th.sticky-col {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--paper-2);
  border-right: 2px solid var(--line);
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.04);
}

.clinical-summary-table tbody tr {
  transition: background-color 0.12s ease;
}

.clinical-summary-table tbody td {
  padding: 9px 13px;
  border-bottom: 1px solid var(--line-light);
  border-right: 1px solid var(--line-light);
  color: var(--ink);
  white-space: nowrap;
  vertical-align: middle;
}

.clinical-summary-table tbody td:last-child {
  border-right: none;
}

.clinical-summary-table tbody tr:last-child td {
  border-bottom: none;
}

.clinical-summary-table tbody td.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #FFF;
  font-weight: 600;
  color: var(--ink);
  border-right: 2px solid var(--line);
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.04);
}

.clinical-summary-table tbody tr:hover td {
  background-color: #FAF8F2;
}

.clinical-summary-table tbody tr:hover td.sticky-col {
  background-color: #FAF8F2;
}

.summary-table-footnote {
  padding: 11px 16px;
  font-size: 11px;
  color: var(--ink-soft);
  background: var(--paper-2);
  border-top: 1px solid var(--line);
  line-height: 1.5;
}

.c-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  line-height: 1.3;
}

.c-low {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
}

.c-high {
  background: #E0E7FF;
  color: #3730A3;
  border: 1px solid #C7D2FE;
}

.c-flag {
  background: #FEE2E2;
  color: #991B1B;
  border: 1px solid #FCA5A5;
}

.c-fail {
  background: #FDE8E8;
  color: #9B2C2C;
  border: 1px solid #F8B4B4;
}
