:root {
    --ink: #102a33;
    --ink-2: #29434b;
    --muted: #6c7e83;
    --muted-2: #94a3a7;
    --paper: #f3f7f6;
    --surface: #ffffff;
    --surface-2: #edf3f2;
    --line: #dce6e4;
    --line-strong: #c7d7d4;
    --brand: #077E9D;
    --brand-dark: #025B7D;
    --brand-soft: #E8F4F7;
    --aqua: #077E9D;
    --blue: #025B7D;
    --danger: #b93838;
    --danger-soft: #fae9e7;
    --warning: #FCBB1C;
    --warning-soft: #FFF5D1;
    --success: #257454;
    --success-soft: #e4f3eb;
    --shadow-sm: 0 1px 2px rgba(16, 42, 51, .05), 0 8px 24px rgba(16, 42, 51, .06);
    --shadow-lg: 0 22px 70px rgba(15, 48, 57, .17);
    --radius: 13px;
    --radius-sm: 9px;
    --topbar-h: 64px;
    --rail-w: 315px;
    --tab-h: 42px;
    --display: "Bahnschrift", "Aptos Display", "Trebuchet MS", sans-serif;
    --body: "Aptos", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--body); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* Auth */
.auth-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 10% 8%, rgba(79, 182, 178, .13), transparent 32%),
        linear-gradient(135deg, #eaf2f1 0 47%, #f8faf9 47% 100%);
}
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.06fr .94fr; }
.login-brand { position: relative; overflow: hidden; padding: clamp(38px, 6vw, 90px); display: flex; flex-direction: column; justify-content: space-between; color: white; background: #025B7D; }
.login-brand::before { content: ""; position: absolute; width: 530px; height: 530px; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; right: -230px; top: -185px; box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.018); }
.login-brand::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(115deg, transparent 0 78px, rgba(255,255,255,.025) 79px 80px); pointer-events: none; }
.brand-ribbon { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; font-family: var(--display); font-size: 15px; letter-spacing: .12em; font-weight: 700; }
.brand-symbol { width: 38px; height: 38px; border-radius: 10px 10px 4px 10px; display: grid; place-items: center; background: var(--aqua); color: #072f36; font-family: var(--display); font-weight: 900; font-size: 22px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.brand-symbol.small { width: 34px; height: 34px; font-size: 19px; flex: 0 0 auto; }
.login-copy { position: relative; z-index: 1; max-width: 690px; }
.eyebrow { margin: 0 0 8px; color: var(--brand); font-family: var(--display); font-size: 10px; line-height: 1.2; letter-spacing: .18em; font-weight: 800; }
.login-brand .eyebrow { color: #7bd2cf; }
.login-copy h1 { margin: 0; max-width: 660px; font-family: var(--display); font-size: clamp(44px, 5vw, 76px); line-height: .98; letter-spacing: -.045em; font-weight: 750; }
.login-copy > p:last-child { max-width: 610px; margin: 28px 0 0; color: #bad0d3; font-size: 17px; line-height: 1.7; }
.login-metrics { position: relative; z-index: 1; display: flex; gap: 35px; color: #90afb4; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.login-metrics b { color: #77d2cf; margin-right: 6px; }
.login-panel { display: grid; place-items: center; padding: 45px; }
.login-card { width: min(440px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.88); box-shadow: var(--shadow-lg); backdrop-filter: blur(14px); }
.login-card-head { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 30px; }
.login-card-head h2 { margin: 0; font-family: var(--display); font-size: 29px; letter-spacing: -.025em; }
.status-dot { width: 11px; height: 11px; margin-top: 10px; border-radius: 50%; background: var(--aqua); box-shadow: 0 0 0 5px rgba(79,182,178,.12); }
.field { display: grid; gap: 7px; margin: 17px 0; }
.field > span, .field-label { color: var(--ink-2); font-size: 12px; font-weight: 750; letter-spacing: .02em; }
.field input, .field select, .field textarea, .control {
    width: 100%; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; color: var(--ink); outline: none; transition: border-color .16s, box-shadow .16s, background .16s;
}
.field input, .field select, .control { height: 41px; padding: 0 12px; }
.field textarea { min-height: 94px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus, .control:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(8,127,140,.11); }
.form-error { margin: 12px 0; padding: 11px 12px; border-radius: 8px; color: #882f2f; background: var(--danger-soft); font-size: 13px; }
.btn { min-height: 38px; border: 0; border-radius: 9px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 750; font-size: 13px; transition: transform .14s ease, background .14s, border-color .14s, box-shadow .14s; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { color: white; background: var(--brand); box-shadow: 0 8px 20px rgba(8,127,140,.16); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { color: var(--ink); background: white; border: 1px solid var(--line-strong); }
.btn-secondary:hover { border-color: #9db9b4; background: #f9fbfb; }
.btn-ghost { color: var(--ink-2); background: transparent; border: 1px solid var(--line); }
.btn-danger { color: white; background: var(--danger); }
.btn-login { width: 100%; height: 48px; margin-top: 8px; justify-content: space-between; padding-inline: 18px; }
.login-footnote { margin: 20px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }

/* Application shell */
.app-page { height: 100vh; overflow: hidden; background: #edf3f2; }
.hc-shell { min-width: 1020px; height: 100vh; display: grid; grid-template-rows: var(--topbar-h) 1fr; }
.topbar { z-index: 30; display: grid; grid-template-columns: var(--rail-w) minmax(520px,1fr) auto; align-items: stretch; background: #025B7D; color: white; border-bottom: 1px solid #01435C; box-shadow: 0 5px 18px rgba(9,34,39,.13); }
.brand-block { display: flex; align-items: center; gap: 10px; padding: 0 18px; border-right: 1px solid rgba(255,255,255,.09); }
.brand-text { display: grid; gap: 1px; }
.brand-text strong { font-family: var(--display); font-size: 13px; letter-spacing: .1em; }
.brand-text span { color: #9ab8bd; font-size: 11px; }
.patient-context { min-width: 0; display: grid; grid-template-columns: minmax(210px, 1.5fr) repeat(3, minmax(105px,.7fr)); align-items: center; }
.context-cell { height: 37px; min-width: 0; padding: 2px 16px; border-right: 1px solid rgba(255,255,255,.08); display: grid; align-content: center; gap: 2px; }
.context-cell:last-child { border-right: 0; }
.context-label { color: #8baab0; font-size: 9px; text-transform: uppercase; letter-spacing: .13em; font-weight: 700; }
.context-cell strong, .context-cell b { overflow: hidden; color: #eff8f7; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.patient-context[data-empty="true"] strong { color: #a9c0c4; font-weight: 500; }
.user-menu { display: flex; align-items: center; gap: 9px; padding: 0 14px; border-left: 1px solid rgba(255,255,255,.09); }
.user-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: #1b4d55; color: #bfe8e5; font-family: var(--display); font-weight: 800; font-size: 11px; }
.user-meta { max-width: 180px; display: grid; gap: 1px; }
.user-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.user-meta span { overflow: hidden; color: #8fb0b5; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.icon-btn { width: 34px; height: 34px; border: 0; border-radius: 8px; display: grid; place-items: center; background: transparent; color: #9bb8bd; cursor: pointer; }
.icon-btn:hover { color: white; background: rgba(255,255,255,.07); }

.workspace-grid { min-height: 0; display: grid; grid-template-columns: var(--rail-w) 1fr; }
.clinical-rail { min-height: 0; overflow-y: auto; background: #f7faf9; border-right: 1px solid var(--line); scrollbar-width: thin; }
.rail-section { padding: 17px 18px; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading.compact { margin-bottom: 10px; }
.section-heading h2, .section-heading h3 { margin: 0; font-family: var(--display); letter-spacing: -.02em; }
.section-heading h2 { font-size: 19px; }
.section-heading h3 { font-size: 15px; }
.section-heading .eyebrow { margin-bottom: 3px; }
.kbd { padding: 3px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; color: var(--muted); background: white; font-size: 9px; font-weight: 750; }
.search-box { height: 41px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 10px; background: white; box-shadow: 0 2px 7px rgba(16,42,51,.025); }
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(8,127,140,.08); }
.search-box svg { color: var(--muted); flex: 0 0 auto; }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12px; }
.search-box input::placeholder { color: #9aa9ad; }
.search-results { position: absolute; z-index: 60; width: 279px; max-height: 330px; overflow-y: auto; margin-top: 6px; border: 1px solid var(--line); border-radius: 11px; background: white; box-shadow: var(--shadow-lg); }
.patient-result { width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid #edf2f1; display: grid; gap: 3px; text-align: left; background: white; cursor: pointer; }
.patient-result:last-child { border-bottom: 0; }
.patient-result:hover, .patient-result.is-selected { background: #edf7f6; }
.patient-result strong { font-size: 12px; }
.patient-result span { color: var(--muted); font-size: 10px; }
.empty-result { padding: 20px 12px; color: var(--muted); text-align: center; font-size: 11px; }
.patient-summary { display: grid; grid-template-columns: 43px 1fr; column-gap: 10px; align-items: center; background: linear-gradient(180deg,#f7faf9,#f2f7f6); }
.patient-monogram { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 13px; background: #dceeed; color: var(--brand-dark); font-family: var(--display); font-weight: 800; }
.patient-identity { min-width: 0; display: grid; gap: 3px; }
.patient-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.patient-identity span { color: var(--muted); font-size: 10px; }
.mini-facts { grid-column: 1 / -1; margin: 14px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.mini-facts div { min-width: 0; padding: 7px 8px; border-radius: 7px; background: rgba(255,255,255,.75); border: 1px solid #e5eceb; }
.mini-facts dt { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .1em; }
.mini-facts dd { margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; font-weight: 700; }
.admission-list { display: grid; gap: 6px; }
.admission-item { width: 100%; min-height: 49px; padding: 8px 10px; display: grid; grid-template-columns: 1fr auto; gap: 5px 8px; border: 1px solid var(--line); border-radius: 9px; text-align: left; background: white; cursor: pointer; }
.admission-item:hover { border-color: #a9c4c0; }
.admission-item.is-active { border-color: var(--brand); background: #edf8f7; box-shadow: inset 3px 0 0 var(--brand); }
.admission-item strong { font-size: 11px; }
.admission-item small { color: var(--muted); font-size: 9px; }
.admission-item .status { align-self: center; padding: 2px 5px; border-radius: 999px; color: var(--success); background: var(--success-soft); font-size: 8px; font-weight: 800; text-transform: uppercase; }
.rail-action { width: 100%; padding: 8px 7px; border: 0; border-radius: 9px; display: grid; grid-template-columns: 33px 1fr; gap: 9px; align-items: center; text-align: left; background: transparent; cursor: pointer; }
.rail-action:hover { background: #edf4f3; }
.action-glyph { width: 33px; height: 31px; display: grid; place-items: center; border: 1px solid #c8dcda; border-radius: 8px; color: var(--brand-dark); background: white; font-family: var(--display); font-size: 9px; font-weight: 800; }
.rail-action > span:last-child { display: grid; gap: 1px; }
.rail-action b { font-size: 10px; }
.rail-action small { color: var(--muted); font-size: 9px; }

.clinical-workspace { min-width: 0; min-height: 0; display: grid; grid-template-rows: var(--tab-h) 1fr; background: var(--paper); }
.tabbar { min-width: 0; display: flex; align-items: flex-end; gap: 0; overflow-x: auto; overflow-y: hidden; border-bottom: 1px solid #cfdcda; background: #e4ecea; scrollbar-width: none; }
.tabbar::-webkit-scrollbar { display: none; }
.tab { position: relative; height: var(--tab-h); min-width: 140px; max-width: 245px; padding: 0 9px 0 12px; border-right: 1px solid #cfdbd9; display: flex; align-items: center; gap: 7px; color: #536a70; background: #e4ecea; cursor: pointer; user-select: none; }
.tab:hover { background: #eaf1f0; }
.tab.is-active { color: var(--ink); background: var(--paper); }
.tab.is-active::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--brand); }
.tab-icon { width: 17px; height: 17px; display: grid; place-items: center; color: #608187; flex: 0 0 auto; }
.tab-icon svg { width: 14px; height: 14px; }
.tab-label { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; font-weight: 700; }
.tab-dirty { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--warning); }
.tab-close { width: 20px; height: 20px; border: 0; border-radius: 5px; display: grid; place-items: center; color: #70888d; background: transparent; cursor: pointer; opacity: .7; }
.tab-close:hover { opacity: 1; color: var(--ink); background: #d6e1df; }
.tab-close svg { width: 11px; height: 11px; }
.tab-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.tab-panel { position: absolute; inset: 0; display: none; overflow: auto; }
.tab-panel.is-active { display: block; }
.home-empty { min-height: 100%; padding: 80px 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: radial-gradient(circle at 50% 38%, rgba(79,182,178,.09), transparent 22%); }
.home-graphic { position: relative; width: 230px; height: 78px; margin-bottom: 28px; }
.pulse-line { position: absolute; inset: 36px 0 auto; height: 1px; background: #cbdedb; }
.pulse-line::after { content: ""; position: absolute; left: 21px; right: 21px; top: -25px; height: 50px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 188 50'%3E%3Cpath d='M0 25h42l8-14 10 29 12-28 10 13h28l7-8 9 17 8-9h54' fill='none' stroke='%23087f8c' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; }
.cross-mark { position: absolute; right: -5px; top: 19px; width: 35px; height: 35px; display: grid; place-items: center; border-radius: 50%; color: white; background: #025B7D; font-family: var(--display); font-size: 21px; box-shadow: 0 5px 20px rgba(16,47,54,.18); }
.home-empty h1 { margin: 0; font-family: var(--display); font-size: 33px; letter-spacing: -.04em; }
.home-empty > p:not(.eyebrow) { max-width: 600px; margin: 12px 0 24px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.home-empty .btn span { margin-left: 8px; color: #b8e7e4; font-size: 9px; }
.home-dashboard { min-height: 100%; padding: 24px; }
.dashboard-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; margin-bottom: 19px; }
.dashboard-head h1 { margin: 0; font-family: var(--display); font-size: 27px; letter-spacing: -.035em; }
.dashboard-head p:not(.eyebrow) { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.dashboard-actions { display: flex; gap: 8px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(480px, 1.55fr) minmax(260px, .65fr); gap: 14px; }
.dashboard-card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow-sm); overflow: hidden; }
.card-head { min-height: 64px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; font-family: var(--display); font-size: 16px; }
.count-badge { min-width: 28px; height: 24px; padding: 0 8px; border-radius: 999px; display: grid; place-items: center; color: var(--brand-dark); background: var(--brand-soft); font-size: 10px; font-weight: 800; }
.history-list { max-height: calc(100vh - 235px); overflow-y: auto; }
.history-item { width: 100%; padding: 12px 16px; border: 0; border-bottom: 1px solid #edf2f1; display: grid; grid-template-columns: 92px 1fr auto; gap: 13px; text-align: left; background: white; cursor: pointer; }
.history-item:hover { background: #f8fbfa; }
.history-item:last-child { border-bottom: 0; }
.history-date { color: var(--muted); font-size: 9px; }
.history-type { display: inline-flex; margin-top: 4px; padding: 3px 6px; border-radius: 5px; color: var(--brand-dark); background: #e6f3f2; font-size: 8px; font-weight: 800; text-transform: uppercase; }
.history-copy { min-width: 0; }
.history-copy strong { display: block; margin-bottom: 3px; font-size: 11px; }
.history-copy p { margin: 0; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.history-author { align-self: center; color: #759096; font-size: 9px; }
.empty-card-state { padding: 28px 19px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.admission-detail { padding: 16px; }
.admission-detail .admission-number { margin: 0 0 3px; font-family: var(--display); font-size: 24px; }
.admission-detail .admission-date { color: var(--muted); font-size: 10px; }
.admission-facts { margin-top: 16px; display: grid; gap: 7px; }
.admission-facts div { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 7px; border-bottom: 1px solid #edf2f1; font-size: 10px; }
.admission-facts span { color: var(--muted); }
.admission-facts b { text-align: right; }

/* Module panels */
.module-shell { min-height: 100%; display: grid; grid-template-rows: auto 1fr auto; background: #f4f7f6; }
.module-head { min-height: 65px; padding: 13px 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.86); position: sticky; top: 0; z-index: 12; backdrop-filter: blur(10px); }
.module-title { min-width: 0; display: flex; align-items: center; gap: 11px; }
.module-title-mark { width: 37px; height: 37px; border-radius: 10px; display: grid; place-items: center; color: white; background: #025B7D; font-family: var(--display); font-size: 10px; font-weight: 800; }
.module-title h1 { margin: 0; font-family: var(--display); font-size: 18px; letter-spacing: -.02em; }
.module-title p { margin: 2px 0 0; color: var(--muted); font-size: 9px; }
.module-status { display: flex; align-items: center; gap: 8px; }
.status-chip { padding: 5px 8px; border-radius: 999px; color: var(--success); background: var(--success-soft); font-size: 8px; font-weight: 850; letter-spacing: .05em; text-transform: uppercase; }
.status-chip.dirty { color: var(--warning); background: var(--warning-soft); }
.module-body { padding: 16px 18px 30px; overflow: auto; }
.module-footer { min-height: 55px; padding: 8px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); background: #fff; position: sticky; bottom: 0; z-index: 10; box-shadow: 0 -5px 18px rgba(16,42,51,.035); }
.module-footer .footer-hint { color: var(--muted); font-size: 9px; }
.footer-actions { display: flex; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0,1fr)); gap: 10px; }
.form-section { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 11px; background: white; box-shadow: 0 1px 0 rgba(16,42,51,.02); overflow: visible; }
.form-section-title { min-height: 38px; padding: 9px 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e8efee; background: #fbfcfc; }
.form-section-title h3 { margin: 0; font-family: var(--display); font-size: 11px; letter-spacing: .01em; }
.form-section-title span { color: var(--muted); font-size: 8px; }
.form-section-body { padding: 11px; display: grid; grid-template-columns: repeat(12,minmax(0,1fr)); gap: 9px 10px; }
.col-12 { grid-column: span 12; }.col-9 { grid-column: span 9; }.col-8 { grid-column: span 8; }.col-7 { grid-column: span 7; }.col-6 { grid-column: span 6; }.col-5 { grid-column: span 5; }.col-4 { grid-column: span 4; }.col-3 { grid-column: span 3; }.col-2 { grid-column: span 2; }
.field.compact { margin: 0; gap: 5px; }
.field.compact input, .field.compact select { height: 36px; font-size: 11px; }
.field.compact textarea { min-height: 82px; font-size: 11px; }
.field small { color: var(--muted); font-size: 8px; }
.inline-controls { display: grid; grid-template-columns: repeat(7,minmax(75px,1fr)); gap: 8px; }
.input-with-unit { position: relative; }
.input-with-unit input { padding-right: 34px; }
.input-with-unit span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 8px; }
.autocomplete { position: relative; }
.autocomplete-results { position: absolute; left: 0; right: 0; z-index: 35; max-height: 240px; overflow: auto; margin-top: 4px; border: 1px solid var(--line); border-radius: 9px; background: white; box-shadow: var(--shadow-lg); }
.autocomplete-option { width: 100%; padding: 8px 10px; border: 0; border-bottom: 1px solid #eef3f2; display: grid; grid-template-columns: 62px 1fr; gap: 7px; text-align: left; background: white; cursor: pointer; }
.autocomplete-option:last-child { border-bottom: 0; }
.autocomplete-option:hover { background: #edf7f6; }
.autocomplete-option b { color: var(--brand-dark); font-size: 9px; }
.autocomplete-option span { font-size: 9px; line-height: 1.35; }
.clinical-textarea { min-height: 100px !important; }
.vitals-row { display: grid; grid-template-columns: 1.2fr repeat(6,1fr); gap: 8px; }
.ta-control { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 4px; }
.ta-control span { color: var(--muted); }

/* Formulation */
.segmented { display: inline-flex; padding: 3px; border-radius: 9px; background: #e8efee; }
.segmented button { height: 29px; padding: 0 12px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 9px; font-weight: 800; cursor: pointer; }
.segmented button.is-active { color: var(--ink); background: white; box-shadow: 0 1px 4px rgba(16,42,51,.09); }
.formulation-grid { display: grid; grid-template-columns: minmax(380px,1fr) minmax(310px,.74fr); gap: 12px; }
.entry-stack { display: grid; gap: 8px; }
.rx-entry { border: 1px solid var(--line); border-radius: 10px; background: white; overflow: hidden; }
.rx-entry-head { padding: 8px 10px; border-bottom: 1px solid #ebf0ef; display: flex; justify-content: space-between; align-items: center; }
.rx-entry-head strong { font-size: 10px; }
.rx-entry textarea { width: 100%; min-height: 90px; border: 0; padding: 10px; outline: 0; resize: vertical; font-size: 10px; }
.medication-builder { display: grid; gap: 8px; }
.medication-line { padding: 9px; display: grid; grid-template-columns: minmax(180px,1.5fr) 70px minmax(120px,1fr) 115px 30px; gap: 7px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.medication-line input, .medication-line select { height: 34px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 0 8px; font-size: 9px; }
.remove-line { width: 30px; border: 0; border-radius: 7px; color: var(--danger); background: var(--danger-soft); cursor: pointer; }
.formulation-history { max-height: 465px; overflow: auto; border: 1px solid var(--line); border-radius: 11px; background: white; }
.formulation-record { padding: 10px 11px; border-bottom: 1px solid #edf2f1; }
.formulation-record:last-child { border-bottom: 0; }
.formulation-record header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.formulation-record strong { font-size: 10px; }
.formulation-record time { color: var(--muted); font-size: 8px; }
.formulation-record p { margin: 0; white-space: pre-wrap; color: var(--ink-2); font-size: 9px; line-height: 1.5; }

/* Tables */
.data-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: white; }
.data-table { width: 100%; border-collapse: collapse; font-size: 9px; }
.data-table th { position: sticky; top: 0; z-index: 2; padding: 8px; color: #60777c; background: #f6f9f8; border-bottom: 1px solid var(--line); text-align: left; text-transform: uppercase; letter-spacing: .06em; font-size: 8px; }
.data-table td { padding: 8px; border-bottom: 1px solid #edf2f1; vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.quantity-control { width: 62px; height: 31px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 0 7px; }
.table-empty { padding: 28px 12px; color: var(--muted); text-align: center; font-size: 10px; }

/* Utility */
.skeleton { position: relative; overflow: hidden; background: #e8efee; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg,transparent,rgba(255,255,255,.7),transparent); animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-stack { position: fixed; z-index: 150; right: 18px; bottom: 18px; width: min(360px, calc(100vw - 36px)); display: grid; gap: 8px; }
.toast { padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; display: grid; grid-template-columns: 7px 1fr auto; gap: 10px; align-items: start; color: var(--ink); background: rgba(255,255,255,.97); box-shadow: var(--shadow-lg); animation: toastIn .18s ease-out; }
.toast::before { content: ""; width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; background: var(--brand); }
.toast.error::before { background: var(--danger); }.toast.success::before { background: var(--success); }.toast.warning::before { background: var(--warning); }
.toast p { margin: 0; font-size: 10px; line-height: 1.45; }.toast button { border: 0; background: transparent; cursor: pointer; color: var(--muted); }
@keyframes toastIn { from { opacity:0; transform: translateY(8px); } }
.confirm-backdrop { position: fixed; z-index: 200; inset: 0; display: grid; place-items: center; background: rgba(10,31,36,.45); backdrop-filter: blur(4px); }
.confirm-dialog { width: min(460px, calc(100vw - 32px)); padding: 20px; display: grid; grid-template-columns: 42px 1fr; gap: 12px; border: 1px solid rgba(255,255,255,.75); border-radius: 16px; background: white; box-shadow: var(--shadow-lg); }
.confirm-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: var(--warning); background: var(--warning-soft); font-family: var(--display); font-weight: 900; }
.confirm-dialog h2 { margin: 2px 0 5px; font-family: var(--display); font-size: 17px; }.confirm-dialog p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.confirm-actions { grid-column: 1/-1; display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.text-muted { color: var(--muted); }.text-danger { color: var(--danger); }.mono { font-family: Consolas, "Courier New", monospace; }

@media (max-width: 1240px) {
    :root { --rail-w: 285px; }
    .topbar { grid-template-columns: var(--rail-w) minmax(470px,1fr) auto; }
    .user-meta { display: none; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .admission-card { display: none; }
    .formulation-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { min-height: 42vh; padding: 34px; }
    .login-copy h1 { font-size: 43px; }.login-metrics { display:none; }
    .login-panel { padding: 25px; }.login-card { padding: 28px; }
}
