/* ============================================================
   Cleaning module — Billing Workflow aggregator.
   Layout: filter bar → patient list → patient record modal
   (fullscreen medical-record style organized per Datacleaning.pdf).
   ============================================================ */

/* --- Organization picker (required first step, freezable) ------------- */
.cleaning-org-bar {
  margin: 0 0 12px;
}
.cleaning-org-choose {
  padding: 14px 16px;
  background: #eef2fb;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.cleaning-org-choose-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #1e3a8a;
}
.cleaning-org-choose select {
  padding: 8px 12px;
  border: 1px solid #94a3b8;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  background: #fff;
  color: #1e293b;
  min-width: 260px;
}

.cleaning-org-locked {
  padding: 12px 16px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.cleaning-org-locked-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #166534;
}
.cleaning-org-locked-value {
  font-size: 15px;
  font-weight: 600;
  color: #14532d;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cleaning-org-change {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid #16a34a;
  background: #fff;
  color: #166534;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.cleaning-org-change:hover {
  background: #16a34a;
  color: #fff;
}

.cleaning-org-empty {
  padding: 14px 16px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 10px;
  color: #92400e;
  font-size: 13px;
}

/* Gate shown until an organization is committed. */
.cleaning-org-gate {
  margin: 20px auto;
  padding: 30px 24px;
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  text-align: center;
  color: #475569;
  max-width: 620px;
}
.cleaning-org-gate-icon {
  font-size: 40px;
  margin-bottom: 8px;
}
.cleaning-org-gate h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
}
.cleaning-org-gate p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

