/* ============================================================
   AUTOMATA — score entry
   Uses the app design tokens in app.css. Nothing here restyles
   an existing surface; every selector is prefixed .se-.
   ============================================================ */

.se-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(14, 31, 61, 0.42);
  backdrop-filter: blur(3px);
}

.se-overlay.hidden { display: none; }
body.se-open { overflow: hidden; }

.se-shell,
.se-panel {
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  height: min(880px, 100%);
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.se-panel {
  position: absolute;
  inset: 24px;
  margin: auto;
  z-index: 2;
}

.se-panel.hidden { display: none; }

/* ---------- head / foot ---------- */

.se-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, var(--sunken));
}

.se-eyebrow {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--blue);
}

.se-head h2 {
  margin: 2px 0 0;
  font-size: 19px;
  font-weight: 650;
  color: var(--navy);
}

.se-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.se-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  border-top: 1px solid var(--line);
  background: var(--sunken);
}

.se-foot-actions { display: flex; gap: 8px; }

.se-status {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}

.se-status.is-ok { color: var(--ok); }
.se-status.is-warn { color: var(--warn); }
.se-status.is-error { color: var(--danger); }

/* ---------- buttons ---------- */

.se-btn {
  font: inherit;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.se-btn:hover { background: var(--sunken); border-color: #cfd8e3; }

.se-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.se-primary:hover { background: var(--navy); border-color: var(--navy); }

.se-open-btn {
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  width: 100%;
  margin: 6px 0 10px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--blue);
  background: var(--blue-soft);
  color: var(--navy);
  cursor: pointer;
}

.se-open-btn:hover { background: #dfeaf8; }

.se-row-open {
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s var(--ease);
}

.tests-given-row:hover .se-row-open,
.se-row-open:focus { opacity: 1; }

.se-mini {
  font: inherit;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.se-mini:hover { background: var(--sunken); color: var(--ink); }

/* ---------- body ---------- */

.se-body {
  flex: 1;
  display: grid;
  grid-template-columns: 208px 1fr;
  min-height: 0;
}

.se-rail {
  border-right: 1px solid var(--line);
  background: var(--sunken);
  padding: 12px 10px;
  overflow-y: auto;
}

.se-rail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  font: inherit;
  font-weight: 600;
  text-align: left;
  padding: 9px 11px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.se-rail-item:hover { background: #eef2f7; }

.se-rail-item.is-active {
  background: #fff;
  border-color: var(--blue);
  box-shadow: var(--shadow-xs);
  color: var(--navy);
}

.se-rail-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.se-rail-item.is-part .se-rail-count { color: var(--warn); }
.se-rail-item.is-done .se-rail-count { color: var(--ok); }

.se-card {
  padding: 20px 24px 28px;
  overflow-y: auto;
  min-height: 0;
}

.se-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.se-card-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  color: var(--navy);
}

.se-card-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* Kevin, 2026-09-07: the LINK banner. Green when the sheet is the source of
   truth and the boxes are read-only; amber when the app is the database. */
.se-linked,
.se-unlinked {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  line-height: 1.45;
}
.se-linked {
  border: 1px solid var(--ok);
  background: var(--ok-soft);
  color: var(--ink);
}
.se-unlinked {
  border: 1px dashed var(--warn);
  background: var(--warn-soft);
  color: var(--ink);
}
.se-linked strong, .se-unlinked strong { font-weight: 700; }
.se-linked-icon { line-height: 1.4; }

/* Read-only boxes read as printed, not as typeable. */
.se-card.is-linked .se-in {
  background: var(--sunken);
  color: var(--ink);
  cursor: default;
}
.se-card.is-linked .se-in:focus { border-color: var(--line); box-shadow: none; }
.se-card.is-linked .se-textarea { background: var(--sunken); }

.se-empty {
  margin: 32px auto;
  max-width: 380px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- groups and rows ---------- */

.se-group {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 6px 16px 14px;
  margin: 0 0 16px;
  background: #fff;
}

.se-group legend {
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.se-rows { display: flex; flex-direction: column; }

.se-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) 92px 104px minmax(150px, 1fr);
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
}

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

.se-label { display: flex; flex-direction: column; min-width: 0; }

.se-label-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.se-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  color: var(--faint);
}

.se-in {
  font: inherit;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--ink);
  width: 100%;
}

.se-in:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.14);
}

.se-band { font-size: 12px; color: var(--muted); }
.se-band-gap { display: block; }

