/* Reconciliation, dressed like the Cowork dashboard. hybridge.css (Part 3,
   <html data-theme="dark">) supplies the tokens, the glass and the hb-*
   components; this file lays out the bar, the pages and the pieces only this
   app has. Colour means one thing each: green matched, amber the ledger and
   notes disagree, red something is missing. Everything else is graphite. */

:root {
  --page: 1296px;
  --edge: 12px;
}

* { box-sizing: border-box; }
body { font-size: 14px; line-height: 1.5; }
a { color: inherit; }
[hidden] { display: none !important; }

.faint { color: var(--hb-ink-faint); }
.soft { color: var(--hb-ink-soft); }

/* ---------- The bar: one floating glass strip, as on Cowork ---------- */
.stickyhead {
  position: sticky; top: 12px; z-index: 20;
  width: min(var(--page), calc(100% - var(--edge) * 2));
  margin: 12px auto 0;
  border-radius: 22px;
}
.topbar {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center; gap: 10px 16px;
  padding: 10px 12px 10px 16px;
}
.brand-block { display: flex; align-items: center; gap: 12px; min-width: 0; text-decoration: none; }
.brand-logo { display: block; height: 26px; width: auto; }
.brand-rule { width: 1px; height: 22px; background: var(--hb-line-strong); }
.brand { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; color: var(--hb-ink); white-space: nowrap; }

.tabs {
  justify-self: center; display: flex; max-width: 100%;
  gap: 2px; padding: 3px; border-radius: 9999px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--hb-ink-line);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px; padding: 0 16px; border-radius: 9999px;
  color: var(--hb-ink-soft); font-size: 13.5px; font-weight: 500; letter-spacing: -0.006em;
  text-decoration: none; white-space: nowrap;
  transition: color 150ms var(--ease-glass), background-color 200ms var(--ease-glass), box-shadow 200ms var(--ease-glass);
}
.tab:hover { color: var(--hb-ink); }
.tab-short { display: none; }
.tab[aria-current="page"] {
  color: var(--hb-ink); background: rgba(255, 255, 255, 0.11);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 16px -8px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.bar-actions { display: flex; align-items: center; gap: 10px; justify-self: end; }
.who { font-size: 12px; color: var(--hb-ink-soft); white-space: nowrap; }

@media (max-width: 820px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; padding: 10px 10px 10px 14px; }
  .tabs { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; }
  .tab { flex: 1; padding: 0 10px; }
  .tab-long { display: none; }
  .tab-short { display: inline; }
  .who { display: none; }
}
@media (max-width: 420px) {
  .brand-logo { height: 22px; }
  .brand-rule { height: 18px; }
}

/* ---------- Page ---------- */
.page {
  width: min(var(--page), calc(100% - var(--edge) * 2));
  margin: 0 auto; padding: 32px 16px 24px;
}
.page-head { margin: 0 0 24px; }
.page-head .hb-lede { margin-top: 10px; }
.foot {
  width: min(var(--page), calc(100% - var(--edge) * 2));
  margin: 0 auto; padding: 8px 16px 40px;
  font-size: 12px; line-height: 1.55; color: var(--hb-ink-faint);
}
@media (max-width: 640px) {
  .page { padding: 24px 12px 16px; }
  .foot { padding: 8px 12px 32px; }
}

.section { margin-top: 32px; }
.page-head + .section { margin-top: 0; }
.banner.section { margin-top: 32px; margin-bottom: 0; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px 16px; flex-wrap: wrap; margin: 0 0 12px;
}
.count { font-weight: 500; color: var(--hb-ink-faint); font-variant-numeric: tabular-nums; }
.spec { margin: 4px 0 0; max-width: 62rem; font-size: 12.5px; line-height: 1.55; color: var(--hb-ink-faint); }
.spec b { color: var(--hb-ink-soft); font-weight: 500; }

