﻿/* =====================================================================
   HospitalMS – web application styles (no external dependencies)
   ===================================================================== */
:root {
  --brand: #0b5394; --brand-dark: #083c6c; --brand-soft: #e8f0fa;
  --side: #10233b; --side-2: #1a3456; --side-ink: #c9d6e6; --side-muted: #7f97b5;
  --bg: #f3f5f8; --panel: #ffffff; --line: #dfe3e8; --line-2: #eceff3;
  --ink: #1f2328; --ink-2: #52514e; --muted: #8a8984;
  --good: #1a7f37; --good-bg: #e6f4ea; --warn: #b25e00; --warn-bg: #fff4e5;
  --crit: #c62828; --crit-bg: #fdecea; --info-bg: #eef3f9;
  --radius: 8px; --shadow: 0 1px 2px rgba(16,35,59,.06), 0 2px 8px rgba(16,35,59,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; font-size: 14px; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; color: var(--brand); font-weight: 600; }
h2 { font-size: 16px; margin: 20px 0 10px; color: var(--brand); border-bottom: 2px solid #dbe6f3; padding-bottom: 5px; font-weight: 600; }
h3 { font-size: 14px; margin: 14px 0 6px; font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 250px; flex: 0 0 250px; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand { flex-direction: column; text-align: center; gap: 6px; }
.brand .logo-img { width: 92px; height: 92px; object-fit: contain; background: #fff; border-radius: 12px; padding: 6px; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.brand .motto { color: #e8c35a; font-size: 11px; font-style: italic; }
.brand .name { color: #fff; font-weight: 600; line-height: 1.2; font-size: 14px; }
.brand .sub { color: var(--side-muted); font-size: 11px; }
.nav-sec { color: var(--side-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; padding: 16px 18px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-ink); padding: 9px 16px; margin: 1px 8px; border-radius: 6px; text-decoration: none; }
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav .ico { flex: 0 0 18px; opacity: .9; }
.side-foot { margin-top: auto; padding: 12px 16px; font-size: 11px; color: var(--side-muted); border-top: 1px solid rgba(255,255,255,.06); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 58px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 22px; position: sticky; top: 0; z-index: 20; }
.topbar .title { font-size: 18px; font-weight: 600; color: var(--ink); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who { text-align: right; line-height: 1.2; }
.topbar .who b { display: block; font-size: 13px; } .topbar .who span { font-size: 11px; color: var(--muted); }
.topbar .clock { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; }
.content { padding: 20px 22px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; color: var(--ink-2); }

/* ---------- cards & grid ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card > .card-title { font-weight: 600; font-size: 15px; margin: 0 0 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cols { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; } .cols-3 { grid-template-columns: repeat(3,1fr); }
.cols-side { grid-template-columns: 420px 1fr; } .cols-main { grid-template-columns: 1.4fr 1fr; }
.grid { display: grid; gap: 10px 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; } .span4 { grid-column: 1 / -1; }
@media (max-width: 1200px) { .cols-side, .cols-main, .cols-2 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 760px) { .sidebar { display: none; } .g3, .g2, .g4 { grid-template-columns: 1fr; } .span2, .span3 { grid-column: auto; } }

/* ---------- forms ---------- */
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field .req { color: var(--crit); } .field .hint { font-size: 11px; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=email], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cfd6de; border-radius: 6px; font: inherit; background: #fff; color: var(--ink); }
textarea { resize: vertical; min-height: 38px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11,83,148,.15); }
input.bad { border-color: var(--crit); background: var(--crit-bg); }
fieldset.section { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0 0 14px; background: #fcfdfe; }
fieldset.section legend { font-weight: 600; color: var(--brand); padding: 0 6px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px,1fr)); gap: 6px 14px; }
.checks label { display: flex; gap: 8px; align-items: center; font-weight: 400; color: var(--ink); padding: 5px 8px; border: 1px solid var(--line-2); border-radius: 6px; cursor: pointer; }
.checks label:hover { background: var(--info-bg); }
.search-big { font-size: 17px !important; padding: 12px 14px !important; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px; border: 1px solid #cfd6de; background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { background: var(--info-bg); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn-primary:hover { background: var(--brand-dark); }
.btn-good { background: var(--good); border-color: var(--good); color: #fff; } .btn-good:hover { filter: brightness(.95); background: var(--good); }
.btn-danger { color: var(--crit); border-color: #e7b3b3; } .btn-danger:hover { background: var(--crit-bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actionbar { position: sticky; bottom: 0; background: rgba(255,255,255,.97); border-top: 1px solid var(--line); padding: 10px 16px; display: flex; gap: 8px; flex-wrap: wrap; margin: 0 -22px -40px; z-index: 10; }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; background: #fff; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2); background: #f6f8fa; padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #f3f7fd; }
.tbl tr.sel td { background: #dce9f8 !important; }
.tbl tr.p2 td { background: var(--crit-bg); } .tbl tr.p1 td { background: var(--warn-bg); }
.tbl tr.inprog td { background: var(--info-bg); font-weight: 600; }
.tbl tr.new td { animation: flash 2.5s ease-out; }
@keyframes flash { 0% { background: #fff3a8; } 100% { background: transparent; } }
.tbl-wrap { max-height: 560px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
td.num, th.num { text-align: right; }

/* ---------- badges, chips ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--info-bg); color: var(--brand); }
.b-good { background: var(--good-bg); color: var(--good); } .b-warn { background: var(--warn-bg); color: var(--warn); } .b-crit { background: var(--crit-bg); color: var(--crit); }
/* ---------- triage (South African Triage Scale colours) ---------- */
:root { --tri-red: #C62828; --tri-orange: #EF6C00; --tri-yellow: #F9C80E; --tri-yellow-ink: #2B2100; --tri-green: #2E7D32; --tri-blue: #1565C0; }
.triage { display: inline-block; padding: 2px 9px; border-radius: 4px; font-weight: 700; font-size: 12px; color: #fff; letter-spacing: .3px; white-space: nowrap; }
.t-red { background: var(--tri-red); color: #fff; } .t-orange { background: var(--tri-orange); color: #fff; } .t-yellow { background: var(--tri-yellow); color: var(--tri-yellow-ink); }
.t-green { background: var(--tri-green); color: #fff; } .t-blue { background: var(--tri-blue); color: #fff; } .t-none { background: #eceff3; color: var(--ink-2); }
.triage-panel { display: grid; grid-template-columns: 320px 1fr; gap: 16px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
@media (max-width: 1100px) { .triage-panel { grid-template-columns: 1fr; } }
.triage-big { border-radius: 10px; padding: 14px 16px; font-size: 20px; margin: 6px 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.triage-big small { display: block; font-size: 13px; font-weight: 600; opacity: .9; margin-top: 2px; }
.triage-big.t-none { font-size: 14px; }
.triage-suggest ul { margin: 6px 0 0; padding-left: 18px; }
.tri-pills { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tri-pill { position: relative; cursor: pointer; border-radius: 8px; border: 2px solid transparent; padding: 8px 10px; font-size: 13px; line-height: 1.25; display: block; }
.tri-pill input { position: absolute; opacity: 0; pointer-events: none; }
.tri-pill small { display: block; font-size: 11px; opacity: .9; }
.tri-pill.t-auto { background: #fff; border-color: var(--line); color: var(--ink); display: flex; align-items: center; }
.tri-pill:has(input:checked) { outline: 3px solid #111; outline-offset: 2px; }
.tri-pill:hover { filter: brightness(1.05); }
/* worklist: coloured triage stripe on the first cell */
.tbl tr.tri-red td:first-child { box-shadow: inset 6px 0 0 var(--tri-red); }
.tbl tr.tri-orange td:first-child { box-shadow: inset 6px 0 0 var(--tri-orange); }
.tbl tr.tri-yellow td:first-child { box-shadow: inset 6px 0 0 var(--tri-yellow); }
.tbl tr.tri-green td:first-child { box-shadow: inset 6px 0 0 var(--tri-green); }
.tbl tr.tri-blue td:first-child { box-shadow: inset 6px 0 0 var(--tri-blue); }
.overdue { color: var(--crit); font-weight: 700; }
.tri-legend { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; }
.qno { display: inline-grid; place-items: center; min-width: 34px; height: 28px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); font-weight: 700; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; border-left: 4px solid var(--brand); }
.stat .l { font-size: 11px; text-transform: uppercase; color: var(--ink-2); letter-spacing: .4px; } .stat .v { font-size: 24px; font-weight: 600; } .stat .s { font-size: 11px; color: var(--muted); }
.stat.crit { border-left-color: var(--crit); } .stat.good { border-left-color: var(--good); } .stat.warn { border-left-color: var(--warn); }

/* ---------- patient banner ---------- */
.banner { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; display: flex; gap: 16px; align-items: flex-start; box-shadow: var(--shadow); }
.banner .pic { width: 52px; height: 52px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: 0 0 52px; }
.banner .nm { font-size: 18px; font-weight: 600; }
.banner .meta { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.banner .meta span { margin-right: 14px; }
.banner .alert { margin-top: 6px; }
.allergy { background: var(--crit-bg); color: var(--crit); padding: 3px 10px; border-radius: 4px; font-weight: 700; display: inline-block; }
.vline { margin-top: 6px; font-size: 13px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: none; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--ink-2); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.tabs button:hover { color: var(--brand); }
.pane { display: none; } .pane.on { display: block; }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(16,35,59,.45); display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 60px 16px; overflow: auto; }
.modal-back.on { display: flex; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 620px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 900px; }
.modal-h { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 16px; display: flex; justify-content: space-between; }
.modal-h .x { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.modal-b { padding: 16px 18px; } .modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1f2328; color: #fff; padding: 11px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 420px; animation: slide .25s ease-out; }
.toast.good { background: var(--good); } .toast.crit { background: var(--crit); } .toast.warn { background: #8a4b00; }
@keyframes slide { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.alertbox { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; }
.alertbox.crit { background: var(--crit-bg); color: var(--crit); } .alertbox.good { background: var(--good-bg); color: var(--good); } .alertbox.warn { background: var(--warn-bg); color: var(--warn); } .alertbox.info { background: var(--info-bg); color: var(--brand); }

/* ---------- search results / list items ---------- */
.list { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; max-height: 260px; overflow: auto; }
.list .it { padding: 8px 12px; border-bottom: 1px solid var(--line-2); cursor: pointer; } .list .it:hover { background: var(--info-bg); }
.list .it .sub { font-size: 12px; color: var(--muted); }
.oos { color: var(--crit); font-weight: 600; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login .hero { background: linear-gradient(160deg, #10233b 0%, #0b5394 100%); color: #fff; padding: 60px; display: flex; flex-direction: column; justify-content: center; }
.login .hero h1 { color: #fff; font-size: 32px; } .login .hero p { color: #c9d6e6; font-size: 15px; line-height: 1.6; max-width: 460px; }
.login .hero .hero-logo { width: 150px; height: 150px; object-fit: contain; background: #fff; border-radius: 18px; padding: 10px; margin-bottom: 22px; box-shadow: 0 8px 30px rgba(0,0,0,.3); }
.login .hero .motto { color: #e8c35a; font-style: italic; font-weight: 600; margin-top: -4px; }
.login .hero ul { color: #c9d6e6; line-height: 1.9; padding-left: 18px; }
.login .form { display: flex; align-items: center; justify-content: center; padding: 40px; background: #fff; }
.login .box { width: 100%; max-width: 380px; }
@media (max-width: 900px) { .login { grid-template-columns: 1fr; } .login .hero { display: none; } }

/* ---------- queue board (TV) ---------- */
.board { background: #0e1b2c; color: #fff; min-height: 100vh; padding: 30px; }
.board h1 { color: #fff; font-size: 36px; margin: 0; } .board .board-logo { height: 80px; width: 80px; object-fit: contain; background: #fff; border-radius: 12px; padding: 4px; }
.logo-preview { width: 180px; height: 180px; object-fit: contain; background: repeating-conic-gradient(#f0f0f0 0% 25%, #fff 0% 50%) 50% / 16px 16px; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.board .now { display: flex; gap: 20px; flex-wrap: wrap; margin: 20px 0 30px; }
.board .now div { background: #1a7f37; border-radius: 12px; padding: 20px 30px; font-size: 48px; font-weight: 700; min-width: 180px; text-align: center; }
.board .now small { display: block; font-size: 16px; font-weight: 400; }
.board .wait { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 12px; }
.board .wait div { background: #1a3456; border-radius: 10px; padding: 14px 18px; font-size: 26px; }
.board .wait small { font-size: 15px; color: #9fb5d1; display: block; }

/* ---------- report styles (shared with server-rendered reports/AI output) ---------- */
.rpt .letterhead { border-bottom: 3px solid var(--brand); padding-bottom: 8px; margin-bottom: 12px; }
.rpt .letterhead .fac { font-size: 20px; font-weight: bold; color: var(--brand); } .rpt .letterhead .motto { font-style: italic; color: #8a6d00; font-size: 12px; font-weight: 600; } .rpt .letterhead .sub { color: var(--ink-2); font-size: 12px; }
table.grid { border-collapse: collapse; width: 100%; background: #fff; margin: 4px 0 10px; display: table; }
table.grid th { background: #eef3f9; text-align: left; padding: 6px 8px; border: 1px solid #d8dee4; font-weight: 600; font-size: 12px; }
table.grid td { padding: 5px 8px; border: 1px solid #e1e4e8; vertical-align: top; font-size: 12px; }
table.grid tr:nth-child(even) td { background: #fafbfc; }
table.kv { border-collapse: collapse; width: 100%; } table.kv td { padding: 3px 8px 3px 0; vertical-align: top; font-size: 13px; } table.kv td.k { color: var(--ink-2); width: 190px; font-weight: 600; }
.kpis { margin: 0 0 8px; } .kpi { display: inline-block; vertical-align: top; width: 175px; background: #fff; border: 1px solid #e1e4e8; border-radius: 6px; padding: 10px 12px; margin: 0 8px 8px 0; }
.kpi .v { font-size: 24px; font-weight: 600; } .kpi .l { font-size: 11px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .3px; } .kpi .s { font-size: 11px; color: var(--muted); }
.kpi.good { border-left: 4px solid var(--good); } .kpi.warn { border-left: 4px solid var(--warn); } .kpi.crit { border-left: 4px solid var(--crit); } .kpi.info { border-left: 4px solid var(--brand); }
.visit { border-left: 4px solid var(--brand); background: #fff; border-radius: 4px; padding: 10px 12px; margin: 0 0 12px; border-top: 1px solid #e1e4e8; border-right: 1px solid #e1e4e8; border-bottom: 1px solid #e1e4e8; }
.enc { border-top: 1px dashed #d8dee4; padding-top: 8px; margin-top: 8px; }
.chart { display: inline-block; vertical-align: top; background: #fff; border: 1px solid #e1e4e8; border-radius: 6px; padding: 10px; margin: 0 10px 10px 0; max-width: 100%; overflow-x: auto; }
.chart .t { font-weight: 600; font-size: 12px; margin-bottom: 4px; }
.ai { background: #f3f7fd; border: 1px solid #c9dcf3; border-radius: 6px; padding: 12px 14px; }
.ai h3 { color: var(--brand); } .disclaimer { font-size: 11px; color: var(--muted); font-style: italic; margin-top: 8px; }
.up { color: var(--good); font-weight: 600; } .down { color: var(--crit); font-weight: 600; } .flat { color: var(--muted); }
.sig td { padding-top: 30px; font-size: 12px; }

@media print {
  .sidebar, .topbar, .actionbar, .noprint, .tabs, .toolbar { display: none !important; }
  body { background: #fff; } .content { padding: 0; } .card { box-shadow: none; border-color: #bbb; }
  .pane { display: block !important; }
}
