/* Digital Case Sheet – Srinivasan Super Speciality Hospital */

:root {
  --font: Arial, "Helvetica Neue", Helvetica, "Liberation Sans", sans-serif;
  --font-ta: "Latha", "Nirmala UI", "Noto Sans Tamil", Arial, sans-serif;

  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --ink: #17212b;
  --ink-2: #3d4a57;
  --muted: #66727f;
  --line: #dde3e9;
  --line-2: #c9d2db;

  --brand: #0b6e4f;
  --brand-dark: #085a40;
  --brand-soft: #e5f2ec;
  --brand-ink: #ffffff;

  --danger: #c0262d;
  --danger-soft: #fdecec;
  --warn: #a35a00;
  --warn-soft: #fff3df;
  --info: #1f5fbf;
  --info-soft: #e8f0fc;
  --ok: #1e7a3c;
  --ok-soft: #e6f4ea;

  --temp: #d23a2c;
  --pulse: #2457c5;
  --bp: #0b7a6e;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.06);
  --focus: 0 0 0 3px rgba(11, 110, 79, 0.28);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; }
a { color: var(--brand); }
[hidden] { display: none !important; }
:lang(ta), [lang="ta"] { font-family: var(--font-ta); }

input, select, textarea, button { font: inherit; color: inherit; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }
.cap { text-transform: capitalize; }
.pre, .note-text { white-space: pre-wrap; }
.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loading, .empty { color: var(--muted); padding: 18px 4px; margin: 0; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 100; background: #fff; padding: 8px; }

:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- Buttons, badges ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 13.5px; text-decoration: none; white-space: nowrap;
  cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); border-color: #b3bec9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a11f25; }
