/* NHREF OtoScan
   Nawaloka Hospital PLC Research and Education Foundation

   Light clinical interface. Navy carries structure, amber marks the single
   active control and anything that asks for attention, and a restrained green
   is used only for the routine outcome, so status reads at a glance. */

:root {
  color-scheme: light;

  --navy-900: #112c47;
  --navy-800: #16395c;
  --navy-700: #1f5182;
  --navy-500: #3d7bb3;
  --navy-100: #dde8f3;
  --navy-050: #eef4fa;

  --amber-800: #8a4a14;
  --amber-700: #a4581a;
  --amber-600: #c06f1f;
  --amber-500: #d97e28;
  --amber-200: #f0c893;
  --amber-050: #fdf4e9;

  --green-700: #2c6a4b;
  --green-500: #3f8c65;
  --green-100: #d6eadf;
  --green-050: #eef7f1;

  --ink-900: #16202b;
  --ink-700: #33465a;
  --ink-500: #5f7489;
  --ink-400: #8396a8;

  --paper:     #ffffff;
  --canvas:    #f2f5f8;
  --line:      #dae2ea;
  --line-soft: #e9eef3;

  --red-700: #a32a21;
  --red-050: #fbeceb;

  --sans: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

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

/* Keep [hidden] authoritative even where a block sets its own display. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--ink-900);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 28px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============ Masthead ============ */

.masthead {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 62px;
}

.identity { display: flex; align-items: stretch; gap: 13px; }

.identity-rule {
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--amber-500) 0 50%, var(--navy-700) 50% 100%);
}

.identity-text { display: flex; flex-direction: column; justify-content: center; }

.identity-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--navy-800);
  line-height: 1.25;
}

.identity-unit {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  color: var(--ink-500);
  line-height: 1.3;
}

.masthead-meta { display: flex; align-items: center; gap: 12px; }

.meta-item { font-size: 12.5px; font-weight: 500; color: var(--ink-700); }

.meta-muted {
  color: var(--ink-400);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

.meta-divider { width: 1px; height: 14px; background: var(--line); }

/* ============ Title bar ============ */

.titlebar {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.titlebar-inner { padding-top: 26px; padding-bottom: 24px; }

.titlebar h1 {
  margin: 0 0 4px;
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.016em;
  color: var(--navy-900);
}

.titlebar p { margin: 0; font-size: 14px; color: var(--ink-500); }

/* ============ Workspace ============ */

.workspace {
  flex: 1 0 auto;
  display: grid;
  /* Patient, Image and Assessment side by side, so the whole examination is
     visible without scrolling. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.12fr);
  gap: 20px;
  align-items: start;
  padding-top: 28px;
  padding-bottom: 48px;
}

.column { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.card-wide { grid-column: 1 / -1; }

/* ============ Card ============ */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.card-head h2 {
  margin: 0;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.085em;
  text-transform: uppercase;
  color: var(--navy-700);
}

.step {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-400);
}

.card-body { padding: 20px; }

/* ============ Dropzone ============ */

.dropzone {
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--navy-050);
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease;
}

.dropzone:hover { border-color: var(--navy-500); background: #e8f0f8; }
.dropzone:focus-visible { outline: 2px solid var(--navy-700); outline-offset: 2px; }
.dropzone.is-dragover { border-color: var(--amber-500); background: var(--amber-050); }

.dz-frame {
  width: 42px;
  height: 42px;
  margin: 0 auto 11px;
  display: grid;
  place-items: center;
  border: 1px solid var(--navy-100);
  border-radius: 3px;
  background: var(--paper);
  color: var(--navy-500);
}

.dropzone.is-dragover .dz-frame { color: var(--amber-600); border-color: var(--amber-200); }

.dz-glyph { width: 22px; height: 22px; }

.dz-lead { margin: 0 0 3px; font-size: 13.5px; font-weight: 600; color: var(--navy-800); }
.dz-or { font-weight: 400; color: var(--ink-500); }
.dz-note { margin: 0; font-size: 12px; color: var(--ink-400); }

/* ============ Specimen preview ============ */

.specimen {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px 0 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 3px;
}

.specimen img {
  width: 58px;
  height: 58px;
  flex: none;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: var(--canvas);
}

.specimen-meta { display: grid; gap: 1px; min-width: 0; }

.specimen-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.textbtn {
  justify-self: start;
  margin-top: 3px;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy-700);
  cursor: pointer;
  border-bottom: 1px solid var(--navy-100);
}

.textbtn:hover { color: var(--amber-700); border-bottom-color: var(--amber-200); }

.textlink {
  font-size: 12px;
  font-weight: 600;
  color: var(--navy-700);
  text-decoration: none;
  border-bottom: 1px solid var(--navy-100);
}

.textlink:hover { color: var(--amber-700); border-bottom-color: var(--amber-200); }

/* ============ Actions ============ */

.action {
  width: 100%;
  margin-top: 16px;
  padding: 11px 18px;
  border: 1px solid var(--amber-600);
  border-radius: 3px;
  background: var(--amber-500);
  color: #fff;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease;
}

.action:hover:not(:disabled) { background: var(--amber-600); border-color: var(--amber-700); }
.action:active:not(:disabled) { background: var(--amber-700); }
.action:focus-visible, .secondary:focus-visible { outline: 2px solid var(--navy-700); outline-offset: 2px; }

.action:disabled {
  background: var(--canvas);
  border-color: var(--line);
  color: var(--ink-400);
  cursor: not-allowed;
}

.secondary {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  color: var(--navy-800);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.secondary:hover { border-color: var(--navy-500); background: var(--navy-050); }

.privacy-note {
  margin: 12px 0 0;
  font-size: 11.5px;
  color: var(--ink-400);
  text-align: center;
}

/* ============ Placeholder and busy ============ */

.placeholder { padding: 34px 4px; text-align: center; }

.placeholder p { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--ink-700); }

.placeholder .placeholder-note {
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--ink-400);
}

