.patient-registration-page .span-2 {
  grid-column: 1 / -1;
}

.patient-registration-page .span-3 {
  grid-column: 1 / -1;
}

.patient-registration-page .span-wide {
  grid-column: span 3;
}

.patient-registration-page {
  padding-bottom: 12px;
}

.patient-registration-page .table-toolbar {
  align-items: center;
  margin-bottom: 4px;
}

.patient-registration-page .toolbar-title h3 {
  margin-bottom: 0;
}

.patient-registration-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.patient-registration-form textarea {
  resize: vertical;
}

.patient-registration-page .patient-registration-form {
  grid-template-columns: repeat(4, minmax(155px, 1fr)) !important;
  gap: 6px 10px;
  width: 100% !important;
  max-width: none !important;
  padding-bottom: 0;
}

.patient-registration-form label {
  gap: 4px;
}

.patient-registration-form .form-control,
.patient-registration-form .form-select {
  min-height: 40px;
}

.patient-registration-form textarea.form-control {
  min-height: 42px;
}

.required-mark {
  color: #dc2626;
  font-style: normal;
  font-weight: 900;
}

.patient-photo-panel {
  background: linear-gradient(135deg, #f8fbff, #ffffff);
  border: 1px solid #e5edf8;
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.patient-photo-panel {
  align-items: center;
  display: grid;
  gap: 9px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 8px 12px;
}

.patient-appointment-context {
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: linear-gradient(135deg, #f8fbff, #ffffff);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.045);
  display: grid;
  gap: 8px;
  padding: 9px 10px;
}

.patient-appointment-head,
.patient-appointment-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-width: 0;
}

.patient-appointment-head strong,
.patient-appointment-head span {
  display: block;
}

.patient-appointment-head strong {
  color: #0f172a;
  font-size: 13px;
}

.patient-appointment-head span {
  color: #64748b;
  font-size: 11px;
  margin-top: 2px;
}

.patient-payment-pill {
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.patient-payment-pill.is-paid,
.patient-payment-pill.is-ready {
  background: #dcfce7;
  color: #166534;
}

.patient-payment-pill.is-due {
  background: #fef3c7;
  color: #92400e;
}

.patient-payment-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(105px, 1fr));
  gap: 6px;
}

.patient-payment-metric {
  border: 1px solid #e5edf8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  min-width: 0;
  padding: 5px 7px;
}

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

.patient-payment-metric span {
  color: #64748b;
  font-size: 9.5px;
  font-weight: 800;
}

.patient-payment-metric strong {
  color: #0f172a;
  font-size: 12.5px;
  font-weight: 900;
  margin-top: 1px;
}

.patient-appointment-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.patient-appointment-actions .compact {
  min-height: 34px;
  padding: 0 12px;
}

.patient-collect-balance {
  align-items: center;
  display: grid;
  gap: 5px;
  grid-template-columns: auto 120px;
  margin: 0;
}

.patient-collect-balance span {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.patient-collect-balance .form-control {
  min-height: 34px;
  height: 34px;
}

.patient-queue-modal {
  position: fixed;
  inset: 0;
  z-index: 5200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 3vh, 24px);
  background: rgba(15, 23, 42, 0.18);
}

.patient-queue-dialog {
  width: min(1080px, 96vw);
  max-height: min(760px, 88vh);
  overflow: hidden;
  border: 1px solid #dbe7f3;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
}

.patient-queue-head {
  align-items: center;
  border-bottom: 1px solid #e5edf8;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 14px;
}

.patient-queue-head strong,
.patient-queue-head span {
  display: block;
}

.patient-queue-head strong {
  color: #0f172a;
  font-size: 16px;
  font-weight: 900;
}

.patient-queue-head span {
  color: #64748b;
  font-size: 12px;
  margin-top: 2px;
}

.patient-queue-filters {
  display: grid;
  grid-template-columns: 160px minmax(180px, 240px) minmax(260px, 1fr);
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid #eef4fb;
}

.patient-queue-search {
  align-items: center;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px;
}

.patient-queue-search i {
  color: #64748b;
}

.patient-queue-table-wrap {
  min-height: 0;
  overflow: auto;
  padding: 0 14px 14px;
}

.patient-queue-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.patient-queue-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbff;
  color: #334155;
  font-size: 11px;
  font-weight: 900;
  text-align: left;
}

.patient-queue-table th,
.patient-queue-table td {
  border-bottom: 1px solid #e5edf8;
  padding: 9px 8px;
  white-space: nowrap;
}

.patient-queue-table td {
  color: #0f172a;
}

.patient-queue-table .compact {
  min-height: 32px;
  padding: 0 10px;
}

.patient-queue-pill {
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 900;
}

.patient-queue-pill.is-paid {
  background: #dcfce7;
  color: #166534;
}

.patient-queue-pill.is-due {
  background: #fef3c7;
  color: #92400e;
}

@media (min-width: 1600px) {
  .patient-registration-page .patient-registration-form {
    grid-template-columns: repeat(5, minmax(150px, 1fr)) !important;
  }

  .patient-registration-page .span-wide {
    grid-column: span 3;
  }
}

@media (min-width: 1200px) and (max-width: 1599px) {
  .patient-registration-page .patient-registration-form {
    grid-template-columns: repeat(4, minmax(155px, 1fr)) !important;
  }

  .patient-registration-page .span-wide {
    grid-column: span 2;
  }
}

