/* =====================================================================
   HMS components — hospital-only screens (patient banner, bed tiles,
   hospital switcher, duplicate panel, form grids).
   RULES (same design system as the College ERP):
   * colours come from the theme tokens (--acc-*, --surface, --ink, --line),
     so Classic / Ivory / Midnight and dark mode all work with no extra CSS;
   * plain class names, never Tailwind utilities (the Tailwind build is a
     frozen file — a missing class renders as NOTHING);
   * status colours: emerald ok · rose danger · amber warning · sky info.
   ===================================================================== */

/* ---- hospital chip / switcher in the header ---- */
.fac-chip,.fac-switch{display:inline-flex;align-items:center;gap:.45rem;border:1px solid var(--line);
    border-radius:9999px;padding:.3rem .75rem;font-size:.8rem;font-weight:600;color:var(--ink);
    background:var(--surface);white-space:nowrap;max-width:22rem;overflow:hidden;text-overflow:ellipsis}
.fac-switch select{border:0;background:transparent;font-weight:600;color:inherit;padding:0;
    max-width:18rem;cursor:pointer}
.fac-dot{width:.7rem;height:.7rem;border-radius:9999px;flex:none;box-shadow:0 0 0 2px var(--surface)}

/* ---- generic building blocks ---- */
.hms-card{background:var(--surface);border:1px solid var(--line);border-radius:.85rem;
    box-shadow:0 1px 2px rgba(15,23,42,.04);padding:1.1rem 1.2rem}
