/* IPD discharge bill — in-app preview + print (dense, repeating header/footer) */

.ipd-bill-preview {
  max-width: 960px;
  margin: 0 auto;
}

.ipd-bill-preview__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.75rem;
  background: var(--eu-surface, #fff);
  border: 1px solid var(--eu-border, #e2e8f0);
  border-radius: 0.5rem;
}

.ipd-bill-preview__toolbar-left,
.ipd-bill-preview__toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.ipd-bill-doc {
  width: 210mm;
  max-width: 100%;
  margin: 0 auto;
  padding: 10mm 12mm;
  background: #fff;
  color: #1f2937;
  border: 1px solid #e2e8f0;
  border-radius: 0.35rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 11px;
  line-height: 1.3;
}

.ipd-bill-doc * {
  box-sizing: border-box;
}

/* Screen-only fixed chrome placeholders (shown only when printing) */
.ipd-bill-doc__print-header,
.ipd-bill-doc__print-footer {
  display: none;
}

.ipd-bill-doc__header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.ipd-bill-doc__hospital {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.ipd-bill-doc__hospital-meta {
  font-size: 10px;
  color: #64748b;
  margin-top: 2px;
}

.ipd-bill-doc__title {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  margin: 6px 0 10px;
  text-decoration: underline;
  letter-spacing: 0.02em;
}

.ipd-bill-doc__info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 14px;
  margin-bottom: 10px;
  font-size: 10px;
}

.ipd-bill-doc__info-row {
  display: flex;
  gap: 6px;
}

.ipd-bill-doc__label {
  font-weight: 700;
  min-width: 92px;
  color: #475569;
}

.ipd-bill-doc__section-title {
  font-size: 11px;
  font-weight: 700;
  margin: 10px 0 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid #cbd5e1;
}

.ipd-bill-doc__section-count {
  font-weight: 600;
  color: #64748b;
  margin-left: 0.25rem;
}

.ipd-bill-doc table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 6px;
  font-size: 9.5px;
}

.ipd-bill-doc thead {
  display: table-header-group;
}

.ipd-bill-doc tfoot {
  display: table-footer-group;
}

.ipd-bill-doc th,
.ipd-bill-doc td {
  border: 1px solid #e2e8f0;
  padding: 3px 5px;
  text-align: left;
  vertical-align: top;
}

.ipd-bill-doc th {
  background: #f8fafc;
  font-weight: 700;
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #475569;
}

.ipd-bill-doc .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ipd-bill-doc__lines th:nth-child(1),
.ipd-bill-doc__lines td:nth-child(1) { width: 28px; }
.ipd-bill-doc__lines th:nth-child(3),
.ipd-bill-doc__lines td:nth-child(3) { width: 72px; white-space: nowrap; }
.ipd-bill-doc__lines th:nth-child(4),
.ipd-bill-doc__lines td:nth-child(4) { width: 108px; }
.ipd-bill-doc__posting {
  font-size: 8.5px;
  word-break: break-all;
}

.ipd-bill-doc__desc {
  font-weight: 600;
  line-height: 1.25;
}

.ipd-bill-doc__codes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.55rem;
  margin-top: 1px;
  font-size: 8px;
  color: #475569;
  font-weight: 600;
}

.ipd-bill-doc__pending-tag {
  margin-top: 1px;
  font-size: 8px;
  font-weight: 700;
  color: #c2410c;
  text-transform: uppercase;
}

.ipd-bill-doc__subtotal td {
  background: #f8fafc;
}

.ipd-bill-doc__summary {
  margin-top: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  overflow: hidden;
}

.ipd-bill-doc__summary-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 4px 8px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 10px;
}

.ipd-bill-doc__summary-row:last-child {
  border-bottom: none;
}

.ipd-bill-doc__summary-row--total {
  background: #f1f5f9;
  font-weight: 700;
  font-size: 11px;
}

.ipd-bill-doc__summary-row--due {
  background: #fef2f2;
  color: #b91c1c;
  font-weight: 800;
}

.ipd-bill-doc__empty {
  margin: 0 0 0.5rem;
  font-size: 10px;
  color: #555;
}

.ipd-bill-doc__note {
  margin-top: 8px;
  padding: 6px 8px;
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  font-size: 9px;
  color: #78716c;
}

.ipd-bill-doc__signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 20px;
  text-align: center;
  font-size: 9px;
}

.ipd-bill-doc__sig-line {
  border-top: 1px solid #94a3b8;
  margin-top: 28px;
  padding-top: 3px;
  font-weight: 600;
}

.ipd-bill-doc__footer {
  margin-top: 12px;
  padding-top: 6px;
  border-top: 1px solid #e2e8f0;
  text-align: center;
  font-size: 8px;
  color: #64748b;
}

@media print {
  .no-print,
  .ipd-bill-preview__toolbar,
  .app-sidebar,
  .app-shell__overlay,
  .app-topbar,
  .app-shell__topbar,
  .app-shell__topnav,
  .request-timing,
  [data-controller="request-timing"] {
    display: none !important;
  }

  .app-shell,
  .app-shell__workspace,
  .app-shell__main,
  .ipd-bill-preview {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
    background: #fff !important;
    box-shadow: none !important;
    border: none !important;
  }

  .ipd-bill-doc {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    border-radius: 0;
  }

  /* Hide in-flow header/footer on print — fixed chrome repeats every page */
  .ipd-bill-doc__header,
  .ipd-bill-doc__footer {
    display: none !important;
  }

  .ipd-bill-doc__print-header {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 0 0 4px;
    border-bottom: 1.5px solid #0f172a;
    background: #fff;
    z-index: 10;
    font-size: 9px;
    line-height: 1.25;
  }

  .ipd-bill-doc__print-header-main {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 10px;
  }

  .ipd-bill-doc__print-header-sub {
    margin-top: 1px;
    color: #64748b;
    font-size: 8px;
  }

  .ipd-bill-doc__print-footer {
    display: block !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding-top: 3px;
    border-top: 1px solid #cbd5e1;
    background: #fff;
    text-align: center;
    font-size: 8px;
    color: #64748b;
    z-index: 10;
  }

  /* Reserve space so content does not collide with fixed chrome */
  .ipd-bill-doc__title {
    margin-top: 18mm;
  }

  .ipd-bill-doc__signatures {
    margin-bottom: 12mm;
  }

  .ipd-bill-doc table {
    page-break-inside: auto;
  }

  .ipd-bill-doc tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  .ipd-bill-doc thead {
    display: table-header-group;
  }

  .no-print-link {
    color: inherit;
    text-decoration: none;
  }

  @page {
    size: A4;
    margin: 14mm 10mm 12mm 10mm;
  }
}