.patient-photo-preview {
  align-items: center;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  color: #2563eb;
  display: flex;
  height: 58px;
  justify-content: center;
  overflow: hidden;
  width: 58px;
}

.patient-photo-preview img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.patient-photo-preview i {
  font-size: 22px;
}

.patient-photo-copy strong,
.patient-photo-copy span {
  display: block;
}

.patient-photo-copy strong {
  color: #0f172a;
  font-size: 14px;
}

.patient-photo-copy span {
  color: #64748b;
  font-size: 12px;
  margin-top: 2px;
}

.patient-photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.patient-photo-actions .icon-text-btn {
  min-height: 32px;
  padding: 0 10px;
}

.patient-photo-upload {
  cursor: pointer;
  margin: 0;
}

.patient-photo-video {
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  height: 70px;
  object-fit: cover;
  width: 104px;
}

.patient-registration-form .master-message,
.patient-registration-form .patient-duplicate-warning,
.patient-registration-form .patient-whatsapp-welcome {
  border-radius: 8px;
  font-weight: 600;
  padding: 10px 12px;
}

.patient-registration-form .master-message {
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #991b1b;
}

.patient-registration-form .patient-duplicate-warning {
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.patient-registration-form .patient-whatsapp-welcome {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
}

.patient-whatsapp-welcome strong,
.patient-whatsapp-welcome span {
  display: block;
}

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

.patient-duplicate-warning .duplicate-title {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

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

.patient-duplicate-warning .duplicate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border-top: 1px solid #fde68a;
  padding-top: 8px;
}

.patient-duplicate-warning strong,
.patient-duplicate-warning span {
  display: block;
}

.patient-registration-page .row-action.reuse {
  color: #2563eb;
}

.patient-registration-page .row-action[title] {
  min-width: 34px;
}

.patient-status-field {
  display: none !important;
}

.patient-registration-page.is-editing .patient-status-field {
  display: flex !important;
}

.patient-sticky-actions {
  position: sticky;
  bottom: 10px;
  z-index: 20;
  justify-content: flex-end;
  margin-top: 2px;
  padding: 10px;
  border: 1px solid #dbe7f3;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(10px);
}

.patient-sticky-actions .secondary {
  background: #0f766e;
  border-color: #0f766e;
}

@media (max-width: 767px) {
  .patient-queue-filters,
  .patient-duplicate-warning .duplicate-row,
  .patient-registration-form .patient-whatsapp-welcome,
  .patient-appointment-head,
  .patient-payment-grid,
  .patient-photo-panel,
  .patient-photo-panel {
    grid-template-columns: 1fr;
  }

  .patient-registration-page .patient-registration-form {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .patient-registration-page .span-wide {
    grid-column: 1 / -1;
  }

  .patient-whatsapp-actions {
    justify-content: flex-start;
  }

  .patient-appointment-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .patient-appointment-actions > *,
  .patient-collect-balance {
    width: 100%;
  }

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

  .patient-photo-video {
    width: 100%;
  }

  .patient-registration-header-actions,
  .patient-sticky-actions {
    justify-content: stretch;
  }

  .patient-registration-header-actions > *,
  .patient-sticky-actions > * {
    width: 100%;
    justify-content: center;
  }

  .patient-queue-modal {
    align-items: flex-end;
    padding: 8px;
  }

  .patient-queue-dialog {
    width: 100%;
    max-height: calc(100dvh - 16px);
    border-radius: 14px 14px 10px 10px;
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .patient-registration-page .patient-registration-form {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

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

  .patient-registration-page .span-3 {
    grid-column: 1 / -1;
  }

  .patient-registration-page .span-wide {
    grid-column: span 2;
  }

}

body[data-theme="dark"] .patient-photo-panel,
body[data-theme="dark"] .patient-appointment-context,
body[data-theme="dark"] .patient-queue-dialog {
  background: linear-gradient(135deg, var(--surface-card), var(--surface-elevated));
  border-color: var(--card-border);
  box-shadow: var(--shadow-card);
}

body[data-theme="dark"] .patient-photo-copy strong,
body[data-theme="dark"] .patient-appointment-head strong,
body[data-theme="dark"] .patient-payment-metric strong,
body[data-theme="dark"] .patient-queue-head strong,
body[data-theme="dark"] .patient-queue-table td {
  color: var(--text-color);
}

body[data-theme="dark"] .patient-photo-copy span,
body[data-theme="dark"] .patient-appointment-head span,
body[data-theme="dark"] .patient-payment-metric span,
body[data-theme="dark"] .patient-collect-balance span,
body[data-theme="dark"] .patient-queue-head span {
  color: var(--text-muted);
}

body[data-theme="dark"] .patient-queue-head,
body[data-theme="dark"] .patient-queue-filters,
body[data-theme="dark"] .patient-queue-table th,
body[data-theme="dark"] .patient-queue-table td {
  border-color: var(--card-border);
}

body[data-theme="dark"] .patient-queue-table th {
  background: rgba(15, 23, 42, 0.92);
  color: var(--text-color);
}

body[data-theme="dark"] .patient-photo-preview {
  background: var(--accent-weak);
  border-color: var(--control-focus-border);
  color: var(--text-color);
}

body[data-theme="dark"] .patient-payment-metric,
body[data-theme="dark"] .patient-sticky-actions {
  background: rgba(15, 23, 42, 0.74);
  border-color: var(--card-border);
}