.busy-line { display: flex; align-items: center; justify-content: center; gap: 9px; }

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid var(--navy-100);
  border-top-color: var(--navy-700);
  border-radius: 50%;
  animation: spin .68s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Notices ============ */

.notice {
  display: grid;
  gap: 3px;
  padding: 11px 14px;
  border-radius: 3px;
  font-size: 12.5px;
}

.notice strong { font-size: 12px; }

.notice ul { margin: 2px 0 0; padding-left: 18px; }

.notice-error {
  border: 1px solid #edc9c5;
  border-left: 3px solid var(--red-700);
  background: var(--red-050);
  color: var(--red-700);
}

.notice-warn {
  margin-top: 16px;
  border: 1px solid #f1d9b9;
  border-left: 3px solid var(--amber-500);
  background: var(--amber-050);
  color: var(--amber-800);
}

/* ============ Referral decision ============ */

.referral {
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 3px;
}

.referral.is-refer   { border-left-color: var(--amber-500); background: var(--amber-050); }
.referral.is-routine { border-left-color: var(--green-500); background: var(--green-050); }

.referral-head { display: flex; align-items: center; gap: 12px; }

.referral-icon {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.referral.is-refer .referral-icon   { background: var(--amber-500); }
.referral.is-routine .referral-icon { background: var(--green-500); }
.referral.is-refer .referral-icon::before   { content: "!"; }
.referral.is-routine .referral-icon::before { content: "\2713"; font-size: 15px; }

.referral-caption {
  margin: 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-500);
}

.referral-value {
  margin: 1px 0 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.referral.is-refer .referral-value   { color: var(--amber-800); }
.referral.is-routine .referral-value { color: var(--green-700); }

.referral-explain { margin: 10px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-700); }

.gauge { margin-top: 13px; }

.gauge-track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: rgba(17, 44, 71, 0.09);
}

.gauge-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 4px;
  transition: width .5s cubic-bezier(.22,.61,.36,1);
}

.referral.is-refer .gauge-fill   { background: var(--amber-500); }
.referral.is-routine .gauge-fill { background: var(--green-500); }

.gauge-mark {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 16px;
  margin-left: -1px;
  background: var(--navy-900);
  border-radius: 1px;
}

