:root {
  color-scheme: light;
  --nav: #07182c;
  --nav-mid: #0b3d6e;
  --nav-ink: #ffffff;
  --nav-muted: #b7c9db;
  --accent: #1a5fa8;
  --accent-soft: #e7f0f8;
  --bg: #e8eef5;
  --card: #ffffff;
  --ink: #12161c;
  --muted: #5c6770;
  --line: #d5dde5;
  --ok: #1f6b4a;
  --danger: #c0392b;
  --focus: #1a5fa8;
  --scroll: #7eb6dc;
  --scroll-track: #e7f1f8;
  --shadow: 0 18px 48px #03101f14;
  --radius: 12px;
  --font-ui: "Segoe UI", "Calibri", system-ui, sans-serif;
  --font-brand: Cambria, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll) var(--scroll-track);
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: var(--scroll-track);
}

*::-webkit-scrollbar-thumb {
  background: var(--scroll);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font: 15px/1.45 var(--font-ui);
  color: var(--ink);
  background: var(--bg);
}

.app-stage {
  display: none;
}

.cabinet-page .app-stage {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 42% at 88% -8%, #1a5fa828 0%, transparent 58%),
    radial-gradient(circle at 12% 0%, #0b3d6e14 0 18%, transparent 46%),
    linear-gradient(180deg, #f4f7fb 0%, #e8eef5 100%);
}

.cabinet-page .app-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(#0b3d6e0a 1px, transparent 1px),
    linear-gradient(90deg, #0b3d6e0a 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at 70% 0%, #000 0 36%, transparent 78%);
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.nav {
  display: flex;
  flex-direction: column;
  width: 248px;
  height: 100%;
  min-height: 0;
  background:
    radial-gradient(ellipse 120% 50% at 50% -10%, #1a5fa866 0%, transparent 56%),
    linear-gradient(180deg, #0b3d6e 0%, #07182c 100%);
  color: var(--nav-ink);
  padding: 24px 0 16px;
  overflow: hidden;
  transition: width 0.2s ease;
}

.app.is-nav-collapsed .nav { width: 80px; }

.brand {
  display: block;
  padding: 4px 20px 24px;
  text-align: center;
  border-bottom: 1px solid #ffffff1a;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 148px;
  height: 148px;
  margin: 0 auto;
  padding: 5px;
  border-radius: 50%;
  background: conic-gradient(from 200deg, #0b3d6e, #7eb6dc, #1a5fa8, #0b3d6e);
  box-shadow: 0 12px 28px #03101f55;
}

.brand img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #fff;
  border: 4px solid #fff;
  border-radius: 50%;
}

.brand:hover .brand-mark { box-shadow: 0 0 0 3px #7eb6dc88, 0 12px 28px #03101f55; }

.brand-name {
  margin: 14px 0 0;
  font-family: var(--font-brand);
  font-size: 23px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.brand-tag {
  margin: 4px 0 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nav-muted);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 10px;
  padding: 11px 12px;
  color: var(--nav-muted);
  text-decoration: none;
  border-radius: 10px;
  border-left: 0;
}

.nav-link svg,
.tab svg,
.page-title svg,
.btn-icon,
.fact-ico,
.drop-ico,
.search svg,
.field-input svg,
.empty-state svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.nav-link.active,
.nav-link:hover {
  color: var(--nav-ink);
  background: #ffffff18;
}

.nav-link.active {
  background: #ffffff22;
  box-shadow: inset 0 0 0 1px #ffffff2e;
}

nav { flex: 1; padding-top: 12px; }

.nav-collapse,
.nav-logout {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 24px);
  margin: 8px 12px 0;
  padding: 10px 12px;
  border: 1px solid #ffffff28;
  border-radius: 10px;
  background: #ffffff10;
  color: #fff;
  font: 600 13px/1.2 inherit;
  cursor: pointer;
  text-decoration: none;
}

.nav-collapse svg,
.nav-logout svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  transition: transform 0.2s ease;
}

.nav-collapse:hover,
.nav-logout:hover { background: #ffffff1c; }

.app.is-nav-collapsed .brand { padding: 4px 8px 16px; }
.app.is-nav-collapsed .brand-mark { width: 48px; height: 48px; padding: 3px; }
.app.is-nav-collapsed .brand-copy,
.app.is-nav-collapsed .nav-link span,
.app.is-nav-collapsed .nav-collapse-label,
.app.is-nav-collapsed .nav-logout-label { display: none; }
.app.is-nav-collapsed .nav-link {
  justify-content: center;
  margin: 4px 12px;
  padding: 12px 0;
}
.app.is-nav-collapsed .nav-collapse,
.app.is-nav-collapsed .nav-logout {
  width: 48px;
  margin-left: auto;
  margin-right: auto;
  justify-content: center;
  padding: 10px 0;
}
.app.is-nav-collapsed .nav-collapse svg { transform: rotate(180deg); }

.nav-logout { margin-top: auto; }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: auto;
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 0 0 auto;
  gap: 20px;
  padding: 20px 28px 18px;
  border-bottom: 1px solid #ffffffa8;
  background: #fffffff2;
  backdrop-filter: blur(10px);
}

.dash-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.dash {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 196px;
  min-height: 70px;
  padding: 8px 16px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff 0%, #f4f8fb 100%);
  box-shadow: 0 1px 0 #0b3d6e0d;
}

.dash-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.dash-ico svg {
  width: 18px;
  height: 18px;
}

.dash-value {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 24px;
  line-height: 1.1;
  color: var(--nav-mid);
  font-variant-numeric: tabular-nums;
}

.dash-label {
  margin: 3px 0 0;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.dash-hint {
  margin: 2px 0 0;
  font-size: 10px;
  color: #8a96a3;
}

.dash.is-live {
  border-color: #9bb8d6;
  background: linear-gradient(180deg, #f7fbff 0%, #eaf2f9 100%);
}

.dash.is-live .dash-ico {
  background: var(--accent);
  color: #fff;
}

.dash.is-live .dash-value { color: var(--accent); }

.dash.report-dash {
  appearance: none;
  margin: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: #fff;
  min-width: 196px;
  align-self: stretch;
  border: 1px solid #1a5fa8;
  background: #1a5fa8;
  box-shadow: 0 8px 18px #0b3d6e2e;
}

.dash.report-dash:hover,
.dash.report-dash:focus,
.dash.report-dash:active {
  background: #1a5fa8;
  border-color: #1a5fa8;
  color: #fff;
}

.dash.report-dash .dash-ico {
  background: #ffffff22;
  color: #fff;
}

.dash.report-dash .dash-value,
.dash.report-dash .dash-label,
.dash.report-dash .dash-hint {
  color: #fff;
}

.dash.report-dash .dash-label,
.dash.report-dash .dash-hint {
  opacity: 0.82;
}

.report-spin {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff55;
  border-top-color: #fff;
  border-radius: 50%;
  animation: report-spin 0.7s linear infinite;
}

.dash.report-dash.is-busy {
  cursor: wait;
  opacity: 1;
}

.dash.report-dash.is-busy .report-ico { display: none; }
.dash.report-dash.is-busy .report-spin { display: block; }

.dash.report-dash:disabled:not(.is-busy) {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

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

.masthead h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: var(--font-brand);
  font-size: 28px;
  font-weight: 400;
}

.masthead h1 svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.mast-sub,
.muted,
.lead,
.field span,
.card-head .muted {
  color: var(--muted);
}

.mast-sub { margin: 6px 0 0; font-size: 13px; }

.page {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 20px 28px 28px;
  animation: page-in 0.35s ease both;
}

.hidden { display: none !important; }

#page-visit {
  display: flex;
  flex-direction: column;
}

#page-visit .split {
  flex: 1 1 auto;
  min-height: 0;
  align-items: stretch;
}

#page-visit .stack {
  min-height: 0;
  overflow: auto;
}

#page-visit .split > .stack:first-child {
  align-self: start;
  height: auto;
  overflow: visible;
}

#page-visit .split > .stack:first-child .card {
  padding: 14px 16px;
}

#page-visit .split > .stack:first-child .field {
  margin-bottom: 10px;
}

#page-visit .split > .stack:first-child .dropzone {
  padding: 14px 12px;
}

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

