:root {
  color-scheme: light;
  --bg: #f4f8f7;
  --surface: #ffffff;
  --surface-soft: #f8fbfb;
  --surface-raised: #ffffff;
  --panel-2: #edf5f3;
  --text: #17212b;
  --muted: #64748b;
  --line: #d9e5e3;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --primary: #0f766e;
  --primary-soft: #dff7f1;
  --secondary: #155e75;
  --clinical-blue: #155e75;
  --accent: #f59e0b;
  --success: #15803d;
  --danger: #b91c1c;
  --focus: #2563eb;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.07);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-bg: #f9fcfb;
  --sidebar-active: #e3f7f2;
  --content-max: 1480px;
  --touch-target: 40px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

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

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-target);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  font-weight: 700;
  max-width: 100%;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

button:hover,
.button-link:hover {
  border-color: #b6c7d4;
  background: #f8fbfb;
  box-shadow: var(--shadow-soft);
}

.button-link.disabled,
.button-link[aria-disabled="true"] {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.62;
  pointer-events: none;
}

button.primary,
.button-link.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

button.primary:hover,
.button-link.primary:hover {
  background: var(--brand-dark);
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

input,
select,
textarea {
  width: 100%;
  min-height: var(--touch-target);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

img,
svg,
canvas,
video {
  max-width: 100%;
}

input:focus,
select:focus,
textarea:focus,
button:focus,
.button-link:focus {
  outline: 2px solid color-mix(in srgb, var(--focus) 28%, transparent);
  outline-offset: 2px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: #526575;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  background: #f8fbfb;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
  min-width: 0;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.07), transparent 34%),
    var(--bg);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
  background: var(--sidebar-bg);
  color: var(--text);
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  box-shadow: 8px 0 30px rgba(15, 23, 42, 0.03);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0;
  padding: 10px;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius);
}

.brand strong {
  font-size: 18px;
  font-weight: 800;
}

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

.brand-mark {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #dff7f1, #eef9ff);
  color: var(--brand);
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.12);
}

.nav {
  display: grid;
  gap: 16px;
  align-content: start;
  overflow: auto;
  padding-right: 4px;
}

.nav-group {
  display: grid;
  gap: 5px;
}

.nav-group-title {
  color: #80909d;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 12px;
}

.nav a,
.nav button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  color: #334155;
  background: transparent;
  border: 0;
  border-radius: 10px;
  min-height: 42px;
  padding: 10px 12px;
  text-align: left;
  text-decoration: none;
  font-weight: 700;
}

.nav a.active,
.nav a:hover,
.nav button:hover {
  background: var(--sidebar-active);
  color: var(--brand-dark);
  box-shadow: inset 3px 0 0 var(--brand);
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.sidebar-footer button {
  width: 100%;
}

.content {
  width: 100%;
  max-width: var(--content-max);
  min-width: 0;
  margin: 0 auto;
  padding: 28px;
  overflow: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
  padding: 18px 20px;
  border: 1px solid rgba(216, 225, 234, 0.8);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
  min-width: 0;
}

.topbar-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.page-heading {
  min-width: 0;
}

.page-kicker {
  display: inline-flex;
  margin-bottom: 6px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

.page-title {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 0;
}

.page-subtitle {
  margin: 7px 0 0;
  max-width: 760px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.user-context-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(320px, 100%);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
}

.user-context-card > span:last-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.user-context-card strong,
.user-context-card span span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.user-avatar {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  background: var(--primary-soft);
  color: var(--brand-dark);
  font-weight: 900;
}

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

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #edf5f3;
  min-width: 0;
}

.tab {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 750;
  text-decoration: none;
}

.tab:hover {
  background: var(--surface-soft);
  color: var(--clinical-blue);
}

.tab.active {
  background: var(--surface);
  border-color: rgba(15, 118, 110, 0.18);
  color: var(--brand);
  box-shadow: var(--shadow-soft);
}

.panel h2,
.panel h3 {
  color: var(--clinical-blue);
}

.panel h2:first-child,
.panel h3:first-child {
  margin-top: 0;
}

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

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

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

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

.inline-form {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}

.inline-form label {
  flex: 0 1 220px;
}

.inline-form button {
  flex: 0 0 auto;
}

.compact-inline-form {
  margin: 4px 0;
}

.compact-inline-form .muted {
  font-size: 12px;
}

.opd-filter-form {
  max-width: none;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.opd-vitals-line {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--clinical-blue);
}

.opd-vitals-panel {
  border-left: 4px solid var(--brand);
}

.frontdesk-tabs {
  width: fit-content;
  max-width: 100%;
}

.frontdesk-work-panel {
  border-color: rgba(15, 118, 110, 0.18);
}

.frontdesk-work-panel > .section-title-row:first-child {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.frontdesk-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
}

.frontdesk-table {
  margin: 0;
  border: 0;
}

.frontdesk-table th {
  background: #f2f8f7;
  color: var(--clinical-blue);
}

.frontdesk-table th,
.frontdesk-table td {
  vertical-align: top;
}

.frontdesk-table tr:last-child td {
  border-bottom: 0;
}

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

.form-section-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.form-section-card h3 {
  margin: 0 0 10px;
}

.patient-results-table .badge {
  margin-top: 4px;
}

.patient-identifier-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

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

.patient-result-row-editing td {
  background: #f0fdfa;
}

.patient-edit-detail-row td {
  background: #f8fbfb;
}

.patient-edit-form,
.appointment-reschedule-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.compact-heading {
  margin-bottom: 0;
}

.appointment-booking-panel .appointment-patient-lookup {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8fbfb;
}

.appointment-patient-empty {
  margin: 0;
}

.appointment-lookup-results table {
  font-size: 14px;
}

.appointment-date-filter {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8fbfb;
}

.frontdesk-token,
.opd-token-card {
  display: inline-grid;
  gap: 3px;
  min-width: 126px;
  padding: 8px 10px;
  border: 1px solid #99f6e4;
  border-radius: 10px;
  background: #f0fdfa;
  color: var(--brand);
}

.frontdesk-token strong,
.opd-token-card strong {
  font-size: 13px;
  line-height: 1.2;
}

.frontdesk-token small,
.opd-token-card small {
  color: var(--muted);
  font-weight: 700;
}

.frontdesk-token.pending {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--clinical-blue);
}

.appointment-queue-table .badge,
.opd-queue-table .badge {
  white-space: normal;
}

.opd-queue-row td:first-child {
  border-left: 4px solid var(--brand);
}

.opd-queue-status-in-consultation td:first-child {
  border-left-color: #6366f1;
}

.opd-queue-row-highlight td {
  background: #ecfeff;
  box-shadow: inset 0 0 0 999px rgba(20, 184, 166, 0.06);
}

.opd-queue-row-highlight td:first-child {
  border-left-color: #0f766e;
}

.opd-investigation-flow-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.vitals-patient-strip {
  display: flex;
  align-items: start;
  gap: 14px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.vitals-patient-strip h2 {
  margin: 0 0 4px;
}

.vitals-card-grid label {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.compact-inline-form {
  display: grid;
  gap: 8px;
  min-width: 220px;
}

.compact-inline-form label {
  font-size: 12px;
}

.media-preview-thumb {
  display: inline-block;
  max-height: 54px;
  max-width: 140px;
  object-fit: contain;
  vertical-align: middle;
}

.admin-workspace-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid rgba(21, 94, 117, 0.14);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.1), transparent 42%),
    var(--surface);
  box-shadow: var(--shadow);
}

.admin-workspace-hero h2 {
  margin: 2px 0 6px;
  color: var(--clinical-blue);
  font-size: 26px;
  line-height: 1.15;
}

.admin-workspace-hero p:last-child {
  max-width: 740px;
  margin: 0;
  color: var(--muted);
}

.admin-hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(118px, 1fr));
  gap: 10px;
}

.admin-hero-stat {
  display: grid;
  gap: 2px;
  min-width: 118px;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow-soft);
}

.admin-hero-stat strong {
  color: var(--brand-dark);
  font-size: 21px;
  line-height: 1.1;
}

.admin-hero-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.admin-workspace-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.admin-workspace-grid > .panel {
  margin-bottom: 0;
}

.admin-setup-panel,
.admin-form-panel,
.session-security-card {
  border-color: rgba(15, 118, 110, 0.14);
}

