/* -- APEC house palette -- */
:root {
  --apecgreen:        #2d8b3f;   /* primary brand green */
  --apecgreendark:    #1a5c1a;   /* print footer / strong accents */
  --apecgreenlight:   #ecfdf5;   /* tinted backgrounds */
  --apecgreenborder:  #6ee7b7;   /* light borders */
  --apec-text:        #1f2933;
  --apec-text-muted:  #5a6b7a;
  --apec-divider:     #e0e4e8;
}

body {
  background: #f5f7fa;
  font-family: 'Lato', 'Helvetica Neue', Arial, sans-serif;
  margin: 0;
  color: var(--apec-text);
}

/* APEC-themed top menu — overrides Fomantic's inverted blue */
.ui.inverted.blue.menu {
  background: var(--apecgreendark) !important;
  border-color: var(--apecgreendark) !important;
  border-radius: 0;
  box-shadow: 0 1px 0 rgba(0,0,0,0.08);
  flex-wrap: wrap;
}
.ui.inverted.blue.menu .item.active,
.ui.inverted.blue.menu .item.active:hover {
  background: var(--apecgreen) !important;
  color: #fff !important;
}
.ui.inverted.blue.menu .item:hover {
  background: rgba(255,255,255,0.08) !important;
}
.ui.menu { flex-wrap: wrap; }

/* PBDPy Home tab — modern, wider landing page.
 * Sections: hero (gradient + decorative pattern), stats strip, modules
 * grid, developer credit, footer. */
.pbdpy-home {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 32px 48px;
  height: calc(100vh - 47px);
  overflow-y: auto;
  box-sizing: border-box;
}

/* -- Hero -- */
.pbdpy-hero {
  position: relative;
  overflow: hidden;
  padding: 56px 56px 60px;
  border-radius: 18px;
  background:
    radial-gradient(ellipse at 80% 0%, rgba(110, 231, 183, 0.22), transparent 55%),
    radial-gradient(ellipse at 0% 100%, rgba(255, 255, 255, 0.08), transparent 50%),
    linear-gradient(135deg, var(--apecgreendark) 0%, var(--apecgreen) 90%);
  color: #fff;
  margin-bottom: 28px;
  box-shadow: 0 12px 36px -10px rgba(26, 92, 26, 0.45);
}
.pbdpy-hero-decor {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: -1px -1px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at 70% 30%,
                              rgba(0,0,0,0.55), transparent 65%);
}
.pbdpy-hero-inner {
  position: relative;
  max-width: 760px;
}
.pbdpy-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.78em;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 18px;
  backdrop-filter: blur(4px);
}
.pbdpy-hero-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6ee7b7;
  box-shadow: 0 0 0 4px rgba(110, 231, 183, 0.25);
}
.pbdpy-hero-title {
  font-size: 3.6em;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0 0 14px;
}
.pbdpy-hero-tagline {
  font-size: 1.32em;
  font-weight: 500;
  line-height: 1.4;
  margin: 0 0 8px;
  opacity: 0.96;
  max-width: 620px;
}
.pbdpy-hero-sub {
  font-size: 0.98em;
  line-height: 1.55;
  opacity: 0.78;
  margin: 0 0 26px;
  max-width: 560px;
}
.pbdpy-hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.pbdpy-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease,
              box-shadow 0.15s ease,
              background 0.15s ease;
  font-family: inherit;
}
.pbdpy-btn .icon { margin: 0; }
.pbdpy-btn-primary {
  background: #fff;
  color: var(--apecgreendark);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.pbdpy-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
}
.pbdpy-btn-ghost {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.32);
}
.pbdpy-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