.stack,
.field-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid #d7e3ee;
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nav-mid);
}

h2 svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
}

.field-input,
.search,
.login-input {
  position: relative;
  display: block;
}

.field-input svg,
.search svg {
  position: absolute;
  top: 50%;
  left: 12px;
  color: var(--accent);
  transform: translateY(-50%);
  pointer-events: none;
}

.field input,
select,
textarea {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  width: 100%;
}

.field-input input,
.field-input select,
.search input,
.login-input input {
  padding: 10px 12px 10px 42px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 12px;
}

.tab {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 0;
  min-height: 42px;
  padding: 8px;
  font: inherit;
  cursor: pointer;
  color: var(--muted);
}

.tab + .tab { border-left: 1px solid var(--line); }
.tab.active { background: var(--accent); color: #fff; }

.dropzone {
  position: relative;
  display: block;
  padding: 22px 14px;
  border: 1px dashed #b7c9db;
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  background: #f7fafc;
}

.drop-ico {
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 8px;
  color: var(--accent);
}

.dropzone.dragover,
.dropzone:hover { border-color: var(--accent); background: #eef5fb; }
.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-title { display: block; font-weight: 600; }
#file-name { display: block; margin-top: 8px; color: var(--muted); }
#file-name.is-set { color: var(--nav-mid); font-weight: 600; }

.recorder {
  padding: 16px 14px;
  border: 1px dashed #b7c9db;
  border-radius: 10px;
  background: #f7f9fb;
}

.recorder-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.recorder-actions .btn {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 6px;
  white-space: normal;
  line-height: 1.15;
}

.recorder-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.recorder-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
}

#mic-pane.is-live .recorder {
  border-color: var(--accent);
  background: #eef5fb;
}

