:root {
  --bg: #eef2f3;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --line: #d7dee2;
  --line-strong: #c7d1d6;
  --text: #172126;
  --muted: #64727a;
  --teal: #00a6c9;
  --teal-ink: #e6f8fb;
  --amber: #a96812;
  --amber-ink: #fff2d8;
  --coral: #c84f44;
  --coral-ink: #fff0ee;
  --blue: #25699a;
  --blue-ink: #e7f1f8;
  --green: #2e7d5b;
  --shadow: 0 10px 24px rgba(20, 33, 39, 0.07);
  --shadow-strong: 0 16px 36px rgba(20, 33, 39, 0.12);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
}

.login-gate {
  align-items: center;
  background: linear-gradient(180deg, #eef8fb 0%, #eef2f3 100%);
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.login-gate[hidden],
.app-shell[hidden] {
  display: none !important;
}

.login-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-strong);
  display: grid;
  gap: 14px;
  margin: 0 auto;
  max-width: 420px;
  padding: 24px;
  width: min(100%, 420px);
}

.login-card h1 {
  margin: 0 0 6px;
}

.login-card label {
  display: grid;
  gap: 6px;
}

.login-card input {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  min-height: 38px;
  padding: 0 10px;
}

.login-card button {
  background: var(--teal);
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
}

.login-card button:hover {
  filter: brightness(0.96);
}

.login-error {
  color: #9a3412;
  font-size: 13px;
  margin: 0;
  min-height: 18px;
}

.login-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.sidebar {
  background: #fbfcfd;
  border-right: 1px solid var(--line-strong);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.brand {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 72px;
  padding: 18px 18px 16px;
}

.brand strong {
  display: block;
  font-size: 19px;
  letter-spacing: 0;
}

.brand span,
.muted,
.metric span,
label span {
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.search-block {
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  padding: 14px 14px 16px;
}

input[type="search"],
input[type="date"] {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  min-height: 38px;
  padding: 0 12px;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid rgba(8, 127, 118, 0.2);
  outline-offset: 2px;
}

#clinicDate {
  margin-bottom: 8px;
}

.date-jump-row {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 8px;
}

.date-jump-button {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #334044;
  cursor: pointer;
  font-size: 12px;
  min-height: 32px;
  min-width: 0;
  padding: 6px 4px;
}

.date-jump-button:hover {
  border-color: rgba(8, 127, 118, 0.45);
}

.date-jump-button.primary {
  background: rgba(8, 127, 118, 0.08);
  border-color: rgba(8, 127, 118, 0.22);
  color: var(--teal);
  font-weight: 700;
}

.date-jump-button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}

.range-switch {
  background: #edf2f4;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 8px;
  padding: 4px;
}

.range-option {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #334044;
  cursor: pointer;
  min-height: 32px;
}

.range-option.is-active {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 5px 12px rgba(37, 105, 154, 0.18);
}

.appointment-summary {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 10px;
}

.appointment-summary span {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
  padding: 7px 6px;
  text-align: center;
}

.appointment-summary strong {
  color: var(--text);
  display: block;
  font-size: 18px;
  margin-top: 2px;
}

.filter-row {
  background: #edf2f4;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 10px;
  padding: 4px;
}

.filter {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #334044;
  cursor: pointer;
  min-height: 32px;
}

.filter.is-active {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 5px 12px rgba(8, 127, 118, 0.16);
}

.appointment-schedule {
  display: none;
  margin-top: 12px;
}

.schedule-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.schedule-legend span {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  gap: 5px;
}

.schedule-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}

.schedule-day {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: 8px;
}

.schedule-day.is-today {
  border-color: rgba(0, 127, 120, 0.45);
  box-shadow: inset 0 0 0 1px rgba(8, 127, 118, 0.08);
}

.schedule-day header {
  align-items: center;
  display: flex;
  gap: 6px;
  justify-content: space-between;
  margin-bottom: 7px;
}

.schedule-day header strong {
  color: #273235;
  font-size: 12px;
}

.schedule-day header span {
  color: var(--muted);
  font-size: 11px;
}

.schedule-slots {
  display: grid;
  gap: 6px;
}

.schedule-patient {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 7px;
  color: #273235;
  cursor: pointer;
  min-height: 54px;
  padding: 7px;
  text-align: left;
}

.schedule-patient.is-active {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.schedule-patient time,
.schedule-patient span {
  color: var(--muted);
  display: block;
  font-size: 11px;
}

.schedule-patient strong {
  display: block;
  font-size: 12px;
  margin: 2px 0;
}

.record-dot {
  border-radius: 999px;
  display: inline-block;
  height: 8px;
  margin-right: 5px;
  width: 8px;
}

.record-dot.written,
.patient-card.record-written,
.schedule-patient.record-written {
  border-left-color: var(--teal);
}

.record-dot.partial,
.patient-card.record-partial,
.schedule-patient.record-partial {
  border-left-color: var(--amber);
}

.record-dot.missing,
.patient-card.record-missing,
.schedule-patient.record-missing {
  border-left-color: var(--coral);
}

.record-dot.written {
  background: var(--teal);
}

.record-dot.partial {
  background: var(--amber);
}

.record-dot.missing {
  background: var(--coral);
}

.patient-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 14px;
}

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

.patient-list-day-header {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  justify-content: space-between;
  padding: 0 2px;
}

.patient-list-day-header strong {
  color: #273235;
  font-size: 13px;
}

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

.patient-card {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 10px;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  min-height: 66px;
  padding: 12px;
  text-align: left;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
  width: 100%;
}

.patient-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.patient-card.is-active {
  background: #ffffff;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-strong);
}

.patient-card header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.patient-card-name {
  display: block;
  font-size: 15px;
  margin: 0;
}

.patient-card-time {
  color: #17272d;
  font-size: 13px;
  font-weight: 700;
}

.patient-card-main,
.patient-card-state {
  min-width: 0;
}

.patient-card-main small,
.patient-card-state em,
.patient-card-state b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patient-card-main small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.patient-card-state {
  text-align: right;
}

.patient-card-state em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  margin-bottom: 5px;
}

.patient-card-state b {
  color: #334044;
  font-size: 12px;
  font-weight: 700;
}

.patient-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 5px 0 0;
}

.patient-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.patient-card-tags span {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #455156;
  display: inline-flex;
  font-size: 12px;
  gap: 4px;
  min-height: 26px;
  padding: 0 8px;
}

.patient-status-actions {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 10px;
}

.patient-status-actions button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #435154;
  cursor: pointer;
  font-size: 12px;
  min-height: 28px;
}

.patient-status-actions button:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--blue);
}

.patient-status-actions button:disabled {
  background: var(--teal-ink);
  border-color: var(--teal);
  color: #0e625d;
  cursor: default;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  line-height: 1;
  padding: 6px 8px;
  white-space: nowrap;
}

.badge.waiting {
  background: var(--amber-ink);
  color: var(--amber);
}

.badge.in_progress {
  background: var(--blue-ink);
  color: var(--blue);
}

