/* Patient accounting detail: keep summary, editors and category cards readable. */

html[data-theme] .patient-accounting-panel > .patient-accounting-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 12px !important;
  margin: 16px 0 18px !important;
}

html[data-theme] .patient-accounting-panel > .patient-accounting-stats .patient-accounting-stat {
  min-width: 0;
  min-height: 94px !important;
  padding: 14px 16px !important;
}

html[data-theme] .patient-accounting-panel > .patient-accounting-stats .patient-accounting-stat span {
  display: block;
  line-height: 1.3;
}

html[data-theme] .patient-accounting-panel > .patient-accounting-stats .patient-accounting-stat strong {
  margin-top: 8px !important;
  font-size: 1.22rem !important;
  line-height: 1.18 !important;
  overflow-wrap: anywhere;
}

html[data-theme] .patient-accounting-observation-form {
  grid-template-columns: minmax(240px, 0.8fr) minmax(320px, 1.35fr) auto !important;
  gap: 16px !important;
  align-items: end !important;
  margin: 0 0 18px !important;
  padding: 14px 16px !important;
  border: 1px solid var(--theme-border, var(--border)) !important;
  border-radius: 14px !important;
  background: color-mix(in srgb, var(--theme-surface, var(--card)) 94%, var(--theme-primary, #238c84) 6%) !important;
  box-shadow: none !important;
}

html[data-theme] .patient-accounting-observation-form > .muted {
  align-self: center !important;
  max-width: 600px;
  font-size: 0.88rem;
  line-height: 1.42;
}

html[data-theme] .patient-accounting-observation-form > .btn {
  align-self: end;
  min-height: 44px;
  white-space: nowrap;
}

html[data-theme] .patient-accounting-observations {
  gap: 14px;
}

html[data-theme] .patient-accounting-observation-card {
  padding: 17px 18px !important;
  border-radius: 15px !important;
  box-shadow: none !important;
}

html[data-theme] .patient-accounting-observation-card .patient-accounting-detail-head {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

html[data-theme] .patient-accounting-observation-card h3 {
  margin-bottom: 7px !important;
  font-size: 1.08rem;
  line-height: 1.3;
}

html[data-theme] .patient-accounting-observation-card .patient-accounting-observation-description {
  margin: 12px 0 14px;
  line-height: 1.45;
}

html[data-theme] .patient-accounting-observation-card .patient-accounting-compact-form {
  grid-template-columns: minmax(0, 1fr) auto !important;
  gap: 12px !important;
  align-items: end !important;
}

html[data-theme] .patient-accounting-add-form {
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr) auto !important;
  gap: 14px !important;
  align-items: end !important;
}

html[data-theme] .patient-accounting-add-form > .muted {
  align-self: center !important;
  font-size: 0.88rem;
  line-height: 1.42;
}

html[data-theme] .patient-accounting-add-form > .btn {
  min-height: 44px;
  white-space: nowrap;
}

/* Passport categories on the patient card should read as records, not cramped pills. */
html[data-theme] .patient-accounting-panel:has(#passport-category-add) > .patient-accounting-badges,
html[data-theme] .patient-accounting-panel:has(form[action*="passport"]) > .patient-accounting-badges {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin: 12px 0 4px;
}

html[data-theme] .patient-accounting-panel:has(#passport-category-add) > .patient-accounting-badges > .patient-accounting-badge,
html[data-theme] .patient-accounting-panel:has(form[action*="passport"]) > .patient-accounting-badges > .patient-accounting-badge {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 13px;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.3;
}

html[data-theme] .patient-accounting-panel:has(#passport-category-add) > .patient-accounting-badges .btn,
html[data-theme] .patient-accounting-panel:has(form[action*="passport"]) > .patient-accounting-badges .btn {
  width: 30px;
  min-width: 30px;
  min-height: 30px !important;
  height: 30px;
  padding: 0 !important;
  border-radius: 8px;
}

html[data-theme] .patient-accounting-panel:has(#passport-category-add) .patient-accounting-compact-form {
  grid-template-columns: minmax(0, 1fr) auto !important;
  gap: 12px !important;
  align-items: end !important;
}

html[data-theme] .patient-accounting-panel:has(#passport-category-add) hr,
html[data-theme] .patient-accounting-panel:has(.patient-accounting-add-form) hr {
  margin: 16px 0 !important;
  border: 0 !important;
  border-top: 1px solid var(--theme-border, var(--border)) !important;
}

@media (max-width: 980px) {
  html[data-theme] .patient-accounting-observation-form {
    grid-template-columns: minmax(240px, 1fr) auto !important;
  }

  html[data-theme] .patient-accounting-observation-form > .muted {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: none;
  }

  html[data-theme] .patient-accounting-add-form {
    grid-template-columns: minmax(260px, 1fr) auto !important;
  }

  html[data-theme] .patient-accounting-add-form > .muted {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (max-width: 760px) {
  html[data-theme] .patient-accounting-panel > .patient-accounting-stats,
  html[data-theme] .patient-accounting-observation-form,
  html[data-theme] .patient-accounting-add-form,
  html[data-theme] .patient-accounting-observation-card .patient-accounting-detail-head,
  html[data-theme] .patient-accounting-observation-card .patient-accounting-compact-form,
  html[data-theme] .patient-accounting-panel:has(#passport-category-add) .patient-accounting-compact-form {
    grid-template-columns: 1fr !important;
  }

  html[data-theme] .patient-accounting-observation-form > .muted,
  html[data-theme] .patient-accounting-add-form > .muted {
    grid-column: auto;
    grid-row: auto;
  }

  html[data-theme] .patient-accounting-observation-form > .btn,
  html[data-theme] .patient-accounting-add-form > .btn,
  html[data-theme] .patient-accounting-observation-card .patient-accounting-detail-head > form .btn {
    width: 100%;
  }
}