.admin-form-panel {
  background:
    linear-gradient(180deg, #ffffff, #f9fcfb);
}

.admin-media-upload {
  border-style: dashed;
  background: #f8fbfb;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
}

.admin-table {
  min-width: 760px;
}

.admin-table th {
  background: #f2f8f7;
  color: var(--clinical-blue);
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-media-cell {
  display: grid;
  gap: 8px;
  justify-items: start;
}

button.subtle-danger,
.subtle-danger {
  min-height: 34px;
  padding-inline: 10px;
  background: #fff5f5;
  border-color: #fecaca;
  color: var(--danger);
  box-shadow: none;
}

button.subtle-danger:hover,
.subtle-danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.empty-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fbfb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.admin-user-table td:last-child {
  min-width: 210px;
}

.user-access-chip-list,
.permission-chip-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.user-access-chip {
  display: grid;
  gap: 2px;
  min-width: 170px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbfb;
}

.user-access-chip span:not(.badge) {
  color: var(--text);
  font-weight: 750;
}

.user-access-chip small {
  color: var(--muted);
  font-size: 11px;
}

.user-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.user-row-actions button,
.user-row-actions .button-link {
  min-height: 34px;
  padding-inline: 10px;
}

.user-management-controls {
  display: grid;
  gap: 10px;
  min-width: 320px;
}

.compact-actions {
  margin-top: 0;
}

.admin-inline-access-form {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.admin-inline-access-form .grid-3 {
  grid-template-columns: repeat(3, minmax(110px, 1fr));
}

.user-access-detail-row td {
  padding: 0;
  background: #f8fbfb;
}

.user-access-detail-panel {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 16px;
  border-top: 1px solid rgba(15, 118, 110, 0.18);
  border-bottom: 1px solid rgba(15, 118, 110, 0.18);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 36%),
    #f8fbfb;
}

.user-access-detail-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.user-access-detail-header h3,
.user-access-detail-panel h4 {
  margin: 0;
  color: var(--clinical-blue);
}

.user-access-detail-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(340px, 1.1fr);
  gap: 16px;
  align-items: start;
}

.user-access-assignment-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.user-access-assignment {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.user-access-assignment > div {
  display: grid;
  gap: 3px;
}

.user-access-assignment strong {
  color: var(--text);
}

.user-access-assignment small {
  color: var(--muted);
}

.user-access-assign-form {
  margin: 0;
  background: var(--surface);
}

.rbac-matrix-panel .badge {
  margin: 0;
}

.doctor-profile-panel .media-preview-thumb {
  max-height: 42px;
}

.doctor-create-card {
  display: grid;
  gap: 14px;
}

.doctor-create-sections {
  display: grid;
  gap: 14px;
}

.doctor-create-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.doctor-create-section h3 {
  margin: 0;
  color: var(--clinical-blue);
}

.doctor-create-section .section-eyebrow {
  margin-bottom: 2px;
}

.doctor-user-section {
  border-color: rgba(15, 118, 110, 0.22);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 42%),
    var(--surface-soft);
}

.doctor-user-guidance {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
  color: var(--clinical-blue);
}

.doctor-user-guidance strong {
  font-size: 13px;
}

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

.doctor-create-actions {
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.audit-log-table strong {
  color: var(--clinical-blue);
}

.session-security-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(180px, 0.5fr));
  gap: 14px;
  align-items: stretch;
}

.session-meta-card {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.session-meta-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.session-meta-card strong {
  overflow-wrap: anywhere;
  color: var(--text);
}

.billing-order-line {
  display: grid;
  gap: 3px;
  margin: 4px 0;
}

.tariff-inactive-row {
  color: var(--muted);
  background: #f8fafc;
}

.section-heading-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.investigation-workbench-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid rgba(21, 94, 117, 0.12);
  border-radius: 18px;
  background: linear-gradient(135deg, #ffffff 0%, #edf7f5 100%);
  box-shadow: var(--shadow-soft);
}

.investigation-workbench-hero h2 {
  margin: 0;
}

.investigation-hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 10px;
}

.investigation-hero-stats span {
  display: grid;
  gap: 2px;
  min-width: 96px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
}

.investigation-hero-stats strong {
  color: var(--text);
  font-size: 1.06rem;
}

.investigation-hero-stats small {
  color: var(--muted);
}

.investigation-workflow-panel,
.lab-report-workspace-panel,
.report-template-manager {
  border-color: rgba(15, 118, 110, 0.12);
  box-shadow: var(--shadow-soft);
}

.investigation-filter-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(180px, 0.55fr) minmax(260px, 1.1fr);
  gap: 12px;
  align-items: end;
}

.investigation-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.investigation-pagination-summary {
  margin: 12px 0 0;
}

.investigation-tab-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: -6px 0 14px;
}