.badge.registered {
  background: #eef3f3;
  color: #526165;
}

.badge.completed {
  background: #e8f5ef;
  color: var(--green);
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 20px 22px 28px;
}

.patient-header {
  align-items: flex-start;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 18px;
}

.eyebrow {
  color: var(--teal);
  font-size: 13px;
  margin: 0 0 4px;
}

.back-to-schedule {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: #1d4f5d;
  cursor: pointer;
  min-height: 32px;
  padding: 0 10px;
}

.back-to-schedule:hover {
  border-color: var(--teal);
  color: var(--teal);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 27px;
  letter-spacing: 0;
  margin-bottom: 8px;
}

h2 {
  font-size: 16px;
  margin: 0;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-strip span {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #384447;
  font-size: 13px;
  padding: 8px 10px;
}

.is-hidden {
  display: none !important;
}

.case-command-panel {
  display: grid;
  gap: 12px;
}

.case-command-heading {
  align-items: flex-start;
}

.case-command-heading p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 5px 0 0;
}

.case-command-tools {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(220px, 1fr) 132px 92px;
  min-width: min(100%, 520px);
}

.case-command-tools input,
.case-command-tools select,
.case-writer select {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  min-height: 36px;
  padding: 0 10px;
  width: 100%;
}

.case-summary-strip {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.case-summary-strip span {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
  padding: 9px 10px;
}

.case-summary-strip strong {
  color: var(--text);
  display: block;
  font-size: 18px;
  margin-bottom: 2px;
}

.case-insight-strip,
.case-writer-insights {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.case-insight-strip span,
.case-writer-insights span {
  background: #f6f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
  padding: 8px 9px;
}

.case-insight-strip strong,
.case-writer-insights strong {
  color: var(--text);
  display: block;
  font-size: 16px;
  margin-bottom: 2px;
}

.case-writer-insights {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.case-writer-insights .case-writer-missing {
  grid-column: 1 / -1;
}

.case-history-overview {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 10px;
}

.case-history-overview header,
.case-history-overview-empty {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.case-history-overview header strong,
.case-history-overview-empty strong {
  font-size: 14px;
}

.case-history-overview header span,
.case-history-overview-empty span {
  color: var(--muted);
  font-size: 12px;
}

.case-history-overview-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-height: 260px;
  overflow: auto;
}

.case-patient-chart-header {
  background: #f8fbfc;
  border: 1px solid #e0eaee;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 10px 12px;
}

.case-patient-chart-header > div {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.case-patient-chart-header > div strong {
  font-size: 18px;
}

.case-patient-chart-header > div span {
  color: var(--muted);
  font-size: 12px;
}

.case-patient-chart-header dl {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0;
}

.case-patient-chart-header dl span {
  background: #ffffff;
  border: 1px solid #e5edf0;
  border-radius: 6px;
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 7px 8px;
}

.case-patient-chart-header dt {
  color: var(--muted);
  font-size: 11px;
}

.case-patient-chart-header dd {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-history-overview-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 6px;
  min-height: 92px;
  padding: 9px 10px;
  text-align: left;
}

.case-history-overview-list.is-patient-timeline {
  gap: 0;
  grid-template-columns: minmax(0, 1fr);
  max-height: min(62vh, 760px);
  padding-left: 0;
}

.case-history-overview-list.is-patient-timeline.has-expanded-record {
  max-height: none;
  overflow: visible;
}

.case-history-overview-list.is-patient-timeline .case-history-overview-card {
  border-left: 0;
  border-radius: 0;
  border-width: 0 0 1px 0;
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  min-height: 112px;
  padding: 0;
}

.case-history-overview-list.is-patient-timeline .case-history-overview-card.is-expanded {
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  grid-template-columns: 152px minmax(0, 1fr);
  margin: 16px 0 18px;
  min-height: 520px;
}

.case-history-overview-list.is-patient-timeline .case-history-overview-card:first-child {
  border-top: 1px solid var(--line);
}

.case-history-date-rail {
  background: #f7fbfc;
  border-right: 1px solid #e5edf0;
  display: grid;
  gap: 4px;
  justify-items: start;
  padding: 12px 12px;
}

.case-history-date-rail strong {
  color: var(--text);
  font-size: 13px;
}

.case-history-date-rail span {
  color: var(--muted);
  font-size: 11px;
}

.case-history-overview-card > button {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: grid;
  gap: 6px;
  padding: 0;
  text-align: left;
}

.case-history-overview-list.is-patient-timeline .case-history-overview-card > button {
  padding: 12px;
}

.case-history-overview-list.is-patient-timeline .case-history-overview-card.is-expanded .case-history-date-rail {
  grid-row: 1 / span 4;
}

.case-history-overview-list.is-patient-timeline .case-history-overview-card.is-expanded > button {
  grid-column: 2;
  padding: 18px 20px 10px;
}

.case-history-overview-list.is-patient-timeline .case-history-overview-card.is-expanded .case-action-shortcuts,
.case-history-overview-list.is-patient-timeline .case-history-overview-card.is-expanded .case-history-expanded-panel {
  grid-column: 2;
  margin: 0 20px 16px;
}

.case-history-overview-card:hover {
  background: #f3fbfc;
}

.case-history-overview-card.is-expanded {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(23, 33, 38, 0.09);
  margin: 16px 0 18px;
  min-height: 460px;
  overflow: hidden;
}

.case-history-overview-card strong,
.case-history-overview-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-history-overview-card strong {
  font-size: 13px;
}

.case-history-overview-card small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}

.case-history-overview-card em {
  color: var(--muted);
  display: -webkit-box;
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.case-history-overview-card.is-expanded strong,
.case-history-overview-card.is-expanded small {
  white-space: normal;
}

.case-history-overview-card.is-expanded .case-history-overview-meta strong {
  font-size: 18px;
  line-height: 1.3;
}

.case-history-overview-card.is-expanded .case-history-overview-meta small {
  font-size: 12px;
}

.case-history-overview-card.is-expanded .case-history-section-grid em {
  color: var(--text);
  -webkit-line-clamp: unset;
}

.case-history-overview-card.is-expanded > button .case-history-section-grid span {
  min-height: 88px;
  padding: 10px 12px;
}

.case-history-overview-card.is-expanded > button .case-history-section-grid b {
  font-size: 13px;
}

.case-history-overview-card.is-expanded > button .case-history-section-grid em {
  font-size: 15px;
  line-height: 1.55;
}

.case-history-overview-meta {
  min-width: 0;
}

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

.case-history-section-grid span {
  background: #f8fbfc;
  border: 1px solid #e5edf0;
  border-radius: 6px;
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 6px 7px;
}

.case-history-section-grid b {
  color: #51616a;
  font-size: 11px;
}

.case-history-section-grid em {
  -webkit-line-clamp: 3;
}

.case-history-detail-grid {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-top: 8px;
}

.case-history-expanded-panel {
  background: #ffffff;
  display: grid;
  gap: 12px;
}

.case-history-expanded-panel header {
  display: flex;
  justify-content: space-between;
}

.case-history-expanded-panel header strong {
  color: var(--text);
  display: block;
  font-size: 18px;
  line-height: 1.3;
}

.case-history-expanded-panel header span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 4px;
}

.case-history-expanded-summary {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.case-history-expanded-summary span {
  min-height: 104px;
  padding: 12px;
}

.case-history-expanded-summary b {
  font-size: 13px;
}

.case-history-expanded-summary em {
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-line-clamp: unset;
}

.case-history-expanded-panel .case-history-detail-grid {
  border-top: 1px solid var(--line);
  gap: 12px;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  padding-top: 12px;
}

.case-history-expanded-panel .case-history-detail-grid section {
  min-height: 104px;
  padding: 12px;
}

.case-history-expanded-panel .case-history-detail-grid strong {
  font-size: 13px;
}

.case-history-expanded-panel .case-history-detail-grid p {
  font-size: 15px;
}

.case-history-overview-list.is-patient-timeline .case-history-detail-grid {
  grid-column: 2;
  margin: 0 12px 12px;
}

.case-history-detail-grid section {
  background: #fbfdfe;
  border: 1px solid #e5edf0;
  border-radius: 6px;
  display: grid;
  gap: 4px;
  padding: 8px;
}

.case-history-detail-grid strong {
  color: #405054;
  font-size: 12px;
}

.case-history-detail-grid p {
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
  white-space: pre-wrap;
}

.case-history-detail-full {
  grid-column: 1 / -1;
}

.case-template-library {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 10px;
}

.case-template-library header {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.case-template-library header strong {
  font-size: 13px;
}

.case-template-library header span {
  color: var(--muted);
  font-size: 12px;
}

.case-template-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.case-template-card {
  align-items: center;
  background: #ffffff;
  border: 1px solid #e5edf0;
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 8px;
}

.case-template-card strong,
.case-template-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-template-card small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}

.case-command-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(520px, 1.2fr) minmax(360px, 0.8fr);
  min-width: 0;
}

.case-command-panel.is-patient-focused .case-command-grid {
  grid-template-columns: minmax(0, 1fr);
}

.case-command-panel.is-patient-focused .case-list-shell {
  display: none !important;
}

.case-command-panel.is-patient-focused .case-list-shell.is-hidden,
.case-command-panel.is-patient-focused .case-command-tools.is-hidden,
.case-command-panel.is-patient-focused .case-insight-strip.is-hidden {
  display: none !important;
}

.case-command-panel.is-patient-focused .case-history-overview-list:not(.is-patient-timeline) {
  grid-template-columns: minmax(0, 1fr);
  max-height: 620px;
}

.case-command-panel.is-patient-focused .case-history-section-grid {
  grid-template-columns: repeat(2, minmax(160px, 1fr));
}

.case-patient-context {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 10px;
}

.case-patient-context header {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.case-patient-context header strong {
  font-size: 14px;
}

.case-patient-context header span {
  color: var(--muted);
  font-size: 12px;
}

.case-patient-context-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.case-patient-context-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 8px 10px;
}

.case-patient-context-card.missing {
  border-left-color: #b85c38;
}

.case-patient-context-card strong,
.case-patient-context-card small,
.case-patient-context-card em {
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-patient-context-card strong {
  font-size: 13px;
  white-space: nowrap;
}

.case-patient-context-card small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.case-patient-context-card em {
  color: var(--text);
  display: -webkit-box;
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.case-command-panel [hidden] {
  display: none !important;
}

.case-list-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
}

.case-list-shell[hidden] {
  display: none;
}

.case-list-header,
.case-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(190px, 1.1fr) 96px 108px minmax(220px, 1fr);
}

.case-list-header {
  background: #f8fbfc;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 9px 12px;
}

.case-list-table {
  display: grid;
  max-height: 560px;
  overflow: auto;
}

.case-row {
  align-items: center;
  background: #ffffff;
  border: 0;
  border-left: 4px solid var(--line);
  border-top: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  min-height: 72px;
  padding: 9px 12px 9px 8px;
  text-align: left;
  width: 100%;
}

.case-row:first-child {
  border-top: 0;
}

.case-row:hover {
  background: #f3fbfc;
}

.case-row.is-active {
  background: #f8fffd;
  box-shadow: inset 0 0 0 1px rgba(0, 166, 201, 0.2);
}

.case-row.record-written {
  border-left-color: var(--teal);
}

.case-row.record-partial {
  border-left-color: var(--amber);
}

.case-row.record-missing {
  border-left-color: var(--coral);
}

.case-patient-cell,
.case-note-cell,
.case-status-cell,
.case-media-cell {
  min-width: 0;
}

.case-patient-cell strong,
.case-patient-cell small,
.case-note-cell strong,
.case-note-cell small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-patient-cell strong {
  font-size: 15px;
  margin-bottom: 4px;
}

.case-patient-cell small,
.case-note-cell small,
.case-media-cell {
  color: var(--muted);
  font-size: 12px;
}

.case-note-cell strong {
  color: #263236;
  font-size: 12px;
  margin-bottom: 4px;
}

.case-status-cell {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  justify-content: center;
  min-height: 28px;
  padding: 0 8px;
  white-space: nowrap;
}

.case-status-cell.written {
  background: #eef8f5;
  color: #0d675f;
}

.case-status-cell.partial {
  background: #fff7ed;
  color: #8a4d08;
}

.case-status-cell.missing,
.case-media-cell.needs-review {
  color: #9a3412;
}

.case-writer {
  align-content: start;
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
}

.case-writer-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding-bottom: 10px;
}

.case-writer-header strong,
.case-writer-header span {
  display: block;
}

.case-writer-header strong {
  font-size: 16px;
  margin-bottom: 4px;
}

.case-writer-header span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.case-writer label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.case-writer textarea {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  line-height: 1.55;
  min-height: 74px;
  padding: 8px 10px;
  resize: vertical;
  width: 100%;
}

#caseDraftPreview {
  min-height: 148px;
}

.case-writer-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.case-writer-actions button {
  min-height: 34px;
  padding-inline: 8px;
}

.case-action-shortcuts {
  background: #f8fbfc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.case-history-overview-card .case-action-shortcuts {
  margin-top: 2px;
}

.range-overview {
  display: grid;
  gap: 14px;
}

.range-overview-head {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.range-overview-head > div:first-child strong {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}

.range-overview-head > div:first-child span {
  color: var(--muted);
  font-size: 13px;
}

.range-overview-counts {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(76px, 1fr));
}

.range-overview-counts span {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  padding: 8px;
  text-align: center;
}

.range-overview-counts strong {
  color: var(--text);
  display: block;
  font-size: 18px;
  margin-top: 2px;
}

.range-focus-filter {
  background: #edf2f4;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 4px;
}

.range-focus-option {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #334044;
  cursor: pointer;
  display: flex;
  gap: 6px;
  justify-content: center;
  min-height: 34px;
  padding: 0 8px;
  white-space: nowrap;
}

.range-focus-option strong {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  color: inherit;
  font-size: 12px;
  min-width: 22px;
  padding: 2px 6px;
}

.range-focus-option.is-active {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 5px 12px rgba(37, 105, 154, 0.18);
}

.range-timeline {
  display: grid;
  gap: 14px;
}

.range-day-lane {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.range-day-lane > header {
  align-items: center;
  background: #f6faf9;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
}

.range-day-lane > header strong {
  display: block;
  font-size: 15px;
}

.range-day-lane > header span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.range-day-lane.is-today > header {
  background: #eef8f5;
}

.range-time-rail {
  display: grid;
  gap: 0;
  padding: 6px 0;
}

.range-appointment-header {
  align-items: center;
  background: #f8fbfc;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 700;
  gap: 10px;
  grid-template-columns: 58px 14px minmax(150px, 1.25fr) minmax(160px, 1fr) 76px 88px minmax(130px, 0.9fr) 96px;
  padding: 8px 12px 8px 10px;
}

.range-appointment-header span:first-child {
  grid-column: 1 / span 2;
}

.range-appointment-row {
  align-items: center;
  background: transparent;
  border: 0;
  border-left: 4px solid transparent;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 10px;
  grid-template-columns: 58px 14px minmax(150px, 1.25fr) minmax(160px, 1fr) 76px 88px minmax(130px, 0.9fr) 96px;
  min-height: 52px;
  padding: 8px 12px 8px 10px;
  position: relative;
  text-align: left;
  width: 100%;
}

.range-appointment-row + .range-appointment-row {
  border-top: 1px solid var(--line);
}

.range-appointment-row::before {
  background: #d8e5e4;
  bottom: -50%;
  content: "";
  left: 74px;
  position: absolute;
  top: -50%;
  width: 1px;
}

.range-appointment-row:first-child::before {
  top: 50%;
}

.range-appointment-row:last-child::before {
  bottom: 50%;
}

.range-appointment-row:hover {
  background: #f1fbfd;
}

.range-appointment-row:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

.range-appointment-row.record-written {
  border-left-color: var(--teal);
}

.range-appointment-row.record-partial {
  border-left-color: var(--amber);
}

.range-appointment-row.record-missing {
  border-left-color: var(--coral);
}

.range-appointment-row time {
  color: #17272d;
  font-size: 15px;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.range-appointment-dot {
  background: var(--teal);
  border: 3px solid #ffffff;
  border-radius: 999px;
  box-shadow: 0 0 0 1px #c7dfdc;
  height: 12px;
  position: relative;
  width: 12px;
  z-index: 1;
}

.range-appointment-row.record-partial .range-appointment-dot {
  background: var(--amber);
}

.range-appointment-row.record-missing .range-appointment-dot {
  background: var(--coral);
}

.range-patient-main,
.range-patient-note,
.range-media-note,
.range-last-note {
  min-width: 0;
}

.range-patient-main strong,
.range-patient-main span,
.range-patient-note,
.range-media-note,
.range-last-note {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.range-patient-main strong {
  display: block;
  font-size: 15px;
  margin-bottom: 3px;
}

.range-patient-main span,
.range-patient-note,
.range-media-note,
.range-last-note {
  color: var(--muted);
  font-size: 12px;
}

.range-status-chip,
.range-record-chip {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  gap: 5px;
  justify-content: center;
  min-height: 28px;
  padding: 0 8px;
  white-space: nowrap;
}

.range-status-chip.waiting,
.range-status-chip.registered {
  background: #fff7ed;
  color: #8a4d08;
}

.range-status-chip.in_progress {
  background: #edf6ff;
  color: #1f5f90;
}

.range-status-chip.completed {
  background: #eef8f5;
  color: #0d675f;
}

.range-record-chip.written {
  background: #eef8f5;
  color: #0d675f;
}

.range-record-chip.partial {
  background: #fff7ed;
  color: #8a4d08;
}

.range-record-chip.missing {
  background: #fff1f2;
  color: #9a3412;
}

.day-board {
  min-width: 720px;
}

.day-board-head {
  align-items: center;
  background: #f8fbfc;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 700;
  gap: 10px;
  grid-template-columns: 72px minmax(240px, 1fr) 86px 94px minmax(150px, 0.8fr);
  padding: 9px 12px;
}

.day-board-body {
  display: grid;
}

.day-time-row {
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  min-height: 70px;
}

.day-time-row.is-empty {
  min-height: 38px;
}

.day-time-row > time {
  align-items: flex-start;
  background: #fbfcfd;
  border-right: 1px solid var(--line);
  color: #17272d;
  display: flex;
  font-size: 14px;
  font-weight: 700;
  justify-content: center;
  padding-top: 14px;
}

.day-time-row.is-empty > time {
  color: #93a0a6;
  font-size: 12px;
  padding-top: 10px;
}

.day-appointment-cell {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 7px;
}

.day-time-row.is-empty .day-appointment-cell {
  background-image: linear-gradient(90deg, rgba(215, 222, 226, 0.7) 0 1px, transparent 1px);
  background-position: 0 center;
  background-repeat: repeat-x;
  background-size: 10px 1px;
}

.day-patient-block {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(240px, 1fr) minmax(120px, 0.65fr) 86px 94px minmax(150px, 0.8fr);
  min-height: 58px;
  padding: 8px 10px;
  text-align: left;
  width: 100%;
}

.day-patient-block:hover {
  border-color: #9fdde8;
  box-shadow: 0 8px 18px rgba(0, 104, 126, 0.12);
}

.day-patient-block.is-active {
  border-color: var(--teal);
  box-shadow: var(--shadow);
}

.day-patient-block.record-written {
  border-left-color: var(--teal);
  background: linear-gradient(90deg, #f6fffd 0%, #ffffff 34%);
}

.day-patient-block.record-partial {
  border-left-color: var(--amber);
  background: linear-gradient(90deg, #fffaf1 0%, #ffffff 34%);
}

.day-patient-block.record-missing {
  border-left-color: var(--coral);
  background: linear-gradient(90deg, #fff6f5 0%, #ffffff 34%);
}

.day-patient-main,
.day-patient-meta {
  min-width: 0;
}

.day-patient-main strong,
.day-patient-main span,
.day-patient-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-patient-main strong {
  font-size: 15px;
  margin-bottom: 4px;
}

.day-patient-main span,
.day-patient-insight,
.day-patient-meta {
  color: var(--muted);
  font-size: 12px;
}

.day-patient-insight {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-board {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 820px;
  overflow: auto;
}

.week-board-head,
.week-time-row {
  display: grid;
  grid-template-columns: 72px repeat(7, minmax(120px, 1fr));
}

.week-board-head {
  background: #f8fbfc;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 2;
}

.week-board-head > span,
.week-board-head > button {
  background: transparent;
  border-right: 1px solid var(--line);
  border-bottom: 0;
  border-left: 0;
  border-top: 0;
  color: inherit;
  cursor: pointer;
  min-height: 48px;
  padding: 8px;
  text-align: left;
}

.week-board-head > span:first-child {
  align-items: center;
  cursor: default;
  display: flex;
}

.week-board-head > button:hover {
  background: #eef9fc;
}

.week-board-head > button:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

.week-board-head strong,
.week-board-head small,
.week-board-head em {
  display: block;
}

.week-board-head strong {
  color: var(--text);
  font-size: 14px;
}

.week-board-head small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.week-board-head em {
  color: #0d7184;
  font-size: 11px;
  font-style: normal;
  margin-top: 4px;
}

.week-board-head .is-today {
  background: #e6f8fb;
}

.week-board-head .has-pending em {
  color: #9a3412;
}

.week-time-row {
  border-bottom: 1px solid var(--line);
  min-height: 72px;
}

.week-time-row.is-empty {
  min-height: 38px;
}

.week-time-row.is-empty > time {
  color: #93a0a6;
  font-size: 12px;
  padding-top: 10px;
}

.week-time-row.is-empty .week-day-cell {
  min-height: 38px;
  padding: 4px 7px;
}

.week-time-row > time {
  align-items: flex-start;
  background: #fbfcfd;
  border-right: 1px solid var(--line);
  color: #17272d;
  display: flex;
  font-size: 14px;
  font-weight: 700;
  justify-content: center;
  padding-top: 14px;
}

.week-day-cell {
  border-right: 1px solid var(--line);
  display: grid;
  gap: 6px;
  min-height: 72px;
  padding: 7px;
}

.week-day-cell.is-today {
  background: #f4fcfd;
}

.week-patient-block {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  min-height: 58px;
  padding: 7px 8px;
  text-align: left;
  width: 100%;
}

.week-patient-block:hover {
  border-color: #9fdde8;
  box-shadow: 0 6px 16px rgba(0, 104, 126, 0.12);
}

.week-patient-block.is-active {
  border-color: var(--teal);
  box-shadow: var(--shadow);
}

.week-patient-block.record-written {
  border-left-color: var(--teal);
  background: linear-gradient(90deg, #f6fffd 0%, #ffffff 34%);
}

.week-patient-block.record-partial {
  border-left-color: var(--amber);
  background: linear-gradient(90deg, #fffaf1 0%, #ffffff 34%);
}

.week-patient-block.record-missing {
  border-left-color: var(--coral);
  background: linear-gradient(90deg, #fff6f5 0%, #ffffff 34%);
}

.week-patient-block strong,
.week-patient-block span,
.week-patient-block em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-patient-block strong {
  font-size: 13px;
  margin-bottom: 3px;
}

.week-patient-block span {
  color: var(--muted);
  font-size: 12px;
}

.week-patient-block em {
  color: #0d7184;
  font-size: 11px;
  font-style: normal;
  margin-top: 4px;
}

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

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

.readiness-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.readiness-card strong {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
}

.readiness-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
}

.sync-blocker-diagnostics {
  grid-column: 1 / -1;
}

.sync-blocker-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 4px 0;
}

.sync-blocker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.sync-blocker-pulse {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 8px;
}

.sync-blocker-pulse.ready {
  background: #eef8f5;
  border-color: rgba(0, 166, 150, 0.3);
}

.sync-blocker-pulse.blocked {
  background: #fff7ed;
  border-color: rgba(245, 158, 11, 0.28);
}

.sync-blocker-pulse strong,
.sync-blocker-pulse em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-blocker-pulse em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.readiness-card.ready {
  border-left: 3px solid var(--teal);
}

.readiness-card.blocked {
  border-left: 3px solid var(--amber);
}

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

.preview-link-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: 12px;
}

.preview-link-card.ready {
  border-left-color: var(--teal);
}

.preview-link-card.blocked {
  border-left-color: var(--amber);
}

.preview-link-card.command {
  border-left-color: #7c6f56;
}

.preview-link-card span,
.preview-link-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.preview-link-card span {
  display: block;
  margin-bottom: 4px;
}

.preview-link-card strong {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.preview-link-card p {
  margin: 0;
}

.preview-ip-check {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 8px;
  grid-column: 1 / -1;
  padding: 12px;
}

.preview-ip-check.ready {
  border-left-color: var(--teal);
}

.preview-ip-check.blocked {
  border-left-color: var(--amber);
}

.preview-ip-check label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.preview-ip-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.preview-ip-row input {
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  min-width: 0;
  padding: 9px 10px;
}

.preview-ip-check textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  min-height: 94px;
  padding: 9px 10px;
  resize: vertical;
  width: 100%;
}

.preview-ip-row button,
.preview-ip-actions button {
  background: var(--teal);
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  padding: 9px 12px;
}

.preview-ip-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.preview-ip-actions button.secondary {
  background: #ffffff;
  border: 1px solid var(--teal);
  color: var(--teal);
}

.preview-ip-check p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin: 8px 0 0;
}

.preview-ip-check pre {
  background: #f6f8f7;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.6;
  margin: 10px 0 0;
  overflow-x: auto;
  padding: 10px;
  white-space: pre-wrap;
}

.preview-copy-command {
  background: #ffffff;
  border: 1px solid var(--teal);
  border-radius: 8px;
  color: var(--teal);
  cursor: pointer;
  font-weight: 700;
  margin-top: 10px;
  padding: 8px 10px;
}

.preview-copy-command:hover {
  background: #e8f5f3;
}

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

.sync-status {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.sync-request-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin: -4px 0 12px;
  min-height: 18px;
}

.manual-snapshot-panel {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
}

.manual-snapshot-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.manual-snapshot-head strong,
.manual-snapshot-head span {
  display: block;
}

.manual-snapshot-head strong {
  font-size: 14px;
}

.manual-snapshot-head span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.manual-snapshot-head select {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  min-height: 36px;
  min-width: 160px;
  padding: 0 10px;
}

.manual-snapshot-panel textarea {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  line-height: 1.55;
  min-height: 112px;
  padding: 8px 10px;
  resize: vertical;
  width: 100%;
}

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

.sync-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: 8px;
  min-width: 0;
  padding: 12px;
}

.sync-card.ready {
  border-left-color: var(--teal);
}

.sync-card.blocked {
  border-left-color: var(--coral);
}

.sync-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.sync-card strong {
  display: block;
  font-size: 15px;
  margin-bottom: 6px;
}

.sync-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
}

.sync-card code {
  overflow-wrap: anywhere;
}

.sync-card .icon-text {
  margin-top: 10px;
}

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

.course-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: 10px;
}

.course-card.wide {
  grid-column: span 2;
}

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

.course-card strong {
  color: var(--text);
  display: block;
  font-size: 15px;
}

.course-card p {
  color: #435154;
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
}

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

.audit-item {
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: 8px;
  min-width: 0;
  padding: 10px;
}

.audit-item strong {
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-item span {
  color: var(--muted);
  font-size: 11px;
}

.audit-item p {
  color: #435154;
  font-size: 12px;
  line-height: 1.45;
  margin: 6px 0 0;
}

.previsit-list {
  display: grid;
  gap: 10px;
  grid-template-columns: 1.2fr repeat(5, minmax(0, 1fr));
}

.previsit-summary,
.previsit-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: 10px;
}

.previsit-item {
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.previsit-item:hover {
  border-color: var(--teal);
}

.previsit-summary {
  align-content: center;
  display: grid;
}

.previsit-summary strong,
.previsit-item strong {
  display: block;
  font-size: 13px;
  margin-bottom: 5px;
}

.previsit-summary span,
.previsit-item span {
  color: var(--muted);
  font-size: 12px;
}

.previsit-item p {
  color: #435154;
  font-size: 12px;
  line-height: 1.45;
  margin: 6px 0 0;
}

.previsit-summary.ready,
.previsit-item.ready {
  border-left: 3px solid var(--teal);
}

.previsit-summary.needs_review,
.previsit-item.needs_review,
.previsit-summary.needs_data,
.previsit-item.missing {
  border-left: 3px solid var(--amber);
}

.previsit-item.optional {
  background: #f8faf9;
}

.focus-flash {
  animation: focusFlash 1.4s ease;
}

@keyframes focusFlash {
  0% {
    box-shadow: 0 0 0 0 rgba(21, 128, 120, 0.32);
  }
  45% {
    box-shadow: 0 0 0 5px rgba(21, 128, 120, 0.18);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(21, 128, 120, 0);
  }
}

.capture-checklist {
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.capture-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: 12px;
}

.capture-step > div {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.capture-step strong,
.capture-step span {
  font-size: 13px;
}

.capture-step span {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  flex: 0 0 auto;
  padding: 2px 8px;
}

.capture-step p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  margin: 6px 0 0;
}

.field-matrix {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.field-pill {
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.3;
  max-width: 100%;
  padding: 4px 6px;
}

.field-pill.ready {
  background: #eef8f5;
  border-color: #b9ded5;
  color: #0d675f;
}

.field-pill.missing {
  background: #fff7ed;
  border-color: #f2c27a;
  color: #8a4d08;
}

.field-pill.optional {
  background: #f6f8fb;
  color: var(--muted);
}

.capture-step.ready {
  border-left: 3px solid var(--teal);
}

.capture-step.blocked {
  border-left: 3px solid var(--amber);
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.metric strong {
  display: block;
  font-size: 20px;
  margin-top: 8px;
}

.content-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
  padding: 16px;
}

.panel-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-heading h2 {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}

.panel-heading h2::before {
  background: var(--teal);
  border-radius: 999px;
  content: "";
  display: inline-block;
  height: 8px;
  width: 8px;
}

select {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  min-height: 34px;
  padding: 0 10px;
}

#timelineSearch {
  min-height: 34px;
  min-width: 150px;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  padding: 12px;
}

.timeline-item time {
  color: var(--muted);
  font-size: 12px;
}

.timeline-item h3 {
  font-size: 15px;
  margin: 4px 0 8px;
}

.timeline-item p {
  color: #3b474a;
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 8px;
}

.note-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.note-chip {
  background: var(--teal-ink);
  border-radius: 6px;
  color: #0e625d;
  font-size: 12px;
  padding: 6px 8px;
}

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

.timeline-section {
  background: #f8fbfa;
  border: 1px solid #dce9e5;
  border-radius: 6px;
  min-width: 0;
  padding: 8px 10px;
}

.timeline-section strong {
  color: #0f6f66;
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.timeline-section p {
  color: #2f3d40;
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
}

.timeline-section p + p {
  margin-top: 4px;
}

.timeline-media-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.timeline-media-chip {
  background: #f7efe8;
  border: 1px solid #ead6c7;
  border-radius: 6px;
  color: #7a4b2c;
  font-size: 12px;
  padding: 6px 8px;
}

.media-grid {
  display: grid;
  gap: 10px;
}

.media-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

.media-summary-item {
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: 9px 10px;
}

.media-summary-item span {
  color: var(--muted);
  display: block;
  font-size: 11px;
}

.media-summary-item strong {
  color: #243136;
  display: block;
  font-size: 16px;
  line-height: 1.35;
  margin-top: 2px;
}

.media-summary-item.needs-review {
  border-left: 3px solid var(--amber);
}

.media-summary-item.blocked {
  border-left: 3px solid var(--coral);
}

.media-summary-item.ready {
  border-left: 3px solid var(--teal);
}

.external-media-form {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 110px 130px;
  margin-top: 14px;
  padding-top: 14px;
}

.external-media-form input,
.external-media-form select {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 34px;
  min-width: 0;
  padding: 0 10px;
}

.external-media-form input[type="file"] {
  padding: 6px 8px;
}

.external-media-form input[type="text"] {
  grid-column: span 2;
}

#registerExternalMedia {
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  min-height: 34px;
  padding: 0 10px;
}

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

.source-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.source-card strong {
  font-size: 14px;
}

.source-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
  word-break: break-all;
}

.model-preview {
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 4px;
  padding: 8px;
}

.model-preview code {
  color: #334044;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.apply-preview {
  background: #eef8f5;
  border: 1px solid #b9ded5;
  border-left: 3px solid var(--teal);
  border-radius: 6px;
  display: grid;
  gap: 4px;
  padding: 8px;
}

.apply-preview strong {
  color: #0d675f;
  font-size: 13px;
}

.apply-preview ul {
  display: grid;
  gap: 6px;
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
}

.apply-preview li {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid #cde8e0;
  border-radius: 6px;
  padding: 6px;
}

.apply-preview li span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 2px;
}

.mapping-editor {
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 8px;
  padding: 8px;
}

.mapping-editor header,
.mapping-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(120px, 1fr) minmax(160px, 1.2fr);
}

.mapping-editor header span,
.mapping-row span {
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mapping-row select {
  min-width: 0;
  width: 100%;
}

.save-mapping-corrections {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #334044;
  cursor: pointer;
  justify-self: start;
  min-height: 30px;
  padding: 0 10px;
}

.save-mapping-corrections:hover {
  border-color: var(--teal);
  color: var(--teal);
}

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

.review-record {
  background: #f8faf9;
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: 6px;
  display: grid;
  gap: 6px;
  padding: 8px;
}

.review-record.ready {
  border-left-color: var(--teal);
}

.review-record.accepted {
  background: #eef8f5;
}

.review-record.skipped {
  background: #f5f6f6;
  border-left-color: #9aa3a7;
  opacity: 0.78;
}

.review-record header {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.review-record header span {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 11px;
  padding: 2px 8px;
}

.review-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.review-field {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #334044;
  font-size: 11px;
  max-width: 100%;
  padding: 4px 6px;
}

.review-field.missing {
  background: #fff7ed;
  border-color: #f2c27a;
  color: #8a4d08;
}

.review-editor {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  padding-top: 8px;
}

.review-editor label {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(110px, 0.7fr) minmax(180px, 1.3fr);
}

.review-editor label span {
  color: var(--muted);
  font-size: 12px;
}

.review-editor input {
  min-width: 0;
  width: 100%;
}

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

.review-record-actions button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #334044;
  cursor: pointer;
  min-height: 30px;
  padding: 0 10px;
}

.review-record-actions button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

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

.save-profile,
.create-import-batch {
  justify-self: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #334044;
  cursor: pointer;
  min-height: 32px;
  padding: 0 10px;
}

.save-profile:hover,
.create-import-batch:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.media-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.media-thumb {
  align-items: center;
  aspect-ratio: 16 / 9;
  background: #eef3f4;
  color: #3f5156;
  display: flex;
  font-size: 28px;
  justify-content: center;
}

.media-thumb img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.media-card div:last-child {
  padding: 10px;
}

.media-card strong {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
}

.media-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
}

.media-confirm-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 132px minmax(0, 1fr) 64px;
  margin-top: 10px;
}

.media-action-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

.media-action-row button {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: #1d4f5d;
  cursor: pointer;
  min-height: 32px;
  padding: 0 10px;
}

.media-action-row button:hover:not(:disabled) {
  border-color: var(--teal);
  color: var(--teal);
}

.media-thumb {
  border: 0;
  padding: 0;
  text-align: center;
  width: 100%;
}

.media-thumb.is-clickable {
  cursor: zoom-in;
}

.media-thumb:disabled {
  cursor: default;
}

.preview-media.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

body.media-preview-open {
  overflow: hidden;
}

.media-preview-modal[hidden] {
  display: none !important;
}

.media-preview-modal {
  inset: 0;
  position: fixed;
  z-index: 1200;
}

.media-preview-backdrop {
  background: rgba(11, 22, 27, 0.58);
  border: 0;
  cursor: zoom-out;
  height: 100%;
  inset: 0;
  padding: 0;
  position: absolute;
  width: 100%;
}

.media-preview-dialog {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: var(--shadow-strong);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  inset: 24px;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  position: absolute;
}

.media-preview-header,
.media-preview-footer {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px 18px;
}

.media-preview-footer {
  border-bottom: 0;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.media-preview-kicker {
  color: var(--teal);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.media-preview-header h2 {
  font-size: 18px;
  margin: 0;
}

.media-preview-header p {
  color: var(--muted);
  font-size: 13px;
  margin: 5px 0 0;
}

.media-preview-close {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-size: 26px;
  height: 38px;
  justify-content: center;
  line-height: 1;
  width: 38px;
}

.media-preview-body {
  background: #f4f7f8;
  display: grid;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.media-preview-body img,
.media-preview-body iframe {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(23, 33, 38, 0.08);
  display: block;
  margin: auto;
  max-height: calc(100vh - 190px);
  max-width: 100%;
}

.media-preview-body img {
  height: auto;
  object-fit: contain;
}

.media-preview-body iframe {
  height: calc(100vh - 190px);
  width: min(100%, 1100px);
}

.media-preview-empty {
  align-self: center;
  background: #ffffff;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  justify-self: center;
  max-width: 520px;
  padding: 24px;
  text-align: center;
}

.media-confirm-row input,
.media-confirm-row select {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 32px;
  min-width: 0;
  padding: 0 8px;
}

.media-confirm-row button {
  background: var(--teal);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  min-height: 32px;
}

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

.structured-note-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-column: 1 / -1;
  padding: 12px;
}

.structured-note-card header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.structured-note-card header > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

.structured-note-grid textarea {
  min-height: 88px;
}

label {
  display: grid;
  gap: 8px;
}

textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 126px;
  padding: 10px;
  resize: vertical;
  width: 100%;
}

.recorder-actions,
.confirm-row,
.confirm-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.icon-text,
#confirmDraft,
#createWritebackPreview,
#confirmWritebackPreview,
#createWritebackJob {
  border: 0;
  border-radius: 6px;
  background: var(--teal);
  color: #fff;
  cursor: pointer;
  min-height: 36px;
  padding: 0 12px;
}

.icon-text:hover:not(:disabled),
#confirmDraft:hover:not(:disabled),
#createWritebackPreview:hover:not(:disabled),
#confirmWritebackPreview:hover:not(:disabled),
#createWritebackJob:hover:not(:disabled),
#registerExternalMedia:hover:not(:disabled),
.media-confirm-row button:hover:not(:disabled) {
  filter: brightness(0.96);
}

.icon-text.secondary {
  background: #526165;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.confirm-row {
  border-top: 1px solid var(--line);
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 14px;
}

.writeback-preview {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.writeback-summary-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 8px 0;
}

.writeback-summary-card {
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 8px;
}

.writeback-summary-card small {
  color: var(--muted);
  font-size: 11px;
}

.writeback-summary-card strong {
  color: #243136;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.writeback-summary-card.ready {
  border-left: 3px solid var(--teal);
}

.writeback-summary-card.needs-review,
.writeback-summary-card.blocked {
  border-left: 3px solid var(--amber);
}

.writeback-copy-text {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  line-height: 1.5;
  margin-top: 8px;
  min-height: 112px;
  padding: 8px;
  resize: vertical;
  width: 100%;
}

.writeback-target-control {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.writeback-target-control span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.writeback-target-field {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  min-height: 38px;
  padding: 7px 9px;
  width: min(100%, 420px);
}

.diff-line {
  border-left: 3px solid var(--line);
  background: #f8faf9;
  border-radius: 6px;
  padding: 8px 10px;
}

.diff-line.added {
  border-left-color: var(--teal);
}

.diff-line.changed {
  border-left-color: var(--amber);
}

.diff-line.removed {
  border-left-color: var(--coral);
}

.diff-line p {
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    min-height: auto;
    position: static;
  }

  .patient-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
  }

  .content-grid,
  .audit-list,
  .case-command-grid,
  .capture-checklist,
  .course-summary,
  .external-media-form,
  .draft-layout,
  .media-confirm-row,
  .previsit-list,
  .preview-links-grid,
  .readiness-grid,
  .structured-note-grid,
  .summary-grid,
  .sync-status,
  .timeline-section-grid,
  .writeback-summary-grid {
    grid-template-columns: 1fr;
  }

  .case-command-tools {
    grid-template-columns: minmax(0, 1fr) 132px 92px;
    min-width: 0;
  }

  .case-list-header,
  .case-row {
    grid-template-columns: minmax(170px, 1fr) 92px 96px minmax(170px, 1fr);
  }

  .case-history-overview-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .external-media-form input[type="text"] {
    grid-column: auto;
  }

  .range-overview-head {
    align-items: stretch;
    flex-direction: column;
  }

  .week-board {
    min-width: 760px;
  }

  .day-board {
    min-width: 680px;
  }

  .range-appointment-row {
    grid-template-columns: 58px 14px minmax(160px, 1fr) minmax(120px, 0.8fr);
  }

  .range-appointment-header {
    grid-template-columns: 58px 14px minmax(160px, 1fr) minmax(120px, 0.8fr);
  }

  .range-appointment-header span:nth-child(n + 4) {
    display: none;
  }

  .range-status-chip,
  .range-record-chip,
  .range-media-note,
  .range-last-note {
    grid-column: span 1;
  }

  .range-appointment-row::before {
    left: 74px;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 14px;
  }

  .patient-header,
  .panel-heading,
  .confirm-row {
    align-items: stretch;
    flex-direction: column;
  }

  .patient-list {
    grid-template-columns: 1fr;
  }

  .status-strip {
    justify-content: flex-start;
  }

  .range-overview-counts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .case-command-tools,
  .case-history-overview-list,
  .case-insight-strip,
  .case-summary-strip,
  .case-writer-insights,
  .case-writer-actions,
  .case-writer-grid {
    grid-template-columns: 1fr;
  }

  .case-list-shell {
    overflow-x: auto;
  }

  .case-list-header,
  .case-row {
    grid-template-columns: minmax(190px, 1fr) 92px 102px minmax(190px, 1fr);
    min-width: 640px;
  }

  .case-writer-header {
    align-items: stretch;
    flex-direction: column;
  }

  .manual-snapshot-head {
    align-items: stretch;
    flex-direction: column;
  }

  .manual-snapshot-head select {
    min-width: 0;
  }

  .range-focus-filter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .week-board {
    min-width: 700px;
  }

  .day-board {
    min-width: 640px;
  }

  .day-board-head {
    grid-template-columns: 64px minmax(190px, 1fr) 82px 90px minmax(120px, 0.8fr);
  }

  .day-time-row {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .day-patient-block {
    grid-template-columns: minmax(180px, 1fr) 82px 90px minmax(120px, 0.8fr);
  }

  .range-appointment-row {
    align-items: start;
    grid-template-columns: 54px 14px minmax(0, 1fr);
    padding-right: 10px;
  }

  .range-appointment-header {
    grid-template-columns: 54px 14px minmax(0, 1fr);
  }

  .range-appointment-header span:nth-child(n + 3) {
    display: none;
  }

  .range-patient-note,
  .range-status-chip,
  .range-record-chip,
  .range-media-note,
  .range-last-note {
    grid-column: 3;
  }

  .range-appointment-row::before {
    left: 70px;
  }
}

/* Daily clinical workspace: keep only records, history, templates, and photos/media. */
.case-command-tools,
.case-summary-strip,
.case-insight-strip,
.case-patient-context,
.case-list-shell,
#patientSummaryPanel,
#coursePanel,
#preVisitPanel,
.readiness-panel,
.preview-links-panel,
.audit-panel,
.sync-panel,
.source-panel,
.import-panel,
.normalization-panel,
#timelinePanel {
  display: none !important;
}