#mic-pane.is-live .recorder-status { color: var(--nav-mid); font-weight: 600; }

#mic-pane.is-live .recorder-status::before {
  background: var(--accent);
  animation: pulse 0.9s ease-in-out infinite;
}

#mic-pane.is-ready .recorder-status::before { background: var(--ok); }

#mic-pane.is-paused .recorder {
  border-color: #d69e2e;
  background: #fffaf0;
}

#mic-pane.is-paused .recorder-status {
  color: #805b10;
  font-weight: 600;
}

#mic-pane.is-paused .recorder-status::before {
  background: #d69e2e;
}

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

.search { min-width: min(260px, 100%); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: 600 13px/1.2 inherit;
  cursor: pointer;
  text-decoration: none;
}

.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #155392; }
.btn.secondary { background: var(--ink); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost {
  background: #fff;
  color: var(--nav-mid);
  border-color: var(--line);
}
#run { width: 100%; min-height: 44px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.run-track {
  margin-top: 14px;
  padding: 12px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fafc;
}

.run-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: var(--nav-mid);
  font-size: 13px;
  font-weight: 600;
}

.run-status svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

#progress {
  margin: 0;
  color: inherit;
}

.btn:focus-visible,
.tab:focus-visible,
.nav-link:focus-visible,
.dash.report-dash:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

input,
select,
textarea { outline: none; }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #1a5fa81f;
}

.busy-bar {
  height: 3px;
  margin: 0 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce6ef;
}

.busy-bar::after {
  content: "";
  display: block;
  width: 40%;
  height: 100%;
  background: var(--accent);
  animation: slide 1.1s linear infinite;
}

@keyframes slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0;
  padding: 0;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding: 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  display: block;
  width: 22px;
  height: 22px;
  margin: 0 auto 6px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  text-align: center;
  font-size: 11px;
  line-height: 20px;
}

.steps li.active { color: var(--ink); font-weight: 600; }
.steps li.active::before {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
  animation: pulse 0.9s ease-in-out infinite;
}
.steps li.done { color: var(--ok); }
.steps li.done::before {
  border-color: var(--ok);
  background: var(--ok);
  color: #fff;
}

@keyframes pulse {
  50% { box-shadow: 0 0 0 4px #1a5fa822; }
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  min-height: 0;
  flex: 1 1 auto;
}

#page-visit .result-grid > .card {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.card-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #f7fafc;
}

.view-tab {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 12px/1 inherit;
  cursor: pointer;
}

