:root {
  --bg: #f6f8f9;
  --panel: #ffffff;
  --card: #ffffff;
  --soft: #f7fafb;
  --text: #1f2933;
  --ink: #1f2933;
  --muted: #5b6770;
  --ink-soft: #5b6770;
  --line: #dce6e8;
  --accent: #0e7c7b;
  --accent-soft: #e6f4f4;
  --recording: #d64545;
  --success: #2e9e5b;
  --warning: #c98a1b;
  --blue: #0e7c7b;
  --blue-dark: #075f60;
  --green: #2e9e5b;
  --green-soft: #e8f6ee;
  --yellow-soft: #fff8e7;
  --shadow: 0 18px 50px rgba(16, 32, 51, .10);
  --radius: 22px;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(20px);
  border-right: 1px solid rgba(220, 230, 239, .95);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--blue), #10b981);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(36, 99, 235, .25);
}

.brand strong { display: block; font-size: 17px; }
.brand span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }

.side-nav {
  display: grid;
  gap: 8px;
}

.user-chip {
  display: grid;
  gap: 2px;
  padding: 12px 13px;
  border-radius: 14px;
  background: #f8fbff;
  border: 1px solid #e6edf4;
}

.user-chip b {
  font-size: 13px;
}

.user-chip span {
  color: var(--muted);
  font-size: 12px;
}

.logout-form {
  margin-top: 12px;
}

.side-nav-section,
.admin-nav summary {
  margin: 14px 12px 4px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 900;
}

.admin-nav { margin-top: 14px; }
.admin-nav summary { cursor: pointer; list-style: none; }
.admin-nav summary::-webkit-details-marker { display: none; }
.admin-nav summary::after { content: "＋"; float: right; }
.admin-nav[open] summary::after { content: "−"; }

.side-nav a,
.admin-nav a {
  display: block;
  padding: 12px 13px;
  border-radius: 14px;
  color: var(--muted);
  font-weight: 800;
}

.side-nav a.active,
.side-nav a:hover,
.admin-nav a.active,
.admin-nav a:hover {
  color: var(--blue-dark);
  background: #edf4ff;
}

.side-nav > a[href="/visit"] {
  text-align: center;
  margin: 8px 0;
  padding: 14px 12px;
  color: white;
  background: linear-gradient(135deg, var(--green), var(--blue));
  box-shadow: 0 14px 28px rgba(18, 130, 92, .18);
}