/* Checkboxes draw as the Cowork switch. */
input[type="checkbox"].switch {
  -webkit-appearance: none; appearance: none;
  position: relative; flex: none; margin: 0;
  width: 30px; height: 18px; border-radius: 9999px;
  background: rgba(255, 255, 255, 0.14); cursor: pointer; outline: none;
  transition: background-color 200ms var(--ease-glass), box-shadow 150ms var(--ease-glass);
}
input[type="checkbox"].switch::before {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 9999px;
  background: var(--hb-ink-soft); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  transition: transform 200ms var(--ease-glass), background-color 200ms var(--ease-glass);
}
input[type="checkbox"].switch:checked { background: var(--hb-ink); }
input[type="checkbox"].switch:checked::before { transform: translateX(12px); background: var(--hb-ink-on); }
input[type="checkbox"].switch:focus-visible { box-shadow: var(--hb-ring); }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--hb-ink); cursor: pointer; user-select: none; }

/* An edge bar (3px, left) is an outcome, never decoration. */
.edge { position: relative; }
.edge::before {
  content: ''; position: absolute; top: 12px; bottom: 12px; left: -1px; width: 3px;
  border-radius: 0 9999px 9999px 0; background: transparent;
  transition: background-color 200ms var(--ease-glass);
}
.edge.good::before { background: var(--hb-status-made); }
.edge.warn::before { background: var(--hb-status-noshow); }
.edge.bad::before { background: var(--hb-status-cancelled); }

/* ---------- Upload ---------- */
.source-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .source-row .hb-segmented { width: 100%; }
  .source-row .hb-segmented > button { flex: 1; padding: 6px 8px; }
}
.uploads { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.uploads[data-cols="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .uploads[data-cols="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .uploads, .uploads[data-cols="4"] { grid-template-columns: minmax(0, 1fr); }
}
.drop {
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 16px 16px 20px; min-width: 0;
  border: 1px solid var(--hb-ink-line); border-radius: 16px; background: var(--hb-panel-2);
  transition: border-color 200ms var(--ease-glass), background-color 200ms var(--ease-glass);
}
.drop:hover { border-color: var(--hb-line-strong); }
.drop .step { font-size: 12px; color: var(--hb-ink-faint); }
.drop .name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--hb-ink); }
.drop .hint { font-size: 12.5px; color: var(--hb-ink-soft); overflow-wrap: anywhere; }
.drop input[type="file"] {
  width: 100%; margin-top: 12px; color: var(--hb-ink-soft);
  font: inherit; font-size: 12.5px; cursor: pointer;
}
.drop input[type="file"]::file-selector-button {
  height: 32px; margin-right: 10px; padding: 0 14px;
  border: 1px solid var(--hb-line-strong); border-radius: 9999px;
  background: var(--hb-ink-wash); color: var(--hb-ink);
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background-color 150ms var(--ease-glass), border-color 150ms var(--ease-glass);
}
.drop input[type="file"]::file-selector-button:hover { background: var(--hb-wash-2); border-color: rgba(255, 255, 255, 0.2); }

.run-row {
  display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--hb-ink-line);
}
.run-row .hb-field { flex: 1 1 260px; max-width: 380px; height: 36px; font-size: 13px; }
.status { font-size: 13px; color: var(--hb-ink-soft); }
.status.err { color: var(--hb-text-danger); }

/* A warning that needs reading before anything else. */
.banner {
  padding: 14px 16px 14px 20px; margin-bottom: 16px;
  border: 1px solid rgba(242, 178, 0, 0.22); border-radius: 16px;
  background: rgba(242, 178, 0, 0.07);
  font-size: 14px; line-height: 1.55; color: var(--hb-text-warning);
}