.btn-light { background: #fff; color: var(--brand); border-color: #fff; }
.btn-light:hover { background: var(--brand-soft); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(0, 0, 0, 0.05); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; height: 40px; }
.btn-link { background: none; border: 0; padding: 4px 0; color: var(--brand); font-weight: 600; cursor: pointer; text-decoration: none; font-size: 13px; }
.btn-link:hover { text-decoration: underline; }
.btn-x { border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 4px; }
.btn-x:hover { color: var(--danger); background: var(--danger-soft); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 12px; font-weight: 700; background: #eceff2; color: var(--ink-2); white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.tag { display: inline-block; padding: 1px 6px; border-radius: 4px; background: var(--info-soft); color: var(--info); font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px;
  height: 58px; padding: 0 20px;
  background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.logo {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 7px;
  background: #fff; color: var(--brand); font-weight: 800; font-size: 19px;
}
.logo.lg { width: 48px; height: 48px; font-size: 28px; border-radius: 10px; background: var(--brand); color: #fff; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text b { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: 11.5px; opacity: 0.85; }
.mainnav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.mainnav a:not(.btn) {
  color: #fff; text-decoration: none; font-weight: 600; padding: 8px 12px; border-radius: 6px; opacity: 0.9;
}
.mainnav a:not(.btn):hover { background: rgba(255, 255, 255, 0.12); opacity: 1; }
.mainnav a[aria-current]:not(.btn) { background: rgba(255, 255, 255, 0.18); opacity: 1; }
.mainnav .btn { margin-left: 8px; }
.whoami { display: flex; align-items: center; gap: 8px; padding-left: 16px; border-left: 1px solid rgba(255, 255, 255, 0.25); }
.who { display: flex; flex-direction: column; text-align: right; }
.who b { font-size: 13px; }
.who small { font-size: 11.5px; opacity: 0.85; }
.whoami .btn-ghost { color: #fff; }
.whoami .btn-ghost:hover { background: rgba(255, 255, 255, 0.14); }

/* ---------- Page layout ---------- */

.page { max-width: 1440px; margin: 0 auto; padding: 22px 24px 48px; }
.page.narrow { max-width: 1100px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card.flush { padding: 0; overflow: hidden; }
.card > h2 { margin-bottom: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head.pad { padding: 14px 16px 0; }
.card.flush > .empty, .card.flush > .legend-text { padding: 12px 16px; }
details.card summary { cursor: pointer; font-weight: 600; }

.search {
  height: 38px; width: min(360px, 100%); padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff;
}
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 0 12px; height: 32px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }

.split { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.split form label { display: block; margin-bottom: 10px; }

/* ---------- Login ---------- */

body.bare { background: var(--bg); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--brand-soft), var(--bg) 55%); }
.login-card { width: min(400px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 28px; box-shadow: 0 8px 30px rgba(16, 24, 40, 0.08); }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.login-brand h1 { font-size: 16px; }
.login-brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.login-card h2 { margin-bottom: 16px; font-size: 20px; }
.login-card label { display: block; margin-bottom: 14px; }
.login-card .muted { margin: 14px 0 0; text-align: center; }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13px; }

/* ---------- Dashboard ---------- */

.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 26px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat.danger { border-color: #f1b8bb; background: var(--danger-soft); }
.stat.danger b { color: var(--danger); }
.stat.warn { border-color: #f2d19c; background: var(--warn-soft); }
.stat.warn b { color: var(--warn); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pill { border: 1px solid var(--line-2); background: #fff; border-radius: 99px; padding: 5px 12px; font-weight: 600; font-size: 12.5px; cursor: pointer; color: var(--ink-2); }
.pill[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.ward { margin-top: 18px; }
.ward > h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 10px; }
.bed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.bed-card {
  display: flex; flex-direction: column; gap: 4px;
  background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--ok);
  border-radius: var(--radius); padding: 12px 14px; color: inherit; text-decoration: none;
  box-shadow: var(--shadow); transition: transform 0.12s, box-shadow 0.12s;
}
.bed-card:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(16, 24, 40, 0.1); }
.bed-card.lvl-warn { border-left-color: #e39b2d; }
.bed-card.lvl-danger { border-left-color: var(--danger); }
.bed-top { display: flex; justify-content: space-between; align-items: center; }
.bed-no { font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--brand); }
.day { font-size: 12px; font-weight: 700; color: var(--muted); }
.pt-name { font-weight: 700; font-size: 16px; }
.pt-name .muted { font-weight: 400; font-size: 13px; }
.dx { font-size: 13px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { font-size: 12px; color: var(--muted); }
.allergy-chip { align-self: flex-start; font-size: 11.5px; font-weight: 700; color: var(--danger); background: var(--danger-soft); border-radius: 4px; padding: 2px 6px; }
.vitals-mini { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 6px 0 2px; border-top: 1px dashed var(--line); margin-top: 4px; font-size: 12.5px; }
.vm { color: var(--muted); }
.vm b { color: var(--ink); }
.vm.high b, .vm.low b { color: var(--danger); }
.vm.high b::after { content: " ↑"; }
.vm.low b::after { content: " ↓"; }
.vm-time { color: var(--muted); margin-left: auto; font-size: 11.5px; }
.alerts { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 4px; }
.alerts li, .tasks li { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; }
.al-danger { background: var(--danger-soft); color: var(--danger); }
.al-warn { background: var(--warn-soft); color: var(--warn); }
.al-info { background: var(--info-soft); color: var(--info); }
.al-ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- Lists ---------- */

.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.list th, .list td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list thead th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-2); font-weight: 700; white-space: nowrap; }
.list tbody tr:last-child td, .list tbody tr:last-child th { border-bottom: 0; }
.list tr[data-href] { cursor: pointer; }
.list tr[data-href]:hover td { background: var(--brand-soft); }
.list a { color: var(--ink); text-decoration: none; }
.list.compact th, .list.compact td { padding: 7px 10px; }
.list td.actions { white-space: nowrap; text-align: right; }
.list td.high, .list td.low { color: var(--danger); font-weight: 700; background: var(--danger-soft); }

/* ---------- Case sheet ---------- */

.banner { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 24px 12px; }
.banner-main { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.pt { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pt h1 { font-size: 22px; }
.pt-sub { color: var(--ink-2); font-weight: 600; }
.banner-grid { display: grid; grid-template-columns: repeat(6, auto) 1fr; gap: 4px 28px; margin: 0; }
.banner-grid div { min-width: 0; }
.banner-grid dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.banner-grid dd { margin: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner-grid .wide dd { white-space: normal; }
.allergy-bar { margin-top: 10px; background: var(--danger); color: #fff; padding: 7px 12px; border-radius: var(--radius-sm); font-weight: 600; }
.allergy-bar b { margin-right: 8px; letter-spacing: 0.06em; }

.cs-body { display: grid; grid-template-columns: 210px minmax(0, 1fr); max-width: 1500px; margin: 0 auto; }
.cs-tabs { position: sticky; top: 58px; align-self: start; padding: 16px 0 24px 16px; max-height: calc(100vh - 58px); overflow-y: auto; }
.tab-group { margin-bottom: 14px; }
.tab-group h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); padding: 0 10px 4px; }
.tab-group a {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: 6px; color: var(--ink-2); text-decoration: none; font-weight: 600;
}
.tab-group a span { flex: 1; }
.tab-group a small { color: var(--muted); font-weight: 400; font-size: 11px; }
.tab-group a:hover { background: #e9edf1; }
.tab-group a[aria-current="page"] { background: var(--brand); color: #fff; }
.tab-group a[aria-current="page"] small { color: rgba(255, 255, 255, 0.8); }
.dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid #b3bec9; }
.dot.done { background: var(--ok); border-color: var(--ok); }
a[aria-current] .dot.done { background: #fff; border-color: #fff; }
.cs-main { padding: 16px 24px 48px; min-width: 0; outline: none; }

.tab-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.tab-head p { margin: 3px 0 0; }
.row-actions { display: flex; align-items: center; gap: 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }
.pager { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }

/* Overview */
.ov-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.ov-grid .card { margin: 0; }
.ov-grid .span2 { grid-column: span 2; grid-row: span 2; }
.vitals-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 8px; }
.vt { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; }
.vt span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.vt b { font-size: 20px; }
.vt small { color: var(--muted); margin-left: 3px; }
.vt.high, .vt.low { background: var(--danger-soft); border-color: #f1b8bb; }
.vt.high b, .vt.low b { color: var(--danger); }
.tasks { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.tasks li { font-size: 13px; padding: 6px 10px; }
.tasks a { color: inherit; }
.progress-forms { display: grid; grid-template-columns: 1fr auto; gap: 6px; font-size: 13px; color: var(--ink-2); }
.progress-forms .bar { grid-column: span 2; height: 6px; background: #e6eaee; border-radius: 99px; overflow: hidden; }
.progress-forms .bar i { display: block; height: 100%; background: var(--brand); }
.med-list { list-style: none; margin: 0; padding: 0; }
.med-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.med-list li:last-child { border: 0; }
.diet { margin: 10px 0 0; font-size: 13px; background: var(--surface-2); padding: 8px 10px; border-radius: var(--radius-sm); }
.io-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.io-sum > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; }
.io-sum span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.io-sum b { font-size: 20px; }
.io-sum small { color: var(--muted); margin-left: 3px; }
.io-sum .neg b { color: var(--danger); }
.io-sum .pos b { color: var(--ok); }
.io-sum.small b { font-size: 16px; }
.io-sum.small > div { padding: 6px 12px; min-width: 96px; }
.stamp { display: inline-block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.stamp::before { content: "✎ "; }

/* ---------- Forms ---------- */

label { display: block; }
.lbl { display: block; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 4px; }
.lbl em { font-style: normal; font-weight: 400; color: var(--muted); }
.req { color: var(--danger); margin-left: 2px; }
input:not([type=radio]):not([type=checkbox]), select, textarea {
  width: 100%; min-height: 34px; padding: 6px 9px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff;
  transition: border-color 0.12s, box-shadow 0.12s;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input[type=radio], input[type=checkbox] { accent-color: var(--brand); width: 15px; height: 15px; margin: 0; }
input[data-flag="high"], input[data-flag="low"], select[data-flag="high"] { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); font-weight: 700; }
input.caps { text-transform: uppercase; }
input.caps::placeholder { text-transform: none; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline .lbl { margin: 0; white-space: nowrap; }
.inline input { width: auto; }

.sheet-form { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.form-bar {
  position: sticky; top: 58px; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px 18px; background: rgba(255, 255, 255, 0.97); border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
}
.form-bar p { margin: 2px 0 0; font-size: 13px; }
.form-bar-r { display: flex; align-items: center; gap: 10px; }
.save-meta { font-size: 12.5px; color: var(--muted); text-align: right; }

.fsec { padding: 16px 18px 6px; border-bottom: 1px solid var(--line); }
.fsec:last-child { border-bottom: 0; }
.fsec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.fsec-head h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--brand-dark); }
.pg { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }
.fsec-note { font-size: 12.5px; color: var(--muted); margin: -6px 0 10px; }
.fgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; margin-bottom: 10px; }
.fld { min-width: 0; }
.w1 { grid-column: span 1; }
.w2 { grid-column: span 2; }
.w3 { grid-column: span 3; }
.w4 { grid-column: span 4; }

fieldset.choice { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.choice legend { padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 5px 11px; border: 1px solid var(--line-2); border-radius: 99px;
  font-size: 13px; font-weight: 600; color: var(--ink-2); background: #fff; user-select: none;
}
.chip:hover span { border-color: var(--brand); }
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip input:focus-visible + span { box-shadow: var(--focus); }
input.other { margin-top: 8px; }

.pain-scale { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 4px; }
.pain-opt { position: relative; cursor: pointer; text-align: center; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 2px; background: #fff; }
.pain-opt input { position: absolute; opacity: 0; }
.pain-opt b { display: block; font-size: 17px; }
.pain-opt span { display: block; font-size: 10.5px; color: var(--muted); line-height: 1.2; }
.pain-opt.pain-mild { border-top: 4px solid #3b9b5b; }
.pain-opt.pain-moderate { border-top: 4px solid #e39b2d; }
.pain-opt.pain-severe { border-top: 4px solid var(--danger); }
.pain-opt:has(input:checked) { background: var(--ink); color: #fff; border-color: var(--ink); }
.pain-opt:has(input:checked) span { color: #d6dde4; }
.pain-opt:has(input:focus-visible) { box-shadow: var(--focus); }

.ftable { border: 1px solid var(--line); border-radius: var(--radius-sm); }
.ftable th, .ftable td { border: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: middle; }
.ftable thead th { background: var(--surface-2); font-size: 12px; color: var(--ink-2); padding: 7px 8px; }
.ftable tbody th { font-weight: 600; font-size: 13px; background: #fcfdfd; white-space: nowrap; }
.ftable td input, .ftable td select { border-color: transparent; min-height: 30px; background: transparent; }
.ftable td input:hover, .ftable td select:hover { border-color: var(--line-2); }
.ftable td input:focus, .ftable td select:focus { background: #fff; }
.ftable .sno { width: 36px; text-align: center; color: var(--muted); }
.ftable .wide { width: 40%; }
.ftable .yn { width: 130px; white-space: nowrap; }
.ftable .yn .chip span { padding: 3px 9px; font-size: 12px; }
.ftable .q { font-size: 13px; color: var(--ink-2); }
.ftable.matrix td { text-align: center; width: 20%; }
.cell-radio { display: grid; place-items: center; min-height: 32px; cursor: pointer; }
.cell-radio input { width: 18px; height: 18px; }
.ftable.scored td { padding: 4px; }
.score-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.score-opt span { flex: 1; }
.score-opt b { color: var(--muted); font-size: 12px; }
.score-opt:hover { background: var(--surface-2); }
.score-opt:has(input:checked) { background: var(--brand-soft); font-weight: 700; }
.score-total { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm); font-weight: 700; background: var(--surface-2); }
.score-total[data-state="ok"] { background: var(--ok-soft); color: var(--ok); }
.score-total[data-state="risk"] { background: var(--warn-soft); color: var(--warn); }

.consent-text { margin: 0; padding: 12px 14px; background: var(--surface-2); border-left: 3px solid var(--brand); border-radius: 4px; font-size: 13px; color: var(--ink-2); line-height: 1.55; }
.sign-pad { position: relative; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); background: #fff; }
.sign-pad canvas { display: block; width: 100%; aspect-ratio: 600 / 160; touch-action: none; cursor: crosshair; }
.sign-pad::after { content: "Sign here"; position: absolute; left: 12px; bottom: 8px; font-size: 11px; color: #a7b1bb; pointer-events: none; }
.sign-pad .btn-link { position: absolute; right: 10px; top: 4px; }
.sign-img { display: block; max-width: 260px; border-bottom: 1px solid var(--line-2); }

.v .val { display: block; padding: 2px 0; }
.nil { color: #a7b1bb; }
.ftable.view td, .ftable.view th { padding: 5px 8px; }

.discharge { margin-top: 14px; border-color: #f1c7c9; }
.discharge h2 { color: var(--danger); }
.lookup { margin-bottom: 14px; }
.lookup .inline input { width: 220px; }
.lookup p { margin: 6px 0 0; }

/* Entry forms (charts) */
.entry { padding: 14px 16px; }
.entry-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px 12px; align-items: end; }
.entry-grid .w2 { grid-column: span 2; }
.entry-grid .w3 { grid-column: span 3; }
.entry-grid .w4 { grid-column: span 4; }
.entry-grid .w8 { grid-column: span 8; }
.entry-actions { grid-column: -2 / -1; display: flex; justify-content: flex-end; }
.entry-grid .w8 + .entry-actions, .entry-grid .w3 + .entry-actions { grid-column: span 8; }
label.in .lbl em { color: var(--info); }
label.out .lbl em { color: var(--warn); }
.allergy-warn { margin: 10px 0 0; padding: 8px 12px; background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm); font-weight: 700; }

.io-table .grp-in { background: var(--info-soft) !important; color: var(--info) !important; text-align: center; }
.io-table .grp-out { background: var(--warn-soft) !important; color: var(--warn) !important; text-align: center; }
.io-table .tot { font-weight: 700; }
.io-table td, .io-table th { white-space: nowrap; }
.day-total td { background: var(--surface-2); font-weight: 700; }

.lab-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.lab-groups fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px 10px; margin: 0; }
.lab-groups legend { font-weight: 700; font-size: 12.5px; color: var(--brand-dark); padding: 0 4px; }
.lab-in { display: grid; grid-template-columns: 1fr 96px; gap: 8px; align-items: center; padding: 3px 0; }
.lab-in.text { grid-template-columns: 1fr 150px; }
.lab-in span { font-size: 13px; }
.lab-in em { font-style: normal; color: var(--muted); font-size: 11px; }
.lab-in input { min-height: 28px !important; padding: 3px 7px !important; }
.lab-in.ordered { background: var(--warn-soft); margin: 0 -6px; padding: 3px 6px; border-radius: 4px; }
.lab-in.ordered span { font-weight: 700; }
.lab-orders { border-left: 4px solid #e39b2d; }
.lo-list { list-style: none; margin: 0; padding: 0; display: grid; }
.lo-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.lo-list li:first-child { border-top: 0; }
.lo-list.done li { justify-content: space-between; }
.lo-name { flex: 1; min-width: 180px; }
.lo-result { display: flex; gap: 6px; }
.lo-result input { width: 220px; max-width: 52vw; }
.lab-orders details { margin-top: 8px; }
.lab-entry .entry-actions { margin-top: 12px; }
.note-warn { background: var(--warn-soft); border-color: #f2d19c; color: #6b3b00; font-size: 13px; }
.cumulative tr.grp th { background: var(--brand-soft); color: var(--brand-dark); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.cumulative tbody th { font-weight: 600; white-space: nowrap; }
.cumulative td { white-space: nowrap; }
.cumulative td.txt { white-space: normal; min-width: 140px; font-size: 12.5px; }

/* Drug chart */
.mar td { vertical-align: middle; }
.slots { display: flex; gap: 6px; flex-wrap: wrap; }
.slot {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 74px; height: 44px; padding: 2px 6px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff; cursor: pointer; line-height: 1.15;
}
.slot b { font-size: 13px; }
.slot small { font-size: 10.5px; color: var(--muted); }
.slot:disabled { cursor: default; opacity: 0.55; }
.slot.due { border-color: #e39b2d; background: var(--warn-soft); }
.slot.due small { color: var(--warn); font-weight: 700; }
.slot.overdue { border-color: var(--danger); background: var(--danger-soft); }
.slot.overdue small, .slot.overdue b { color: var(--danger); font-weight: 700; }
.slot.done { cursor: default; }
.slot.done[data-mine="true"] { cursor: pointer; }
.slot.st-given { background: var(--ok-soft); border-color: #9fd3ae; }
.slot.st-given b { color: var(--ok); }
.slot.st-WH, .slot.st-R, .slot.st-N { background: #eef0f3; }
.slot.na { border-style: dashed; color: var(--muted); cursor: default; }
tr.stopped td { color: var(--muted); }
tr.stopped b { text-decoration: line-through; }
.legend-text { font-size: 12px; color: var(--muted); margin: 0; border-top: 1px solid var(--line); }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.chart-dialog { border: 0; border-radius: 12px; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); }
.chart-dialog::backdrop { background: rgba(15, 23, 32, 0.45); }
.chart-form { padding: 20px; display: grid; gap: 12px; }
.chart-form p { margin: 0; }
.chart-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chart-btns .btn { height: 42px; }

/* Notes, consults */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { padding: 12px 0 12px 16px; border-left: 3px solid var(--brand-soft); margin-left: 4px; position: relative; }
.timeline > li::before { content: ""; position: absolute; left: -7px; top: 16px; width: 11px; height: 11px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }
.timeline > li + li { border-top: 1px solid var(--line); }
.timeline p { margin: 0 0 4px; }
.tl-head { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.pain-chip { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 99px; }
.pain-chip.pain-mild { background: var(--ok-soft); color: var(--ok); }
.pain-chip.pain-moderate { background: var(--warn-soft); color: var(--warn); }
.pain-chip.pain-severe { background: var(--danger-soft); color: var(--danger); }
.inv { font-size: 13px; color: var(--info); }
.inv span { font-weight: 700; }

/* Drugs / investigations ordered from a progress note (①, ②…) */
.chart-btns.yes-no .btn[value="no"] { order: -1; } /* "Yes" is first in the markup so Enter approves */
.chart-form .seg { justify-self: start; flex-wrap: wrap; }
.dlg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ask-q { font-weight: 700; padding: 10px 12px; background: var(--brand-soft); color: var(--brand-dark); border-radius: var(--radius-sm); }
.note-orders { display: grid; gap: 8px; padding: 12px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); background: var(--surface-2); }
.note-orders > p { margin: 0; }
.order-add { display: flex; flex-wrap: wrap; gap: 8px; }
.order-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.order-items li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.order-items .num { font-size: 20px; line-height: 1; color: var(--brand); font-weight: 700; }
.order-items .oi-text { flex: 1; min-width: 0; }
.order-items.saved { margin: 4px 0 8px; }
.order-items.saved li { padding: 4px 10px; }
.order-items .badge { text-decoration: none; white-space: nowrap; }
.advice span { font-weight: 700; }
.from-note { color: var(--brand); font-weight: 700; }
@media (max-width: 640px) {
  .order-items li { flex-wrap: wrap; }
  .order-items .badge { white-space: normal; }
}
.consult.pending { border-left: 4px solid #e39b2d; }
.consult.answered { border-left: 4px solid var(--ok); }
.opinion { margin-top: 12px; padding: 10px 12px; background: var(--ok-soft); border-radius: var(--radius-sm); }
.opinion p { margin: 4px 0; }
.respond { margin-top: 12px; display: grid; gap: 8px; justify-items: start; }
.round summary { display: flex; align-items: center; gap: 10px; }
.round summary .btn { margin-left: auto; }
.round[open] summary { margin-bottom: 12px; }
.round .fsec { padding-left: 0; padding-right: 0; }
#mdt-edit:not(:empty) { margin-bottom: 14px; }

/* ---------- TPR chart ---------- */

.tpr { margin: 0; min-width: 0; }
.tpr svg { display: block; width: 100%; height: auto; font-family: var(--font); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; }
.lg-temp { background: var(--temp); }
.lg-pulse { background: var(--pulse); }
.lg-bp { background: var(--bp); }
.lg-flag { width: 10px !important; height: 10px !important; border-radius: 50% !important; border: 2px solid var(--danger); background: #fff; }
.tpr .band { fill: #f6f8fa; }
.tpr .frame { fill: none; stroke: var(--line-2); }
.tpr .grid { stroke: #e9edf1; }
.tpr .slot { stroke: #eef1f4; }
.tpr .day-line { stroke: #b8c2cc; }
.tpr .day-lbl { font-size: 13px; font-weight: 700; text-anchor: middle; fill: var(--ink); }
.tpr .day-sub { font-size: 11px; text-anchor: middle; fill: var(--muted); }
.tpr .slot-lbl { font-size: 10px; text-anchor: middle; fill: var(--muted); }
.tpr .ax { font-size: 11px; fill: var(--muted); }
.tpr .ax-l { text-anchor: end; }
.tpr .ax-r { fill: var(--pulse); }
.tpr .ref { stroke: var(--temp); stroke-width: 1.2; stroke-dasharray: 5 4; }
.tpr .ref-lbl { font-size: 10px; fill: var(--temp); }
.tpr .panel-lbl { font-size: 11px; font-weight: 700; fill: var(--ink-2); }
.tpr .temp { fill: none; stroke: var(--temp); stroke-width: 2; stroke-linejoin: round; }
.tpr .temp-pt { fill: var(--temp); stroke: #fff; stroke-width: 1; }
.tpr .pulse { fill: none; stroke: var(--pulse); stroke-width: 1.6; stroke-linejoin: round; opacity: 0.85; }
.tpr .pulse-pt { fill: #fff; stroke: var(--pulse); stroke-width: 1.6; }
.tpr .flag { stroke: var(--danger); stroke-width: 2.4; }
.tpr .bp line { stroke: var(--bp); stroke-width: 2.2; stroke-linecap: round; }
.tpr .bp.flag line { stroke: var(--danger); }
.tpr .pain-bar.pain-mild { fill: #6cbf88; }
.tpr .pain-bar.pain-moderate { fill: #edb15a; }
.tpr .pain-bar.pain-severe { fill: #e0575d; }

/* ---------- Toasts ---------- */

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: grid; gap: 8px; }
.toast { padding: 10px 14px; border-radius: var(--radius-sm); color: #fff; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); max-width: 380px; animation: pop 0.18s ease-out; }
.toast-ok { background: #1f2a35; }
.toast-error { background: var(--danger); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Print view ---------- */

.print-bar { position: sticky; top: 0; z-index: 5; display: flex; gap: 16px; align-items: center; padding: 10px 20px; background: var(--ink); color: #fff; }
.print-bar span { margin-right: auto; opacity: 0.7; }
.print-doc { padding: 20px 0 60px; }
.pp {
  width: 210mm; min-height: 297mm; margin: 0 auto 20px; padding: 12mm 12mm 14mm;
  background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12); font-size: 11.5px;
}
.pp.wide { width: 297mm; min-height: 210mm; }
.pp-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--ink); padding-bottom: 6px; margin-bottom: 6px; }
.pp-hosp { display: flex; align-items: center; gap: 8px; }
.pp-hosp .logo { background: var(--ink); color: #fff; width: 28px; height: 28px; font-size: 16px; }
.pp-hosp b { display: block; font-size: 14px; letter-spacing: 0.02em; }
.pp-hosp small { font-size: 10.5px; }
.pp-head h2 { font-size: 13px; border: 1.5px solid var(--ink); padding: 3px 10px; }
.pp-strip { width: 100%; border: 1px solid var(--ink); margin-bottom: 8px; }
.pp-strip td { border: 1px solid var(--line-2); padding: 3px 6px; font-size: 11px; vertical-align: top; }
.pp-strip span { display: block; font-size: 9px; text-transform: uppercase; color: var(--muted); }
.pp-allergy { border: 1.5px solid var(--danger); color: var(--danger); font-weight: 700; padding: 3px 8px; margin: 0 0 8px; }
.pp .fsec { padding: 8px 0 2px; }
.pp .fsec-head { margin-bottom: 6px; }
.pp .fsec-head h3 { font-size: 11.5px; color: var(--ink); }
.pp .pg { display: none; }
.pp .fgrid { gap: 6px 14px; margin-bottom: 4px; }
.pp .lbl { font-size: 9.5px; margin: 0; color: var(--muted); text-transform: uppercase; }
.pp .ftable th, .pp .ftable td { padding: 3px 6px; font-size: 11px; }
.pp .consent-text { font-size: 11px; padding: 6px 8px; }
.pp .score-total { padding: 5px 8px; margin-top: 4px; }
.pp .tpr .legend { font-size: 10px; }
.pp-box { border: 1px solid var(--line-2); padding: 6px 8px; margin: 8px 0; }
.pp-box p { margin: 2px 0; }
.pp-sign { font-size: 10.5px; color: var(--muted); font-style: italic; margin: 6px 0 0; }
.pp-table { width: 100%; border: 1px solid var(--ink-2); margin-bottom: 8px; }
.pp-table th, .pp-table td { border: 1px solid var(--line-2); padding: 3px 5px; text-align: left; vertical-align: top; font-size: 10.5px; }
.pp-table thead th { background: #eef1f4; }
.pp-table td.high, .pp-table td.low { font-weight: 700; color: var(--danger); }
.pp-table tr.grp th { background: #f4f6f8; text-transform: uppercase; font-size: 9.5px; }
.pp h3 { font-size: 12px; margin: 10px 0 4px; }

/* Page margins come from @page so sections that run over a page keep their margins. */
@page { size: A4; margin: 11mm 12mm; }
@page landscape { size: A4 landscape; margin: 10mm 12mm; }
@media print {
  body, body.bare { background: #fff; }
  .print-bar, #toasts { display: none !important; }
  .print-doc { padding: 0; }
  .pp, .pp.wide { width: auto; min-height: 0; margin: 0; padding: 0 2px; box-shadow: none; break-after: page; }
  .pp:last-child { break-after: auto; }
  .pp.wide { page: landscape; }
  .pp-table tr, .ftable tr, .pp-box, .pp .fld { break-inside: avoid; }
  .pp .fsec-head { break-after: avoid; }
}
/* A4 is narrower than the tablet breakpoint – keep the 4-column form layout on paper. */
.pp .fgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pp .fgrid .w3 { grid-column: span 3; }
.pp .fgrid .w4 { grid-column: span 4; }

/* ---------- Responsive ---------- */

@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .ov-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .banner-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .entry-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .entry-grid .w8 { grid-column: span 4; }
  .entry-actions, .entry-grid .w8 + .entry-actions, .entry-grid .w3 + .entry-actions { grid-column: span 4; }
}

@media (max-width: 900px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brand-text small, .who small { display: none; }
  .mainnav a:not(.btn) { padding: 8px; }
  .cs-body { grid-template-columns: minmax(0, 1fr); }
  .cs-tabs { position: static; display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; max-height: none; border-bottom: 1px solid var(--line); background: #fff; }
  .tab-group { display: flex; gap: 2px; margin: 0; align-items: center; }
  .tab-group h4 { display: none; }
  .tab-group a { white-space: nowrap; }
  .tab-group a small { display: none; }
  .cs-main, .page { padding-left: 16px; padding-right: 16px; }
  .banner { padding: 12px 16px; }
  .split { grid-template-columns: 1fr; }
  .ov-grid { grid-template-columns: minmax(0, 1fr); }
  .ov-grid .span2 { grid-column: auto; grid-row: auto; }
  .vitals-row { grid-template-columns: repeat(3, 1fr); }
  .fgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fgrid .w3, .fgrid .w4 { grid-column: span 2; }
  .pain-scale { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .topbar { gap: 6px; }
  .brand-text, .who, .mainnav [data-nav="dashboard"] { display: none; }
  .mainnav { gap: 2px; }
  .mainnav a:not(.btn) { padding: 8px 6px; font-size: 13px; }
  .mainnav .btn { margin-left: 4px; padding: 0 8px; font-size: 12.5px; }
  .whoami { padding-left: 6px; }
  .whoami .btn { padding: 0 6px; font-size: 12.5px; }
  .tpr { overflow-x: auto; }
  .tpr svg { min-width: 720px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .banner-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fgrid, .entry-grid { grid-template-columns: 1fr; }
  .fgrid > *, .entry-grid > * { grid-column: 1 / -1 !important; }
  .form-bar { flex-direction: column; align-items: stretch; }
  .chart-btns { grid-template-columns: 1fr; }
}