/* -- Stats strip -- */
.pbdpy-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  background: var(--apec-divider);
  border: 1px solid var(--apec-divider);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 36px;
}
.pbdpy-stat {
  background: #fff;
  text-align: center;
  padding: 22px 16px;
}
.pbdpy-stat-value {
  font-size: 1.6em;
  font-weight: 700;
  color: var(--apecgreendark);
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.pbdpy-stat-label {
  font-size: 0.82em;
  color: var(--apec-text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* -- Sections -- */
.pbdpy-section { margin-bottom: 40px; }
.pbdpy-section-head { margin-bottom: 18px; }
.pbdpy-section-title {
  font-size: 1.5em;
  font-weight: 600;
  color: var(--apec-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.pbdpy-section-title .icon {
  color: var(--apecgreen);
  font-size: 0.95em;
  margin: 0;
}
.pbdpy-section-sub {
  margin: 4px 0 0;
  font-size: 0.95em;
  color: var(--apec-text-muted);
}

/* -- Module cards -- */
.pbdpy-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}
.pbdpy-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--apec-divider);
  border-radius: 14px;
  padding: 24px 24px 20px;
  cursor: pointer;
  transition: transform 0.18s ease,
              box-shadow 0.18s ease,
              border-color 0.18s ease;
  display: flex;
  flex-direction: column;
}
.pbdpy-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--apecgreen), var(--apecgreenborder));
  border-radius: 14px 14px 0 0;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.pbdpy-card:hover {
  transform: translateY(-4px);
  border-color: var(--apecgreen);
  box-shadow: 0 14px 30px -12px rgba(45, 139, 63, 0.28);
}
.pbdpy-card:hover::before { opacity: 1; }
.pbdpy-card-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--apecgreenlight);
  color: var(--apecgreen);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  transition: background 0.18s ease, color 0.18s ease;
}
.pbdpy-card-icon-wrap .icon {
  font-size: 1.35em;
  margin: 0;
}
.pbdpy-card:hover .pbdpy-card-icon-wrap {
  background: var(--apecgreen);
  color: #fff;
}
.pbdpy-card-title {
  font-size: 1.1em;
  font-weight: 600;
  color: var(--apec-text);
  margin: 0 0 8px;
}
.pbdpy-card-desc {
  font-size: 0.9em;
  color: var(--apec-text-muted);
  line-height: 1.55;
  margin: 0 0 16px;
  flex-grow: 1;
}
.pbdpy-card-cta {
  font-size: 0.86em;
  font-weight: 600;
  color: var(--apecgreen);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: gap 0.18s ease;
}
.pbdpy-card-cta .icon { margin: 0; font-size: 0.9em; }
.pbdpy-card:hover .pbdpy-card-cta { gap: 10px; }

/* -- Developer credit -- */
.pbdpy-credit-section { margin-top: 8px; }
.pbdpy-credit-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 14px;
}
.pbdpy-credit-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--apec-divider);
  border-left: 4px solid var(--apecgreen);
  border-radius: 12px;
  padding: 18px 22px;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.pbdpy-credit-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -8px rgba(45, 139, 63, 0.22);
}
.pbdpy-credit-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--apecgreen), var(--apecgreendark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05em;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.pbdpy-credit-info { display: flex; flex-direction: column; }
.pbdpy-credit-name {
  font-size: 1.05em;
  font-weight: 600;
  color: var(--apec-text);
}
.pbdpy-credit-role {
  font-size: 0.86em;
  color: var(--apec-text-muted);
  margin-top: 2px;
}
.pbdpy-credit-org {
  text-align: center;
  font-size: 0.92em;
  color: var(--apec-text-muted);
  margin: 8px 0 0;
}
.pbdpy-credit-org strong {
  color: var(--apecgreendark);
  letter-spacing: 0.04em;
  margin-right: 4px;
}

/* -- Footer -- */
.pbdpy-footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--apec-divider);
}
.pbdpy-footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  font-size: 0.82em;
  color: var(--apec-text-muted);
}
.pbdpy-footer-sep { opacity: 0.4; margin: 0 4px; }

/* -- Two-column layout -- */
.two-col {
  display: flex;
  height: calc(100vh - 47px);
  overflow: hidden;
}

.col-input {
  width: 400px;
  min-width: 400px;
  background: #fff;
  border-right: 1px solid #ddd;
  overflow-y: auto;
}

/* Landscape input panel — wider form, 2-column section grid.
 * Used by the Midas ASCE 41 tab where the form has many sections;
 * other tabs keep the narrower 400px sidebar. */