.hms-card h2{font-size:.95rem;font-weight:700;margin:0 0 .75rem;color:var(--ink)}
.hms-card h2 .sub{font-weight:400;color:#64748b;font-size:.8rem;margin-left:.35rem}
.hms-grid{display:grid;gap:1rem}
.hms-grid.cols-2{grid-template-columns:repeat(auto-fit,minmax(min(20rem,100%),1fr))}
.hms-grid.cols-3{grid-template-columns:repeat(auto-fit,minmax(min(15rem,100%),1fr))}
.hms-grid.cols-4{grid-template-columns:repeat(auto-fit,minmax(min(9.5rem,100%),1fr))}
.hms-stack>*+*{margin-top:1rem}
.hms-row{display:flex;flex-wrap:wrap;gap:.6rem;align-items:center}
.hms-row.between{justify-content:space-between}
.hms-muted{color:#64748b;font-size:.8rem}
.hms-small{font-size:.8rem}
.hms-mono{font-family:Consolas,"Cascadia Mono",monospace;letter-spacing:.02em}
.hms-hr{border:0;border-top:1px solid var(--line);margin:1rem 0}
.hms-note{border:1px solid var(--line);background:var(--surface-2);border-radius:.6rem;
    padding:.7rem .9rem;font-size:.82rem;color:#475569}
.hms-note.warn{border-color:#fcd34d;background:#fffbeb;color:#92400e}
.hms-note.danger{border-color:#fda4af;background:#fff1f2;color:#9f1239}
.hms-note.ok{border-color:#6ee7b7;background:#ecfdf5;color:#065f46}
html[data-theme="dark"] .hms-note.warn{background:#3a2a06;color:#fde68a;border-color:#92400e}
html[data-theme="dark"] .hms-note.danger{background:#3b0d18;color:#fecdd3;border-color:#9f1239}
html[data-theme="dark"] .hms-note.ok{background:#052e22;color:#a7f3d0;border-color:#065f46}

/* ---- forms: labelled grid, phone-friendly ---- */
.hms-form{display:grid;gap:.85rem 1rem;grid-template-columns:repeat(auto-fit,minmax(min(14rem,100%),1fr))}
.hms-form .span-2{grid-column:span 2}
.hms-form .span-all{grid-column:1/-1}
@media (max-width:640px){.hms-form .span-2{grid-column:1/-1}}
.hms-field{display:flex;flex-direction:column;gap:.25rem;font-size:.85rem;min-width:0}
.hms-field>span{color:#64748b;font-size:.78rem;font-weight:500}
.hms-field>span b{color:#e11d48;font-weight:700}
.hms-field input,.hms-field select,.hms-field textarea,.hms-input{width:100%;border:1px solid #cbd5e1;
    border-radius:.5rem;padding:.5rem .65rem;font-size:.9rem;background:var(--surface);color:var(--ink)}
.hms-field input:focus,.hms-field select:focus,.hms-field textarea:focus,.hms-input:focus{
    outline:2px solid var(--acc-400,#2dd4bf);outline-offset:0;border-color:var(--acc-500,#14b8a6)}
html[data-theme="dark"] .hms-field input,html[data-theme="dark"] .hms-field select,
html[data-theme="dark"] .hms-field textarea,html[data-theme="dark"] .hms-input{border-color:#334155;background:#0b1220}
.hms-field .inline{display:flex;gap:.4rem}
.hms-field .inline>*{flex:1;min-width:0}
.hms-check{display:inline-flex;align-items:center;gap:.4rem;font-size:.85rem;cursor:pointer}
.hms-legend{grid-column:1/-1;font-size:.72rem;text-transform:uppercase;letter-spacing:.06em;
    color:var(--acc-700,#0f766e);font-weight:700;border-bottom:1px solid var(--line);padding-bottom:.3rem;margin-top:.4rem}
.hms-actions{display:flex;flex-wrap:wrap;gap:.6rem;justify-content:flex-end;margin-top:1rem}

/* ---- tables ---- */
.hms-table{width:100%;border-collapse:collapse;font-size:.85rem}
.hms-table th{text-align:left;font-size:.7rem;text-transform:uppercase;letter-spacing:.05em;color:#64748b;
    font-weight:600;padding:.55rem .6rem;border-bottom:1px solid var(--line);background:var(--surface-2)}
.hms-table td{padding:.55rem .6rem;border-bottom:1px solid var(--line);vertical-align:top}
.hms-table tr:hover td{background:var(--surface-2)}
.hms-table .num{text-align:right;font-variant-numeric:tabular-nums}
.hms-table .dim td{opacity:.55}
.hms-table a.row-link{color:var(--acc-700,#0f766e);font-weight:600;text-decoration:none}
.hms-table a.row-link:hover{text-decoration:underline}

/* ---- the PATIENT BANNER: photo, identity, allergies, alerts ----
   Industry pattern (Epic Storyboard / Cerner banner): the same strip on every
   patient screen; allergies always in red; a photo cuts wrong-patient errors. */
.pt-banner{display:flex;gap:1rem;align-items:stretch;background:var(--surface);border:1px solid var(--line);
    border-left:5px solid var(--acc-600,#0d9488);border-radius:.85rem;padding:.85rem 1rem;
    box-shadow:0 1px 3px rgba(15,23,42,.06)}
.pt-photo{width:74px;height:88px;border-radius:.6rem;object-fit:cover;flex:none;background:var(--surface-3);
    display:flex;align-items:center;justify-content:center;font-size:1.9rem;color:#94a3b8;overflow:hidden}
.pt-photo img{width:100%;height:100%;object-fit:cover}
.pt-main{flex:1;min-width:0}
.pt-name{font-size:1.15rem;font-weight:700;color:var(--ink);line-height:1.2}
.pt-name .hi{font-weight:500;color:#64748b;font-size:.95rem;margin-left:.35rem}
.pt-meta{display:flex;flex-wrap:wrap;gap:.25rem .9rem;margin-top:.3rem;font-size:.82rem;color:#475569}
html[data-theme="dark"] .pt-meta{color:#94a3b8}
.pt-meta b{color:var(--ink);font-weight:600}
.pt-uhid{font-family:Consolas,"Cascadia Mono",monospace;font-weight:700;letter-spacing:.04em;
    background:var(--acc-50,#f0fdfa);color:var(--acc-800,#115e59);border-radius:.35rem;padding:.05rem .45rem}
html[data-theme="dark"] .pt-uhid{background:rgba(45,212,191,.12);color:var(--acc-300,#5eead4)}
.pt-flags{display:flex;flex-wrap:wrap;gap:.35rem;margin-top:.5rem}
.pt-flag{display:inline-flex;align-items:center;gap:.3rem;border-radius:9999px;padding:.12rem .6rem;
    font-size:.72rem;font-weight:600;border:1px solid transparent}
.pt-flag.allergy{background:#fff1f2;color:#be123c;border-color:#fecdd3}
.pt-flag.nkda{background:#ecfdf5;color:#047857;border-color:#a7f3d0}
.pt-flag.unknown{background:#fffbeb;color:#b45309;border-color:#fde68a}
.pt-flag.alert{background:#fff7ed;color:#c2410c;border-color:#fed7aa}
.pt-flag.alert.high{background:#fff1f2;color:#be123c;border-color:#fda4af}
.pt-flag.info{background:var(--surface-3);color:#475569;border-color:var(--line)}
html[data-theme="dark"] .pt-flag.allergy,html[data-theme="dark"] .pt-flag.alert.high{background:#3b0d18;color:#fda4af;border-color:#9f1239}
html[data-theme="dark"] .pt-flag.nkda{background:#052e22;color:#6ee7b7;border-color:#065f46}
html[data-theme="dark"] .pt-flag.unknown,html[data-theme="dark"] .pt-flag.alert{background:#3a2a06;color:#fcd34d;border-color:#92400e}
html[data-theme="dark"] .pt-flag.info{color:#cbd5e1}
.pt-side{display:flex;flex-direction:column;gap:.4rem;align-items:flex-end;justify-content:space-between}
@media (max-width:640px){
  .pt-banner{flex-wrap:wrap}
  .pt-side{flex-direction:row;align-items:center;width:100%;justify-content:flex-start}
  .pt-photo{width:60px;height:72px}
}

/* ---- tabs inside a chart ---- */
.hms-tabs{display:flex;gap:.25rem;border-bottom:1px solid var(--line);overflow-x:auto;margin:1rem 0 1rem}
.hms-tabs a{padding:.55rem .9rem;font-size:.85rem;font-weight:600;color:#64748b;text-decoration:none;
    border-bottom:2px solid transparent;white-space:nowrap}
.hms-tabs a.on{color:var(--acc-700,#0f766e);border-bottom-color:var(--acc-600,#0d9488)}

/* ---- duplicate-patient panel on the registration form ---- */
.dup-panel{border:1px solid #fcd34d;background:#fffbeb;border-radius:.75rem;padding:.8rem 1rem}
html[data-theme="dark"] .dup-panel{background:#2a1f05;border-color:#92400e}
.dup-panel h3{margin:0 0 .5rem;font-size:.9rem;color:#92400e}
html[data-theme="dark"] .dup-panel h3{color:#fcd34d}
.dup-item{display:flex;justify-content:space-between;gap:.75rem;align-items:center;padding:.5rem .6rem;
    border-radius:.5rem;background:var(--surface);border:1px solid var(--line);margin-top:.4rem;font-size:.84rem}
.dup-score{font-size:.7rem;font-weight:700;border-radius:9999px;padding:.1rem .5rem;background:#fde68a;color:#78350f;white-space:nowrap}
.dup-score.hi{background:#fecdd3;color:#9f1239}

/* ---- bed tiles (wards master now; the live bed board in the IPD module) ---- */
.bed-grid{display:grid;gap:.6rem;grid-template-columns:repeat(auto-fill,minmax(8.5rem,1fr))}
.bed-tile{border:1px solid var(--line);border-radius:.7rem;padding:.55rem .65rem;background:var(--surface);
    border-top:4px solid #10b981;font-size:.8rem;position:relative}
.bed-tile .code{font-weight:700;font-size:.9rem;color:var(--ink)}
.bed-tile .cls{color:#64748b;font-size:.72rem}
.bed-tile.CLEANING{border-top-color:#f59e0b}
.bed-tile.BLOCKED{border-top-color:#94a3b8;opacity:.75}
.bed-tile.RESERVED{border-top-color:#0ea5e9}
.bed-tile.inactive{opacity:.45;border-style:dashed}
.bed-tile .tag{display:inline-block;margin-top:.25rem;font-size:.65rem;font-weight:700;letter-spacing:.03em;
    text-transform:uppercase;color:#64748b}
.bed-tile details{margin-top:.35rem}
.bed-tile summary{cursor:pointer;font-size:.72rem;color:var(--acc-700,#0f766e)}
.bed-tile .ops{display:flex;flex-wrap:wrap;gap:.25rem;margin-top:.35rem}
.bed-tile .ops button{font-size:.68rem;border:1px solid var(--line);border-radius:.35rem;padding:.1rem .35rem;
    background:var(--surface-2);color:var(--ink);cursor:pointer}
/* live bed board (module 1B): an occupied bed shows its patient */
.bed-tile.OCCUPIED{border-top-color:var(--acc-600,#0d9488);background:var(--surface-2)}
.bed-tile.OCCUPIED.advised{border-top-color:#8b5cf6}
.bed-tile a.pt{display:block;margin-top:.3rem;font-weight:700;color:var(--ink);text-decoration:none;
    line-height:1.25;overflow-wrap:anywhere}
.bed-tile a.pt:hover{text-decoration:underline}
.bed-tile .meta{color:#64748b;font-size:.7rem;margin-top:.15rem}
.bed-tile a.admit{display:inline-block;margin-top:.35rem;font-size:.72rem;font-weight:600;
    color:var(--acc-700,#0f766e);text-decoration:none}
.bed-tile .due{color:#be123c;font-weight:700}
.ward-head{display:flex;flex-wrap:wrap;gap:.4rem .8rem;align-items:baseline;margin:0 0 .6rem}
.ward-head h2{margin:0}
.money-strip{display:grid;gap:.6rem;grid-template-columns:repeat(auto-fit,minmax(min(9rem,100%),1fr))}
.money-strip>div{border:1px solid var(--line);border-radius:.6rem;padding:.5rem .7rem;background:var(--surface-2)}
.money-strip .l{font-size:.68rem;text-transform:uppercase;letter-spacing:.05em;color:#64748b;font-weight:600}
.money-strip .v{font-size:1.15rem;font-weight:800;font-variant-numeric:tabular-nums;color:var(--ink)}
.money-strip .v.due{color:#be123c}
.money-strip .v.back{color:#047857}
.legend{display:flex;flex-wrap:wrap;gap:.8rem;font-size:.75rem;color:#64748b}
.legend i{display:inline-block;width:.8rem;height:.8rem;border-radius:.2rem;margin-right:.3rem;vertical-align:-1px}

/* ---- KPI tiles (dashboard) ---- */
.kpi{background:var(--surface);border:1px solid var(--line);border-radius:.85rem;padding:.9rem 1rem}
.kpi .l{font-size:.68rem;text-transform:uppercase;letter-spacing:.06em;color:#64748b;font-weight:600}
.kpi .v{font-size:1.65rem;font-weight:800;color:var(--ink);margin-top:.1rem;font-variant-numeric:tabular-nums}
.kpi .s{font-size:.75rem;color:#64748b}
.kpi.accent{border-left:4px solid var(--acc-600,#0d9488)}

/* ---- "Start here" checklist ---- */
.start-list{list-style:none;margin:0;padding:0}
.start-list li{display:flex;align-items:center;gap:.6rem;padding:.55rem 0;border-bottom:1px dashed var(--line);font-size:.87rem}
.start-list li:last-child{border-bottom:0}
.start-list .n{width:1.5rem;height:1.5rem;border-radius:9999px;background:var(--acc-600,#0d9488);color:#fff;
    font-size:.75rem;font-weight:700;display:flex;align-items:center;justify-content:center;flex:none}

/* ---- setup / login pages (no sidebar) ---- */
.auth-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:1.5rem;background:#0f172a}
.auth-card{background:var(--surface);border-radius:1.1rem;box-shadow:0 20px 50px rgba(0,0,0,.35);padding:1.6rem;width:100%}
.auth-brand{text-align:center;margin-bottom:1.2rem}
.auth-brand img{width:6.5rem;height:6.5rem;object-fit:contain;border-radius:1rem;padding:.4rem;background:#fff;
    box-shadow:0 6px 18px rgba(0,0,0,.25)}
.auth-brand h1{color:#2dd4bf;font-weight:800;font-size:1.25rem;margin:.7rem 0 0}
.auth-brand p{color:#94a3b8;font-size:.85rem;margin:.2rem 0 0}

/* ---- camera capture for patient photo ---- */
.cam-box{display:none;margin-top:.6rem}
.cam-box.on{display:block}
.cam-box video,.cam-box canvas{width:100%;max-width:320px;border-radius:.6rem;background:#000}

@media print{
  .pt-banner{box-shadow:none;border-color:#94a3b8}
  .hms-card{box-shadow:none}
}

/* compact row actions inside tables (never force a sideways scroll) */
.btn-xs{padding:.2rem .5rem!important;font-size:.72rem!important;line-height:1.1!important}
.row-actions{display:flex;flex-wrap:wrap;gap:.25rem;justify-content:flex-end}
