.sp-patient-hub {
  --ph-border: var(--sp-border);
  --ph-muted: var(--sp-text-muted);
  --ph-navy: var(--sp-navy-900);
  min-width: 0;
}

.sp-patient-hub__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem 1.25rem;
  margin-bottom: .85rem;
}

.sp-patient-hub__identity {
  min-width: 0;
  flex: 1 1 16rem;
}

.sp-patient-hub__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  flex: 0 1 auto;
  margin-left: auto;
}

.sp-patient-hub__actions .btn {
  min-height: 38px;
  padding: .45rem .95rem;
  border-radius: 10px;
}

.sp-patient-hub__pills {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-bottom: 1.15rem;
}

.sp-patient-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .28rem .7rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.sp-patient-pill--active {
  border-color: #c8efe4;
  color: #0f7a63;
  background: #e9f9f3;
}

.sp-patient-pill--card {
  border-color: #d7e4ff;
  color: #315db8;
  background: #eef4ff;
}

.sp-patient-pill i {
  font-size: .85em;
}

.sp-patient-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .85rem;
  margin-bottom: 1.25rem;
}

.sp-patient-kpi {
  display: flex;
  flex-direction: column;
  min-height: 132px;
  padding: 1rem 1.05rem .9rem;
  border: 1px solid var(--ph-border);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--sp-shadow-sm);
}

.sp-patient-kpi__top {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  min-width: 0;
}

.sp-patient-kpi__icon {
  display: inline-flex;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.05rem;
}

.sp-patient-kpi__icon--contact {
  color: #6d5bd0;
  background: #f1eeff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}

.sp-patient-kpi__icon--payment {
  color: #1f8a7a;
  background: #e8f8f4;
}

.sp-patient-kpi__icon--orders {
  color: #4f6ad8;
  background: #eef2ff;
}

.sp-patient-kpi__icon--billing {
  color: #7a5ad0;
  background: #f4eeff;
}

.sp-patient-kpi__copy {
  min-width: 0;
  flex: 1 1 auto;
}

.sp-patient-kpi__label {
  color: var(--ph-navy);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.sp-patient-kpi__value {
  margin-top: .12rem;
  overflow: hidden;
  color: var(--sp-text-secondary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  text-overflow: ellipsis;
}

.sp-patient-kpi__value strong {
  display: block;
  color: var(--ph-navy);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.2;
}

.sp-patient-kpi__hint {
  color: var(--ph-muted);
  font-size: 12.5px;
  font-weight: 500;
}

.sp-patient-kpi__badges {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .4rem;
}

.sp-patient-kpi__link {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  margin-top: auto;
  padding-top: .75rem;
  border: 0;
  color: var(--sp-blue-600);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.sp-patient-kpi__link:hover,
.sp-patient-kpi__link:focus-visible {
  color: var(--sp-blue-700);
  text-decoration: underline;
}

.sp-patient-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .15rem 1.15rem;
  margin-bottom: 1.15rem;
  border-bottom: 1px solid var(--ph-border);
}

.sp-patient-tabs .nav-link {
  margin-bottom: -1px;
  padding: .7rem 0;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--ph-muted);
  background: transparent;
  font-size: 14px;
  font-weight: 600;
}

.sp-patient-tabs .nav-link:hover {
  color: var(--ph-navy);
  border-bottom-color: #d8dee8;
}

.sp-patient-tabs .nav-link.active {
  color: var(--ph-navy);
  border-bottom-color: var(--ph-navy);
}

.sp-patient-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20.5rem;
  gap: 1.15rem;
  align-items: start;
}

.sp-patient-panel {
  margin-bottom: 1rem;
  overflow: hidden;
  border: 1px solid var(--ph-border);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--sp-shadow-sm);
}

.sp-patient-panel__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .95rem 1.1rem .35rem;
}