.workspace {
  gap: 16px;
}

#caseCommandPanel {
  order: 2;
}

#rangeOverviewPanel {
  display: block;
  order: 1;
}

#patientDetailGrid {
  order: 3;
  display: block;
}

#mediaPanel {
  width: 100%;
}

.case-command-grid {
  display: block;
}

.case-writer-header div:last-child span:first-child {
  background: var(--blue-ink);
  border: 1px solid #c9dfef;
  border-radius: 6px;
  color: var(--blue);
  display: inline-flex;
  font-weight: 700;
  min-height: 30px;
  padding: 5px 8px;
}

.case-history-overview {
  margin-bottom: 12px;
}

.case-history-overview-list {
  max-height: min(48vh, 520px);
  overflow: auto;
}

.case-history-overview-card em,
.case-history-preview {
  -webkit-line-clamp: 4;
}

/* Focused clinical charting shell: current note first, history references below, media only. */
.patient-header {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(23, 33, 38, 0.05);
  padding: 14px 16px;
}

.patient-header .eyebrow,
#caseCommandDescription {
  display: none;
}

#patientName {
  font-size: 22px;
  line-height: 1.2;
  margin: 0 0 4px;
}

#caseCommandPanel {
  display: flex;
  flex-direction: column;
}

#caseCommandPanel[hidden],
#caseCommandPanel.is-hidden {
  display: none !important;
}