.side-nav > a[href="/visit"].active,
.side-nav > a[href="/visit"]:hover {
  color: white;
  background: linear-gradient(135deg, #0d9f6e, #1f62d5);
}

.main { padding: 28px; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -.045em;
}

.eyebrow {
  color: var(--blue);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 900;
  margin-bottom: 5px;
}

.top-actions, .button-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.button-row.wrap { flex-wrap: wrap; }

.btn {
  border: 0;
  border-radius: 13px;
  padding: 11px 15px;
  font-weight: 850;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.btn:hover { transform: translateY(-1px); }

.btn.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 12px 24px rgba(14, 124, 123, .18);
}

.btn.secondary {
  background: #e8eff7;
  color: var(--text);
}

.btn.ghost {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
}

.btn.danger {
  background: white;
  color: #a43b3b;
  border: 1px solid rgba(214, 69, 69, .45);
}

.btn.small {
  padding: 8px 11px;
  font-size: 13px;
}

.btn:disabled {
  opacity: .48;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.visit-layout {
  display: grid;
  grid-template-columns: minmax(430px, .9fr) minmax(520px, 1.1fr);
  gap: 22px;
}

.visit-topbar {
  margin-bottom: 14px;
}

.visit-workspace {
  display: grid;
  gap: 14px;
}

.visit-workspace .card {
  padding: 16px;
}

.recorder-card {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

.recorder-main {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.recorder-main h2 {
  margin: 0;
  font-size: 24px;
}

.recorder-main p {
  margin: 5px 0 0;
  color: var(--muted);
}

.record-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 12px 0;
}

.icon-btn {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
}

.record-start {
  background: linear-gradient(135deg, #f04444, #b91c1c);
  box-shadow: 0 12px 22px rgba(220, 38, 38, .22);
}

.record-stop {
  background: #e8eff7;
  color: var(--text);
}

.play-icon {
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 16px solid white;
  margin-left: 4px;
}

.stop-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #26364a;
}

.record-start.live {
  animation: pulse 1.35s infinite;
}

.compact-wave {
  height: 42px;
  margin: 8px 0 10px;
}

.compact-workflow {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 0;
}

.visit-grid {
  display: grid;
  grid-template-columns: minmax(340px, .92fr) minmax(420px, 1.08fr);
  gap: 14px;
}

.compact-form {
  gap: 10px;
  margin-bottom: 10px;
}

.inline-patient-form {
  margin: 10px 0 12px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fbfdff;
}

.inline-patient-form textarea {
  min-height: 70px;
}

.compact-summary {
  grid-template-columns: repeat(2, 1fr);
}

.compact-summary div {
  padding: 10px;
  border-radius: 13px;
}

.compact-transcript {
  min-height: 275px;
  max-height: 330px;
}

.transcript-actions {
  margin-top: 12px;
}

.visit-workspace .note-card {
  min-height: 0;
}

.compact-note {
  min-height: 210px;
  max-height: 290px;
}

.note-locked {
  opacity: .68;
}

.note-locked textarea {
  cursor: not-allowed;
}

.feedback-submit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.visit-workspace .feedback-text {
  min-height: 72px;
}

.left-stack, .right-stack {
  display: grid;
  gap: 22px;
  align-content: start;
}

.card {
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(220, 230, 239, .95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

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

.card h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -.025em;
}

.form-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.form-grid.two { grid-template-columns: 1fr 1.3fr; }
.form-grid.three { grid-template-columns: .8fr .8fr 1fr; }
.form-grid.no-margin { margin-bottom: 0; }

label span, .full-label span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
  font-weight: 700;
}

select, input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 14px;
  color: var(--text);
  outline: none;
}

select, input { padding: 11px 12px; }

textarea {
  padding: 13px;
  resize: vertical;
}

.locked-field {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 14px;
  color: var(--text);
  padding: 10px 12px;
}

.locked-field b,
.locked-field small {
  display: block;
}

.locked-field small {
  color: var(--muted);
  margin-top: 2px;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(220, 230, 239, .95);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-brand {
  margin-bottom: 22px;
}

.form-error {
  padding: 11px 12px;
  border-radius: 14px;
  background: #fee2e2;
  color: #991b1b;
  font-weight: 800;
  font-size: 13px;
}

.doctor-line {
  margin-bottom: 12px;
  padding: 13px;
  border-radius: 16px;
  background: #f8fbff;
  border: 1px solid #e6edf4;
}

.doctor-line span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.new-visit-panel {
  margin: 12px 0;
  padding: 14px;
  border-radius: 18px;
  background: #fbfdff;
  border: 1px solid var(--line);
}

.visit-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.visit-summary div {
  background: var(--soft);
  border: 1px solid #e6edf4;
  border-radius: 16px;
  padding: 12px;
}

.visit-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.visit-summary b { font-size: 13px; }

.context-line {
  margin-top: 12px;
  padding: 13px;
  border-radius: 16px;
  background: var(--yellow-soft);
  border: 1px solid #f2df9b;
  color: #4b3a05;
  font-size: 13px;
  line-height: 1.45;
  min-height: 44px;
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px;
  margin-bottom: 16px;
}

.mode {
  border: 0;
  background: transparent;
  padding: 11px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 850;
  cursor: pointer;
}

.mode.active {
  background: var(--panel);
  color: var(--blue-dark);
  box-shadow: 0 8px 20px rgba(16,32,51,.08);
}

.timer {
  padding: 9px 11px;
  border-radius: 12px;
  background: #edf4ff;
  color: var(--blue-dark);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.recorder {
  display: flex;
  align-items: center;
  gap: 18px;
}

.recorder h3 { margin: 0 0 5px; }

.recorder p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.record {
  width: 82px;
  height: 82px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #ff6868, #df2f37);
  box-shadow: 0 18px 34px rgba(229, 72, 77, .25), inset 0 0 0 8px rgba(255,255,255,.22);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.record span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
}

.record.live { animation: pulse 1.35s infinite; }

.wave {
  height: 72px;
  margin: 18px 0 14px;
  border-radius: 17px;
  background: linear-gradient(180deg, #fbfdff, #edf4ff);
  border: 1px solid #e6edf4;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.wave i {
  width: 7px;
  height: 15px;
  border-radius: 99px;
  background: linear-gradient(180deg, var(--blue), #10b981);
  opacity: .27;
}

.wave.live i {
  opacity: .9;
  animation: wave .9s ease-in-out infinite;
}

.wave i:nth-child(2n) { animation-delay: .1s; }
.wave i:nth-child(3n) { animation-delay: .2s; }
.wave i:nth-child(4n) { animation-delay: .3s; }

.workflow {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin-bottom: 14px;
}

.workflow span {
  background: #eef2f6;
  color: var(--muted);
  border-radius: 11px;
  padding: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.workflow span.done {
  color: #086546;
  background: var(--green-soft);
}

.workflow span.active {
  color: var(--blue-dark);
  background: #e4efff;
}

.status-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: 2px 0 10px;
}

.status-steps.wide {
  margin: 0;
}

.status-steps span {
  min-width: 0;
  padding: 7px 8px;
  border-radius: 10px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-align: center;
}

.status-steps span.done {
  background: var(--green-soft);
  color: #086546;
}

.status-steps span.active {
  background: #e4efff;
  color: var(--blue-dark);
}

.transcript-box {
  min-height: 250px;
  max-height: 380px;
  overflow: auto;
  border: 1px solid #e1e9f2;
  border-radius: 16px;
  background: var(--soft);
  padding: 14px;
  color: var(--muted);
  line-height: 1.55;
}

.transcript-line {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  padding: 10px;
  border-radius: 13px;
  background: white;
  border: 1px solid #e6edf4;
  margin-bottom: 8px;
  color: var(--text);
}

.transcript-line b {
  color: var(--blue-dark);
  font-size: 13px;
}

.status-pill {
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  color: var(--muted);
  background: #eef2f6;
}

.status-pill.ready {
  background: var(--green-soft);
  color: #086546;
}

.note-card { min-height: 580px; }

.note-editor {
  min-height: 430px;
  line-height: 1.55;
  font-size: 15px;
  background: #fbfdff;
  margin-bottom: 14px;
}

.safety-gate {
  margin: 0 0 14px;
  padding: 14px;
  border-radius: 18px;
  background: #fbfdff;
  border: 1px solid var(--line);
}

.safety-title {
  font-weight: 900;
  margin-bottom: 10px;
  color: var(--text);
}

.safety-checks.clean {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.safety-checks.clean label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--soft);
  border: 1px solid #e6edf4;
}

.safety-checks.clean input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin: 0;
}

.safety-checks.clean span {
  display: inline;
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.ai-checks {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.ai-check {
  padding: 12px;
  border-radius: 14px;
  background: #eef9f4;
  border: 1px solid #c4efdc;
}

.feedback-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.feedback {
  border: 1px solid var(--line);
  background: var(--soft);
  padding: 12px;
  border-radius: 14px;
  font-weight: 850;
  cursor: pointer;
}

.feedback.active {
  background: #e4efff;
  color: var(--blue-dark);
  border-color: #b8cdf7;
}

.feedback-card.is-disabled {
  opacity: .62;
}

.feedback-card.is-disabled .feedback,
.feedback-card.is-disabled textarea {
  cursor: not-allowed;
}

.feedback-text {
  min-height: 92px;
  margin-top: 12px;
}

.table {
  display: grid;
  gap: 8px;
}

.tr {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1fr 1fr 1fr 1fr;
  gap: 10px;
  align-items: center;
  padding: 13px;
  border-radius: 15px;
  background: var(--soft);
  border: 1px solid #e6edf4;
}

a.tr:hover {
  border-color: #b8cdf7;
  background: #edf4ff;
}

.tr small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.tr.th {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 900;
}

.tr em {
  font-style: normal;
  color: #086546;
  font-weight: 800;
}

.tr small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.table.compact .tr {
  grid-template-columns: 1.1fr 1fr .9fr 1.2fr 190px;
}

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

.template-sections {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.template-sections span {
  background: #edf4ff;
  color: var(--blue-dark);
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

.template-text {
  min-height: 220px;
  margin-bottom: 12px;
  line-height: 1.55;
}

.settings-layout, .report-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.full-label { display: block; margin-top: 12px; }

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

.settings-list, .success-list {
  display: grid;
  gap: 10px;
}

.settings-list label, .success-list label {
  padding: 12px;
  border-radius: 14px;
  background: var(--soft);
  border: 1px solid #e6edf4;
  display: flex;
  gap: 10px;
  align-items: center;
}

.export-preview {
  white-space: pre-wrap;
  background: #0f172a;
  color: #e5edf7;
  border-radius: 16px;
  padding: 18px;
  line-height: 1.55;
  min-height: 340px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.kpi b {
  display: block;
  font-size: 34px;
  letter-spacing: -.05em;
}

.doctor-admin-layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.admin-form {
  display: grid;
  gap: 12px;
}

.doctor-list {
  display: grid;
  gap: 8px;
}

.doctor-row {
  display: grid;
  grid-template-columns: 1.4fr .8fr 1fr 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 15px;
  background: var(--soft);
  border: 1px solid #e6edf4;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.patient-list {
  display: grid;
  gap: 8px;
}

.patient-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr .8fr .6fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 15px;
  background: var(--soft);
  border: 1px solid #e6edf4;
}

.patient-row:hover {
  border-color: #b8cdf7;
}

.patient-row small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.patient-head {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 900;
}

.empty-state {
  padding: 16px;
  border-radius: 15px;
  background: var(--soft);
  border: 1px solid #e6edf4;
  color: var(--muted);
}

.record-text {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.55;
  color: var(--text);
}

.note-view {
  min-height: 520px;
}

.doctor-row small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.doctor-row input + input {
  margin-top: 8px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.doctor-head {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 900;
}

.role-pill,
.doctor-status {
  display: inline-flex;
  width: fit-content;
  padding: 7px 9px;
  border-radius: 999px;
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
}

.role-pill {
  background: #edf4ff;
  color: var(--blue-dark);
}

.role-pill.admin {
  background: #f4edff;
  color: #5b21b6;
}

.doctor-status.active {
  background: var(--green-soft);
  color: #086546;
}

.doctor-status.disabled {
  background: #fee2e2;
  color: #991b1b;
}

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

.patient-row {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 15px;
  background: var(--soft);
  border: 1px solid #e6edf4;
}

.template-admin-layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.template-admin-layout .template-grid {
  grid-template-columns: 1fr;
}

.toast {
  position: fixed;
  left: 50%;
  top: 22px;
  background: #ecfbf3;
  color: #0b5f37;
  border: 1px solid #b8d9c8;
  border-radius: 14px;
  padding: 13px 18px;
  font-weight: 850;
  box-shadow: 0 18px 40px rgba(11, 95, 55, .18);
  opacity: 0;
  transform: translateX(-50%) translateY(-10px);
  pointer-events: none;
  transition: all .2s ease;
  z-index: 50;
}

.toast-action {
  border: 0;
  background: rgba(255,255,255,.16);
  color: inherit;
  border-radius: 8px;
  padding: 5px 8px;
  margin-left: 10px;
  cursor: pointer;
}

.history-main-link {
  color: inherit;
  text-decoration: none;
  flex: 1;
}

.history-main-disabled {
  color: var(--muted);
  cursor: default;
}

.icon-danger {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  justify-self: end;
  align-self: center;
  border: 1px solid rgba(180, 35, 24, 0.18);
  background: #fff;
  color: #b42318;
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
  padding: 0;
  border-radius: 9px;
  flex: 0 0 auto;
}

.icon-danger:hover {
  background: #fee4e2;
  border-color: rgba(180, 35, 24, 0.32);
}

.danger-text {
  color: #b42318;
}

.narrow-card {
  max-width: 560px;
}

.success-banner {
  padding: 10px 12px;
  border-radius: 10px;
  background: #ecfdf3;
  color: #027a48;
  margin-bottom: 12px;
}

.warning-banner.always-visible {
  display: block;
  margin-bottom: 12px;
}

.editable-visit-fields input,
.editable-visit-fields select,
.detail-context-field textarea,
#patientSearchInput {
  width: 100%;
}

.history-more-row {
  justify-content: center;
  margin-top: 14px;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 18px 34px rgba(229, 72, 77, .25), 0 0 0 0 rgba(229,72,77,.18), inset 0 0 0 8px rgba(255,255,255,.22); }
  50% { box-shadow: 0 18px 34px rgba(229, 72, 77, .25), 0 0 0 14px rgba(229,72,77,.07), inset 0 0 0 8px rgba(255,255,255,.22); }
}

@keyframes wave {
  0%, 100% { height: 15px; }
  50% { height: 48px; }
}

@media (max-width: 1180px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 18px; }
  .visit-layout,
  .visit-grid,
  .settings-layout,
  .report-layout,
  .template-grid,
  .doctor-admin-layout,
  .template-admin-layout,
  .visit-summary,
  .form-grid.two,
  .form-grid.three {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .main { padding: 18px; }
  .topbar { flex-direction: column; }
  .recorder-main,
  .feedback-submit {
    grid-template-columns: 1fr;
  }
  .recorder-main {
    display: grid;
  }
  .record-controls {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .compact-summary,
  .compact-workflow,
  .form-grid.two,
  .form-grid.three {
    grid-template-columns: 1fr;
  }
  .kpi-grid,
  .feedback-grid,
  .workflow,
  .doctor-row,
  .patient-row {
    grid-template-columns: 1fr;
  }
  .tr { grid-template-columns: 1fr; }
}

/* Medical, restrained visual pass */
:root {
  --bg: #f3f6f8;
  --panel: #ffffff;
  --soft: #f8fafc;
  --text: #142433;
  --muted: #607080;
  --line: #d8e1e8;
  --blue: #1f5f8b;
  --blue-dark: #153f5f;
  --green: #167a5a;
  --green-soft: #e8f5ef;
  --yellow-soft: #fff9e8;
  --shadow: 0 8px 22px rgba(20, 36, 51, .06);
  --radius: 10px;
}

html, body {
  background: var(--bg);
}

.sidebar,
.card,
.auth-card {
  background: var(--panel);
  border-color: var(--line);
}

.brand-mark,
.btn.primary {
  background: var(--blue);
  box-shadow: none;
}

.side-nav a,
.admin-nav a,
.user-chip,
.btn,
.icon-btn,
select,
input,
textarea,
.locked-field,
.inline-patient-form,
.visit-summary div,
.context-line,
.wave,
.workflow span,
.transcript-box,
.transcript-line,
.status-pill,
.feedback,
.empty-state,
.doctor-row,
.patient-row,
.tr,
.template-details,
.template-detail-card pre {
  border-radius: var(--radius);
}

.btn:hover,
.icon-btn:hover {
  transform: none;
}

.topbar h1 {
  letter-spacing: 0;
}

.record-start {
  background: #c73b3b;
  box-shadow: none;
}

.wave,
.wave i {
  background: #e9f0f5;
}

.wave i {
  background: var(--blue);
}

.compact-workflow {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.inline-link {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 7px;
  color: var(--blue-dark);
  font-weight: 850;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.history-filters {
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) minmax(150px, .8fr) minmax(180px, 1fr) 145px 145px auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
  padding: 12px;
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.history-search input {
  background: white;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  gap: 9px;
  padding: 12px 13px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(34, 49, 63, 0.04);
}

.history-item:hover {
  border-color: #9bb8cc;
  background: #f7fbfd;
}

.history-main {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(220px, 1fr);
  gap: 16px;
  align-items: start;
}

.history-main b,
.history-main span {
  display: block;
}

.history-main small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.source-badge {
  display: inline-flex;
  width: fit-content;
  margin-top: 7px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(31, 166, 107, 0.12);
  color: var(--green);
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
}

.visit-status-inline {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.visit-status-inline span {
  min-width: 0;
  padding: 7px 8px;
  background: #edf1f4;
  color: var(--muted);
  border: 1px solid #e1e7ec;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 850;
  text-align: center;
}

.visit-status-inline span.done {
  background: var(--green-soft);
  border-color: #cde8dc;
  color: #116647;
}

.visit-status-inline span.active {
  background: #bff3d5;
  border-color: #3acc79;
  color: #064d2b;
  box-shadow: inset 0 0 0 1px rgba(6, 77, 43, .08);
}

.status-steps {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.status-steps span.active,
.workflow span.active {
  background: #bff3d5;
  color: #064d2b;
  border: 1px solid #3acc79;
}

.doctor-admin-layout {
  grid-template-columns: 1fr;
}

.doctor-admin-top {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.doctor-team-card {
  grid-column: 1 / -1;
}

.doctor-row {
  grid-template-columns: minmax(280px, 1.4fr) 150px 210px minmax(190px, .8fr);
  align-items: start;
}

.doctor-head {
  align-items: center;
}

.doctor-row input,
.doctor-row select {
  min-width: 0;
}

.access-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
}

.access-dialog::backdrop { background: rgba(15, 23, 42, .55); }
.access-dialog pre { white-space: pre-wrap; overflow-wrap: anywhere; padding: 14px; background: var(--soft); border: 1px solid var(--line); }
.access-dialog details { margin: 16px 0; }

.patient-row {
  grid-template-columns: minmax(220px, 1.3fr) 150px 160px 130px 100px;
  align-items: center;
}

.patient-head {
  align-items: center;
}

.template-details {
  padding: 0;
  overflow: hidden;
}

.template-details summary {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 16px;
  cursor: pointer;
  list-style: none;
}

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

.template-details summary::after {
  content: "›";
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 20px;
  font-weight: 900;
  transform: rotate(90deg);
  transition: transform .16s ease, background .16s ease, color .16s ease;
  flex: 0 0 auto;
}

.template-details[open] summary::after {
  transform: rotate(-90deg);
  background: var(--green-soft);
  color: var(--success);
}

.template-details summary small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.template-details form {
  display: grid;
  gap: 12px;
  padding: 0 16px 16px;
  border-top: 1px solid var(--line);
}

.template-summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.template-summary-actions form {
  margin: 0;
}

.edit-controls {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin: 8px 0 12px;
}

.operation-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid #b8d9c8;
  border-radius: var(--radius);
  background: #ecfbf3;
  color: #0b5f37;
  font-size: 13px;
  font-weight: 850;
}

.operation-status[hidden] {
  display: none;
}

.operation-status i {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(11, 95, 55, .22);
  border-top-color: #0b5f37;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.audio-playback {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7fafc;
}

.audio-playback span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.audio-playback audio {
  width: 100%;
  min-width: 220px;
}

.compact-audio {
  margin-top: 10px;
  padding: 9px;
}

.table audio {
  width: 180px;
  max-width: 100%;
}

textarea[readonly],
input[readonly] {
  color: var(--text);
  background: #f7fafc;
  cursor: default;
}

.transcript-box:not(.is-editing) [contenteditable="false"] {
  cursor: default;
}

.is-editing {
  background: white;
  border-color: #83b7d2;
}

@media (max-width: 960px) {
  .history-filters,
  .history-main,
  .doctor-row,
  .patient-row,
  .doctor-admin-top {
    grid-template-columns: 1fr;
  }

  .visit-status-inline,
  .compact-workflow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

.nav-with-badge { display: flex !important; align-items: center; justify-content: space-between; gap: 8px; }
.nav-badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--warning); color: white; font-size: 12px; }
.context-strip, .recorder-card { max-width: none; width: 100%; margin: 0; }
.context-row { display: grid; grid-template-columns: minmax(180px,.8fr) minmax(220px,1fr) minmax(240px,1fr) auto auto; gap: 10px; align-items: end; }
.doctor-mini { min-height: 58px; display: grid; align-content: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--soft); }
.doctor-mini span { color: var(--muted); font-size: 12px; }
.visit-summary-line { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.visit-summary-line b { color: var(--text); }
.inline-link-button { border: 0; background: transparent; color: var(--accent); cursor: pointer; font-weight: 800; }
.needs-patient { border-color: rgba(201,138,27,.45) !important; box-shadow: 0 16px 38px rgba(201,138,27,.10); }
.record-live { display: flex; gap: 10px; align-items: center; }
.record-dot { width: 14px; height: 14px; border-radius: 999px; background: #b9c3ca; }
.record-dot.live { background: var(--recording); animation: pulse 1.2s ease-in-out infinite; }
.big-record { min-width: 230px; height: 50px; font-size: 16px; }
.record-controls .btn.danger, .sticky-recording .btn.danger { color: white; border: 0; background: var(--recording); }
.consent-line { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-weight: 850; }
.consent-line input { width: 18px; height: 18px; }
.consent-help { margin: 6px 0 0 28px; color: var(--muted); font-size: 12px; }
.mic-level { height: 54px; display: flex; align-items: end; gap: 5px; margin-top: 14px; padding: 10px; border-radius: 14px; background: var(--soft); border: 1px solid var(--line); }
.mic-level i { flex: 1; min-width: 4px; height: 15%; border-radius: 999px; background: linear-gradient(180deg, var(--accent), #81c7bb); transition: height 80ms linear; }
.mode-panel { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.mode-panel b { display: block; margin-bottom: 3px; }
.mode-panel span { color: var(--muted); font-size: 13px; }
.mode-switch { display: flex; gap: 6px; padding: 5px; border-radius: 13px; background: var(--soft); border: 1px solid var(--line); }
.mode-switch label { cursor: pointer; }
.mode-switch input { position: absolute; opacity: 0; pointer-events: none; }
.mode-switch label span { display: block; padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 900; }
.mode-switch input:checked + span { background: var(--accent); color: white; box-shadow: 0 8px 18px rgba(14,124,123,.16); }
.warning-banner, .pipeline-error { margin-top: 10px; padding: 11px 13px; border-radius: 14px; font-weight: 850; }
.warning-banner { background: #fff8e7; color: #7a4e05; border: 1px solid rgba(201,138,27,.28); }
.pipeline-error { display: grid; gap: 8px; background: white; color: #8f2f2f; border: 1px solid rgba(214,69,69,.35); }
.sticky-recording { position: sticky; top: 0; z-index: 5; margin: -16px -16px 14px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); border-radius: 18px 18px 0 0; }
.sticky-recording i { display: inline-block; width: 9px; height: 9px; border-radius: 999px; background: var(--recording); }
.pipeline-progress { display: grid; gap: 8px; margin-top: 12px; padding: 13px; border-radius: 15px; background: var(--accent-soft); border: 1px solid rgba(14,124,123,.18); }
.pipeline-progress > div:first-child { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.next-visit-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  padding: 14px;
  border-radius: 15px;
  border: 1px solid rgba(46, 158, 91, .24);
  background: var(--green-soft);
}
.next-visit-banner div {
  display: grid;
  gap: 3px;
}
.next-visit-banner span {
  color: var(--muted);
  font-size: 13px;
}
.progress-bar { height: 9px; border-radius: 999px; background: rgba(14,124,123,.16); overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 15%; border-radius: inherit; background: var(--accent); transition: width .25s ease; }
.review-grid { display: grid; grid-template-columns: minmax(0,7fr) minmax(300px,3fr); gap: 14px; align-items: stretch; }
.detail-review-grid { margin-top: 14px; }
.note-main { min-height: 520px; max-height: none; line-height: 1.55; font-size: 16px; background: white; }
.rich-note-editor,
.transcript-rich {
  width: 100%;
  border: 1px solid var(--line);
  outline: none;
  overflow: auto;
  white-space: pre-wrap;
}
.rich-note-editor:empty::before,
.transcript-rich:empty::before {
  content: attr(data-placeholder);
  color: #8a98a3;
}
.rich-note-editor:focus,
.transcript-rich:focus {
  border-color: rgba(14,124,123,.55);
  box-shadow: 0 0 0 3px rgba(14,124,123,.10);
}
.note-line {
  min-height: 0;
  margin: 0 0 4px;
}
.note-section-title {
  margin-top: 14px;
  margin-bottom: 2px;
  color: #173f41;
  font-weight: 900;
}
.note-section-title:first-child {
  margin-top: 0;
}
.evidence-mark {
  border-radius: 5px;
  padding: 1px 3px;
  background: #fff1b8;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  cursor: pointer;
}
.evidence-mark:hover {
  background: #ffe084;
  box-shadow: 0 0 0 2px rgba(201,138,27,.16);
}
.evidence-mark.active {
  background: #f4c950;
  box-shadow: 0 0 0 2px rgba(183,132,20,.22);
}
.evidence-mark.unsupported {
  border-bottom: 1px dashed #a36b09;
  background: #fff8e2;
}
.ai-disclaimer { margin-bottom: 10px; padding: 9px 11px; border-radius: 12px; background: #f4f6f7; color: var(--muted); font-size: 13px; }
.evidence-panel {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #d8e3e5;
  border-radius: 12px;
  background: #fbfcfd;
}
.evidence-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
}
.evidence-head b {
  color: var(--text);
}
.evidence-head span {
  color: var(--muted);
  font-size: 12px;
}
.evidence-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}
.evidence-item {
  border: 1px solid #d9e7e8;
  border-radius: 10px;
  padding: 10px;
  background: white;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.evidence-item:hover {
  border-color: rgba(14,124,123,.42);
  background: var(--accent-soft);
}
.evidence-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.evidence-item b,
.evidence-item span,
.evidence-item small {
  display: block;
}
.evidence-item b {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 4px;
}
.evidence-item span {
  font-size: 13px;
  line-height: 1.35;
}
.evidence-item small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}
.evidence-item.unsupported {
  border-style: dashed;
  border-color: rgba(201,138,27,.45);
}
.evidence-detail {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
  padding: 10px;
  border: 1px solid rgba(201,138,27,.28);
  border-radius: 10px;
  background: #fffaf0;
}
.evidence-detail div {
  display: grid;
  gap: 6px;
}
.evidence-detail span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.evidence-detail mark {
  display: block;
  padding: 8px;
  border-radius: 8px;
  background: #ffe8a3;
  color: #3f3106;
  line-height: 1.4;
}
.evidence-detail em {
  color: var(--muted);
}
.evidence-flash {
  outline: 3px solid rgba(201,138,27,.28);
  outline-offset: 2px;
}
.review-completion-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  border-color: rgba(14,124,123,.22);
  background: linear-gradient(180deg, #f6fffd 0%, #ffffff 100%);
}
.review-completion-card.is-blocked {
  border-color: rgba(201,138,27,.24);
  background: #fffaf0;
}
.review-completion-card.is-complete {
  border-color: rgba(46,158,91,.28);
  background: var(--green-soft);
}
.review-completion-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}
.review-completion-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 20px;
  font-weight: 950;
}
.review-completion-card.is-blocked .review-completion-icon {
  background: #c98a1b;
}
.review-completion-card.is-complete .review-completion-icon {
  background: var(--success);
}
.review-completion-card h2 {
  margin: 2px 0 4px;
}
.review-completion-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}
.review-completion-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.collapsible-admin-card {
  padding: 0;
  overflow: hidden;
}
.collapsible-admin-card > summary {
  list-style: none;
  cursor: pointer;
  margin: 0;
  padding: 18px;
}
.collapsible-admin-card > summary::-webkit-details-marker {
  display: none;
}
.collapsible-admin-card[open] > summary {
  border-bottom: 1px solid var(--line);
}
.collapsible-admin-card[open] > summary .btn {
  background: #eef3f4;
  font-size: 0;
}
.collapsible-admin-card[open] > summary .btn::after {
  content: "Свернуть";
  font-size: 12px;
}
.collapsible-admin-card .admin-form {
  padding: 18px;
}
.dev-badge {
  margin: 8px 0 14px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff3c4;
  color: #6b4a00;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid rgba(201,138,27,.28);
}
.rewrite-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.chip-btn { border: 1px solid var(--line); border-radius: 999px; padding: 8px 11px; background: white; color: var(--accent); font-weight: 850; cursor: pointer; }
.rewrite-row select { width: auto; min-width: 220px; }
.autosave-state { color: var(--success); font-size: 12px; font-weight: 850; margin-bottom: 6px; }
.final-actions { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-top: 12px; }
.final-actions small { display: block; margin-top: 6px; color: var(--warning); font-weight: 750; }
.copy-mis { min-width: 280px; min-height: 52px; font-size: 16px; }
.export-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.side-panel { min-width: 0; }
.side-panel.collapsed { width: 58px; overflow: hidden; }
.tabs { display: flex; gap: 6px; padding: 5px; margin-bottom: 10px; border-radius: 14px; background: var(--soft); border: 1px solid var(--line); }
.tab { flex: 1; border: 0; border-radius: 10px; padding: 9px; background: transparent; color: var(--muted); font-weight: 850; cursor: pointer; }
.tab.active { background: white; color: var(--accent); box-shadow: 0 8px 18px rgba(16,32,51,.08); }
.transcript-textarea { min-height: 560px; line-height: 1.5; font-size: 14px; background: white; }
.transcript-rich {
  padding: 12px;
  resize: vertical;
}
.transcript-rich-line {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 7px 0;
  border-bottom: 1px solid #eef3f4;
}
.transcript-rich-line.plain {
  display: block;
}
.transcript-rich-line:last-child {
  border-bottom: 0;
}
.speaker-badge {
  display: inline-flex;
  justify-content: center;
  min-width: 76px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #e8f2f2;
  color: #174647;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  user-select: none;
}
.transcript-rich-line.patient .speaker-badge {
  background: #fff2db;
  color: #7a4e05;
}
.speech-text {
  min-width: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.side-audio { padding: 12px; border-radius: 14px; background: var(--soft); }
.side-audio audio { width: 100%; }
.micro-feedback { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; padding: 10px; border-radius: 14px; background: var(--green-soft); color: var(--success); font-weight: 850; }
.feedback-inline { display: flex; gap: 8px; min-width: 320px; }
.status-pill.recording, .status-pill.danger, .status-pill.warning, .status-pill.success { border-radius: 999px; padding: 8px 11px; font-size: 12px; font-weight: 900; }
.status-pill.recording { color: var(--recording); background: #fff4f4; border: 1px solid rgba(214,69,69,.24); }
.status-pill.warning { color: #895609; background: #fff8e7; border: 1px solid rgba(201,138,27,.24); }
.status-pill.success { color: var(--success); background: var(--green-soft); border: 1px solid rgba(46,158,91,.22); }
.status-pill.danger { color: #9b3535; background: white; border: 1px solid rgba(214,69,69,.38); }
.modern-history-list { display: grid; gap: 10px; }
.modern-history-item { display: grid; grid-template-columns: minmax(0,1fr) auto 34px; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.history-delete-placeholder { width: 34px; height: 34px; display: block; }
.source-badge.muted { background: #eef2f3; color: var(--muted); }
.review-empty { display: grid; place-items: center; gap: 8px; min-height: 180px; }
.empty-icon { width: 48px; height: 48px; border-radius: 999px; display: grid; place-items: center; background: var(--green-soft); color: var(--success); font-weight: 900; font-size: 22px; }
.visit-data-collapsed summary { display: grid; grid-template-columns: auto auto minmax(0,1fr) auto; gap: 10px; align-items: center; cursor: pointer; list-style: none; }
.visit-data-collapsed summary::-webkit-details-marker { display: none; }
.details-chevron {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform .16s ease, background .16s ease, color .16s ease;
}
.visit-data-collapsed[open] .details-chevron {
  transform: rotate(90deg);
  background: var(--green-soft);
  color: var(--success);
}
.visit-data-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 14px; }
.visit-data-grid div { padding: 11px; border-radius: 13px; background: var(--soft); border: 1px solid var(--line); }
.visit-data-grid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.assign-patient-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, 320px) auto;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
  padding: 14px;
  border-radius: 15px;
  border: 1px solid rgba(201, 138, 27, .35);
  background: var(--yellow-soft);
}
.assign-patient-panel div {
  display: grid;
  gap: 3px;
}
.assign-patient-panel span {
  color: var(--muted);
  font-size: 13px;
}
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.25); opacity: .72; } }

@media (max-width: 1080px) {
  .context-row, .review-grid { grid-template-columns: 1fr; }
  .final-actions, .pipeline-progress > div:first-child { align-items: stretch; flex-direction: column; }
  .copy-mis { width: 100%; }
  .visit-data-grid { grid-template-columns: 1fr; }
  .assign-patient-panel,
  .next-visit-banner { grid-template-columns: 1fr; align-items: stretch; }
  .review-completion-card { flex-direction: column; align-items: stretch; }
  .review-completion-actions { justify-content: stretch; }
  .review-completion-actions .btn { width: 100%; }
}

/* Mature clinical workspace polish */
:root {
  --radius: 14px;
  --shadow: 0 10px 28px rgba(31, 41, 51, .07);
}

.card {
  border-radius: 14px;
}

.btn,
select,
input,
textarea,
.locked-field {
  border-radius: 10px;
}

.btn {
  font-weight: 760;
}

.btn.primary {
  background: #0e7c7b;
  box-shadow: 0 8px 18px rgba(14, 124, 123, .16);
}

.topbar h1 {
  letter-spacing: 0;
}

.recorder-card {
  padding: 18px !important;
  border-color: #d8e1e4;
}

.recorder-main {
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.record-live {
  min-width: 138px;
  justify-content: flex-end;
}

.timer {
  min-width: 76px;
  text-align: center;
  background: #eef4f4;
  color: #174647;
  border: 1px solid #d7e5e6;
}

.mic-level {
  height: 46px;
  background: #fbfcfd;
}

.consent-card {
  position: relative;
  align-items: flex-start;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #cfdde0;
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
}

.consent-card.is-required {
  border-color: rgba(201, 138, 27, .65);
  background: #fffaf0;
  box-shadow: 0 0 0 3px rgba(201, 138, 27, .12);
}

.consent-card input {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  accent-color: var(--accent);
  cursor: pointer;
}

.consent-card b {
  display: block;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 3px;
}

.consent-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.consent-help {
  margin-left: 0;
  padding-left: 50px;
}

.mode-panel {
  align-items: stretch;
  background: #f8fbfb;
}

.mode-panel > span {
  display: flex;
  align-items: center;
  max-width: 560px;
  line-height: 1.35;
}

.mode-switch {
  flex: 0 0 auto;
  background: #eef4f4;
}

.mode-switch label span {
  white-space: nowrap;
  font-size: 13px;
}

.recorder-console {
  justify-content: space-between;
  align-items: stretch;
  gap: 12px;
  margin: 14px 0 8px;
  padding: 12px;
  border: 1px solid #d8e1e4;
  border-radius: 14px;
  background: #fbfcfd;
}

.record-primary-control {
  flex: 1;
  min-height: 62px;
  border: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  text-align: left;
  color: white;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(14, 124, 123, .16);
}

.record-primary-control:disabled {
  color: #62707a;
  background: #e8eef0;
  box-shadow: none;
  cursor: not-allowed;
}

.record-primary-control .control-icon {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .2);
  font-size: 15px;
}

.record-primary-control:disabled .control-icon {
  background: white;
}

.record-primary-control b,
.record-primary-control small {
  display: block;
}

.record-primary-control b {
  font-size: 16px;
  line-height: 1.2;
}

.record-primary-control small {
  margin-top: 3px;
  opacity: .86;
  font-weight: 650;
}

.recorder-secondary-controls {
  display: flex;
  gap: 8px;
}

.recorder-control {
  min-width: 116px;
  border: 1px solid #cfdde0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  background: white;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.recorder-control span {
  color: var(--accent);
}

.recorder-control.stop-control {
  border-color: rgba(214,69,69,.42);
  color: #a43b3b;
}

.recorder-control.stop-control span {
  color: #a43b3b;
}

.workflow span,
.compact-workflow span {
  border-radius: 10px;
  font-weight: 760;
}

.history-filters {
  grid-template-columns: minmax(220px, 1.4fr) repeat(5, minmax(130px, 1fr)) auto auto;
  align-items: end;
  overflow: hidden;
}

.history-filters > * {
  min-width: 0;
}

.history-filters .btn,
.history-filters .link-btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

@media (max-width: 1280px) {
  .history-filters {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }
}

@media (max-width: 900px) {
  .mode-panel,
  .recorder-console {
    flex-direction: column;
  }

  .recorder-secondary-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .evidence-detail {
    grid-template-columns: 1fr;
  }
}