.se-row.has-problem .se-score {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.se-derived { display: flex; flex-wrap: wrap; gap: 5px; }

.se-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--sunken);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.se-chip.is-sheet { border-style: dashed; }
.se-desc.is-high { background: var(--ok-soft); border-color: #bfe3cf; color: var(--ok); }
.se-desc.is-low { background: var(--danger-soft); border-color: #f0c9c9; color: var(--danger); }
.se-desc.is-mid { background: var(--blue-soft); border-color: #cfe0f2; color: var(--blue); }
.se-local { background: #fff; color: var(--faint); }

.se-problem {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 11px;
  color: var(--danger);
}

.se-problem:empty { display: none; }

/* ---------- extracted vs typed ---------- */

/* Green = the app read this off the uploaded report. It is a claim about
   provenance, so it goes the moment the value is edited by hand. */
.se-row.is-extracted .se-score {
  border-color: #7fc7a1;
  background: var(--ok-soft);
  color: #14603c;
  font-weight: 600;
}

.se-row.is-extracted .se-band {
  border-color: #cbe7d8;
  background: #f4fbf7;
}

.se-from {
  margin-left: 7px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--ok-soft);
  border: 1px solid #bfe3cf;
  color: var(--ok);
  vertical-align: 1px;
}

.se-row.has-problem.is-extracted .se-score {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--ink);
}

.se-read-count { color: var(--ok); font-weight: 600; }

.se-extract {
  flex: 0 0 auto;
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--navy);
  box-shadow: var(--shadow-xs);
}

.se-extract:hover { background: #dfeaf8; }

.se-extract:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Same 3D green press the received-survey buttons use. */
.se-extract.is-received {
  background: var(--ok-soft);
  border-color: #9ed6b8;
  color: var(--ok);
  box-shadow: 0 2px 0 #bfe3cf, var(--shadow-xs);
}

.se-extract.is-received:hover { background: #dbf1e6; }

/* ---------- extractor progress ---------- */

/* There is no progress bar in this stylesheet. Extractor progress is drawn by
   merge-overlay.js / merge-overlay.css — the one overlay the app already had —
   so that a second bar cannot drift away from it. See score-extract.js. */

/* ---------- narrative ---------- */

.se-narrative {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 16px 16px;
  background: var(--sunken);
}

.se-narrative-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.se-narrative-head h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy);
}

.se-narrative-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.se-note { font-size: 11px; color: var(--muted); }

.se-textarea {
  font: inherit;
  font-size: 13.5px;
  line-height: 1.62;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--ink);
  resize: vertical;
}

.se-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.14);
}

/* ---------- extracted data ---------- */

.se-search {
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  min-width: 200px;
}

.se-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.se-table-wrap { flex: 1; overflow: auto; }

.se-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.se-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--sunken);
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}

.se-table td {
  padding: 7px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

.se-table tr.is-blank td { color: var(--faint); }
.se-table tbody tr:hover { background: var(--sunken); }

.se-td-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--navy);
  white-space: nowrap;
}

.se-td-test {
  display: block;
  font-family: inherit;
  font-size: 10px;
  color: var(--faint);
}

.se-td-value {
  max-width: 520px;
  white-space: pre-wrap;
  word-break: break-word;
}

.se-blank { color: var(--faint); }

.se-src {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--sunken);
  border: 1px solid var(--line);
  color: var(--muted);
}

.se-src-score { background: var(--blue-soft); border-color: #cfe0f2; color: var(--blue); }
.se-src-formula { background: #f6f1ff; border-color: #ded0f5; color: #6d47b8; }
.se-src-narrative { background: var(--ok-soft); border-color: #bfe3cf; color: var(--ok); }
.se-src-band { background: var(--warn-soft); border-color: #f0dcbb; color: var(--warn); }

.se-yes { font-size: 11px; color: var(--ok); font-weight: 600; }
.se-no { font-size: 11px; color: var(--faint); font-weight: 600; }

@media (max-width: 900px) {
  .se-body { grid-template-columns: 1fr; }
  .se-rail { display: flex; gap: 6px; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .se-rail-item { width: auto; margin-bottom: 0; white-space: nowrap; }
  .se-row { grid-template-columns: 1fr 84px; }
  .se-derived { grid-column: 1 / -1; }
}


/* Kevin, 2026-09-11: "CHANGE 'ENTER SCORES' TO 'MANUAL ENTRY' ... HAVE IT
   EXPAND ON HOVER." Hovering the button lists the tests ticked in the battery
   and takes you straight to one. */
.se-open-wrap { position: relative; display: block; }
.se-open-list {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height .18s ease, opacity .18s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.se-open-wrap:hover > .se-open-list,
.se-open-wrap:focus-within > .se-open-list { max-height: 320px; overflow: auto; opacity: 1; }
.se-open-item {
  text-align: left;
  padding: 4px 8px;
  font-size: 11.5px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
}
.se-open-item:hover { background: var(--al-red-tint, #FBE9E5); border-color: var(--al-line, #DCD5D4); }
.se-open-empty { margin: 4px 2px; font-size: 11px; color: var(--al-muted, #6F6870); }
@media (prefers-reduced-motion: reduce) { .se-open-list { transition: none; } }