.gauge-scale {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--ink-500);
}

.gauge-scale strong {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--navy-900);
  font-variant-numeric: tabular-nums;
}

/* ============ Finding ============ */

.section-caption {
  margin: 0 0 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-400);
}

.section-sep { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-soft); }

.finding { margin-top: 20px; }

.finding-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.finding-value {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--navy-900);
}

.finding.is-low .finding-value { color: var(--ink-500); }

.finding-desc { margin: 4px 0 10px; font-size: 12.5px; color: var(--ink-500); }

.finding-note {
  margin: 10px 0 0;
  padding: 9px 11px;
  border-left: 3px solid var(--navy-100);
  background: var(--navy-050);
  border-radius: 0 3px 3px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-700);
}

.tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tag-muted { background: var(--canvas); color: var(--ink-500); border: 1px solid var(--line); }

.readout-score { display: flex; align-items: center; gap: 12px; }

.scorebar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--navy-050);
  overflow: hidden;
}

.scorebar-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--navy-700);
  transition: width .5s cubic-bezier(.22,.61,.36,1);
}

.finding.is-low .scorebar-fill { background: #9fb2c4; }

.scorebar-figure {
  flex: none;
  min-width: 52px;
  text-align: right;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--navy-800);
  font-variant-numeric: tabular-nums;
}

.group-line {
  margin-top: 12px;
  padding: 8px 11px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  font-size: 12.5px;
  color: var(--ink-700);
}

.group-line strong { font-family: var(--mono); color: var(--navy-800); }

/* ============ Differential ============ */

.ranking { width: 100%; border-collapse: collapse; }

.ranking td {
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  vertical-align: middle;
}

.ranking tr:last-child td { border-bottom: none; }

.rank-name { color: var(--ink-700); }
.ranking tr.is-top .rank-name { font-weight: 600; color: var(--navy-900); }

.rank-value {
  width: 116px;
  text-align: right;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-500);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ranking tr.is-top .rank-value { color: var(--navy-800); font-weight: 600; }

.rank-track {
  display: inline-block;
  width: 54px;
  height: 4px;
  margin-right: 9px;
  border-radius: 2px;
  background: var(--navy-050);
  vertical-align: middle;
  overflow: hidden;
}

.rank-track span { display: block; height: 100%; border-radius: 2px; background: var(--navy-100); }
.ranking tr.is-top .rank-track span { background: var(--navy-500); }

.ranking-toggle { margin-top: 8px; }

/* ============ Advisory and result actions ============ */

.advisory {
  margin: 18px 0 0;
  padding: 11px 13px;
  border-left: 3px solid var(--navy-100);
  background: var(--navy-050);
  border-radius: 0 3px 3px 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-700);
}

.result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.result-meta { font-family: var(--mono); font-size: 11px; color: var(--ink-400); }

/* ============ Attention ============ */

.attention-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.attention-fig { margin: 0; }

.attention-fig img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 3px;
  background: #000;
}

.attention-fig figcaption { margin-top: 6px; font-size: 11.5px; color: var(--ink-500); }

.attention-note { margin: 12px 0 0; font-size: 12px; line-height: 1.5; color: var(--ink-500); }

/* ============ Validation stats ============ */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
}

.stat-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-400);
}

.stat-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--navy-900);
  font-variant-numeric: tabular-nums;
}

.stat-ci { font-family: var(--mono); font-size: 11px; color: var(--ink-400); }

.stats-note { margin: 14px 0 0; font-size: 12px; line-height: 1.5; color: var(--ink-500); }

/* ============ Reference table ============ */

.reference { width: 100%; border-collapse: collapse; }

.reference th {
  width: 290px;
  padding: 8px 16px 8px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-800);
  text-align: left;
  vertical-align: top;
}

.reference td {
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--ink-500);
}

.reference tr:last-child th, .reference tr:last-child td { border-bottom: none; }

/* ============ Colophon ============ */

.colophon { flex: none; background: var(--navy-900); color: rgba(255, 255, 255, .82); }