.view-tab + .view-tab { border-left: 1px solid var(--line); }
.view-tab svg { width: 14px; height: 14px; }
.view-tab.active { background: var(--accent); color: #fff; }

.summary-list {
  display: grid;
  gap: 12px;
}

.summary-row {
  padding-bottom: 10px;
  border-bottom: 1px solid #eef2f6;
}

.summary-row:last-child { border-bottom: 0; padding-bottom: 0; }

.summary-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.summary-value {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
}

.protocol-document {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.protocol-prose {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid #c5d6e8;
  border-radius: 10px;
  background: #fff;
}

.protocol-prose-title,
.protocol-prose h3 {
  margin: 0;
  color: var(--nav-mid);
  font-size: 13px;
  font-weight: 700;
}

.protocol-prose p {
  margin: 0;
  line-height: 1.5;
  color: var(--ink);
}

.protocol-prose textarea {
  min-height: 76px;
  width: 100%;
  resize: vertical;
  line-height: 1.45;
  padding: 10px 12px;
  overflow-y: hidden;
}

.protocol-prose.is-inline textarea {
  min-height: 56px;
}

.protocol-prose.is-inline {
  padding: 2px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
  align-items: start;
  gap: 8px;
}

.protocol-prose.is-inline .protocol-prose-title {
  padding-top: 10px;
}

.protocol-list {
  display: grid;
  gap: 14px;
}

.protocol-section {
  padding: 12px;
  border: 1px solid #dce6ef;
  border-radius: 10px;
  background: #f8fafc;
}

.protocol-section h3 {
  margin: 0 0 10px;
  color: var(--nav-mid);
  font-size: 13px;
}

.protocol-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-top: 8px;
}

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

.protocol-item select {
  align-self: start;
}

.protocol-evidence {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.protocol-evidence summary { cursor: pointer; }

.protocol-warning {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-left: 3px solid #d69e2e;
  background: #fff8e8;
  color: #6f4e0a;
  font-size: 12px;
}

.coverage-strip {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fafc;
}

.coverage-meta {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
}

.coverage-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.coverage-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.3;
}

.coverage-chip.is-on {
  background: #e6f4ea;
  color: #1e6b3a;
}

.coverage-chip.is-off {
  background: #f1f3f5;
  color: #6b7280;
}

.source-pill {
  display: inline-flex;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e8eef6;
  color: var(--nav-mid);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.vitals-editor {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.vitals-editor label {
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.vitals-editor input {
  width: 100%;
  min-width: 0;
  padding: 8px 6px;
  box-sizing: border-box;
}

.protocol-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.card-head h2 svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.history-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.history-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.count-pill {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--nav-mid);
  background: #f4f8fb;
}

#page-history .toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  width: 100%;
}

#page-history .search { min-width: 0; }

.box {
  margin: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  font: inherit;
}

.transcript { white-space: normal; }

.box.empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state {
  max-width: 36ch;
  margin: 20px auto;
  padding: 8px 8px 4px;
  text-align: center;
}

.empty-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  padding: 4px;
  border-radius: 50%;
  background: conic-gradient(from 200deg, #0b3d6e, #7eb6dc, #1a5fa8, #0b3d6e);
  box-shadow: 0 8px 18px #0b3d6e26;
}

.empty-mark svg,
.empty-state svg {
  width: 22px;
  height: 22px;
  margin: 0;
  color: var(--accent);
}

.empty-mark svg {
  width: 56px;
  height: 56px;
  padding: 16px;
  border-radius: 50%;
  background: #fff;
}

.empty-title {
  margin: 0;
  font-weight: 600;
  color: var(--nav-mid);
}

.empty-hint {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.transcript-line {
  display: grid;
  grid-template-columns: minmax(72px, auto) 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #eef2f6;
  line-height: 1.4;
}

.transcript-line:last-child { border-bottom: 0; }

.speaker-label {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.voice-color-1 .speaker-label { color: #0b69a3; }
.voice-color-2 .speaker-label { color: #8a4b08; }
.voice-color-3 .speaker-label { color: #6b3fa0; }
.voice-color-4 .speaker-label { color: #16734a; }
.voice-color-1 .speaker-dot { background-color: #0b69a3; }
.voice-color-2 .speaker-dot { background-color: #8a4b08; }
.voice-color-3 .speaker-dot { background-color: #6b3fa0; }
.voice-color-4 .speaker-dot { background-color: #16734a; }

.speaker-editor {
  flex-shrink: 0;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.visit-audio {
  flex-shrink: 0;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.audio-title {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--nav-mid);
}

.visit-audio audio {
  display: block;
  width: 100%;
  height: 34px;
}

.history-audio audio {
  display: block;
  width: 190px;
  height: 30px;
}

.speaker-editor-title {
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--nav-mid);
}

.speaker-row {
  display: grid;
  grid-template-columns: 8px minmax(100px, 1fr) minmax(150px, 1.3fr);
  gap: 7px;
  align-items: center;
  margin-bottom: 6px;
}

.speaker-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.speaker-row input,
.speaker-row select {
  min-width: 0;
  padding: 6px 7px;
  font-size: 12px;
}

#save-speakers {
  width: 100%;
  margin-top: 2px;
}

.banner {
  padding: 10px 12px;
  border: 1px solid #e2b6b6;
  border-radius: 10px;
  background: #fff6f6;
  color: var(--danger);
}

.banner.ok {
  border-color: #b7d7c7;
  background: #f3faf6;
  color: var(--ok);
}

.facts-card .box {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.fact {
  padding: 10px 0 8px;
  border-top: 1px solid #eef2f6;
}

.fact:first-child { border-top: 0; padding-top: 0; }

.fact-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.fact-ico { color: var(--accent); }

.fact textarea {
  min-height: 36px;
  resize: vertical;
  padding: 6px 8px;
  line-height: 1.3;
}

.fact p { margin: 0; }

.quote {
  margin: 4px 0 0;
  padding-left: 8px;
  border-left: 2px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.fact-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  flex-shrink: 0;
}

.fact-actions .btn { width: 100%; }

.skeleton {
  display: grid;
  gap: 10px;
}

.skeleton i {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: #e7eef4;
  animation: pulse 1s ease-in-out infinite;
}

.lead { margin: 0 0 16px; max-width: 72ch; }

.lead code,
.field-card code {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--nav-mid);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.field-card .top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.field-card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 16px;
  font-family: var(--font-brand);
  font-weight: 400;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.type-pill,
.status-pill {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.status-pill.is-done {
  border-color: #b7d7c7;
  background: #f3faf6;
  color: var(--ok);
}

.status-pill.is-run {
  border-color: #9bb8d6;
  background: #eef5fb;
  color: var(--accent);
}

.status-pill.is-partial {
  border-color: var(--line);
  background: #f7f9fb;
  color: var(--muted);
}

.schema {
  margin: 0;
  max-height: 360px;
  overflow: auto;
  font: 12px/1.45 ui-monospace, Consolas, monospace;
  white-space: pre-wrap;
}

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

.table-wrap th,
.table-wrap td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.table-wrap th {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.table-wrap a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.table-wrap a:hover { text-decoration: underline; }

.table-wrap .hist-del {
  padding: 4px 10px;
  font-size: 12px;
}

.table-wrap th.hist-actions,
.table-wrap td.hist-actions {
  text-align: right;
  width: 1%;
  white-space: nowrap;
}

.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.inline select { width: auto; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #07182ccc;
}

.overlay-card {
  width: min(760px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  text-align: center;
  padding: 0 0 28px;
  overflow: hidden;
  box-shadow: 0 28px 80px #03101f73;
}

.overlay-card img {
  display: block;
  width: 100%;
  height: 280px;
  object-fit: cover;
}

.overlay-card h2 {
  margin: 22px 16px 8px;
  font-family: var(--font-brand);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--nav-mid);
}

.overlay-card p {
  margin: 0 28px 20px;
  color: var(--muted);
}

.overlay-card .btn { width: auto; min-width: 180px; }

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 1100px) {
  .split,
  .result-grid,
  .field-grid { grid-template-columns: 1fr; }
  .masthead { flex-wrap: wrap; }

  #page-visit,
  #page-visit .split,
  #page-visit .stack,
  #page-visit .result-grid,
  #page-visit .result-grid > .card {
    flex: none;
    min-height: auto;
    height: auto;
    overflow: visible;
  }

  #page-visit .split { align-items: start; }
  #page-visit .box { flex: none; min-height: 148px; }

  .card,
  .stack,
  .split,
  .result-grid { min-width: 0; max-width: 100%; }
}

body.login-page {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  overflow: auto;
  background: #07182c;
}

.login-stage {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, #1a5fa866 0%, transparent 58%),
    radial-gradient(circle at 50% 42%, #123d6888 0 18%, transparent 52%),
    linear-gradient(180deg, #0b3d6e 0%, #07182c 46%, #061322 100%);
}

.login-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(#ffffff0f 1px, transparent 1px),
    linear-gradient(90deg, #ffffff0f 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 40%, #000 0 28%, transparent 72%);
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(460px, calc(100% - 32px));
  margin: 36px 0;
  padding: 40px 36px 32px;
  background: #fff;
  border: 1px solid #d7e3ee;
  border-radius: 16px;
  text-align: center;
  box-shadow:
    0 0 0 1px #ffffff0f,
    0 28px 80px #03101f73;
  animation: login-rise 0.55s ease both;
}

.login-mark {
  width: 188px;
  height: 188px;
  margin: 0 auto 18px;
  padding: 7px;
  border-radius: 50%;
  background:
    conic-gradient(from 200deg, #0b3d6e, #7eb6dc, #1a5fa8, #0b3d6e);
  box-shadow: 0 16px 36px #0b3d6e40;
}

.login-mark img,
.login-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: 5px solid #fff;
  background: #fff;
}

.login-card h1 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 40px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--nav-mid);
}

.login-tag {
  margin: 8px 0 26px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.login-card .field { text-align: left; }

.login-input svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--accent);
  transform: translateY(-50%);
  pointer-events: none;
}

.login-input input {
  padding: 10px 12px 10px 42px;
}

.login-card .btn,
.login-submit {
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  font-size: 15px;
}

.login-card .banner { margin-bottom: 16px; }

@keyframes login-rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .login-card,
  .page { animation: none; }
}

@media (max-width: 720px) {
  .login-card { padding: 28px 22px 24px; }
  .login-mark { width: 156px; height: 156px; }
  .login-card h1 { font-size: 34px; }

  html, body,
  .cabinet-page {
    height: 100%;
    overflow: hidden;
  }

  .app,
  .app.is-nav-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%;
    overflow: hidden;
  }

  .nav,
  .app.is-nav-collapsed .nav {
    width: auto;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-top, 0px));
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    padding: 0;
    text-align: left;
    border-bottom: 0;
  }

  .brand-mark,
  .app.is-nav-collapsed .brand-mark {
    width: 44px;
    height: 44px;
    padding: 3px;
    margin: 0;
    flex: 0 0 44px;
  }

  .brand-copy,
  .app.is-nav-collapsed .brand-copy { display: block; min-width: 0; }
  .brand-name { margin: 0; font-size: 18px; }
  .brand-tag { display: none; }

  .app.is-nav-collapsed .nav-link span { display: block; }

  nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 12;
    display: flex;
    flex: none;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    background: #07182c;
    box-shadow: 0 -12px 32px #03101f40;
  }

  .nav-link,
  .app.is-nav-collapsed .nav-link {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    margin: 0 4px;
    padding: 8px 4px;
    border-radius: 10px;
    font-size: 11px;
    text-align: center;
  }

  .nav-link span { line-height: 1.2; }
  .nav-collapse { display: none; }
  .nav-logout,
  .app.is-nav-collapsed .nav-logout {
    width: auto;
    margin: 0;
    padding: 10px 12px;
  }

  .main {
    height: auto;
    min-height: 0;
    overflow: auto;
    overflow-x: hidden;
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  .page {
    flex: none;
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  .masthead,
  .page { padding-left: 16px; padding-right: 16px; }

  .masthead { padding-top: 14px; padding-bottom: 14px; }
  .masthead h1 { font-size: 22px; }

  .dash-row {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .dash.report-dash {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .dash {
    min-width: 0;
    padding: 8px 10px 8px 6px;
  }

  .dash-value { font-size: 20px; }
  .dash-label { font-size: 10px; }

  .field-input input,
  .search input {
    padding: 10px 12px 10px 46px;
  }
  .history-head { align-items: stretch; }
  #page-history .toolbar,
  .toolbar { width: 100%; grid-template-columns: 1fr; }
  .search { min-width: 100%; }
  .inline { flex: 1; }
  .inline select { width: 100%; }
  .fact-actions { grid-template-columns: 1fr; }
  .protocol-item { grid-template-columns: 1fr; }
  .protocol-prose.is-inline { grid-template-columns: 1fr; }
  .protocol-item select,
  .protocol-evidence { grid-column: 1; }
  .vitals-editor { grid-template-columns: 1fr 1fr; }
  .speaker-row { grid-template-columns: 8px 1fr; }
  .speaker-row select { grid-column: 2; }

  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap th,
  .table-wrap td,
  .table-wrap tr { display: block; }

  .table-wrap thead { display: none; }

  .table-wrap tr {
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid #d7e3ee;
    border-radius: 12px;
    background: #f8fafc;
  }

  .table-wrap td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 0;
  }

  .table-wrap td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .table-wrap td.history-audio,
  .table-wrap td.hist-actions {
    display: block;
    width: auto;
    text-align: left;
    white-space: normal;
  }

  .table-wrap td.hist-actions { margin-top: 6px; }
  .table-wrap td.hist-actions::before { display: none; }
  .history-audio audio { width: 100%; }
  .overlay-card img { height: 180px; }
}