#caseCommandPanel .panel-heading {
  order: 0;
  padding-bottom: 6px;
}

#caseCommandPanel .panel-heading h2 {
  font-size: 18px;
  margin: 0;
}

#caseCommandPanel .case-command-grid {
  order: 1;
}

#caseHistoryOverview {
  order: 2;
}

#casePatientContext {
  order: 3;
}

.case-writer {
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(23, 33, 38, 0.06);
  gap: 12px;
  padding: 14px;
}

.case-writer-header {
  align-items: center;
}

.case-writer-header > div:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.case-writer-header > div:last-child span {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  display: inline-flex;
  min-height: 28px;
  padding: 4px 8px;
}

.case-writer-grid {
  gap: 10px;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.case-writer textarea {
  min-height: 88px;
}

#caseDraftPreview {
  min-height: 112px;
}

.case-writer-actions {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.case-history-overview {
  background: #ffffff;
  border-radius: 8px;
}

.case-history-overview header {
  padding: 12px 14px;
}

.case-history-overview-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  max-height: min(36vh, 420px);
  padding: 0 12px 12px;
}

.case-history-overview-list.is-patient-timeline {
  gap: 0;
  grid-template-columns: minmax(0, 1fr);
  max-height: min(62vh, 760px);
  padding: 0 12px 12px;
}