.colophon-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 17px;
  padding-bottom: 17px;
  font-size: 12.5px;
}

.colophon-note { color: rgba(255, 255, 255, .5); }

.print-header { display: none; }

/* ============ Validation report page ============ */

.report { max-width: 860px; padding-top: 28px; padding-bottom: 56px; }

.report h1 { font-size: 24px; color: var(--navy-900); letter-spacing: -0.016em; margin: 0 0 8px; }

.report h2 {
  margin: 34px 0 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 16px;
  color: var(--navy-800);
}

.report p, .report li { font-size: 14px; color: var(--ink-700); }

.report table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 13px;
}

.report th, .report td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.report th { background: var(--navy-050); color: var(--navy-800); font-weight: 600; }

.report pre {
  overflow-x: auto;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}

.report code { font-family: var(--mono); font-size: 12.5px; background: var(--navy-050); padding: 0 4px; border-radius: 2px; }
.report pre code { background: none; padding: 0; }

/* ============ Responsive ============ */

@media (max-width: 1200px) {
  /* Too narrow for three: the result moves under the two input columns. */
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .workspace .assessment-card { grid-column: span 2; }
}

@media (max-width: 900px) {
  .workspace, .workspace .assessment-card { grid-template-columns: minmax(0, 1fr); grid-column: auto; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .shell { padding: 0 16px; }
  .masthead-inner { min-height: 56px; }
  .masthead-meta { display: none; }
  .titlebar h1 { font-size: 20px; }
  .finding-value { font-size: 20px; }
  .rank-track { display: none; }
  .reference th { width: 46%; }
  .gauge-scale { flex-direction: column; gap: 2px; }
  .colophon-inner { flex-direction: column; align-items: flex-start; gap: 3px; }
}

/* ============ Application shell ============ */

.app-nav { display: flex; align-items: center; gap: 4px; }

.app-nav a {
  padding: 7px 12px;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-700);
  text-decoration: none;
}

.app-nav a:hover { background: var(--navy-050); color: var(--navy-800); }
.app-nav a.is-active { background: var(--navy-050); color: var(--navy-800); box-shadow: inset 0 -2px 0 var(--amber-500); }

.user-box { display: flex; align-items: center; gap: 12px; }

.user-name { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.user-name strong { font-size: 12.5px; font-weight: 600; color: var(--ink-900); }
.user-name span { font-size: 11px; color: var(--ink-400); text-transform: capitalize; }

.masthead-inner.app { flex-wrap: wrap; }

.hidden-until-auth { display: none; }

/* ============ Login ============ */

/* Each screen fills the window, so the footer sits at the bottom of short
   pages instead of partway up it, and the sign in card is centred. */
#screen-login, #screen-password, #screen-app {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#view { flex: 1 0 auto; display: flex; flex-direction: column; }
#view > main { flex: 1 0 auto; }

.login-shell {
  flex: 1 0 auto;
  display: grid;
  place-items: center;
  padding: 48px 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.login-card .card-body { padding: 24px; }

.login-identity {
  display: flex;
  align-items: stretch;
  gap: 13px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 600;
  color: var(--navy-900);
}

.login-card .lead { margin: 0 0 18px; font-size: 13px; color: var(--ink-500); }

#login-google-button { display: flex; justify-content: center; min-height: 44px; }

.login-note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-500);
  text-align: center;
}

.login-or {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  text-align: center;
}

.login-foot {
  margin: 16px 0 0;
  font-size: 11.5px;
  color: var(--ink-400);
  text-align: center;
}

/* ============ Forms ============ */

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }

.field label, .field .label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-700);
}

.field .optional { font-weight: 400; color: var(--ink-400); }

.input, .field input[type="text"], .field input[type="password"], .field input[type="number"],
.field select, .field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  font: inherit;
  font-size: 13.5px;
  color: var(--ink-900);
}

.field textarea { min-height: 64px; resize: vertical; }

.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--navy-100);
  border-color: var(--navy-500);
}

.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red-700); }