.investigation-stage-card {
  display: grid;
  gap: 2px;
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.investigation-stage-card:hover,
.investigation-stage-card.active {
  border-color: rgba(15, 118, 110, 0.32);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.investigation-stage-card.active {
  background: #ecfdf5;
  box-shadow: inset 4px 0 0 var(--brand), var(--shadow-soft);
}

.investigation-stage-card strong {
  color: var(--clinical-blue);
  font-size: 1.3rem;
}

.investigation-stage-card span {
  font-weight: 800;
}

.investigation-stage-card small {
  color: var(--muted);
}

.investigation-worklist-table {
  width: 100%;
  overflow-x: auto;
}

.investigation-worklist-table table {
  margin-top: 0;
}

.investigation-worklist-row td {
  vertical-align: top;
}

.investigation-next-action {
  display: grid;
  gap: 8px;
  min-width: 170px;
}

.investigation-next-action .actions {
  margin: 0;
}

.investigation-action-block {
  display: grid;
  gap: 4px;
}

.investigation-action-block .button-link,
.investigation-action-block button,
.investigation-next-action > .button-link,
.investigation-next-action > button {
  width: fit-content;
}

.investigation-action-block button[disabled],
.investigation-next-action button[disabled] {
  opacity: 0.58;
  cursor: not-allowed;
}

.investigation-cancel-form {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.investigation-worklist-row td:first-child {
  border-left: 4px solid transparent;
}

.investigation-stage-ordered td:first-child {
  border-left-color: var(--clinical-blue);
}

.investigation-stage-sample td:first-child {
  border-left-color: var(--accent);
}

.investigation-stage-reporting td:first-child {
  border-left-color: #6366f1;
}

.investigation-stage-reported td:first-child {
  border-left-color: var(--success);
}

.investigation-stage-cancelled td:first-child {
  border-left-color: #94a3b8;
}

.investigation-worklist-row.investigation-stage-ordered {
  background: #f0fdfa;
}

.investigation-worklist-row.investigation-stage-sample {
  background: #fffbeb;
}

.investigation-worklist-row.investigation-stage-reporting {
  background: #f5f3ff;
}

.investigation-worklist-row.investigation-stage-reported {
  background: #f0fdf4;
}

.investigation-worklist-row.investigation-stage-cancelled {
  background: #f8fafc;
  color: var(--muted);
}

.active-investigation-row {
  outline: 2px solid rgba(15, 118, 110, 0.24);
  outline-offset: -2px;
}

.investigation-report-panel {
  border-left: 4px solid var(--brand);
}

.lab-report-workspace-panel {
  scroll-margin-top: 18px;
}

.investigation-report-context {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 14px;
}

.investigation-report-context span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.investigation-report-context strong,
.investigation-report-context small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.investigation-report-context small {
  color: var(--muted);
}

.structured-report-form,
.free-text-report-fallback form {
  margin-top: 12px;
}

.structured-report-form .actions,
.free-text-report-fallback .actions,
.report-review-form.actions {
  justify-content: flex-end;
}

.report-review-form {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.report-template-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 12px 0;
  padding: 12px;
}

.report-template-section legend {
  color: var(--clinical-blue);
  font-weight: 700;
  padding: 0 6px;
}

.field-hint {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  margin-top: 4px;
}

.report-format-summary {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
  padding: 10px;
}

.report-format-summary span {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 4px 10px;
}

.report-print-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 16px;
  padding: 14px;
}

.lab-report-brand {
  align-items: center;
  border-bottom: 3px solid var(--brand);
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
}

.lab-report-brand h2 {
  color: #0f172a;
  letter-spacing: 0;
  margin: 0;
}

.lab-report-brand p {
  color: var(--muted);
  margin: 4px 0 0;
}

.lab-report-qr {
  align-items: center;
  border: 2px solid #0f172a;
  color: var(--muted);
  display: flex;
  font-size: 0.75rem;
  height: 56px;
  justify-content: center;
  width: 56px;
}

.report-title-block {
  margin-bottom: 10px;
  text-align: center;
}

.report-title-block h3 {
  margin: 0;
  text-transform: uppercase;
}

.report-title-block p {
  margin: 4px 0 0;
}

.report-print-header {
  border: 1px solid #334155;
  margin-bottom: 14px;
  padding: 12px;
}

.report-print-meta {
  display: grid;
  gap: 5px 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-result-table th {
  border-bottom: 2px solid #334155;
  color: #0f172a;
  text-transform: uppercase;
}

.report-section-row td {
  background: #f1f5f9;
  color: var(--clinical-blue);
  font-weight: 700;
  text-align: center;
}

.report-interpretation {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 14px;
  padding: 12px;
}

.report-interpretation ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.report-end {
  color: var(--muted);
  margin-bottom: 0;
  text-align: center;
}

.lab-report-signature {
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  justify-content: flex-end;
  margin-top: 48px;
  padding-top: 12px;
}

.report-template-manager h3 {
  margin-top: 18px;
}

.report-template-field-editor {
  margin: 14px 0;
  overflow-x: auto;
}

.report-template-field-editor input,
.report-template-field-editor select {
  min-width: 110px;
}

.report-template-builtins {
  margin-top: 14px;
}

.investigation-tabs .badge {
  margin-left: 6px;
}

.investigation-cancelled-link {
  justify-content: flex-end;
  margin-top: -4px;
  margin-bottom: 10px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.84rem;
  padding: 4px 10px;
}

.result-flag-high,
.result-flag-low {
  background: #fff7ed;
}

.result-flag-critical_high,
.result-flag-critical_low {
  background: #fee2e2;
  color: var(--danger);
  font-weight: 700;
}

@media (max-width: 980px) {
  .investigation-workbench-hero,
  .investigation-filter-row,
  .investigation-report-context {
    grid-template-columns: 1fr;
  }

  .investigation-hero-stats,
  .investigation-tab-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .investigation-hero-stats,
  .investigation-tab-summary {
    grid-template-columns: 1fr;
  }

  .investigation-pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  .investigation-stage-card {
    min-height: auto;
  }
}

.prescription-investigation-strip {
  align-items: center;
  border-left: 4px solid var(--clinical-blue);
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.2fr);
}

.prescription-investigation-strip h2 {
  margin-bottom: 4px;
}

.prescription-investigation-strip-pending {
  border-left-color: var(--accent);
}

.prescription-investigation-strip-review {
  border-left-color: var(--clinical-blue);
}

.prescription-investigation-strip-ready {
  border-left-color: var(--success);
}

.prescription-investigation-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.investigation-status-chip {
  align-items: flex-start;
  display: grid;
  gap: 2px;
  min-height: 48px;
  min-width: 160px;
  padding: 7px 10px;
  text-align: left;
  white-space: normal;
}

.investigation-status-chip-disabled {
  cursor: default;
  opacity: 0.82;
}

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

.investigation-status-chip.pending {
  background: #fffbeb;
  border-color: #f6c453;
}

.investigation-status-chip.reported {
  background: #eff6ff;
  border-color: #93c5fd;
}

.investigation-status-chip.reviewed {
  background: #ecfdf5;
  border-color: #86efac;
}

.investigation-status-chip.cancelled {
  background: #f8fafc;
  border-color: var(--line);
  color: var(--muted);
}

.prescription-investigation-report-drawer {
  border-left: 4px solid var(--clinical-blue);
}

.prescription-investigation-result-table {
  margin-top: 12px;
}

.medicine-dictation-panel {
  border-left: 4px solid var(--brand);
}

.compact-actions {
  margin-top: 6px;
}

@media (max-width: 900px) {
  .prescription-investigation-strip {
    grid-template-columns: 1fr;
  }

  .prescription-investigation-chips {
    justify-content: flex-start;
  }
}

@media print {
  @page {
    size: A4;
    margin: 9mm;
  }

  html,
  body {
    background: #ffffff;
    color: #17212b;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    line-height: 1.16;
    min-height: auto;
    width: 100%;
  }

  body.printing-investigation-report * {
    visibility: hidden;
  }

  body.printing-investigation-report .shell,
  body.printing-investigation-report .content,
  body.printing-investigation-report .investigation-report-panel,
  body.printing-investigation-report .report-print-preview,
  body.printing-investigation-report .report-print-preview * {
    visibility: visible;
  }

  body.printing-investigation-report .sidebar,
  body.printing-investigation-report .topbar,
  body.printing-investigation-report .content > :not(.investigation-report-panel),
  body.printing-investigation-report .investigation-report-panel > :not(.report-print-preview) {
    display: none !important;
  }

  body.printing-investigation-report .shell,
  body.printing-investigation-report .content,
  body.printing-investigation-report .investigation-report-panel {
    border: 0 !important;
    box-shadow: none !important;
    display: block !important;
    margin: 0 !important;
    min-height: auto;
    overflow: visible !important;
    padding: 0 !important;
    width: 100% !important;
  }

  body.printing-investigation-report .report-print-preview {
    -webkit-print-color-adjust: exact;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    color: #17212b;
    display: block;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 9.5px;
    line-height: 1.14;
    margin: 0;
    max-width: 100%;
    padding: 0;
    position: static;
    print-color-adjust: exact;
    width: 100%;
  }

  body.printing-investigation-report .lab-report-brand {
    align-items: flex-start;
    border-bottom: 1px solid #94a3b8;
    margin-bottom: 5px;
    padding-bottom: 5px;
  }

  body.printing-investigation-report .lab-report-brand h2 {
    font-size: 18px;
    line-height: 1.05;
  }

  body.printing-investigation-report .lab-report-brand p {
    font-size: 8.8px;
    line-height: 1.15;
    margin-top: 1.5px;
  }

  body.printing-investigation-report .lab-report-qr {
    display: none !important;
  }

  body.printing-investigation-report .media-preview-thumb {
    max-height: 30px;
    max-width: 92px;
  }

  body.printing-investigation-report .report-title-block {
    margin-bottom: 5px;
    text-align: center;
  }

  body.printing-investigation-report .report-title-block h3 {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.05;
  }

  body.printing-investigation-report .report-title-block p {
    font-size: 10px;
    font-weight: 700;
    margin: 1px 0 0;
    text-transform: uppercase;
  }

  body.printing-investigation-report .report-print-header {
    border: 0.8px solid #64748b;
    margin-bottom: 5px;
    padding: 5px 7px;
  }

  body.printing-investigation-report .report-print-meta {
    gap: 1.5px 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.printing-investigation-report .report-print-meta span {
    font-size: 9.4px;
    line-height: 1.16;
    min-width: 0;
  }

  body.printing-investigation-report .report-result-table {
    border-collapse: collapse;
    table-layout: fixed;
    width: 100%;
  }

  body.printing-investigation-report .report-result-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body.printing-investigation-report .report-result-table th,
  body.printing-investigation-report .report-result-table td {
    border-bottom: 0.6px solid #d8e1ea;
    font-size: 9.5px;
    line-height: 1.08;
    padding: 1.5px 3px;
    vertical-align: top;
  }

  body.printing-investigation-report .report-result-table th {
    border-bottom: 1.2px solid #334155;
    color: #0f172a;
    font-size: 9.2px;
    font-weight: 700;
  }

  body.printing-investigation-report .report-result-table th:nth-child(1),
  body.printing-investigation-report .report-result-table td:nth-child(1) {
    width: 34%;
  }

  body.printing-investigation-report .report-result-table th:nth-child(2),
  body.printing-investigation-report .report-result-table td:nth-child(2) {
    width: 16%;
  }

  body.printing-investigation-report .report-result-table th:nth-child(3),
  body.printing-investigation-report .report-result-table td:nth-child(3) {
    width: 13%;
  }

  body.printing-investigation-report .report-result-table th:nth-child(4),
  body.printing-investigation-report .report-result-table td:nth-child(4) {
    width: 25%;
  }

  body.printing-investigation-report .report-result-table th:nth-child(5),
  body.printing-investigation-report .report-result-table td:nth-child(5) {
    width: 12%;
  }

  body.printing-investigation-report .report-section-row td {
    background: #f8fafc;
    color: #155e75;
    font-size: 10px;
    padding: 1.75px 3px;
    text-transform: uppercase;
  }

  body.printing-investigation-report .report-interpretation {
    border: 0.8px solid #d8e1ea;
    border-radius: 0;
    break-inside: avoid;
    margin-top: 5px;
    padding: 4px 5px;
    page-break-inside: avoid;
  }

  body.printing-investigation-report .report-interpretation ul {
    margin: 2px 0 0;
    padding-left: 11px;
  }

  body.printing-investigation-report .report-print-preview p {
    margin: 4px 0;
  }

  body.printing-investigation-report .lab-report-signature {
    border-top: 0.8px solid #d8e1ea;
    break-inside: avoid;
    font-size: 9px;
    margin-top: 14px;
    padding-top: 5px;
    page-break-inside: avoid;
  }

  body.printing-investigation-report .report-end {
    font-size: 8.8px;
    margin-top: 6px;
  }
}

.billing-desk-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid rgba(21, 94, 117, 0.12);
  border-radius: 18px;
  background: linear-gradient(135deg, #ffffff 0%, #eefdfa 100%);
  box-shadow: var(--shadow-soft);
}

.billing-desk-hero h2 {
  margin: 0;
}

.billing-desk-hero-stats,
.billing-collection-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.billing-desk-hero-stats span,
.billing-collection-summary span {
  display: grid;
  gap: 2px;
  min-width: 120px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
}

.billing-desk-hero-stats strong,
.billing-collection-summary strong {
  color: var(--text);
  font-size: 1.06rem;
}

.billing-desk-hero-stats small,
.billing-collection-summary small,
.billing-collection-summary em {
  color: var(--muted);
  font-style: normal;
}

.billing-desk-layout,
.billing-collect-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.9fr);
  gap: 18px;
  align-items: start;
}

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

.billing-desk-main {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.billing-desk-side {
  display: grid;
  gap: 14px;
}

.billing-inline-payment-details {
  scroll-margin-top: 18px;
}

.billing-worklist-panel,
.billing-new-bill-panel,
.billing-new-patient-panel,
.billing-intake-form,
.billing-tariff-manager-panel,
.billing-find-search-panel,
.billing-results-panel,
.billing-invoice-detail-panel,
.billing-opd-action-panel {
  border-color: rgba(15, 118, 110, 0.12);
  box-shadow: var(--shadow-soft);
}

.billing-collection-summary {
  margin: 12px 0 14px;
}

.billing-collection-summary span {
  background: var(--surface-soft);
}

.billing-worklist-table {
  width: 100%;
  overflow-x: auto;
  margin-top: 12px;
}

.billing-worklist-table table {
  margin-top: 0;
}

.billing-worklist-row td {
  vertical-align: top;
}

.billing-opd-row {
  background: #f0fdfa;
}

.billing-invoice-row {
  background: #f8fafc;
}

.billing-investigation-row {
  background: #fffaf0;
}

.billing-adjustment-note {
  display: inline-flex;
  align-items: center;
  max-width: 280px;
  padding: 6px 9px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 10px;
  background: #f8fafc;
  font-size: 12px;
  line-height: 1.35;
}

.billing-find-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "search"
    "detail"
    "results";
  gap: 16px;
  align-items: start;
}

.billing-search-panel {
  grid-area: search;
}

.billing-find-results {
  grid-area: results;
}

.billing-find-detail {
  grid-area: detail;
}

.billing-find-detail:focus {
  outline: none;
}

.billing-invoice-card-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.billing-invoice-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.billing-invoice-card-main,
.billing-invoice-card-patient {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.billing-invoice-card-main > div,
.billing-invoice-card-patient {
  min-width: 0;
}

.billing-invoice-card-main strong,
.billing-invoice-card-patient strong {
  display: block;
}

.billing-invoice-card-money {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.billing-invoice-card-money span {
  display: grid;
  gap: 2px;
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.billing-invoice-card-money small {
  color: var(--muted);
}

.billing-selected-invoice-card {
  background: #ecfdf5;
  border-color: var(--brand);
  box-shadow: inset 4px 0 0 var(--brand);
}

.billing-filter-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
}

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

.billing-flow-card {
  position: relative;
  display: grid;
  gap: 4px;
  min-height: 112px;
  padding: 16px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  background: var(--surface-soft);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.billing-flow-card:hover,
.billing-flow-card.active {
  border-color: var(--brand);
  background: #ecfdf5;
}

.billing-flow-card span {
  color: var(--muted);
  font-size: 13px;
}

.billing-flow-index {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 6px;
  border-radius: 999px;
  color: var(--brand);
  background: #ccfbf1;
  font-weight: 800;
}

.billing-quick-register-form {
  margin-top: 14px;
  padding: 14px;
  border: 1px dashed rgba(15, 118, 110, 0.34);
  border-radius: 14px;
  background: #f0fdfa;
}

.billing-quick-register-form .section-heading {
  margin-bottom: 8px;
}

.billing-quick-register-form h3 {
  margin: 0;
  color: var(--clinical-blue);
}

.billing-payment-summary {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1.2fr);
  gap: 12px;
  margin-bottom: 14px;
}

.billing-payment-patient,
.billing-payment-money span {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

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

.billing-payment-money small {
  color: var(--muted);
}

.billing-payment-money .billing-outstanding {
  border-color: rgba(245, 158, 11, 0.25);
  background: #fff7ed;
}

.billing-detail-table {
  width: 100%;
  overflow-x: auto;
}

.billing-payment-panel form {
  margin-top: 12px;
}

.billing-primary-payment-form {
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 12px;
  background: #f0fdfa;
}

.billing-secondary-actions {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.billing-secondary-actions summary {
  cursor: pointer;
  color: var(--clinical-blue);
  font-weight: 750;
}

.pagination-controls {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 12px 0;
}

.pagination-controls .actions {
  margin-top: 0;
}

.appointment-patient-lookup {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.lookup-results {
  overflow-x: auto;
}

.selected-patient-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 10px;
}

.selected-patient-card .muted {
  display: block;
  margin-top: 3px;
}

.appointment-stage-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}

.appointment-stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
}

.appointment-stage-chip span {
  font-weight: 800;
}

tr.appointment-stage-booked td {
  background: #f0fdfa;
}

tr.appointment-stage-checked-in td {
  background: #fffbeb;
}

tr.appointment-stage-in-consultation td {
  background: #eef2ff;
}

tr.appointment-stage-completed td {
  background: #f0fdf4;
}

tr.appointment-stage-no-show td {
  background: #f8fafc;
}

tr.appointment-stage-cancelled td {
  background: #fff1f2;
}

tr.appointment-stage-booked td:first-child,
.appointment-stage-chip.appointment-stage-booked,
.badge.appointment-stage-booked {
  border-color: #99f6e4;
  color: var(--brand);
}

tr.appointment-stage-checked-in td:first-child,
.appointment-stage-chip.appointment-stage-checked-in,
.badge.appointment-stage-checked-in {
  border-color: #fde68a;
  color: #92400e;
}

tr.appointment-stage-in-consultation td:first-child,
.appointment-stage-chip.appointment-stage-in-consultation,
.badge.appointment-stage-in-consultation {
  border-color: #c7d2fe;
  color: #3730a3;
}

tr.appointment-stage-completed td:first-child,
.appointment-stage-chip.appointment-stage-completed,
.badge.appointment-stage-completed {
  border-color: #bbf7d0;
  color: var(--success);
}

tr.appointment-stage-no-show td:first-child,
.appointment-stage-chip.appointment-stage-no-show,
.badge.appointment-stage-no-show {
  border-color: #cbd5e1;
  color: var(--muted);
}

tr.appointment-stage-cancelled td:first-child,
.appointment-stage-chip.appointment-stage-cancelled,
.badge.appointment-stage-cancelled {
  border-color: #fecdd3;
  color: var(--danger);
}

tr[class*="appointment-stage-"] td:first-child {
  border-left-width: 4px;
}

.form-keyboard-hint {
  margin: 10px 0 0;
  font-size: 12px;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.dashboard-hero h2,
.dashboard-section h2 {
  margin: 0;
  color: var(--clinical-blue);
}

.dashboard-hero .muted {
  max-width: 680px;
}

.section-eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 14px;
}

.dashboard-section {
  margin-top: 20px;
}

.dashboard-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px;
}

.dashboard-card {
  position: relative;
  display: grid;
  gap: 10px;
  min-height: 188px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.dashboard-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--brand);
}

.dashboard-card:hover {
  border-color: rgba(15, 118, 110, 0.35);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.dashboard-card strong {
  color: var(--clinical-blue);
  font-size: 20px;
  line-height: 1.2;
}

.dashboard-card .muted {
  line-height: 1.45;
}

.dashboard-card-eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.dashboard-card-status {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.dashboard-card-action {
  align-self: end;
  color: var(--brand);
  font-weight: 800;
}

.dashboard-card-amber::before {
  background: var(--accent);
}

.dashboard-card-amber .dashboard-card-status {
  background: #fff7ed;
  color: #b45309;
}

.dashboard-card-blue::before,
.dashboard-card-slate::before {
  background: var(--clinical-blue);
}

.dashboard-card-blue .dashboard-card-status,
.dashboard-card-slate .dashboard-card-status {
  background: #eaf6fb;
  color: var(--clinical-blue);
}

.dashboard-card-green::before {
  background: var(--success);
}

.dashboard-card-green .dashboard-card-status {
  background: #ecfdf3;
  color: var(--success);
}

.dashboard-card-red::before {
  background: var(--danger);
}

.dashboard-card-red .dashboard-card-status {
  background: #fff1f2;
  color: var(--danger);
}

.dashboard-notice {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.dashboard-notice strong {
  color: var(--clinical-blue);
}

.dashboard-notice span {
  color: var(--muted);
  line-height: 1.45;
}

.dashboard-notice-success {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.dashboard-notice-info {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.quick-actions.compact {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin-top: 0;
}

.quick-action-card {
  display: grid;
  align-content: space-between;
  gap: 12px;
  min-height: 136px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(248, 251, 251, 0.95)),
    var(--surface-soft);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-soft);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.quick-action-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.quick-action-card strong {
  color: var(--clinical-blue);
  font-size: 16px;
}

.quick-actions.compact .quick-action-card {
  min-height: 112px;
  box-shadow: none;
}

.compact-list {
  margin: 0;
  padding-left: 16px;
}

.compact-list li + li {
  margin-top: 6px;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(21, 94, 117, 0.05), transparent 46%),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.muted {
  color: var(--muted);
}

.error,
.success,
.warning,
.info,
.empty-state {
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 12px 0;
}

.error {
  color: var(--danger);
  background: #fff1f2;
  border: 1px solid #fecdd3;
}

.success {
  color: var(--success);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.warning {
  color: #9a3412;
  background: #fff7ed;
  border: 1px solid #fed7aa;
}

.info {
  color: var(--clinical-blue);
  background: #eef9ff;
  border: 1px solid #bae6fd;
}

.toast-region {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
  width: min(380px, calc(100vw - 36px));
  pointer-events: none;
}

.toast-stack {
  display: grid;
  gap: 10px;
}

.toast {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: toast-slide-in 180ms ease-out;
}

.toast-success {
  border-left-color: var(--success);
}

.toast-warning {
  border-left-color: #f97316;
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-info,
.toast-loading {
  border-left-color: var(--clinical-blue);
}

.toast-icon {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  color: #ffffff;
  background: var(--clinical-blue);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.toast-success .toast-icon {
  background: var(--success);
}

.toast-warning .toast-icon {
  background: #f97316;
}

.toast-error .toast-icon {
  background: var(--danger);
}

.toast-loading .toast-icon {
  border: 3px solid #dbeafe;
  border-top-color: var(--clinical-blue);
  background: transparent;
  animation: toast-spin 900ms linear infinite;
}

.toast-content {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: var(--text);
}

.toast-content strong {
  color: var(--text);
}

.toast-content span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.toast-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
}

.toast-close:hover,
.toast-close:focus {
  color: var(--text);
  background: var(--surface-soft);
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateX(18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

.empty-state {
  color: var(--muted);
  background: #f8fbfb;
  border: 1px dashed #cbd5e1;
}

@media (max-width: 760px) {
  .toast-region {
    top: auto;
    right: 10px;
    bottom: 12px;
    left: 10px;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }

  .toast-loading .toast-icon {
    animation: none;
  }
}

.emr-grid {
  display: grid;
  gap: 12px;
}

.emr-section {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.emr-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 24px;
  padding: 3px 9px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.muted-badge {
  border-color: #dbe4ec;
  background: #f8fafc;
  color: var(--muted);
}

.status-active,
.status-paid,
.status-waived,
.status-completed,
.status-signed,
.status-reported,
.status-dispensed,
.status-available,
.status-admitted,
.status-transferred {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--success);
}

.status-draft,
.status-pending,
.status-unpaid,
.status-payment-due,
.status-partial,
.status-needs-review,
.status-partially-paid,
.status-in-progress,
.warning-badge {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.status-cancelled,
.status-refunded,
.status-inactive,
.status-locked,
.status-occupied,
.status-discharged {
  border-color: #fecdd3;
  background: #fff1f2;
  color: var(--danger);
}

.pharmacy-workbench-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid rgba(21, 94, 117, 0.12);
  border-radius: 18px;
  background: linear-gradient(135deg, #ffffff 0%, #edf7f5 100%);
  box-shadow: var(--shadow-soft);
}

.pharmacy-workbench-hero h2 {
  margin: 0;
}

.pharmacy-hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 10px;
}

.pharmacy-hero-stats span {
  display: grid;
  gap: 2px;
  min-width: 110px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
}

.pharmacy-hero-stats strong {
  color: var(--text);
  font-size: 1.05rem;
}

.pharmacy-hero-stats small {
  color: var(--muted);
}

.pharmacy-workbench-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.9fr) minmax(0, 1.25fr);
  gap: 18px;
  align-items: start;
}

.pharmacy-detail-column {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.pharmacy-search-panel,
.pharmacy-readonly-prescription-panel,
.pharmacy-dispense-panel,
.pharmacy-sync-panel,
.pharmacy-empty-detail {
  border-color: rgba(15, 118, 110, 0.12);
  box-shadow: var(--shadow-soft);
}

.pharmacy-search-form {
  margin-bottom: 12px;
}

.pharmacy-prescription-list,
.pharmacy-line-item-table,
.pharmacy-dispense-table,
.pharmacy-sync-table {
  width: 100%;
  overflow-x: auto;
}

.pharmacy-prescription-list table,
.pharmacy-line-item-table table,
.pharmacy-dispense-table table,
.pharmacy-sync-table table {
  margin-top: 0;
}

.pharmacy-prescription-row td {
  vertical-align: top;
}

.pharmacy-prescription-row td:first-child {
  border-left: 4px solid var(--clinical-blue);
}

.active-pharmacy-prescription {
  background: #ecfdf5;
  outline: 2px solid rgba(15, 118, 110, 0.22);
  outline-offset: -2px;
}

.pharmacy-readonly-banner,
.pharmacy-boundary-note,
.pharmacy-import-card {
  display: grid;
  gap: 4px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 14px;
  background: #f0fdfa;
}

.pharmacy-readonly-banner strong,
.pharmacy-boundary-note strong,
.pharmacy-import-card strong {
  color: var(--clinical-blue);
}

.pharmacy-readonly-banner span,
.pharmacy-boundary-note span {
  color: var(--muted);
}

.pharmacy-prescription-summary-grid {
  margin-bottom: 12px;
}

.pharmacy-import-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  background: var(--surface-soft);
}

.pharmacy-import-card p {
  margin: 4px 0 0;
}

.pharmacy-dispense-panel form {
  display: grid;
  gap: 12px;
}

.pharmacy-dispense-table h3 {
  margin-top: 0;
}

.pharmacy-empty-detail .empty-state {
  margin-bottom: 12px;
}

@media (max-width: 1100px) {
  .pharmacy-workbench-hero,
  .pharmacy-workbench-layout {
    grid-template-columns: 1fr;
  }

  .pharmacy-hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .pharmacy-hero-stats,
  .pharmacy-import-card {
    grid-template-columns: 1fr;
  }
}

.ipd-workbench-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid rgba(21, 94, 117, 0.12);
  border-radius: 18px;
  background: linear-gradient(135deg, #ffffff 0%, #edf7f5 100%);
  box-shadow: var(--shadow-soft);
}

.ipd-workbench-hero h2 {
  margin: 0;
}

.ipd-hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 10px;
}

.ipd-hero-stats span {
  display: grid;
  gap: 2px;
  min-width: 110px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
}

.ipd-hero-stats strong {
  color: var(--text);
  font-size: 1.05rem;
}

.ipd-hero-stats small {
  color: var(--muted);
}

.ipd-workspace-panel,
.ipd-create-admission-panel,
.ipd-setup-panel,
.ipd-admission-card,
.ipd-clinical-card,
.ipd-discharge-form-card {
  border-color: rgba(15, 118, 110, 0.12);
  box-shadow: var(--shadow-soft);
}

.ipd-filter-form {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
}

.ipd-filter-form label {
  min-width: 220px;
}

.ipd-tabs {
  margin-top: 8px;
}

.ipd-tab-grid,
.ipd-bed-board-layout,
.ipd-discharge-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.ipd-tab-main,
.ipd-bed-board,
.ipd-discharge-list,
.ipd-discharge-forms {
  min-width: 0;
}

.ipd-table-scroll {
  overflow-x: auto;
  width: 100%;
}

.ipd-table-scroll table {
  margin-top: 0;
}

.ipd-admission-row td {
  vertical-align: top;
}

.ipd-admission-row td:first-child {
  border-left: 4px solid var(--clinical-blue);
}

.ipd-admission-row.status-discharged td:first-child {
  border-left-color: var(--success);
}

.ipd-setup-column,
.ipd-admission-card-list {
  display: grid;
  gap: 16px;
}

.ipd-ward-card {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.ipd-ward-card-header,
.ipd-admission-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.ipd-ward-card-header > div,
.ipd-admission-card-header > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.ipd-bed-counts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.ipd-bed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
}

.ipd-bed-chip {
  display: grid;
  gap: 2px;
  min-height: 58px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
}

.ipd-bed-chip small {
  color: var(--muted);
}

.ipd-bed-available {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.ipd-bed-occupied {
  border-color: #fecdd3;
  background: #fff1f2;
}

.ipd-bed-maintenance {
  border-color: #fed7aa;
  background: #fff7ed;
}

.ipd-admission-card-header h3 {
  margin: 0;
}

.ipd-admission-location {
  align-items: flex-end;
  text-align: right;
}

.ipd-care-summary-grid,
.ipd-clinical-snapshot {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.ipd-care-summary-grid span,
.ipd-clinical-snapshot div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.ipd-care-summary-grid strong {
  color: var(--brand);
  font-size: 18px;
}

.ipd-care-summary-grid small,
.ipd-clinical-snapshot span {
  color: var(--muted);
}

.ipd-action-grid,
.ipd-clinical-form-grid {
  display: grid;
  gap: 12px;
}

.ipd-action-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ipd-inline-action-form,
.ipd-billing-panel,
.ipd-investigation-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.ipd-inline-action-form h3,
.ipd-billing-panel h3,
.ipd-investigation-panel h3,
.ipd-clinical-form-grid h3 {
  margin: 0;
}

.ipd-billing-panel,
.ipd-investigation-panel {
  margin-top: 12px;
}

.ipd-clinical-form-grid form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.ipd-discharge-card {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.ipd-discharge-form-card form {
  margin-top: 12px;
}

@media (max-width: 1100px) {
  .ipd-workbench-hero,
  .ipd-tab-grid,
  .ipd-bed-board-layout,
  .ipd-discharge-layout {
    grid-template-columns: 1fr;
  }

  .ipd-hero-stats,
  .ipd-care-summary-grid,
  .ipd-clinical-snapshot {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .ipd-hero-stats,
  .ipd-action-grid,
  .ipd-care-summary-grid,
  .ipd-clinical-snapshot {
    grid-template-columns: 1fr;
  }

  .ipd-ward-card-header,
  .ipd-admission-card-header {
    display: grid;
  }

  .ipd-admission-location {
    align-items: flex-start;
    text-align: left;
  }
}

.patient-summary-header {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 2fr minmax(150px, 220px);
  align-items: center;
  gap: 14px;
}

.clinical-context-header {
  border-color: rgba(21, 94, 117, 0.2);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(255, 255, 255, 0) 42%),
    var(--surface);
}

.clinical-context-main h2,
.prescription-patient-context h2 {
  margin: 0;
  color: var(--clinical-blue);
}

.clinical-context-badges,
.patient-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.clinical-context-meta {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.clinical-context-alerts {
  display: grid;
  gap: 8px;
}

.clinical-timeline-panel .section-title-row,
.clinical-workspace-panel > .section-heading:first-child {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

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

.timeline-search-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.4fr) auto auto;
  gap: 12px;
  align-items: end;
  margin: 14px 0;
}

.timeline-patient-results {
  margin: 0 0 14px;
}

.timeline-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-soft);
}

.timeline-card-main,
.timeline-card-summary {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr);
  gap: 14px;
  align-items: start;
}

.timeline-card h3 {
  margin: 0;
  color: var(--clinical-blue);
}

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

.timeline-card-summary > div,
.timeline-counts span {
  display: grid;
  gap: 4px;
}

.timeline-counts {
  display: grid;
  grid-template-columns: repeat(5, minmax(84px, 1fr));
  gap: 8px;
}

.timeline-counts span {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  text-align: center;
}

.timeline-counts strong {
  color: var(--brand);
  font-size: 18px;
}

.timeline-counts small {
  color: var(--muted);
  font-weight: 700;
}

.consultation-patient-header {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(260px, 1.4fr) minmax(180px, 0.8fr);
  gap: 14px;
  align-items: start;
}

.consultation-patient-title h2 {
  margin: 0;
}

.consultation-care-team,
.consultation-alerts,
.consultation-header-vitals {
  display: grid;
  gap: 6px;
}

.consultation-alerts {
  grid-column: 1 / -1;
}

.consultation-header-vitals {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.consultation-tabs {
  margin-top: 4px;
}

.clinical-workspace-panel {
  border-color: rgba(15, 118, 110, 0.16);
}

.consultation-conversation-panel {
  position: relative;
}

.consultation-step-panel {
  display: grid;
  gap: 16px;
  border-color: rgba(15, 118, 110, 0.18);
  box-shadow: var(--shadow-soft);
}

.consultation-step-panel > .section-heading {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.consultation-secondary-stack {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.consultation-secondary-details {
  padding: 0;
  overflow: hidden;
}

.consultation-secondary-details > summary,
.recorder-history > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  padding: 14px 16px;
  list-style: none;
}

.consultation-secondary-details > summary::-webkit-details-marker,
.recorder-history > summary::-webkit-details-marker {
  display: none;
}

.consultation-secondary-details > :not(summary) {
  margin: 0 16px 16px;
}

.consultation-past-prescriptions-panel table {
  font-size: 0.86rem;
}

.consultation-past-prescriptions-panel td:last-child {
  white-space: nowrap;
}

.consultation-fast-mode-panel {
  display: grid;
  gap: 16px;
  border-color: rgba(15, 118, 110, 0.22);
  background: linear-gradient(135deg, #f0fdfa 0%, #ffffff 70%);
}

.openai-only-consultation-panel {
  position: sticky;
  top: 12px;
  z-index: 20;
}

.consultation-fast-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.consultation-fast-header h2 {
  margin: 0 0 6px;
}

.large-action-button {
  min-height: 48px;
  padding: 12px 18px;
  font-size: 1rem;
  border-radius: 12px;
  white-space: nowrap;
}

.consultation-fast-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.consultation-fast-steps span {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.consultation-fast-steps strong {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #e2e8f0;
  color: var(--text);
}

.consultation-fast-steps .active {
  border-color: rgba(15, 118, 110, 0.35);
  background: #ccfbf1;
  color: #0f766e;
}

.consultation-fast-steps .active strong {
  background: #0f766e;
  color: #fff;
}

.consultation-conversation-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--brand);
}

.consultation-transcript-field {
  display: grid;
  gap: 6px;
}

.consultation-transcript-field textarea {
  min-height: 220px;
}

.consultation-generated-transcript {
  border: 1px solid #b8e1dc;
  border-radius: 18px;
  background: #f2fbf9;
  padding: 16px;
  margin: 16px 0;
}

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

.consultation-generated-transcript pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 18rem;
  overflow: auto;
  margin: 8px 0 0;
  padding: 14px;
  border: 1px solid #d8e8e6;
  border-radius: 12px;
  background: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
}

.consultation-audio-recorder {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fbfd;
  padding: 16px;
  margin-bottom: 16px;
}

.recorder-header,
.recorder-controls,
.recorder-status-grid {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.recorder-header h3 {
  margin: 0 0 4px;
}

.recorder-controls {
  justify-content: flex-start;
  margin: 12px 0;
}

.recorder-status-grid {
  justify-content: flex-start;
  color: var(--muted);
  font-size: 0.9rem;
}

.recorder-status-grid span {
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.consultation-audio-recorder audio {
  display: block;
  width: 100%;
  margin: 12px 0;
}

.recorder-history {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}

.recorder-history table {
  margin: 0 12px 12px;
  width: calc(100% - 24px);
}

.consultation-language-panels {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 16px;
}

.consultation-language-panels textarea {
  min-height: 96px;
}

.subtle-warning {
  border-color: rgba(245, 158, 11, 0.35);
  background: #fffbeb;
}

.consultation-vitals-context {
  display: grid;
  gap: 8px;
  padding: 12px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

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

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

.consultation-vitals-list span {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.consultation-vitals-list small {
  color: var(--muted);
}

.consultation-draft-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfa 100%);
  box-shadow: var(--shadow-soft);
}

.consultation-draft-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.consultation-draft-title {
  display: grid;
  gap: 3px;
}

.consultation-draft-title h3 {
  margin: 0;
  color: var(--text);
}

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

.consultation-draft-metrics span {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.consultation-draft-metrics strong {
  color: var(--text);
  font-size: 1.02rem;
}

.consultation-draft-metrics small {
  color: var(--muted);
}

.consultation-draft-metrics .draft-pdf-ready {
  border-color: rgba(21, 128, 61, 0.2);
  background: #f0fdf4;
}

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

.consultation-draft-actions {
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.3fr);
  align-items: center;
}

.consultation-draft-actions .actions,
.consultation-draft-pdf-action {
  justify-content: flex-end;
}

.consultation-draft-empty {
  padding: 18px;
}

.consultation-inline-review-panel {
  display: grid;
  gap: 16px;
  margin: 18px 0;
}

.consultation-inline-review-panel > .section-heading {
  padding: 18px;
  border: 1px solid rgba(21, 94, 117, 0.16);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.consultation-inline-review-panel .prescription-patient-context {
  position: static;
}

.compact-inline-prescription-review {
  gap: 14px;
}

.compact-inline-prescription-review > .panel {
  box-shadow: none;
}

.compact-inline-prescription-review .clinical-assessment-panel,
.compact-inline-prescription-review .doctor-prescription-form,
.compact-inline-prescription-review .warning-panel,
.compact-inline-prescription-review .investigation-order-panel,
.compact-inline-prescription-review .advice-followup-panel,
.compact-inline-prescription-review .preview-prescription {
  border-color: rgba(15, 118, 110, 0.14);
}

.compact-inline-prescription-review .medicine-master-search,
.compact-inline-prescription-review .medicine-master-results {
  max-width: 920px;
}

.compact-inline-prescription-review .medicine-review-table {
  font-size: 0.92rem;
}

.clinical-investigation-order-panel table,
.consultation-investigation-status table {
  margin-top: 10px;
}

.workflow-helper,
.prescription-workflow-helper {
  font-size: 0.9rem;
}

.prescription-workflow-helper {
  display: grid;
  gap: 4px;
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.prescription-workflow-helper p {
  margin: 0;
  color: var(--muted);
}

.investigation-status-summary,
.consultation-investigation-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.consultation-resume-actions {
  margin-top: 10px;
}

.consultation-advanced-notice,
.consultation-advanced-panel {
  border-color: #fed7aa;
  background: #fffaf3;
}

@media (max-width: 980px) {
  .billing-desk-hero,
  .billing-desk-layout,
  .billing-desk-hero-stats,
  .billing-collection-summary,
  .billing-filter-row,
  .billing-flow-choices,
  .billing-payment-summary,
  .billing-payment-money,
  .grid-4,
  .consultation-patient-header,
  .timeline-search-form,
  .timeline-card-main,
  .timeline-card-summary,
  .timeline-counts,
  .consultation-vitals-list,
  .consultation-draft-metrics,
  .consultation-draft-actions,
  .consultation-generated-transcript-grid,
  .consultation-fast-header,
  .consultation-fast-steps {
    grid-template-columns: 1fr;
  }

  .consultation-draft-header {
    flex-direction: column;
  }

  .consultation-draft-actions .actions,
  .consultation-draft-pdf-action {
    justify-content: flex-start;
  }

  .timeline-status-stack {
    justify-content: flex-start;
  }

  .billing-desk-side {
    position: static;
  }
}

.patient-summary-header h2 {
  margin: 0;
}

.patient-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.summary-stat,
.summary-tile {
  display: grid;
  gap: 4px;
}

.clinical-review-workspace {
  display: grid;
  gap: 18px;
}

.clinical-review-workspace > .panel {
  margin-bottom: 0;
}

.prescription-patient-context {
  position: sticky;
  top: 12px;
  z-index: 1;
}

.prescription-encounter-panel,
.prescription-transcript-panel,
.clinical-assessment-panel,
.prescription-ai-suggestions,
.prescription-safety-panel,
.doctor-prescription-form,
.investigation-order-panel,
.investigation-status-panel,
.advice-followup-panel,
.preview-prescription {
  border-color: rgba(21, 94, 117, 0.16);
}

.prescription-safety-panel {
  border-left: 4px solid var(--danger);
}

.doctor-prescription-form {
  border-left: 4px solid var(--brand);
}

.clinical-assessment-panel {
  border-left: 4px solid #14b8a6;
}

.prescription-secondary-review {
  border-left: 4px solid #cbd5e1;
  background: #fbfdff;
}

.prescription-secondary-review summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
}

.prescription-secondary-review summary::-webkit-details-marker {
  display: none;
}

.prescription-secondary-review summary h2,
.prescription-secondary-review summary p {
  margin-bottom: 0;
}

.prescription-secondary-review .draft-section-grid {
  margin-top: 14px;
}

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

.draft-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.draft-section .section-heading {
  align-items: flex-start;
}

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

.clinical-assessment-card {
  border: 1px solid rgba(20, 184, 166, 0.2);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #f8fdfc);
  padding: 14px;
}

.clinical-assessment-card:nth-child(1),
.clinical-assessment-card:nth-child(4) {
  grid-column: 1 / -1;
}

.clinical-assessment-card-heading {
  align-items: flex-start;
}

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

.clinical-assessment-card:nth-child(1) .clinical-assessment-fields,
.clinical-assessment-card:nth-child(4) .clinical-assessment-fields {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.clinical-assessment-fields label {
  min-width: 0;
}

.clinical-assessment-fields textarea {
  min-height: 72px;
}

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

.section-heading h2,
.section-heading h3 {
  margin: 0;
}

.transcript-panel pre {
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
}

.transcript-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-top: 10px;
}

.transcript-details summary {
  cursor: pointer;
  font-weight: 800;
  padding: 10px 12px;
}

.transcript-provider-line {
  margin-top: 0.3rem;
  font-size: 0.88rem;
}

.transcript-details pre,
.transcript-details .muted {
  margin: 0 12px 12px;
}

.translation-warning-panel {
  margin: 10px 0;
}

.prescription-preview-card {
  border: 1px solid #b8c6d6;
  border-radius: 6px;
  background: #fff;
  color: #17212b;
  overflow: hidden;
}

.prescription-preview-a4 {
  width: min(100%, 794px);
  min-height: 1122px;
  margin: 0 auto;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.12);
}

.prescription-preview-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 2px solid #155e75;
}

.prescription-preview-header h3 {
  margin: 0 0 4px;
  font-size: 1.3rem;
  color: #155e75;
}

.prescription-preview-header p {
  margin: 2px 0;
  color: #475569;
}

.prescription-preview-title {
  display: grid;
  gap: 4px;
  align-content: center;
  text-align: right;
}

.prescription-preview-title strong {
  font-size: 1rem;
  color: #0f766e;
  letter-spacing: 0.04em;
}

.prescription-preview-title span {
  color: #64748b;
}

.prescription-preview-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border-bottom: 1px solid #d8e1ea;
}

.prescription-preview-meta div {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-right: 1px solid #d8e1ea;
  border-bottom: 1px solid #eef2f7;
}

.prescription-preview-meta div:nth-child(4n) {
  border-right: 0;
}

.prescription-preview-meta span {
  color: #64748b;
  font-size: 0.78rem;
}

.prescription-preview-meta strong {
  font-size: 0.92rem;
}

.prescription-preview-section {
  padding: 12px 20px;
  border-bottom: 1px solid #eef2f7;
}

.prescription-preview-section h4 {
  margin: 0 0 8px;
  color: #155e75;
  font-size: 0.86rem;
  text-transform: uppercase;
}

.prescription-preview-section p {
  margin: 0;
}

.prescription-followup-date {
  display: inline-block;
  color: #17212b;
  font-size: 1rem;
  font-weight: 800;
}

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

.prescription-preview-assessment-grid div {
  border: 1px solid #d8e1ea;
  border-radius: 6px;
  padding: 9px;
  background: #fbfdff;
}

.prescription-preview-assessment-grid strong,
.prescription-preview-assessment-grid span {
  display: block;
}

.prescription-preview-assessment-grid strong {
  color: #155e75;
  margin-bottom: 4px;
}

.prescription-preview-assessment-grid span {
  color: #334155;
  font-size: 0.86rem;
  margin-top: 3px;
  line-height: 1.45;
}

.prescription-preview-assessment-row + .prescription-preview-assessment-row {
  margin-top: 5px;
}

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

.prescription-preview-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  table-layout: fixed;
}

.prescription-preview-table th:nth-child(1),
.prescription-preview-table td:nth-child(1) {
  width: 23%;
}

.prescription-preview-table th:nth-child(2),
.prescription-preview-table td:nth-child(2) {
  width: 10%;
}

.prescription-preview-table th:nth-child(3),
.prescription-preview-table td:nth-child(3) {
  width: 9%;
}

.prescription-preview-table th:nth-child(4),
.prescription-preview-table td:nth-child(4) {
  width: 11%;
}

.prescription-preview-table th:nth-child(5),
.prescription-preview-table td:nth-child(5) {
  width: 8%;
}

.prescription-preview-table th:nth-child(6),
.prescription-preview-table td:nth-child(6) {
  width: 39%;
}

.prescription-preview-table th,
.prescription-preview-table td {
  border: 1px solid #d8e1ea;
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.prescription-preview-table th {
  background: #f1f5f9;
  color: #17212b;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.prescription-preview-table td span {
  display: block;
  margin-top: 3px;
  color: #64748b;
  font-size: 0.78rem;
}

.prescription-frequency-legend {
  margin-top: 8px;
  color: #64748b;
  font-size: 0.78rem;
}

.prescription-preview-signature {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(90px, 0.5fr) minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
  padding: 18px 20px;
}

.prescription-preview-signature > div {
  display: grid;
  gap: 4px;
}

.prescription-preview-signature strong {
  color: #64748b;
  font-size: 0.8rem;
}

.prescription-preview-signature-box {
  justify-items: center;
  border-top: 1px solid #17212b;
  padding-top: 8px;
  text-align: center;
}

.prescription-preview-signature-box span {
  font-weight: 700;
}

.prescription-preview-signature-box small {
  color: #64748b;
}

.medicine-review-table input,
.medicine-review-table select {
  min-width: 130px;
}

.medicine-row-autocomplete {
  position: relative;
}

.medicine-row-autocomplete input[role="combobox"] {
  width: 100%;
}

.medicine-row-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  display: none;
  max-height: 280px;
  overflow: auto;
  min-width: 320px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}

.medicine-row-autocomplete:focus-within .medicine-row-results,
.medicine-row-autocomplete input[aria-expanded="true"] + .medicine-row-results {
  display: block;
}

.medicine-master-search {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.medicine-master-results {
  margin-bottom: 12px;
}

.medicine-default-result-list {
  display: grid;
  gap: 8px;
}

.medicine-default-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.medicine-default-result.is-highlighted {
  border-color: var(--primary);
  background: #ecfdf5;
  box-shadow: inset 3px 0 0 var(--primary);
}

.medicine-result-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.warning-text {
  color: #92400e;
}

.inventory-availability-panel {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  margin-bottom: 10px;
}

.inventory-availability-panel p {
  margin: 4px 0 0;
}

.inventory-status {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.inventory-status-available .badge {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--success);
}

.inventory-status-out_of_stock .badge,
.inventory-status-not_found .badge,
.inventory-status-unavailable .badge {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.small-warning,
.small-text {
  margin-top: 6px;
  font-size: 12px;
}

.field-label {
  display: block;
  margin-top: 6px;
  margin-bottom: 3px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.source-text-details {
  font-size: 12px;
}

.source-text-details summary {
  cursor: pointer;
  color: var(--secondary);
  font-weight: 700;
}

.needs-review-row {
  background: #fff7ed;
}

.field-missing {
  border-color: #f97316;
  background: #fff7ed;
}

.checkbox-label {
  display: flex;
  gap: 6px;
  align-items: center;
}

.checkbox-label input {
  width: auto;
  min-height: auto;
}

.next-clinical-step,
.pending-investigation-acknowledgement {
  margin-top: 12px;
}

.active-draft-card {
  border-color: var(--primary);
  background: linear-gradient(180deg, #ffffff 0%, #f0fdfa 100%);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.2), var(--shadow-soft);
}

.investigation-status-panel table,
.investigation-order-panel table {
  margin-top: 10px;
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 252px minmax(0, 1fr);
  }

  .sidebar {
    padding: 18px 12px;
  }

  .content {
    padding: 24px;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-workspace-hero,
  .billing-desk-hero,
  .pharmacy-workbench-hero,
  .ipd-workbench-hero {
    gap: 14px;
  }
}

@media (max-width: 1024px) {
  .dashboard-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-actions,
  .review-summary-grid,
  .draft-section-grid,
  .clinical-assessment-grid,
  .prescription-preview-assessment-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .billing-find-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "search"
      "detail"
      "results";
  }

  .billing-find-detail {
    position: static;
  }

  .billing-invoice-card-list {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    height: auto;
    grid-template-rows: auto auto auto;
    gap: 12px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
    padding-right: 0;
  }

  .nav-group {
    align-content: start;
  }

  .content {
    padding: 18px;
  }

  .page-title {
    font-size: 26px;
  }

  .dashboard-hero {
    grid-template-columns: 1fr;
  }

  .grid,
  .grid-3,
  .grid-4,
  .admin-workspace-hero,
  .admin-workspace-grid,
  .session-security-grid,
  .dashboard-card-grid,
  .quick-actions,
  .patient-summary-header,
  .review-summary-grid,
  .draft-section-grid,
  .clinical-assessment-grid,
  .clinical-assessment-fields,
  .clinical-assessment-card:nth-child(1) .clinical-assessment-fields,
  .clinical-assessment-card:nth-child(4) .clinical-assessment-fields,
  .prescription-preview-assessment-grid {
    grid-template-columns: 1fr;
  }

  .clinical-assessment-card,
  .clinical-assessment-card:nth-child(1),
  .clinical-assessment-card:nth-child(4) {
    grid-column: auto;
  }

  .topbar {
    display: grid;
    padding: 16px;
  }

  .topbar-actions,
  .user-context-card {
    width: 100%;
    justify-content: stretch;
  }

  .user-context-card {
    min-width: 0;
  }

  .frontdesk-tabs {
    width: 100%;
  }

  .frontdesk-tabs .tab {
    flex: 1 1 160px;
    justify-content: center;
  }

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

  .admin-user-table td:last-child,
  .user-management-controls {
    min-width: 0;
  }

  .user-row-actions,
  .user-access-detail-header,
  .user-access-assignment {
    align-items: stretch;
  }

  .user-row-actions,
  .user-access-detail-header,
  .user-access-detail-grid,
  .user-access-assignment {
    display: grid;
  }

  .admin-inline-access-form .grid-3 {
    grid-template-columns: 1fr;
  }

  .vitals-patient-strip,
  .selected-patient-card {
    display: grid;
  }
}

.finance-two-column,
.finance-entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.finance-inline-form {
  margin: 12px 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.finance-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

@media (max-width: 520px) {
  :root {
    --touch-target: 44px;
  }

  .content {
    padding: 12px;
  }

  .topbar,
  .panel,
  .admin-workspace-hero,
  .billing-desk-hero,
  .pharmacy-workbench-hero,
  .ipd-workbench-hero {
    padding: 14px;
    border-radius: 12px;
  }

  .page-title {
    font-size: 24px;
  }

  .page-subtitle {
    font-size: 13px;
  }

  .tabs,
  .frontdesk-tabs,
  .consultation-tabs,
  .ipd-tabs,
  .investigation-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  .tab,
  .frontdesk-tabs .tab,
  .consultation-tabs .tab,
  .ipd-tabs .tab,
  .investigation-tabs .tab {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  .actions > button,
  .actions > .button-link {
    flex: 1 1 160px;
  }

  button,
  .button-link {
    white-space: normal;
    text-align: center;
  }

  th,
  td {
    padding: 9px 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
