/* City Care Hospital — ward-chart palette, Atkinson Hyperlegible for legibility at a glance */
:root {
  --ink: #14213D;
  --ink-2: #4A5572;
  --ward: #1F6F5C;
  --ward-dark: #16503F;
  --ward-tint: #E3EFEA;
  --paper: #F2F5F3;
  --surface: #FFFFFF;
  --line: #D5DDD9;
  --amber: #9A5B00;
  --amber-tint: #FFF1D6;
  --red: #B42318;
  --red-tint: #FDE8E6;
  --blue-tint: #E7EDF8;
  --radius-s: 4px;
  --radius-m: 8px;
  font-family: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
a { color: var(--ward-dark); }
table, .num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid #5B8DEF; outline-offset: 2px; }

/* ---------- Sign in ---------- */
.signin { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); }
.signin-side { background: var(--ward); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.signin-side h1 { font-size: 2.5rem; max-width: 14ch; }
.signin-side p { max-width: 42ch; opacity: .9; }
.cross { width: 44px; height: 44px; }
.signin-form { background: var(--surface); padding: 56px 40px; display: flex; flex-direction: column; justify-content: center; gap: 16px; }
.demo { font-size: .875rem; color: var(--ink-2); border-top: 1px solid var(--line); padding-top: 16px; }
.demo button { margin: 4px 4px 0 0; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
nav.side { background: var(--ink); color: #DCE3F0; padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; padding: 4px 10px 20px; }
.brand svg { width: 28px; height: 28px; flex: none; }
nav.side a { color: inherit; text-decoration: none; padding: 9px 12px; border-radius: var(--radius-s); }
nav.side a:hover { background: rgba(255,255,255,.07); }
nav.side a.active { background: var(--ward); color: #fff; }
.who { margin-top: auto; padding: 12px; font-size: .875rem; border-top: 1px solid rgba(255,255,255,.15); }
.who b { display: block; color: #fff; }
.who button { margin-top: 8px; }
main { padding: 28px 36px 60px; max-width: 1200px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }

/* ---------- Controls ---------- */
button, .btn { font: inherit; border: 1px solid var(--ward); background: var(--ward); color: #fff; padding: 8px 14px; border-radius: var(--radius-s); cursor: pointer; font-weight: 700; }
button:hover { background: var(--ward-dark); }
button.quiet { background: transparent; color: var(--ward-dark); }
button.quiet:hover { background: var(--ward-tint); }
button.small { padding: 4px 10px; font-size: .875rem; }
button.danger { background: transparent; color: var(--red); border-color: var(--red); }
button.on-dark { background: transparent; border-color: rgba(255,255,255,.4); color: #fff; }
button:disabled { opacity: .5; cursor: wait; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .875rem; font-weight: 700; color: var(--ink-2); }
input, select, textarea { font: inherit; font-weight: 400; color: var(--ink); padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; width: 100%; }
textarea { min-height: 96px; resize: vertical; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.span-all { grid-column: 1 / -1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* ---------- Panels and tables ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 20px; margin-bottom: 20px; }
.panel > h2 { margin-bottom: 14px; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8125rem; color: var(--ink-2); font-weight: 700; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--paper); }
.muted { color: var(--ink-2); }
.empty { color: var(--ink-2); padding: 20px 0; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .8125rem; font-weight: 700; background: var(--blue-tint); color: var(--ink); white-space: nowrap; }
.tag.ok { background: var(--ward-tint); color: var(--ward-dark); }
.tag.warn { background: var(--amber-tint); color: var(--amber); }
.tag.bad { background: var(--red-tint); color: var(--red); }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); margin-bottom: 20px; }
.stat { padding: 16px 20px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat .n { font-size: 2rem; font-weight: 700; }
.stat .l { color: var(--ink-2); font-size: .875rem; }
.two { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: .75rem; color: var(--ink-2); }
.bar i { display: block; width: 100%; max-width: 36px; background: var(--ward); border-radius: 3px 3px 0 0; min-height: 2px; }
.bar b { color: var(--ink); margin-bottom: 4px; }

/* ---------- Patient wristband (the signature element) ---------- */
.wristband { display: flex; align-items: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; margin-bottom: 20px; }
.wristband .clasp { width: 22px; background: repeating-linear-gradient(0deg, var(--ward) 0 6px, var(--ward-dark) 6px 12px); flex: none; }
.wristband .body { padding: 14px 22px; display: flex; gap: 28px; flex-wrap: wrap; align-items: center; flex: 1; }
.wristband .name { font-size: 1.5rem; font-weight: 700; }
.wristband .field small { display: block; color: var(--ink-2); font-size: .75rem; }
.wristband .field span { font-weight: 700; }
.wristband .allergy { background: var(--red-tint); color: var(--red); padding: 6px 12px; border-radius: var(--radius-s); font-weight: 700; }
.wristband .allergy.none { background: var(--paper); color: var(--ink-2); font-weight: 400; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--ink-2); border-bottom: 3px solid transparent; border-radius: 0; margin-bottom: -2px; padding: 10px 14px; white-space: nowrap; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--ward); }
.tabs button:hover { background: var(--ward-tint); }

.note { border-left: 3px solid var(--line); padding: 4px 0 4px 16px; margin-bottom: 20px; }
.note.draft { border-left-color: var(--amber); }
.note dl { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; margin: 8px 0 0; }
.note dt { color: var(--ink-2); font-weight: 700; font-size: .875rem; }
.note dd { margin: 0; white-space: pre-wrap; }

/* ---------- AI ---------- */
.ai-draft { border: 2px dashed var(--amber); background: var(--amber-tint); border-radius: var(--radius-m); padding: 16px; margin-top: 14px; }
.ai-draft > .flag { font-weight: 700; color: var(--amber); margin-bottom: 10px; display: block; }
.ai-answer { white-space: pre-wrap; background: var(--paper); border-radius: var(--radius-m); padding: 14px; margin-top: 12px; }
.ai-off { background: var(--blue-tint); padding: 10px 14px; border-radius: var(--radius-m); font-size: .9375rem; margin-bottom: 16px; }

.chat { display: flex; flex-direction: column; height: calc(100vh - 170px); min-height: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.chat-log { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 70ch; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--ward); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--paper); border-bottom-left-radius: 4px; }
.msg.emergency { background: var(--red); color: #fff; font-weight: 700; }
.msg .suggest { margin-top: 8px; }
.chat form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat .disclaimer { font-size: .8125rem; color: var(--ink-2); padding: 0 14px 10px; }

/* ---------- Modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(20,33,61,.45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: var(--surface); border-radius: var(--radius-m); padding: 24px; width: min(720px, 100%); max-height: 90vh; overflow-y: auto; }
.modal h2 { margin-bottom: 16px; }
.modal .row.end { margin-top: 20px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(120px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: var(--radius-m); transition: transform .2s ease; z-index: 60; max-width: 90vw; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--red); }
.slots { display: flex; flex-wrap: wrap; gap: 6px; }
.slots button { background: #fff; color: var(--ink); border-color: var(--line); font-weight: 400; }
.slots button.picked { background: var(--ward); color: #fff; border-color: var(--ward); }

/* ---------- Print (invoices) ---------- */
@media print {
  nav.side, .no-print, .page-head button { display: none !important; }
  .shell { display: block; }
  main { padding: 0; }
}

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
  .signin { grid-template-columns: 1fr; }
  .signin-side { padding: 32px 24px; gap: 24px; }
  .signin-form { padding: 32px 24px; }
  .shell { grid-template-columns: 1fr; }
  nav.side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .brand { width: 100%; padding-bottom: 8px; }
  .who { width: 100%; margin-top: 8px; display: flex; align-items: center; gap: 12px; }
  .who button { margin: 0 0 0 auto; }
  main { padding: 20px 16px 48px; }
  .two { grid-template-columns: 1fr; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