/* --- Filter bar ------------------------------------------------------- */
.cleaning-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface-2, #f5f6f8);
  border: 1px solid var(--border, #d6dadf);
  border-radius: 10px;
  margin: 0 0 12px;
}
.cleaning-toolbar label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted, #6b7280);
  font-weight: 700;
  white-space: nowrap;
}
.cleaning-toolbar select,
.cleaning-toolbar input[type="month"] {
  padding: 7px 10px;
  border: 1px solid var(--border, #d6dadf);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface, #fff);
  color: inherit;
  min-width: 150px;
}
.cleaning-summary {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted, #6b7280);
}

.cleaning-warnings { display: block; margin: 0 0 12px; }
.cleaning-warning {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #92400e;
  font-size: 12px;
  margin-bottom: 6px;
}

/* --- Patient list ---------------------------------------------------- */
.cleaning-list-panel {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #d6dadf);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cleaning-list-search {
  padding: 8px 10px;
  border: 1px solid var(--border, #d6dadf);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface, #fff);
  color: inherit;
}
.cleaning-patient-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 70vh;
  overflow-y: auto;
}

/* Shared 6-column grid for header + data rows so columns align exactly. */
.cleaning-patient-header,
.cleaning-patient-row {
  display: grid;
  grid-template-columns: 90px 100px minmax(0, 1.4fr) minmax(0, 1.4fr) 90px 90px;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
}

.cleaning-patient-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  border-radius: 8px 8px 0 0;
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cleaning-patient-header .cp-count { text-align: right; }

.cleaning-patient-row {
  border: 1px solid var(--border-soft, #eef0f3);
  border-radius: 8px;
  background: var(--surface, #fff);
  color: inherit;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 100ms ease, border-color 100ms ease;
}
.cleaning-patient-row:hover {
  background: var(--surface-3, #eef2fb);
  border-color: var(--primary, #4f46e5);
}

.cleaning-patient-row .cp-month {
  color: #475569;
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
}
.cleaning-patient-row .cp-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  color: #1e40af;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cleaning-patient-row .cp-name {
  font-weight: 600;
  color: var(--text, #1f2937);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cleaning-patient-row .cp-physician {
  color: var(--muted, #6b7280);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cleaning-patient-row .cp-count {
  font-size: 12px;
  color: var(--muted, #6b7280);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cleaning-patient-row .cp-status { text-align: left; }

/* Status pill — green "Active" indicator replacing the old "Open →". */
.status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.status-active {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

/* Narrower screens: collapse to key columns so it's still legible. */
@media (max-width: 900px) {
  .cleaning-patient-header,
  .cleaning-patient-row {
    grid-template-columns: 80px 90px 1fr 80px 80px;
  }
  .cleaning-patient-header .cp-physician,
  .cleaning-patient-row .cp-physician { display: none; }
}
@media (max-width: 700px) {
  .cleaning-patient-header,
  .cleaning-patient-row {
    grid-template-columns: 1fr 1fr;
  }
  .cleaning-patient-header .cp-month,
  .cleaning-patient-header .cp-physician,
  .cleaning-patient-header .cp-count,
  .cleaning-patient-row .cp-month,
  .cleaning-patient-row .cp-physician,
  .cleaning-patient-row .cp-count { display: none; }
}
.cleaning-empty {
  padding: 32px 12px;
  color: var(--muted, #6b7280);
  font-size: 13px;
  text-align: center;
}

/* ============================================================
   Fullscreen record modal — medical-record document layout.
   ============================================================ */

.cleaning-record-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: stretch;
  justify-content: stretch;
  z-index: 200;
  padding: 24px;
}
.cleaning-record-backdrop.active { display: flex; }

.cleaning-record-frame {
  background: #f8fafc;
  border-radius: 12px;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.cleaning-record-header {
  padding: 14px 20px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.cleaning-record-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.cleaning-record-header .meta {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
}
.cleaning-record-header .btn {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
}
.cleaning-record-header .btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.cleaning-record-body {
  flex: 1;
  overflow: auto;
  padding: 20px;
  background: #f8fafc;
}

.record-shell { display: flex; flex-direction: column; gap: 16px; }

/* --- Source-doc strip (top of each patient record) ------------------- */
.record-source-strip {
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--border, #d6dadf);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}
.record-source-label {
  color: var(--muted, #6b7280);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 11px;
  white-space: nowrap;
}
.record-source-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.record-source-none { color: var(--muted, #6b7280); font-style: italic; font-size: 12px; }
.record-source-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2fb;
  color: #1e40af;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  font-size: 12px;
}
.record-source-pill:hover { background: #dbeafe; }

/* "Attributes" button pinned to the right end of the strip. */
.record-attr-btn {
  margin-left: auto;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid #2563eb;
  background: #fff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.record-attr-btn:hover { background: #2563eb; color: #fff; }

/* --- Section card ---------------------------------------------------- */
.record-section {
  background: #fff;
  border: 1px solid var(--border, #d6dadf);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.record-section-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Field grid — now tighter since tier badges moved to Attributes ---- */
.field-grid {
  display: grid;
  gap: 6px 12px;
}
.field-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .field-grid-4 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .field-grid-4, .field-grid-3, .field-grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 600px) {
  .field-grid-4, .field-grid-3, .field-grid-2 { grid-template-columns: 1fr; }
}

.field {
  padding: 6px 10px;
  border: 1px solid var(--border-soft, #eef0f3);
  border-radius: 6px;
  background: #fafbfc;
  min-width: 0;
}
/* Column names: bold + subtle gray so the label reads as a heading. */
.field-name {
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}
/* Values: less gray than the label — darker slate, medium weight — so the
   value stands out as the meaningful content. */
.field-value {
  font-size: 12.5px;
  color: #1e293b;
  font-weight: 500;
  word-break: break-word;
  line-height: 1.4;
}
.field-multi { font-size: 12px; }
.field-multi-count {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: #eef2fb;
  color: #1e40af;
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 4px;
}
.field-multi-list {
  margin: 0;
  padding-left: 16px;
  color: #1e293b;
  font-size: 12.5px;
}
.field-multi-list li { margin: 1px 0; word-break: break-word; }

/* --- Tier badges ----------------------------------------------------- */
.tier-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.tier-DIRECT   { background: #dcfce7; color: #166534; border-color: #86efac; }
.tier-DERIVED  { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.tier-NO_SOURCE { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

/* --- Payer 2-column card -------------------------------------------- */
.payer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .payer-grid { grid-template-columns: 1fr; } }
.payer-col {
  padding: 10px 12px;
  border: 1px solid var(--border-soft, #eef0f3);
  border-radius: 8px;
  background: #fafbfc;
}
.payer-col-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: 4px;
}
.payer-defs {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 3px 12px;
  margin: 0;
  font-size: 12px;
}
.payer-defs dt {
  color: #64748b;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-size: 10.5px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.payer-defs dd {
  margin: 0;
  color: #1e293b;
  font-weight: 500;
  word-break: break-word;
}
.payer-empty {
  color: var(--muted, #6b7280);
  font-size: 12px;
  padding: 8px 0;
}

/* --- Medical Condition (full-width block) ---------------------------- */
.med-condition-section {
  background: #fff;
}
.med-condition-body {
  padding: 4px 0;
}
.med-condition-text,
.med-condition-list {
  margin: 0;
  color: #1e293b;
  font-size: 13.5px;
  line-height: 1.55;
  text-align: justify;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
}
.med-condition-list {
  padding-left: 20px;
  list-style-type: disc;
}
.med-condition-list li { margin: 2px 0; }

/* --- Census calendar ------------------------------------------------- */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--muted, #6b7280);
}
.cal-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  background: #fff;
}
.cal-head {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
  color: var(--muted, #6b7280);
  text-align: center;
  padding: 4px 0;
  border-bottom: 1px solid #e2e8f0;
}
.cal-cell {
  padding: 6px 4px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  min-height: 66px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  background: #fff;
}
.cal-blank { background: transparent; border-color: transparent; }
/* Full-date label on a single row — "1st Jan 2026". */
.cal-date {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  line-height: 1.1;
  white-space: nowrap;
}
.cal-date-day {
  font-size: 12.5px;
  color: #1e293b;
  font-weight: 700;
}
.cal-date-month {
  font-size: 10px;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.cal-status {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  min-width: 28px;
  text-align: center;
}
.cal-A  { background: #dcfce7; color: #166534; }  /* admission */
.cal-P  { background: #dcfce7; color: #166534; }  /* present */
.cal-RA { background: #bbf7d0; color: #14532d; }  /* readmission */
.cal-D  { background: #e5e7eb; color: #374151; }  /* discharge */
.cal-L  { background: #fef3c7; color: #92400e; }  /* leave */
.cal-BH { background: #fde68a; color: #78350f; }  /* bed hold */
.cal-H  { background: #fee2e2; color: #991b1b; }  /* hospital */
.cal-T  { background: #fed7aa; color: #7c2d12; }  /* transfer */
.cal-none { background: #f3f4f6; color: #9ca3af; }

/* --- Treatments container (table-like frame, card rows) --------------- */
.tx-container {
  border: 1px solid var(--border, #d6dadf);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
/* Column-label strip at the top of the container so cards below make
   sense at a glance. Mimics a table header row. */
.tx-container-head {
  display: grid;
  grid-template-columns: 60px 140px 1fr minmax(220px, 30%);
  gap: 12px;
  padding: 8px 14px;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
@media (max-width: 900px) {
  .tx-container-head { grid-template-columns: 60px 1fr; }
  .tx-container-head .tx-h-name,
  .tx-container-head .tx-h-meta { display: none; }
}
.tx-container-body {
  display: flex;
  flex-direction: column;
}

/* --- Individual treatment card --------------------------------------- */
.tx-card {
  padding: 12px 14px;
  border-bottom: 1px solid #eef0f3;
  background: #fff;
  transition: background 100ms ease;
}
.tx-card:last-child { border-bottom: 0; }
.tx-card:hover { background: #fafbfc; }

.tx-card-head {
  display: grid;
  grid-template-columns: 60px 140px 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 8px;
}
@media (max-width: 900px) {
  .tx-card-head { grid-template-columns: 60px 1fr; }
  .tx-type-badge { grid-column: 1 / -1; }
  .tx-name-block { grid-column: 1 / -1; }
}

.tx-line-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 24px;
  padding: 0 10px;
  border-radius: 6px;
  background: #eef2fb;
  color: #1e40af;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  font-size: 12px;
}
.tx-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #475569;
  background: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
  height: 24px;
}
.tx-type-badge.tx-type-med { background: #dbeafe; color: #1e3a8a; }
.tx-type-badge.tx-type-tx  { background: #fef3c7; color: #92400e; }
.tx-type-badge.tx-type-nut { background: #dcfce7; color: #14532d; }

.tx-name-block { min-width: 0; }
.tx-name-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  color: var(--muted, #6b7280);
}
.tx-name-value {
  font-size: 13.5px;
  color: #1e293b;
  line-height: 1.4;
  font-weight: 500;
  /* Critical: allow long treatment descriptions to wrap cleanly. */
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* --- L1 validation chip + popover ------------------------------------ */
.l1-chip {
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  padding: 3px 10px;
  transition: transform 60ms ease;
}
.l1-chip:hover { transform: translateY(-1px); }
.l1-chip .l1-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
/* Fully saturated backgrounds so the L1/L2 status reads at a glance from
   across the treatment table. Compound selectors (.l1-chip.l1-clean) so they
   always win over the neutral .tx-chip base — the color is permanent, not a
   hover-only effect. */
.l1-chip.l1-clean {
  background: #16a34a;
  color: #fff;
  border-color: #15803d;
  box-shadow: 0 1px 2px rgba(22, 101, 52, 0.25);
}
.l1-chip.l1-clean:hover { background: #15803d; }
.l1-chip.l1-clean .l1-dot { background: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,0.35); }

.l1-chip.l1-dirty {
  background: #dc2626;
  color: #fff;
  border-color: #b91c1c;
  box-shadow: 0 1px 2px rgba(153, 27, 27, 0.28);
}
.l1-chip.l1-dirty:hover { background: #b91c1c; }
.l1-chip.l1-dirty .l1-dot { background: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,0.35); }

/* Keep the label text white too — the .tx-chip-value default is dark. */
.l1-chip.l1-clean .tx-chip-value,
.l1-chip.l1-dirty .tx-chip-value { color: #fff; }

.l1-pin { font-size: 10px; opacity: 0.95; filter: grayscale(0) drop-shadow(0 0 1px rgba(0,0,0,0.15)); }

/* L2 chip is the same shape as L1 but a hair narrower and slightly
   flatter so the pair reads as two distinct validations at a glance. */
.l2-chip {
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* Popover reused for L2 — chip listing the matched keywords. */
.l2-hit-chip {
  display: inline-block;
  padding: 1px 6px;
  margin: 2px 3px 0 0;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  font-size: 10.5px;
  font-weight: 600;
}

/* Highlight matched supply keywords inside the treatment Name so users
   see what phrases drove the L2 decision. Warm amber underline — reads
   as an annotation rather than a warning. */
mark.tx-kw-hit {
  background: linear-gradient(180deg, transparent 55%, #fde68a 55%);
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-weight: 600;
  cursor: help;
}

/* Popover — absolute-positioned singleton, appended to body. */
.l1-popover {
  position: absolute;
  z-index: 240;
  width: 320px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  padding: 12px 14px;
  font-size: 12.5px;
  color: #1e293b;
}
.l1-popover.hidden { display: none; }
.l1-pop-arrow {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: #fff;
  border-left: 1px solid #e2e8f0;
  border-top: 1px solid #e2e8f0;
}
.l1-pop-head {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #64748b;
  margin-bottom: 6px;
}
.l1-pop-current {
  padding: 6px 8px;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 12px;
  margin-bottom: 10px;
}
.l1-clean-text { color: #166534; }
.l1-dirty-text { color: #991b1b; }
.l1-source { color: #64748b; font-size: 11px; }
.l1-current-reason {
  margin-top: 3px;
  color: #475569;
  font-size: 11.5px;
  font-style: italic;
}
.l1-pop-toggle {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.l1-pop-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.l1-pop-radio:hover { background: #f1f5f9; }
.l1-radio-label.l1-clean-label { color: #166534; }
.l1-radio-label.l1-dirty-label { color: #991b1b; }
.l1-pop-reason { display: flex; flex-direction: column; gap: 4px; }
.l1-pop-reason span {
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.l1-pop-reason textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d6dadf;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  resize: vertical;
  min-height: 44px;
}
.l1-pop-reason textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.l1-pop-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* Metadata chips (Category, Keyword, Count, Time, MarTarId). */
.tx-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 10px;
  padding-left: 72px;  /* align under the name column, not under the line/type */
}
@media (max-width: 900px) { .tx-chips { padding-left: 0; } }
.tx-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 11px;
}
.tx-chip-label {
  font-weight: 700;
  color: var(--muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-size: 9px;
}
.tx-chip-value {
  color: #1e293b;
  font-weight: 500;
  word-break: break-word;
}

/* --- Daily schedule strip -------------------------------------------- */
.tx-schedule {
  padding-left: 72px;
  margin-top: 4px;
}
@media (max-width: 900px) { .tx-schedule { padding-left: 0; } }
.tx-schedule-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  color: var(--muted, #6b7280);
  margin-bottom: 4px;
}
.tx-shift-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tx-shift-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  align-items: center;
}
@media (max-width: 700px) {
  .tx-shift-row { grid-template-columns: 1fr; }
}
.tx-shift-time {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 4px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  min-width: 0;
}
.tx-shift-time-label {
  font-size: 9px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.tx-shift-time-value {
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  white-space: nowrap;
}
.tx-shift-count {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 10px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}
.tx-cells {
  display: grid;
  grid-template-columns: repeat(31, minmax(0, 1fr));
  gap: 3px;
  min-width: 0;
}
.tx-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 2px;
  border-radius: 4px;
  border: 1px solid #eef0f3;
  background: #fff;
  min-width: 0;
}
.tx-cell-day {
  font-size: 9px;
  color: var(--muted, #6b7280);
  font-weight: 600;
  line-height: 1;
}
.tx-cell-value {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Color-coded value backgrounds (retain the palette from the old table). */
.tx-cell.tx-day-blank .tx-cell-value { color: #cbd5e1; }
.tx-cell.tx-day-num   { background: #eef2fb; border-color: #dbeafe; }
.tx-cell.tx-day-num .tx-cell-value { color: #1e40af; font-family: ui-monospace, monospace; }
.tx-cell.tx-day-A     { background: #dcfce7; border-color: #bbf7d0; }
.tx-cell.tx-day-A .tx-cell-value { color: #166534; }
.tx-cell.tx-day-X     { background: #fee2e2; border-color: #fecaca; }
.tx-cell.tx-day-X .tx-cell-value { color: #991b1b; }
.tx-cell.tx-day-tick  { background: #f0fdf4; border-color: #bbf7d0; }
.tx-cell.tx-day-tick .tx-cell-value { color: #15803d; font-size: 10px; }
.tx-cell.tx-day-other { background: #f8fafc; border-color: #e2e8f0; }
.tx-cell.tx-day-other .tx-cell-value { color: #475569; }

/* Long dose readings (e.g. "√ tprn") need more room — expand the row. */
@media (max-width: 700px) {
  .tx-cells { grid-template-columns: repeat(7, 1fr); }
}

/* ============================================================
   Editable Billing section — one card per column with a stack of
   value inputs. "+ Add value" appends; each row has its own remove.
   ============================================================ */
.billing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.billing-field {
  padding: 8px 10px;
  border: 1px solid var(--border-soft, #eef0f3);
  border-radius: 8px;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.billing-field-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 0;
}
.billing-edited-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 10px;
  font-weight: 700;
  text-transform: lowercase;
  letter-spacing: 0.3px;
}
.billing-value-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.billing-value-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.billing-value-input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border, #d6dadf);
  border-radius: 6px;
  background: #fff;
  color: #1e293b;
  font-size: 12.5px;
  font-family: inherit;
  min-width: 0;
}
.billing-value-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}
.billing-remove-btn {
  border: 1px solid #fecaca;
  background: #fff;
  color: #991b1b;
  border-radius: 6px;
  width: 26px;
  height: 26px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.billing-remove-btn:hover { background: #fee2e2; }
.billing-add-btn {
  align-self: flex-start;
  border: 1px dashed #94a3b8;
  background: transparent;
  color: #475569;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.billing-add-btn:hover {
  background: #f1f5f9;
  border-color: #64748b;
  color: #1e293b;
}

/* ============================================================
   Attributes modal — column-to-mapping reference.
   Nested inside the fullscreen patient record modal.
   ============================================================ */
.cleaning-attr-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: none;
  align-items: stretch;
  justify-content: center;
  z-index: 220;   /* above the record modal (z=200) */
  padding: 40px 24px;
}
.cleaning-attr-backdrop.active { display: flex; }
.cleaning-attr-frame {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.cleaning-attr-header {
  padding: 12px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.cleaning-attr-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
}
.cleaning-attr-header .meta {
  font-size: 12px;
  color: var(--muted, #6b7280);
  margin-top: 2px;
}
.cleaning-attr-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  background: #fff;
}

.attr-legend {
  display: grid;
  grid-template-columns: max-content 1fr max-content 1fr max-content 1fr;
  gap: 6px 10px;
  align-items: center;
  font-size: 11.5px;
  color: #475569;
  padding: 8px 10px;
  margin-bottom: 14px;
  background: #f8fafc;
  border: 1px dashed #e2e8f0;
  border-radius: 8px;
}
@media (max-width: 700px) {
  .attr-legend { grid-template-columns: max-content 1fr; }
}

.attr-group { margin-bottom: 14px; }
.attr-group h4 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted, #6b7280);
  font-weight: 700;
}
.attr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}
.attr-table thead th {
  background: #f1f5f9;
  padding: 7px 10px;
  text-align: left;
  font-weight: 700;
  color: #1e293b;
  border-bottom: 1px solid #e2e8f0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.attr-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid #eef0f3;
  vertical-align: top;
}
.attr-table tbody tr:last-child td { border-bottom: 0; }
.attr-table tbody tr:hover { background: #fafbfc; }
.attr-table .attr-name {
  width: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 500;
  color: #1e293b;
  word-break: break-word;
}
.attr-table .attr-mapping {
  display: table-cell;
  color: #475569;
  line-height: 1.4;
}
.attr-table .attr-source {
  display: inline-block;
  margin-left: 8px;
  color: #475569;
}