.field-hint { font-size: 11.5px; color: var(--ink-400); }
.field-hint.is-known { color: var(--green-700); }
.field-error { font-size: 11.5px; color: var(--red-700); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.segmented { display: flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }

.segmented label {
  flex: 1;
  position: relative;
  cursor: pointer;
}

.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }

.segmented span {
  display: block;
  padding: 7px 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-700);
  border-left: 1px solid var(--line);
}

.segmented label:first-child span { border-left: none; }
.segmented input:checked + span { background: var(--navy-700); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--amber-500); outline-offset: -2px; }

/* ============ Buttons ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  color: var(--navy-800);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { border-color: var(--navy-500); background: var(--navy-050); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--navy-700); outline-offset: 2px; }

.btn-primary { background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-800); border-color: var(--navy-800); }

.btn-confirm { background: var(--green-500); border-color: var(--green-500); color: #fff; }
.btn-confirm:hover:not(:disabled) { background: var(--green-700); border-color: var(--green-700); }

.btn-danger { color: var(--red-700); }
.btn-danger:hover:not(:disabled) { border-color: var(--red-700); background: var(--red-050); }

.btn-small { padding: 4px 9px; font-size: 11.5px; }
.btn-block { width: 100%; }

/* ============ Pills ============ */

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.pill-refer      { background: var(--amber-050); color: var(--amber-800); border-color: #f1d9b9; }
.pill-routine    { background: var(--green-050); color: var(--green-700); border-color: var(--green-100); }
.pill-unreviewed { background: var(--canvas); color: var(--ink-500); border-color: var(--line); }
.pill-confirmed  { background: var(--green-050); color: var(--green-700); border-color: var(--green-100); }
.pill-corrected  { background: var(--amber-050); color: var(--amber-800); border-color: #f1d9b9; }
.pill-other      { background: var(--navy-050); color: var(--navy-800); border-color: var(--navy-100); }
.pill-active     { background: var(--green-050); color: var(--green-700); border-color: var(--green-100); }
.pill-candidate  { background: var(--amber-050); color: var(--amber-800); border-color: #f1d9b9; }
.pill-retired, .pill-rejected, .pill-inactive { background: var(--canvas); color: var(--ink-500); border-color: var(--line); }
.pill-running    { background: var(--navy-050); color: var(--navy-800); border-color: var(--navy-100); }
.pill-failed     { background: var(--red-050); color: var(--red-700); border-color: #edc9c5; }
.pill-succeeded  { background: var(--green-050); color: var(--green-700); border-color: var(--green-100); }

/* ============ Review ============ */

.review-intro { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-500); }

.review-or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-400);
}

.review-or::before, .review-or::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }

.review-options {
  border: 1px solid var(--line);
  border-radius: 3px;
  max-height: 330px;
  overflow-y: auto;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  font-size: 13px;
}

.option-row:last-child { border-bottom: none; }
.option-row:hover { background: var(--navy-050); }
.option-row.is-selected { background: var(--navy-050); }
.option-row input { accent-color: var(--navy-700); margin: 0; }
.option-name { flex: 1; color: var(--ink-900); }
.option-prob { font-family: var(--mono); font-size: 11.5px; color: var(--ink-400); }

.option-tag {
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--navy-700);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.option-other { flex-wrap: wrap; }
.option-other .input { flex-basis: 100%; margin-top: 7px; }
.option-other:not(.is-selected) .input { background: var(--canvas); }

.review-actions { display: flex; gap: 10px; margin-top: 12px; }

.review-done {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green-500);
  border-radius: 3px;
  background: var(--green-050);
}

.review-done.is-disagreement { border-left-color: var(--amber-500); background: var(--amber-050); }

.review-done p { margin: 0; font-size: 13px; color: var(--ink-700); }
.review-done .verdict { font-size: 15px; font-weight: 600; color: var(--ink-900); margin-bottom: 2px; }
.review-done .meta { font-size: 11.5px; color: var(--ink-500); margin-top: 4px; }

.review-history { margin: 12px 0 0; padding: 0; list-style: none; }

.review-history li {
  padding: 6px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--ink-500);
}

/* ============ Tables ============ */

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