.col-input.col-input-wide {
  width: 620px;
  min-width: 620px;
}
.col-input.col-input-wide .input-panel {
  padding: 14px 18px 24px;
}
.col-input.col-input-wide .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 18px;
}
.col-input.col-input-wide .form-grid > .form-section {
  min-width: 0;
}
.col-input.col-input-wide .form-grid > .form-section.full-span {
  grid-column: 1 / -1;
}
.col-input.col-input-wide h4.ui.dividing.header {
  margin-top: 8px;
}

.input-panel {
  padding: 16px 20px 24px;
}

.input-panel .ui.header {
  margin-bottom: 4px;
}

.input-panel .ui.form .field > label {
  font-size: 0.85em;
  color: #555;
}

.input-panel .ui.form input {
  padding: 7px 10px;
}

.input-panel .ui.form .fields {
  margin-bottom: 6px;
}

.input-panel h4.ui.dividing.header {
  margin-top: 14px;
  margin-bottom: 8px;
  font-size: 0.95em;
}

.col-report {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  background: #f5f7fa;
}

/* -- Handsontable panel (sits above report toolbar in the right column) -- */
.hot-panel {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 12px 24px 16px;
  overflow: hidden;        /* contain Handsontable's measured width */
  max-width: 100%;
  box-sizing: border-box;
}
.hot-panel > div[id^="hot-"] {
  width: 100%;
  overflow: auto;          /* let Handsontable scroll horizontally inside */
}
.hot-panel-header {
  font-size: 0.95em;
  font-weight: 600;
  color: #2185d0;
  margin-bottom: 8px;
}
.hot-panel-hint {
  font-weight: 400;
  font-size: 0.78em;
  color: #888;
  margin-left: 8px;
}
/* Make Handsontable text a touch smaller so all 13 cols fit cleanly */
.hot-panel .handsontable {
  font-size: 0.85em;
}

/* -- Report toolbar -- */
.report-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f5f7fa;
  padding: 12px 24px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
}

/* -- Report area -- */
.report-area {
  padding: 16px 24px 40px;
}