/* ---------- Summary: one bar for the day, then number tiles ---------- */
.split {
  display: flex; gap: 2px; height: 8px; overflow: hidden;
  border-radius: 9999px; background: var(--hb-ink-wash);
}
.split span { display: block; height: 100%; min-width: 4px; }
.split .good { background: var(--hb-status-made); }
.split .warn { background: var(--hb-status-noshow); }
.split .bad { background: var(--hb-status-cancelled); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; font-size: 12.5px; color: var(--hb-ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 7px; height: 7px; border-radius: 50%; background: var(--hb-ink-faint); }
.legend .good i { background: var(--hb-status-made); }
.legend .warn i { background: var(--hb-status-noshow); }
.legend .bad i { background: var(--hb-status-cancelled); }
.legend b { color: var(--hb-ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.tiles { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 10px; }
@media (max-width: 760px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.tile {
  display: flex; flex-direction: column; align-items: flex-start; min-width: 0;
  padding: 14px 16px 14px 18px; margin: 0;
  border: 1px solid var(--hb-ink-line); border-radius: 16px; background: var(--hb-panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.025);
  color: inherit; font: inherit; text-align: left; cursor: pointer; outline: none;
  transition: background-color 200ms var(--ease-glass), border-color 200ms var(--ease-glass), box-shadow 200ms var(--ease-glass);
}
.tile:hover {
  background: var(--hb-panel-hover); border-color: var(--hb-line-strong);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 14px 32px -18px rgba(0, 0, 0, 0.85);
}
.tile:focus-visible { box-shadow: var(--hb-ring); }
.tile .l { font-size: 13px; font-weight: 500; letter-spacing: -0.003em; color: var(--hb-ink-soft); }
.tile .n {
  margin-top: 4px; font-size: 32px; font-weight: 600; line-height: 1.04;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--hb-ink);
}
.tile.zero .n { color: var(--hb-ink-faint); }
.tile.zero::before { background: transparent; }
.tiles + .spec { margin-top: 10px; }

/* ---------- Patients: soft cards, one per person ---------- */
.plist { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.pcard {
  border: 1px solid var(--hb-ink-line); border-radius: 16px; background: var(--hb-panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.025);
  transition: background-color 200ms var(--ease-glass), border-color 200ms var(--ease-glass), box-shadow 200ms var(--ease-glass);
}
.pcard:hover { border-color: var(--hb-line-strong); }
.pcard[open] { background: var(--hb-panel); border-color: var(--hb-line-strong); }
.pcard.done { background: rgba(21, 21, 23, 0.55); }
.pcard.done .pname { color: var(--hb-ink-soft); }
.pcard > summary {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px 14px 20px; cursor: pointer; list-style: none; outline: none;
  border-radius: 16px;
}
.pcard > summary::-webkit-details-marker { display: none; }
.pcard > summary:focus-visible { box-shadow: var(--hb-ring); }
.pcard > summary::after {
  content: ''; flex: none; width: 7px; height: 7px; margin: 7px 2px 0 0;
  border-right: 1.6px solid var(--hb-ink-faint); border-bottom: 1.6px solid var(--hb-ink-faint);
  transform: rotate(45deg); transition: transform 200ms var(--ease-glass);
}
.pcard[open] > summary::after { transform: rotate(-135deg); margin-top: 10px; }
.pmain { flex: 1; min-width: 0; }
.ptop { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.pname { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--hb-ink); }
.pid { font-size: 12.5px; color: var(--hb-ink-faint); }
.preason { margin-top: 4px; font-size: 13px; line-height: 1.55; color: var(--hb-ink-soft); }
.pissue { margin-top: 4px; font-size: 13px; line-height: 1.55; color: var(--hb-ink); }
.pside { display: flex; align-items: center; gap: 8px; flex: none; }
.pdetail { padding: 2px 16px 16px 20px; }
@media (max-width: 640px) {
  .pcard > summary { flex-wrap: wrap; }
  .pside { order: 3; width: 100%; }
}

/* Inside a patient: the day's rows, the notes, then each check. */
.dblock { margin-top: 16px; }
.dtitle { margin: 0 0 6px; font-size: 13px; font-weight: 600; letter-spacing: -0.006em; color: var(--hb-heading); }
.dscroll { overflow-x: auto; border: 1px solid var(--hb-ink-line); border-radius: 12px; }
.dtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.dtable th {
  padding: 7px 12px; text-align: left; white-space: nowrap;
  font-size: 12px; font-weight: 500; color: var(--hb-ink-faint); background: var(--hb-ink-wash);
  border-bottom: 1px solid var(--hb-ink-line);
}
.dtable td { padding: 8px 12px; vertical-align: top; color: var(--hb-ink); border-bottom: 1px solid var(--hb-ink-line); }
.dtable tr:last-child td { border-bottom: 0; }
.dtable .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dtable .nowrap { white-space: nowrap; }
.rowref { font-size: 12px; color: var(--hb-ink-faint); white-space: nowrap; }
.none { color: var(--hb-ink-faint); }
.empty-line { margin: 0; font-size: 13px; color: var(--hb-ink-faint); }

.notes { display: flex; flex-direction: column; gap: 8px; }
.note {
  padding: 12px 14px; border: 1px solid var(--hb-ink-line); border-radius: 12px;
  background: var(--hb-ink-wash);
}
.note-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 6px; font-size: 12px; color: var(--hb-ink-faint); }
.note-text { margin: 0; font: inherit; font-size: 13px; line-height: 1.6; color: var(--hb-ink); white-space: pre-wrap; overflow-wrap: anywhere; }

.checks { display: flex; flex-direction: column; gap: 6px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.55; color: var(--hb-ink-soft); }
.check i { flex: none; width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; background: var(--hb-status-made); }
.check b { font-weight: 500; color: var(--hb-ink); }
.check.fail { color: var(--hb-text-danger); }
.check.fail i { background: var(--hb-status-cancelled); }

/* ---------- Sheet: glass over the page, wide enough for a patient ---------- */
.hb-sheet.sheet { max-width: 980px; padding: 0; }
.sheet-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--hb-ink-line);
  background: rgba(26, 26, 29, 0.9);
}
.sheet-body { padding: 16px 20px 20px; }
.sheet-close { width: 32px; padding: 0; font-size: 15px; }
body.locked { overflow: hidden; }

/* ---------- Lists of runs, people and recipients ---------- */
.rows { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.row-card {
  display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap;
  padding: 14px 16px 14px 20px;
  border: 1px solid var(--hb-ink-line); border-radius: 16px; background: var(--hb-panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.025);
  transition: background-color 200ms var(--ease-glass), border-color 200ms var(--ease-glass);
}
.row-card:hover { background: var(--hb-panel-hover); border-color: var(--hb-line-strong); }
.row-main { flex: 1 1 260px; min-width: 0; }
.row-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--hb-ink); overflow-wrap: anywhere; }
.row-meta { margin-top: 2px; font-size: 12.5px; color: var(--hb-ink-soft); overflow-wrap: anywhere; }
.figs { display: flex; gap: 22px; }
.fig { display: flex; flex-direction: column; min-width: 64px; }
.fig .l { font-size: 12px; color: var(--hb-ink-faint); }
.fig .n { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--hb-ink); }
.fig.zero .n { color: var(--hb-ink-faint); }
.row-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.controls { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.controls .hb-field { height: 36px; font-size: 13px; }
.controls .search { flex: 1 1 260px; max-width: 420px; }
.controls select.hb-field { width: auto; }

.form-grid { display: grid; grid-template-columns: 2fr 1.4fr 1fr auto; gap: 12px; align-items: end; margin-top: 16px; }
.form-grid.two { grid-template-columns: minmax(0, 1fr) auto; max-width: 640px; }
@media (max-width: 760px) {
  .form-grid, .form-grid.two { grid-template-columns: minmax(0, 1fr); }
}
.form-note { margin: 10px 0 0; font-size: 13px; color: var(--hb-ink-soft); }
.form-note.err { color: var(--hb-text-danger); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 6px 0 12px;
  border: 1px solid var(--hb-ink-line); border-radius: 9999px; background: var(--hb-ink-wash);
  font-size: 13px; color: var(--hb-ink);
}
.chip button {
  display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0;
  border: 0; border-radius: 9999px; background: transparent; color: var(--hb-ink-faint);
  font: inherit; font-size: 12px; cursor: pointer;
}
.chip button:hover { background: var(--hb-wash-2); color: var(--hb-ink); }

@media (prefers-reduced-motion: reduce) {
  .tab, .tile, .pcard, .pcard > summary::after, .drop, .row-card,
  input[type="checkbox"].switch, input[type="checkbox"].switch::before { transition: none; }
}
