/* =====================================================================
   CareLite UI layer over Bootstrap 5.
   Design brief: a hospital counter ledger. Dense, high contrast, legible
   across a long shift. Money is always set in tabular figures so columns
   line up and a wrong digit is visible. Status is carried by an edge bar
   on the row, not by scattered colour.
   No web fonts — hospital LANs are often locked down or offline.
   ===================================================================== */

:root {
  --cl-ink:        #12212e;   /* petrol navy — headers, primary text   */
  --cl-ink-soft:   #4a5c6a;
  --cl-canvas:     #eef1f4;   /* cool paper                            */
  --cl-surface:    #ffffff;
  --cl-rule:       #d6dde3;
  --cl-accent:     #0b6e5f;   /* clinical teal — primary action        */
  --cl-accent-dk:  #085447;
  --cl-money-in:   #0b6e5f;
  --cl-due:        #b26a00;   /* amber — outstanding                   */
  --cl-danger:     #b3261e;
  --cl-occupied:   #b3261e;
  --cl-available:  #0b6e5f;
  --cl-blocked:    #6c757d;
  --cl-radius:     6px;
  --cl-shadow:     0 1px 2px rgba(18,33,46,.08), 0 1px 8px rgba(18,33,46,.04);
  --cl-mono: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
}

body {
  background: var(--cl-canvas);
  color: var(--cl-ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------- counter strip */
.cl-topbar {
  background: var(--cl-ink);
  color: #fff;
  padding: .45rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.cl-brand {
  font-weight: 700;
  letter-spacing: .04em;
  font-size: 1.05rem;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.cl-brand span { color: #8fd8c9; font-weight: 400; }
.cl-topbar .cl-hospital {
  font-size: .8rem;
  opacity: .85;
  border-left: 1px solid rgba(255,255,255,.25);
  padding-left: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cl-search { flex: 1 1 auto; max-width: 460px; }
.cl-search input {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  font-size: .85rem;
}
.cl-search input::placeholder { color: rgba(255,255,255,.55); }
.cl-search input:focus {
  background: #fff; color: var(--cl-ink);
  border-color: #8fd8c9; box-shadow: none;
}
.cl-topmeta { margin-left: auto; display: flex; align-items: center; gap: 1.1rem; font-size: .78rem; }
.cl-topmeta .k { opacity: .6; display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; }
.cl-topmeta .v { font-family: var(--cl-mono); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ shell */
.cl-shell { display: flex; min-height: calc(100vh - 42px); }
.cl-side {
  width: 218px; flex: 0 0 218px;
  background: var(--cl-surface);
  border-right: 1px solid var(--cl-rule);
  padding: .5rem 0 2rem;
}
.cl-side .nav-group {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--cl-ink-soft); padding: .9rem 1rem .3rem;
}
.cl-side a {
  display: block; padding: .38rem 1rem; color: var(--cl-ink);
  text-decoration: none; font-size: .86rem; border-left: 3px solid transparent;
}
.cl-side a:hover { background: var(--cl-canvas); }
.cl-side a.active {
  border-left-color: var(--cl-accent);
  background: var(--cl-canvas);
  font-weight: 600;
}
.cl-main { flex: 1 1 auto; padding: 1.1rem 1.35rem 3rem; min-width: 0; }

.cl-page-head { display: flex; align-items: baseline; gap: .8rem; margin-bottom: .9rem; flex-wrap: wrap; }
.cl-page-head h1 { font-size: 1.22rem; font-weight: 650; margin: 0; letter-spacing: -.01em; }
.cl-page-head .sub { color: var(--cl-ink-soft); font-size: .82rem; }
.cl-page-head .spacer { margin-left: auto; }

/* ------------------------------------------------------------ cards */
.cl-card {
  background: var(--cl-surface);
  border: 1px solid var(--cl-rule);
  border-radius: var(--cl-radius);
  box-shadow: var(--cl-shadow);
  margin-bottom: 1rem;
}
.cl-card > h2, .cl-card-head {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--cl-ink-soft); margin: 0;
  padding: .6rem .9rem; border-bottom: 1px solid var(--cl-rule);
  display: flex; align-items: center; gap: .6rem;
}
.cl-card-body { padding: .9rem; }

/* --------------------------------------------------------------- KPI */
.cl-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: .7rem; margin-bottom: 1.1rem; }
.cl-kpi {
  background: var(--cl-surface); border: 1px solid var(--cl-rule);
  border-radius: var(--cl-radius); padding: .65rem .8rem; box-shadow: var(--cl-shadow);
  border-top: 3px solid var(--cl-accent);
}
.cl-kpi.due   { border-top-color: var(--cl-due); }
.cl-kpi.plain { border-top-color: var(--cl-ink-soft); }
.cl-kpi .k { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--cl-ink-soft); }
.cl-kpi .v { font-size: 1.4rem; font-weight: 650; font-family: var(--cl-mono); font-variant-numeric: tabular-nums; line-height: 1.35; }
.cl-kpi .n { font-size: .72rem; color: var(--cl-ink-soft); }

/* ------------------------------------------------------------ tables */
.table.cl-table { background: var(--cl-surface); margin-bottom: 0; font-size: .855rem; }
.cl-table > thead > tr > th {
  background: #f6f8f9; border-bottom: 1px solid var(--cl-rule);
  font-size: .7rem; text-transform: uppercase; letter-spacing: .055em;
  color: var(--cl-ink-soft); font-weight: 600; white-space: nowrap; padding: .5rem .6rem;
}
.cl-table > tbody > tr > td { padding: .45rem .6rem; vertical-align: middle; border-color: #e8ecef; }
.cl-table > tbody > tr:hover { background: #f7fafb; }
.cl-table th.num, .cl-table td.num {
  text-align: right; font-family: var(--cl-mono); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.cl-table td.due  { color: var(--cl-due); font-weight: 600; }
.cl-table .th-sort { color: inherit; text-decoration: none; }
.cl-table .th-sort:hover { color: var(--cl-accent); }

/* status edge bar instead of loud pills */
tr.st-cancelled > td:first-child { box-shadow: inset 3px 0 0 var(--cl-danger); }
tr.st-cancelled { color: var(--cl-ink-soft); }
tr.st-cancelled td:nth-child(2) { text-decoration: line-through; }
tr.st-open > td:first-child { box-shadow: inset 3px 0 0 var(--cl-due); }
tr.st-closed > td:first-child { box-shadow: inset 3px 0 0 var(--cl-accent); }

.cl-tag {
  display: inline-block; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em;
  padding: .08rem .4rem; border-radius: 3px; border: 1px solid var(--cl-rule); color: var(--cl-ink-soft);
}
.cl-tag.corp { border-color: #b8d7f0; background: #eff7fd; color: #1d5b86; }
.cl-tag.cash { border-color: #bfe3d9; background: #f0f9f6; color: var(--cl-accent-dk); }

/* --------------------------------------------------------- bed board */
.cl-beds { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: .55rem; }
.cl-bed {
  border: 1px solid var(--cl-rule); border-left: 4px solid var(--cl-available);
  border-radius: var(--cl-radius); background: var(--cl-surface);
  padding: .5rem .6rem; min-height: 74px; text-decoration: none; color: inherit; display: block;
}
.cl-bed:hover { box-shadow: var(--cl-shadow); }
.cl-bed.occupied    { border-left-color: var(--cl-occupied); background: #fdf6f5; }
.cl-bed.reserved    { border-left-color: var(--cl-due); background: #fdfaf4; }
.cl-bed.blocked,
.cl-bed.maintenance { border-left-color: var(--cl-blocked); background: #f4f5f6; }
.cl-bed .bed-no { font-weight: 650; font-size: .9rem; }
.cl-bed .bed-meta { font-size: .72rem; color: var(--cl-ink-soft); line-height: 1.3; }

/* ------------------------------------------------------------ forms */
.form-label { font-size: .76rem; font-weight: 600; color: var(--cl-ink-soft); margin-bottom: .15rem; }
.form-label .req { color: var(--cl-danger); }
.form-control, .form-select { font-size: .875rem; border-color: #c9d2d9; }
.form-control:focus, .form-select:focus {
  border-color: var(--cl-accent); box-shadow: 0 0 0 .18rem rgba(11,110,95,.14);
}
.form-control.num { text-align: right; font-family: var(--cl-mono); font-variant-numeric: tabular-nums; }
.btn { font-size: .86rem; }
.btn-primary { background: var(--cl-accent); border-color: var(--cl-accent); }
.btn-primary:hover, .btn-primary:focus { background: var(--cl-accent-dk); border-color: var(--cl-accent-dk); }
.btn-outline-primary { color: var(--cl-accent); border-color: var(--cl-accent); }
.btn-outline-primary:hover { background: var(--cl-accent); border-color: var(--cl-accent); }
.btn-link { color: var(--cl-accent); }
a { color: var(--cl-accent-dk); }

.cl-filters {
  background: var(--cl-surface); border: 1px solid var(--cl-rule); border-radius: var(--cl-radius);
  padding: .65rem .75rem; margin-bottom: .9rem; box-shadow: var(--cl-shadow);
}
.cl-filters .row { --bs-gutter-y: .5rem; }

.cl-empty { padding: 2.2rem 1rem; text-align: center; color: var(--cl-ink-soft); }
.cl-empty strong { display: block; color: var(--cl-ink); margin-bottom: .25rem; }

/* -------------------------------------------------------- patient bar */
.cl-patient-bar {
  background: var(--cl-ink); color: #fff; border-radius: var(--cl-radius);
  padding: .55rem .85rem; margin-bottom: .9rem;
  display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap;
}
.cl-patient-bar .name { font-weight: 650; font-size: 1rem; }
.cl-patient-bar .f { font-size: .74rem; }
.cl-patient-bar .f .k { display: block; opacity: .6; text-transform: uppercase; letter-spacing: .06em; font-size: .64rem; }
.cl-patient-bar .f .v { font-family: var(--cl-mono); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ login */
.cl-login-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
}
.cl-login-brand {
  background: var(--cl-ink); color: #fff; padding: 3rem;
  display: flex; flex-direction: column; justify-content: center;
}
.cl-login-brand h1 { font-size: 2.25rem; font-weight: 650; letter-spacing: -.02em; max-width: 15ch; line-height: 1.15; }
.cl-login-brand p { color: rgba(255,255,255,.7); max-width: 46ch; }
.cl-login-brand .flow { margin-top: 2rem; font-family: var(--cl-mono); font-size: .78rem; color: #8fd8c9; line-height: 1.9; }
.cl-login-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--cl-surface); }
.cl-login-form .inner { width: 100%; max-width: 340px; }

/* ------------------------------------------------------------ print */
/* ------------------------------------------------------------ PRINTING
   Two printed things exist: documents (bill, receipt) rendered on a
   .print-sheet, and reports printed straight from an application screen.
   Both use the same letterhead block so a hospital's stationery looks the
   same whichever it is. */

@media print {
  .cl-topbar, .cl-side, .no-print, .btn,
  .cl-filters, .cl-kpis, form.cl-filters { display: none !important; }
  body { background: #fff; font-size: 11px; color: #000; }
  .cl-main { padding: 0; margin: 0; }
  .cl-card { border: 0; box-shadow: none; margin: 0 0 6px; page-break-inside: auto; }
  .cl-card-head { border: 0; padding: 0 0 4px; font-size: 12px; color: #000; }
  .cl-page-head { display: none; }
  a { color: #000; text-decoration: none; }

  /* A long report must repeat its column headings on every sheet */
  table { page-break-inside: auto; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  tr { page-break-inside: avoid; page-break-after: auto; }

  .cl-table th, .cl-table td { border: 1px solid #999 !important; padding: 2px 4px; font-size: 10px; }
  .cl-table th { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cl-tag { border: 0; padding: 0; background: none !important; color: #000; }
  tr.st-cancelled { opacity: 1; }
  tr.st-cancelled td:first-child::after { content: " (cancelled)"; font-size: 9px; }

  .print-only { display: block !important; }
}
.print-only { display: none; }

/* Letterhead shared by documents and reports */
.print-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12mm; }
.print-head.blank-mode { justify-content: flex-end; }
.print-head-left h2 { font-size: 15px; margin: 0 0 2px; }
.print-head-left div { font-size: 10px; line-height: 1.45; }
.print-head-right { text-align: right; font-size: 10px; line-height: 1.5; white-space: nowrap; }
.print-head-right .k { color: #555; }
.print-logo { display: block; margin-bottom: 3px; width: auto; max-width: 70mm; }
.print-reserve { width: 100%; }
.doc-title .copies { float: right; font-weight: 400; letter-spacing: 0; text-transform: none; font-size: 10px; }
.report-meta { font-size: 10px; color: #333; margin: 0 0 6px; }
.print-sheet {
  background: #fff; width: 210mm; min-height: 148mm; margin: 0 auto; padding: 12mm;
  color: #000; font-size: 12px;
}
.print-sheet h2 { font-size: 15px; margin: 0; }
.print-sheet .doc-title {
  text-align: center; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
  font-size: 12px; border-top: 1px solid #000; border-bottom: 1px solid #000; padding: 3px 0; margin: 10px 0;
}
.print-sheet table { width: 100%; border-collapse: collapse; }
.print-sheet table th, .print-sheet table td { border: 1px solid #999; padding: 3px 5px; font-size: 11px; }
.print-sheet table th { background: #f0f0f0; text-align: left; }
.print-sheet .num { text-align: right; font-variant-numeric: tabular-nums; }
.print-sheet .foot,
.report-foot { margin-top: 14px; font-size: 10px; color: #333; display: flex; justify-content: space-between; }
.print-sheet .foot .sign,
.report-foot .sign { text-align: right; padding-top: 22px; min-width: 55mm; border-top: 1px solid transparent; }

/* ------------------------------------------------------- responsive */
@media (max-width: 992px) {
  .cl-shell { flex-direction: column; }
  .cl-side { width: 100%; flex: 1 1 auto; border-right: 0; border-bottom: 1px solid var(--cl-rule); }
  .cl-side .nav-group { padding-top: .5rem; }
  .cl-login-wrap { grid-template-columns: 1fr; }
  .cl-login-brand { padding: 2rem; }
  .cl-topmeta .cl-collection { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
:focus-visible { outline: 2px solid var(--cl-accent); outline-offset: 1px; }