.sp-patient-panel__title {
  margin: 0;
  color: var(--ph-navy);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.sp-patient-panel__link {
  border: 0;
  color: var(--sp-blue-600);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.sp-patient-panel__link:hover,
.sp-patient-panel__link:focus-visible {
  color: var(--sp-blue-700);
  text-decoration: underline;
}

.sp-patient-panel__body {
  padding: 0 0 .35rem;
}

.sp-patient-panel__body--pad {
  padding: .35rem 1.1rem 1.05rem;
}

.sp-patient-table {
  width: 100%;
}

.sp-patient-table thead th {
  padding: .55rem 1.1rem;
  color: var(--ph-muted) !important;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
}

.sp-patient-table tbody td {
  padding: .8rem 1.1rem;
  color: var(--sp-text-secondary);
  font-size: 13.5px;
}

.sp-patient-table tbody tr {
  height: auto;
}

.sp-patient-order-id {
  color: var(--sp-blue-600);
  font-weight: 700;
  text-decoration: none;
}

.sp-patient-order-id:hover {
  text-decoration: underline;
}

.sp-patient-date {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  color: var(--sp-text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.sp-patient-date small {
  color: var(--ph-muted);
  font-size: 12px;
}

.sp-patient-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  padding: 1.6rem 1rem 1.75rem;
  color: var(--ph-muted);
  text-align: center;
}

.sp-patient-empty i {
  margin-bottom: .35rem;
  color: #c5ced9;
  font-size: 1.55rem;
}

.sp-patient-empty strong {
  color: var(--sp-text-primary);
  font-size: 14px;
  font-weight: 650;
}

.sp-patient-empty span {
  font-size: 13px;
}

.sp-patient-view {
  color: var(--sp-blue-600);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.sp-patient-view:hover {
  text-decoration: underline;
}

.sp-order-status[data-status="Paid"] {
  border-color: rgba(19, 138, 98, .06);
  color: var(--sp-success-600);
  background: var(--sp-success-100);
}

.sp-order-status[data-status="Unpaid"] {
  border-color: rgba(37, 99, 255, .06);
  color: #2457d6;
  background: rgba(37, 99, 255, .08);
}

.sp-order-status[data-status="Overdue"] {
  border-color: rgba(180, 83, 9, .08);
  color: #9a3412;
  background: rgba(245, 158, 11, .12);
}

.sp-order-status[data-status="Draft"] {
  border-color: rgba(100, 116, 139, .08);
  color: var(--sp-slate-600);
  background: var(--sp-slate-100);
}

.sp-patient-profile {
  padding: 1rem 1.1rem 1.05rem;
}

.sp-patient-profile__title {
  margin: 0 0 1rem;
  color: var(--ph-navy);
  font-size: 15px;
  font-weight: 700;
}

.sp-patient-section {
  padding-bottom: .95rem;
  margin-bottom: .95rem;
  border-bottom: 1px solid var(--ph-border);
}

.sp-patient-section:last-of-type {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: 0;
}

.sp-patient-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .55rem;
}

.sp-patient-section__head h3 {
  margin: 0;
  color: var(--ph-navy);
  font-size: 13.5px;
  font-weight: 700;
}

.sp-patient-section__edit {
  color: var(--sp-blue-600);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.sp-patient-section__edit:hover {
  text-decoration: underline;
}

.sp-patient-dl {
  display: grid;
  grid-template-columns: 6.25rem minmax(0, 1fr);
  gap: .35rem .75rem;
  margin: 0;
}

.sp-patient-dl dt {
  color: var(--ph-muted);
  font-size: 12.5px;
  font-weight: 500;
}

.sp-patient-dl dd {
  margin: 0;
  color: var(--sp-text-primary);
  font-size: 13px;
  font-weight: 550;
  overflow-wrap: anywhere;
}

.sp-patient-address {
  color: var(--sp-text-primary);
  font-size: 13px;
  font-weight: 550;
  line-height: 1.45;
  white-space: pre-line;
}

.sp-patient-actions {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.sp-patient-action {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: .5rem;
  width: 100%;
  min-height: 38px;
  padding: .45rem .7rem;
  border: 1px solid var(--ph-border);
  border-radius: 10px;
  color: var(--sp-blue-600);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.sp-patient-action:hover,
.sp-patient-action:focus-visible {
  border-color: #d7e4ff;
  color: var(--sp-blue-700);
  background: #f7f9ff;
}

.sp-patient-action--danger {
  border-color: #f4c9c9;
  color: var(--sp-danger-600);
}

.sp-patient-action--danger:hover,
.sp-patient-action--danger:focus-visible {
  border-color: #f0b4b4;
  color: #b91c1c;
  background: #fff7f7;
}

.sp-patient-footnote {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid var(--ph-border);
  color: var(--ph-muted);
  font-size: 12px;
}

.sp-patient-footnote strong {
  display: block;
  margin-bottom: .1rem;
  color: var(--ph-muted);
  font-size: 11px;
  font-weight: 600;
}

.sp-patient-footnote span {
  color: var(--sp-text-secondary);
  font-weight: 550;
}

.sp-patient-activity {
  display: flex;
  flex-direction: column;
  padding: .25rem 1.1rem 1rem;
}

.sp-patient-activity__item {
  display: grid;
  grid-template-columns: 7.25rem auto minmax(0, 1fr) auto;
  gap: .65rem 1rem;
  align-items: start;
  padding: .7rem 0;
}

.sp-patient-activity__when {
  display: flex;
  flex-direction: column;
  color: var(--ph-muted);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
}

.sp-patient-activity__rail {
  position: relative;
  display: flex;
  justify-content: center;
  width: 1.15rem;
  min-height: 100%;
}

.sp-patient-activity__rail::before {
  content: "";
  position: absolute;
  top: 1.15rem;
  bottom: -0.7rem;
  left: 50%;
  width: 1px;
  background: #e6eaf0;
  transform: translateX(-50%);
}

.sp-patient-activity__item:last-child .sp-patient-activity__rail::before {
  display: none;
}

.sp-patient-activity__dot {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #5b6c82;
  background: #eef2f6;
  font-size: .85rem;
}

.sp-patient-activity__dot--payment {
  color: #1f8a7a;
  background: #e8f8f4;
}

.sp-patient-activity__dot--order {
  color: #4f6ad8;
  background: #eef2ff;
}

.sp-patient-activity__dot--person {
  color: #6d5bd0;
  background: #f1eeff;
}

.sp-patient-activity__dot--billing {
  color: #7a5ad0;
  background: #f4eeff;
}

.sp-patient-activity__copy {
  min-width: 0;
}

.sp-patient-activity__copy strong {
  display: block;
  color: var(--ph-navy);
  font-size: 13.5px;
  font-weight: 650;
}

.sp-patient-activity__copy span {
  color: var(--ph-muted);
  font-size: 12.5px;
}

.sp-patient-activity__actor {
  color: var(--ph-muted);
  font-size: 12.5px;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.sp-patient-note {
  margin-bottom: .85rem;
}

.sp-patient-note:last-child {
  margin-bottom: 0;
}

.sp-patient-note__label {
  margin-bottom: .2rem;
  color: var(--ph-muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.sp-patient-note__body {
  color: var(--sp-text-primary);
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.sp-patient-paymeta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem 1.25rem;
  padding: .25rem 1.1rem 1rem;
  color: var(--sp-text-secondary);
  font-size: 13px;
}

.sp-patient-paymeta dt {
  color: var(--ph-muted);
  font-weight: 500;
}

.sp-patient-paymeta dd {
  margin: 0 0 .55rem;
  font-weight: 550;
}

@media (max-width: 1199.98px) {
  .sp-patient-layout {
    grid-template-columns: 1fr;
  }

  .sp-patient-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767.98px) {
  .sp-patient-hub__name {
    font-size: 1.45rem;
  }

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

  .sp-patient-activity__item {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "rail when"
      "rail copy"
      "rail actor";
  }

  .sp-patient-activity__when { grid-area: when; }
  .sp-patient-activity__rail { grid-area: rail; }
  .sp-patient-activity__copy { grid-area: copy; }
  .sp-patient-activity__actor {
    grid-area: actor;
    text-align: left;
  }

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