.data-table th {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--navy-050);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--navy-800);
  text-align: left;
  white-space: nowrap;
}

.data-table td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr.is-link { cursor: pointer; }
.data-table tbody tr.is-link:hover td { background: #f7fafc; }
.data-table .num { font-family: var(--mono); font-size: 12px; text-align: right; white-space: nowrap; }
.data-table th.num { font-family: var(--sans); font-size: 11px; }
.data-table .muted { color: var(--ink-400); }
.data-table .sub { display: block; font-size: 11.5px; color: var(--ink-400); }

.table-wrap { overflow-x: auto; }

/* Editing a value in place inside a table cell. */
.cell-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cell-edit .input { flex: 1 1 200px; min-width: 180px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar .field { margin: 0; min-width: 180px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--ink-500);
}

.empty { padding: 30px 8px; text-align: center; font-size: 13px; color: var(--ink-400); }

/* ============ Detail facts ============ */

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
.facts dt { color: var(--ink-500); }
.facts dd { margin: 0; color: var(--ink-900); font-weight: 500; }

.original-image {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 3px;
  background: #000;
}

/* ============ Tabs ============ */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }

.tabs button {
  padding: 9px 14px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-500);
  cursor: pointer;
}

.tabs button.is-active { color: var(--navy-800); border-bottom-color: var(--amber-500); }

/* ============ Admin and dashboard ============ */

.inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.inline-form .field { margin: 0; }
/* When a field is hidden, so the remaining ones keep their proportions. */
.inline-form.three-fields { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }

.log {
  max-height: 260px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #0f1a26;
  color: #cfe0ef;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.compare { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.compare th, .compare td { padding: 5px 8px; border-bottom: 1px solid var(--line-soft); text-align: right; }
.compare th:first-child, .compare td:first-child { text-align: left; color: var(--ink-500); }
.compare .better { color: var(--green-700); font-weight: 600; }
.compare .worse { color: var(--red-700); font-weight: 600; }

.gate { margin-top: 10px; font-size: 12.5px; }
.gate ul { margin: 4px 0 0; padding-left: 18px; color: var(--ink-700); }

.caution {
  margin: 0 0 16px;
  padding: 10px 13px;
  border-left: 3px solid var(--amber-500);
  background: var(--amber-050);
  border-radius: 0 3px 3px 0;
  font-size: 12.5px;
  color: var(--amber-800);
}

.list-plain { margin: 0; padding: 0; list-style: none; }
.list-plain li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.list-plain li:last-child { border-bottom: none; }
.list-plain .count { font-family: var(--mono); color: var(--navy-800); }

/* ============ Daily backtest ============ */

.head-actions { display: flex; align-items: center; gap: 10px; }
.bt-meta { margin: 0 0 16px; font-size: 13px; color: var(--ink-700); }
.bt-notes { margin: 8px 0 0; padding-left: 18px; font-size: 12px; line-height: 1.5; color: var(--ink-500); }
.bt-notes:empty { display: none; }
.subhead {
  margin: 26px 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-500);
}
.bt-chart { overflow-x: auto; }
.bt-chart svg { display: block; width: 100%; min-width: 620px; height: auto; margin-bottom: 12px; }
.bt-chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.bt-chart .axis-label { font-family: var(--mono); font-size: 11px; fill: var(--ink-400); }
.bt-chart .alert-line { stroke: var(--red-700); stroke-width: 1; stroke-dasharray: 4 4; opacity: .6; }
.bt-chart .line { fill: none; stroke-width: 2; }
.bt-chart .line-agreement { stroke: var(--navy-700); }
.bt-chart .line-sensitivity { stroke: var(--amber-600); }
.bt-chart .dot-agreement { fill: var(--navy-700); }
.bt-chart .dot-sensitivity { fill: var(--amber-600); }
.bt-legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 0 0 8px; font-size: 12px; color: var(--ink-500); }
.bt-legend span::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 2px;
  margin-right: 6px;
  vertical-align: middle;
  background: currentColor;
}
.bt-legend .key-agreement { color: var(--navy-700); }
.bt-legend .key-sensitivity { color: var(--amber-600); }
.bt-legend .key-alert { color: var(--red-700); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ============ Camera capture ============ */

.source-toggle { margin-bottom: 14px; }

.camera-stage {
  position: relative;
  border-radius: 3px;
  background: #000;
  overflow: hidden;
  aspect-ratio: 4 / 3;
}

.camera-stage video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.camera-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 20px;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: #dbe6f0;
  background: rgba(15, 26, 38, 0.82);
}