.case-history-overview-card {
  background: var(--surface-soft);
}

.case-history-overview-list.is-patient-timeline .case-history-overview-card {
  background: #ffffff;
}

#recorderPanel {
  background: #ffffff;
}

#recorderPanel .structured-note-card,
#recorderPanel label:has(#draftNote) {
  display: none;
}

#recorderPanel .panel-heading {
  align-items: center;
  gap: 12px;
}

#recorderPanel .panel-heading h2 {
  font-size: 18px;
  margin: 0;
}

#recorderPanel .recorder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

#recorderPanel .draft-layout {
  display: block;
}

#recorderPanel label:has(#transcript) {
  display: grid;
  gap: 6px;
}

#transcript {
  min-height: 138px;
}

#recorderPanel .confirm-row {
  align-items: flex-start;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, 2fr);
  padding-top: 12px;
}

#recorderPanel .confirm-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

#mediaPanel {
  background: #ffffff;
}

#mediaPanel .panel-heading {
  align-items: center;
}

.media-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.media-card {
  align-items: stretch;
  background: #ffffff;
  border-color: var(--line);
  box-shadow: 0 8px 20px rgba(23, 33, 38, 0.05);
}

.media-thumb {
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  min-height: 118px;
}

.external-media-form {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 12px;
  padding: 10px;
}

@media (max-width: 1180px) {
  .case-writer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #recorderPanel .confirm-row,
  #recorderPanel .confirm-actions {
    grid-template-columns: 1fr;
  }
}