.report-section {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 20px 28px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.report-section h3 {
  color: var(--apecgreendark);
  border-bottom: 2px solid var(--apecgreen);
  padding-bottom: 6px;
  margin-bottom: 14px;
}

.report-section h4 {
  color: var(--apecgreendark);
  margin: 14px 0 8px;
  font-weight: 600;
}

/* Form-section headers in the input panel: apec-green underline */
.input-panel h4.ui.dividing.header {
  color: var(--apecgreendark);
  border-bottom: 1px solid var(--apecgreenborder);
}

.calc-line {
  margin: 6px 0;
  padding: 4px 0;
  font-size: 1.05em;
}

.check-pass {
  color: #21ba45;
  font-weight: bold;
}

.check-fail {
  color: #db2828;
  font-weight: bold;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}

.result-table th,
.result-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.result-table th {
  background: #f8f9fa;
  color: #555;
  font-weight: 600;
  text-align: center;
  vertical-align: middle;
}

.result-table td.mono {
  text-align: right;
  font-family: 'Consolas', 'Courier New', monospace;
}

/* Beam-group banding: alternate beam_id groups (M3, M4, …) get a faint
   diagonal hatch so the I/MID/J rows of one beam read as a single block. */
.result-table tbody tr.beam-band-alt td {
  background-image: repeating-linear-gradient(
    -45deg,
    transparent 0,
    transparent 5px,
    rgba(46, 125, 50, 0.07) 5px,
    rgba(46, 125, 50, 0.07) 6px
  );
}
.result-table tbody tr.beam-group-start td {
  border-top: 2px solid #b8c8b8;
}

/* Click-to-expand audit trail.  Tap the MIDAS ID cell to drop a detail
   row below the beam group with the full per-location calculation; the
   detail HTML is generated lazily on first click and cached thereafter. */
.midas-id-clickable {
  cursor: pointer;
  user-select: none;
  color: #1a5d2a;
  text-decoration: underline dotted rgba(45, 139, 63, 0.4);
}
.midas-id-clickable:hover {
  color: #2d8b3f;
  text-decoration-style: solid;
}
.midas-id-chevron {
  display: inline-block;
  font-size: 0.85em;
  color: #888;
  transition: transform 0.15s ease;
  margin-left: 2px;
}
.midas-id-clickable.expanded .midas-id-chevron { transform: rotate(180deg); }

.result-table tbody tr.midas-detail-row td {
  background: #fafdfa;
  border-top: 2px solid #b8c8b8;
  border-bottom: 2px solid #b8c8b8;
  padding: 14px 22px;
}
.midas-detail-content { font-size: 0.92em; line-height: 1.45; color: #2c3e2c; }
.midas-detail-content h5 {
  margin: 0 0 4px;
  color: #2d8b3f;
  border-bottom: 1px solid #d8e6d8;
  padding-bottom: 4px;
}
.midas-detail-content h6 {
  margin: 14px 0 4px;
  color: #1a5d2a;
  background: #eaf3ea;
  padding: 4px 10px;
  border-left: 3px solid #2d8b3f;
}
.audit-step {
  margin: 10px 0 4px;
  font-weight: 600;
  color: #1a5d2a;
}
.audit-line {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.92em;
  margin: 1px 0;
  padding: 1px 0;
  white-space: pre-wrap;
}
.audit-line.result { font-weight: 600; }
.audit-line.flag-pass { color: #2d8b3f; font-weight: 600; }
.audit-line.flag-fail { color: #d9534f; font-weight: 600; }
.audit-line.indent { padding-left: 2em; }

/* LaTeX-rendered audit (column flexure / shear detail). Drop monospace so
   labels read naturally next to MathJax-rendered math, and give display
   equations (\[...\]) breathing room. */
.latex-audit .audit-line {
  font-family: 'Lato', 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.95em;
  white-space: normal;
  line-height: 1.55;
  margin: 3px 0;
}
.latex-audit .audit-step {
  font-size: 1.0em;
  margin-top: 14px;
}
.latex-audit mjx-container[display="true"] {
  margin: 6px 0 !important;
}
.latex-audit .audit-line.result {
  background: #f4faf4;
  border-left: 3px solid var(--apecgreen);
  padding: 4px 10px;
  border-radius: 0 3px 3px 0;
}

/* Detail rows shouldn't appear in print.  If a developer needs the
   audit on paper, expand them on screen and screenshot — the table
   itself prints in summary form. */
@media print { .midas-detail-row { display: none !important; } }

.summary-box {
  background: #f0f7ff;
  border-left: 4px solid #2185d0;
  padding: 14px 18px;
  margin: 16px 0;
  border-radius: 0 4px 4px 0;
}

.summary-box.pass {
  background: #f0fff4;
  border-left-color: #21ba45;
}

.summary-box.fail {
  background: #fff6f6;
  border-left-color: #db2828;
}

.summary-box.info {
  background: #f0f7ff;
  border-left-color: #2185d0;
}

.ui.menu .item.active {
  font-weight: bold;
}

/* -- Equation reference badges -- */
.eq-ref {
  display: inline-block;
  background: #e8f4fd;
  color: #2185d0;
  font-size: 0.82em;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 3px;
  margin-right: 6px;
  border: 1px solid #b8d9f0;
  vertical-align: middle;
}

.art-ref {
  color: #2185d0;
  font-weight: normal;
  font-size: 0.9em;
  font-style: italic;
}

/* -- Data items -- */
.bearing-data {
  margin: 14px 0 6px;
  padding: 0 4px;
}

.bd-item {
  margin-bottom: 2px;
}

.bd-desc {
  color: #333;
  font-size: 0.93em;
  margin-top: 6px;
}

.bd-two-col {
  display: flex;
  gap: 32px;
}

.bd-two-col .bd-item {
  flex: 1;
}

/* -- Narrative -- */
.narrative {
  margin: 10px 0 6px 24px;
  font-size: 0.97em;
  color: #333;
  line-height: 1.6;
}

.calc-block {
  margin: 6px 0 10px 48px;
}

/* -- Param table (for acceptance criteria) -- */
.param-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.95em;
}

.param-table th,
.param-table td {
  padding: 8px 10px;
  text-align: center;
  border: 1px solid #ddd;
}

.param-table th {
  background: #f0f4f8;
  color: #333;
  font-weight: 600;
  font-size: 0.88em;
}

.param-table th.group-header {
  background: #e0e8f0;
  font-size: 0.92em;
}

.param-table td {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.92em;
}

.param-table tr.governing {
  background: #f0fff4;
  font-weight: bold;
}

.param-table tr.governing td {
  border-top: 2px solid #21ba45;
}

.param-table td.na {
  color: #bbb;
  font-style: italic;
}

/* -- Condition tag -- */
.cond-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  font-size: 0.82em;
  font-weight: 600;
  margin-right: 6px;
}

.cond-tag.active {
  background: #e8f4fd;
  color: #2185d0;
  border: 1px solid #b8d9f0;
}

.cond-tag.inactive {
  background: #f0f0f0;
  color: #999;
  border: 1px solid #ddd;
}

/* -- Design Sheet Header -- */
.ds-table {
  width: 100%;
  border-collapse: collapse;
  border: 2px solid #333;
  margin-bottom: 16px;
}
.ds-table td {
  border: 1px solid #aaa;
  padding: 5px 10px;
  vertical-align: middle;
}
.ds-logo-cell {
  width: 72px;
  text-align: center;
}
.ds-logo-cell img {
  height: 48px;
}
.ds-title-cell {
  text-align: center;
  font-size: 1.45em;
  font-weight: bold;
  letter-spacing: 3px;
  padding: 12px 0;
  color: #222;
  background: #f6f6f6;
}
.ds-lbl {
  font-weight: bold;
  white-space: nowrap;
  color: #333;
  width: 72px;
}
.ds-val {
  min-width: 160px;
}
.ds-right-cell {
  text-align: left;
  min-width: 160px;
  line-height: 1.7;
}
.ds-lbl-i {
  font-weight: bold;
  color: #333;
}
.ds-item-cell {
  text-align: center;
  font-weight: bold;
  letter-spacing: 1px;
  font-size: 0.95em;
}

/* -- 6-status taxonomy badges (ASCE 41-17 spec §11.4 / §11.5) -- */
.status-pass                  { background: #5cb85c; color: #fff; }
.status-pass-ls-fail-cp       { background: #f0ad4e; color: #fff; }
.status-fail-ls               { background: #d9534f; color: #fff; }
.status-force-controlled-fail { background: #7b1d1d; color: #fff; }
.status-splice-governed       { background: #9b59b6; color: #fff; }
.status-data-missing          { background: #5a6b7a; color: #fff; }
.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 600;
  font-size: 0.78em;
  letter-spacing: 0.3px;
}

/* MIDAS API trace pre block readability */
#midas-trace-panel pre {
  font-family: 'Consolas', 'Courier New', monospace;
}

/* Global MIDAS API bar — sticks below the nav menu and is the single
 * source of truth for the MAPI-Key.  Per-tab fetch handlers read it via
 * getMapiKey() in app.js.  Hidden on non-MIDAS tabs by the tab handler. */
.global-midas-bar {
  background: linear-gradient(180deg, #f5fbf5 0%, #eaf3ea 100%);
  border-bottom: 1px solid #c8d8c8;
  padding: 10px 16px;
}
.global-midas-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.global-midas-label {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  color: #1a5d2a;
  white-space: nowrap;
  margin-right: 4px;
}
.global-midas-label > i.icon {
  margin-right: 4px;
}
.global-midas-row > input[type="password"],
.global-midas-row > input[type="text"] {
  flex: 1 1 220px;
  min-width: 200px;
  max-width: 480px;
  padding: 6px 10px;
  border: 1px solid #c8d8c8;
  border-radius: 3px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.92em;
}
.global-midas-row > input:focus {
  border-color: #2d8b3f;
  outline: none;
  box-shadow: 0 0 0 2px rgba(45, 139, 63, 0.15);
}
.global-midas-row > .ui.button.compact {
  padding: 6px 14px;
  font-size: 0.92em;
}
.global-midas-banner {
  margin-top: 8px;
  margin-bottom: 0;
  grid-template-columns: repeat(3, minmax(0, 220px));
  justify-content: flex-start;
}

/* MIDAS Source header — title + connection flag share the row, but the
 * flag wraps cleanly to the next line when the column is tight. */
.midas-source-header.ui.dividing.header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  padding-bottom: 6px;
}
.midas-source-header .midas-source-title {
  flex: 1 1 auto;
  min-width: 0;
}
.midas-source-header .midas-conn-flag {
  flex: 0 0 auto;
  margin-left: auto;
}

/* -- MIDAS fetch-status banner (ELEM / STLD / LCOM) -- */
.midas-banner {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0 12px;
}
.midas-banner-cell {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 6px 9px;
  border-radius: 5px;
  background: #f4f6f8;
  border: 1px solid var(--apec-divider);
  color: var(--apec-text-muted);
  font-size: 0.74em;
  font-weight: 500;
  cursor: help;
  transition: all 0.15s ease;
  overflow: hidden;
}
.midas-banner-cell > i.icon {
  margin: 0;
  font-size: 1.05em;
}
.midas-banner-cell .midas-banner-label {
  letter-spacing: 0.2px;
  line-height: 1.15;
  /* Allow 2-line wrap but cap height to keep cells uniform */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.midas-banner-cell .midas-banner-count {
  font-family: 'Consolas', 'Courier New', monospace;
  font-weight: 700;
  font-size: 1.05em;
  color: #98a4ae;
  text-align: right;
  min-width: 28px;
}
.midas-banner-cell.fetched {
  background: var(--apecgreenlight);
  border-color: var(--apecgreenborder);
  color: var(--apecgreendark);
}
.midas-banner-cell.fetched .midas-banner-count { color: var(--apecgreendark); }
.midas-banner-cell.error {
  background: #fff1f1;
  border-color: #f5b8b8;
  color: #a02020;
}
.midas-banner-cell.error .midas-banner-count { color: #a02020; }

/* -- MIDAS action button grid (5 buttons in 2 cols, Fetch full-width) -- */
.midas-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.midas-actions .ui.button {
  margin: 0;
  min-height: 32px;
  padding: 7px 10px;
  font-size: 0.82em;
  font-weight: 600;
}
.midas-actions .ui.button.full-row {
  grid-column: 1 / -1;
}
.midas-actions .ui.green.button {
  background: var(--apecgreen);
  color: #fff;
}
.midas-actions .ui.green.button:hover {
  background: var(--apecgreendark);
}

/* -- MIDAS connection flag -- */
.midas-conn-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px 2px 7px;
  border-radius: 11px;
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.2px;
  border: 1px solid;
  cursor: help;
  user-select: none;
  white-space: nowrap;
}
.midas-conn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.midas-conn-flag.idle {
  background: #f4f6f8; color: #5a6b7a; border-color: #d3d8dc;
}
.midas-conn-flag.idle .midas-conn-dot { background: #98a4ae; }

.midas-conn-flag.checking {
  background: #fff7e6; color: #b86e00; border-color: #ffd58a;
}
.midas-conn-flag.checking .midas-conn-dot {
  background: #f0ad4e;
  animation: midas-pulse 1.0s ease-in-out infinite;
}

.midas-conn-flag.connected {
  background: var(--apecgreenlight);
  color: var(--apecgreendark);
  border-color: var(--apecgreenborder);
}
.midas-conn-flag.connected .midas-conn-dot {
  background: var(--apecgreen);
  box-shadow: 0 0 0 0 rgba(45, 139, 63, 0.6);
  animation: midas-pulse-green 1.6s ease-out infinite;
}

.midas-conn-flag.error {
  background: #fff1f1; color: #a02020; border-color: #f5b8b8;
}
.midas-conn-flag.error .midas-conn-dot { background: #d9534f; }

@keyframes midas-pulse {
  0%, 100% { opacity: 1.0; }
  50%      { opacity: 0.35; }
}
@keyframes midas-pulse-green {
  0%   { box-shadow: 0 0 0 0   rgba(45, 139, 63, 0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(45, 139, 63, 0.0);  }
  100% { box-shadow: 0 0 0 0   rgba(45, 139, 63, 0.0);  }
}

/* Methodology help modal — full-viewport overlay + centered dialog,
   shown via .active class toggled by openMidasHelp / closeMidasHelp.
   Content lives in the DOM from page load so MathJax auto-typesets it. */
.midas-help-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 25, 0.55);
  z-index: 9999;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px 16px;
  overflow-y: auto;
}
.midas-help-overlay.active { display: flex; }
.midas-help-dialog {
  background: #fff;
  max-width: 920px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px 36px 32px;
  border-radius: 6px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
  position: relative;
  font-size: 0.92em;
  line-height: 1.55;
  color: #2c3e2c;
}
.midas-help-dialog h3 {
  color: #2d8b3f;
  border-bottom: 2px solid #d8e6d8;
  padding-bottom: 8px;
}
.midas-help-dialog h4 {
  color: #2d8b3f;
  margin-top: 18px;
  margin-bottom: 6px;
}
.midas-help-dialog ul { margin: 6px 0 12px 4px; padding-left: 22px; }
.midas-help-dialog li { margin-bottom: 4px; }
.midas-help-dialog .calc-line {
  background: #f6faf6;
  border-left: 3px solid #b8d8b8;
  padding: 8px 14px;
  margin: 8px 0;
}
.midas-help-close {
  position: absolute;
  top: 8px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.8em;
  line-height: 1;
  color: #888;
  cursor: pointer;
  padding: 4px 10px;
}
.midas-help-close:hover { color: #2d8b3f; }

/* m-factor reference table inside the methodology modal */
.midas-help-dialog .m-factor-table-wrap {
  margin: 8px 0 4px;
  overflow-x: auto;
}
.midas-help-dialog .m-factor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
}
.midas-help-dialog .m-factor-table th,
.midas-help-dialog .m-factor-table td {
  border: 1px solid #d0d6dc;
  padding: 4px 8px;
  text-align: center;
  white-space: nowrap;
}
.midas-help-dialog .m-factor-table thead th {
  background: var(--apecgreenlight);
  color: var(--apecgreendark);
  font-weight: 600;
}
.midas-help-dialog .m-factor-table th.grp { background: #d6f0de; }
.midas-help-dialog .m-factor-table tbody tr.section-row td {
  background: #f0f4f7;
  text-align: left;
  color: var(--apec-text-muted);
  font-style: italic;
  padding: 6px 10px;
}
.midas-help-dialog .m-factor-table tbody td:nth-child(-n+3) {
  background: #fafbfc;
  font-variant-numeric: tabular-nums;
}
.midas-help-dialog .m-factor-table tbody td:nth-child(n+4) {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
@media print { .midas-help-overlay { display: none !important; } }

/* Print styles for status pills — keep solid color */
@media print {
  .status-pass, .status-pass-ls-fail-cp, .status-fail-ls,
  .status-force-controlled-fail, .status-splice-governed, .status-data-missing {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* -- Print styles -- */
@media print {
  /* Landscape with tight margins so the 26-column per-location table
     can fit at small font without horizontal overflow.  Without this
     a multi-hundred-row evaluation balloons to 100+ portrait pages. */
  @page { size: landscape; margin: 10mm; }

  body { background: #fff; }
  .ui.menu, .col-input, .report-toolbar { display: none !important; }
  .two-col {
    display: block;
    height: auto;
    overflow: visible;
  }
  .col-report {
    overflow: visible;
    padding: 0;
    background: #fff;
  }
  .report-area { padding: 0; }
  .report-section {
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
  }
  .summary-box {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .param-table {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .ds-table { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ds-title-cell { background: #f6f6f6 !important; }

  /* Tight per-location result table — overrides inline font-size from the
     report renderer.  At 0.58em with 2px×4px cell padding, a 26-column
     row still reads cleanly on landscape Letter/A4 and ~40 rows fit per
     page (vs ~3 rows per portrait page at 0.82em). */
  .result-table {
    font-size: 0.58em !important;
    line-height: 1.15 !important;
  }
  .result-table th,
  .result-table td {
    padding: 2px 4px !important;
  }
  .result-table tbody tr,
  .result-table thead tr {
    page-break-inside: avoid;
  }
  /* Repeat the header on each printed page */
  .result-table thead { display: table-header-group; }

  /* Narrative blocks shouldn't split awkwardly across pages */
  .narrative, .calc-line {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