.camera-message.is-error { color: #ffd4cf; }

.camera-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }

kbd {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--paper);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-700);
}

/* ============ Destructive actions ============ */

.btn-danger-solid { background: var(--red-700); border-color: var(--red-700); color: #fff; }
.btn-danger-solid:hover:not(:disabled) { background: #861f18; border-color: #861f18; }

.textbtn-danger { margin-top: 16px; color: var(--red-700); border-bottom-color: #edc9c5; }
.textbtn-danger:hover { color: #861f18; border-bottom-color: var(--red-700); }

.danger-form {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #edc9c5;
  border-left: 3px solid var(--red-700);
  border-radius: 3px;
  background: var(--red-050);
}

.danger-form p { margin: 0 0 12px; font-size: 12.5px; color: var(--red-700); }

.card-danger { border-color: #edc9c5; }
.card-danger .card-head { border-bottom-color: #f3dcd9; }
.card-danger .card-head h2 { color: var(--red-700); }

.danger-lead { margin: 0 0 10px; font-size: 13.5px; color: var(--ink-900); }
.danger-list { margin: 0 0 16px; padding-left: 18px; font-size: 12.5px; color: var(--ink-700); }
.danger-list li { margin-bottom: 3px; }

/* ============ Toast ============ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 16px;
  border-radius: 3px;
  background: var(--navy-900);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 6px 24px rgba(17, 44, 71, .25);
  z-index: 50;
}

.toast.is-error { background: var(--red-700); }

@media (max-width: 900px) {
  .inline-form { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 620px) {
  .app-nav { order: 3; width: 100%; overflow-x: auto; }
  .user-name { display: none; }
  .field-row, .inline-form { grid-template-columns: minmax(0, 1fr); }
  .data-table th, .data-table td { padding: 8px; }
}

/* ============ Print ============ */

@media print {
  @page { margin: 14mm; }

  body { background: #fff; font-size: 12px; }
  .no-print, .masthead, .titlebar, .colophon { display: none !important; }

  .print-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--navy-700);
    font-size: 12px;
    color: var(--ink-700);
  }

  .print-header strong { font-size: 14px; color: var(--navy-900); }

  .shell { max-width: none; padding: 0; }

  /* Lead with the decision: the assessment prints first, the attention maps
     after it, and the whole result fits on one sheet. */
  .workspace { display: flex; flex-direction: column; padding: 0; }
  .assessment-card { order: -1; }
  .column { display: block; order: 1; }

  .card { border: none; margin-bottom: 6px; }
  .card-head { padding: 4px 0; }
  .card-body { padding: 6px 0; }

  .referral { padding: 9px 12px; }
  .referral-value { font-size: 16px; }
  .referral-explain { margin-top: 6px; }
  .gauge { margin-top: 8px; }
  .finding { margin-top: 10px; }
  .finding-value { font-size: 17px; }
  .finding-desc { margin: 2px 0 6px; }
  .group-line { margin-top: 8px; padding: 5px 9px; }
  .section-sep { margin-top: 10px; padding-top: 8px; }
  .ranking td { padding: 2px 0; font-size: 11.5px; }
  .advisory { margin-top: 8px; padding: 7px 10px; font-size: 11px; }

  #attention { page-break-inside: avoid; }
  .attention-grid { grid-template-columns: 1fr 1fr; max-width: 280px; gap: 10px; }
  .attention-fig figcaption { font-size: 10px; margin-top: 3px; }
  .attention-note { font-size: 10px; margin-top: 6px; }

  .referral, .notice-warn, .advisory, .finding-note,
  .gauge-fill, .gauge-mark, .scorebar-fill, .rank-track span, .referral-icon {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
