/* Notera clinic console. Builds on notera.css tokens. */
body.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; background: var(--bg); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn[disabled]:active { transform: none; }

/* Sidebar — white, quiet, a teal rule marks where you are */
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 24px; }
.side-brand span { font-family: var(--font-display); font-weight: 500; font-size: 25px; line-height: 1; }
.side-nav { display: grid; gap: 2px; }
.side-nav a { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 14px; color: var(--ink-2); transition: background-color var(--t-fast) ease, color var(--t-fast) ease, transform var(--t-press) var(--ease-out); }
.side-nav a:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .side-nav a:hover { background: var(--bg); color: var(--ink); } }
.side-nav a[aria-current='page'] { background: var(--accent-soft); color: var(--accent-deep); font-weight: 500; }
.side-badge { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 6px; background: var(--ink); color: #fff; font-size: 11px; display: grid; place-items: center; font-weight: 600; }
.side-badge[hidden] { display: none; }
.side-badge-amber { background: var(--amber-soft); color: var(--amber); }
.side-rec { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--rec); animation: blink 1.4s ease-in-out infinite; }
.side-foot { margin-top: auto; display: grid; gap: 16px; padding: 0 4px; }
.side-org { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--bg); font-size: 13px; }
.side-org .muted { font-size: 12px; }
.org-dot { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; }
.side-db { padding-left: 6px; color: var(--muted); }

/* Main */
.main { min-width: 0; padding: 16px clamp(16px, 3vw, 36px) 40px; }
.demo-banner { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--amber-soft); color: var(--amber); font-size: 13px; margin-bottom: 18px; }
.demo-banner svg { flex: none; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.top-kicker { font-size: 12px; color: var(--muted); letter-spacing: .06em; }
.top-title { font-family: var(--font-display); font-weight: 400; font-size: 42px; line-height: 1.08; letter-spacing: -.02em; }
.top-actions:empty { display: none; }
.demo-note { margin-top: 28px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }

.view[data-entering] { animation: viewIn 260ms var(--ease-out); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }

.box { padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.box h3 { font-size: 15px; }

/* Segmented control and chips */
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.seg button, .chips button { height: 32px; padding: 0 12px; border-radius: 7px; font-size: 13px; color: var(--ink-2); transition: background-color var(--t-fast) ease, color var(--t-fast) ease, transform var(--t-press) var(--ease-out); white-space: nowrap; }
.seg button:active, .chips button:active { transform: scale(0.97); }
.seg button[aria-pressed='true'] { background: var(--ink); color: #fff; }
@media (hover: hover) and (pointer: fine) { .seg button[aria-pressed='false']:hover, .chips button[aria-pressed='false']:hover { background: var(--bg); } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: var(--surface); }
.chips button[aria-pressed='true'] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-deep); }

/* Queue */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { padding: 14px 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.kpi p { font-size: 13px; color: var(--muted); }
.kpi b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 40px; line-height: 1.1; }
.kpi.k-live b { color: #9E2A21; }
.kpi.k-draft b { color: var(--amber); }
.q-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.q-box { padding: 6px; }
.qtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.qtable th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.qtable td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.qtable tbody tr:last-child td { border-bottom: 0; }
.qtable tbody tr { cursor: pointer; transition: background-color var(--t-fast) ease; }
@media (hover: hover) and (pointer: fine) { .qtable tbody tr:hover { background: var(--bg); } }
.qtable tr.is-now { background: #FDF5F4; }
.c-act { text-align: right; width: 1%; }
.c-time { font-size: 13px; color: var(--muted); white-space: nowrap; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who b { display: block; font-weight: 600; }
.who small { font-size: 12.5px; color: var(--muted); }
.av { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--bg-2); color: var(--accent-deep); }
.m-only { display: none; }
.st-manual { background: #EEF0F3; color: #4A5260; }

/* Patient strip */
.pt-strip { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 12px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.cs { font-size: 12.5px; padding: 5px 10px; border-radius: 7px; font-weight: 500; }
.cs-ok { background: var(--accent-soft); color: var(--accent-deep); }
.cs-no { background: #EEF0F3; color: #4A5260; }
.cs-wait { background: var(--amber-soft); color: var(--amber); }

/* Consult — live */
.live { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.live-listen { display: flex; flex-direction: column; padding-bottom: 0; }
.ll-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ll-ctl { margin-left: auto; display: flex; gap: 6px; }
.meter { display: flex; align-items: center; gap: 3px; height: 26px; }
.meter i { width: 3px; height: 100%; border-radius: 2px; background: var(--accent); transform: scaleY(.12); transform-origin: center; }
.live-script { height: 520px; overflow-y: auto; margin-top: 12px; justify-content: flex-start; mask-image: none; -webkit-mask-image: none; scrollbar-width: thin; }
.live-script .sl:first-child { border-top: 0; }
.live-draft { display: flex; flex-direction: column; }
.ld-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 8px; border-bottom: 2px solid var(--accent); }
.ld-foot { margin-top: auto; padding-top: 14px; }
.live-draft .nf::before { inset: 2px -6px; }

.consent-card { max-width: 720px; padding: clamp(20px, 3vw, 32px); }
.consent-card h3 { font-family: var(--font-display); font-weight: 400; font-size: 30px; line-height: 1.15; margin-bottom: 6px; }
.consent-card .kicker { margin-bottom: 8px; }
.consent-card .seg { margin-top: 18px; }
.consent-q { margin: 14px 0 22px; padding: 16px 18px; border-left: 3px solid var(--accent); border-radius: 0 12px 12px 0; background: var(--bg); font-size: 17px; line-height: 1.6; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.empty-state { max-width: 560px; padding: 28px; display: grid; gap: 8px; justify-items: start; }
.empty-state h3 { font-family: var(--font-display); font-weight: 400; font-size: 26px; }
.empty-state .btn { margin-top: 8px; }

/* Note editor */
.note-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; align-items: start; }
.editor { display: grid; gap: 4px; padding: 20px; }
.ed-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.ef { padding: 10px 0; border-top: 1px solid var(--line); }
.ef label:not(.switch), .ef-label { display: block; font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.ef textarea, .med-row input, .dlg input, .dlg select {
  width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line-2); background: #FBFDFC; font-size: 14.5px; line-height: 1.5; resize: none; overflow: hidden;
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}
.ef textarea:focus, .med-row input:focus, .dlg input:focus, .dlg select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11,122,113,.14); background: #fff; }
.ef textarea[readonly], .med-row input[readonly] { background: transparent; border-color: transparent; resize: none; padding-left: 0; }
.src { display: flex; gap: 8px; align-items: baseline; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.src span { flex: none; font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-deep); }
.src q { font-family: var(--font-te), var(--font-hi), var(--font-ui); quotes: '“' '”'; overflow-wrap: anywhere; }
.meds { display: grid; gap: 6px; }
.med-row { display: grid; grid-template-columns: minmax(0, 2.2fr) 84px minmax(0, 1.3fr) 90px 32px; gap: 6px; align-items: center; }
.med-row input { padding: 7px 9px; font-size: 14px; }
.med-row input:first-child { font-weight: 600; }
.med-head span { font-size: 11.5px; color: var(--muted); padding-left: 2px; }
.add-med { margin-top: 8px; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); transition: background-color var(--t-fast) ease, color var(--t-fast) ease, transform var(--t-press) var(--ease-out); }
.icon-btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: #FCEBE9; color: #9E2A21; } }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { position: relative; width: 32px; height: 18px; border-radius: 9px; background: #C9D5D3; transition: background-color var(--t-fast) ease; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform var(--t-fast) var(--ease-out); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.sign-box { position: sticky; top: 16px; display: grid; gap: 12px; padding: 20px; }
.sign-box h3 { font-family: var(--font-display); font-weight: 400; font-size: 24px; }
.checklist { display: grid; gap: 8px; font-size: 14px; color: var(--ink-2); }
.checklist li { position: relative; padding-left: 20px; }
.checklist li::before { content: ''; position: absolute; left: 2px; top: 8px; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); }
.confirm { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 10px; background: var(--bg); font-size: 14px; cursor: pointer; }
.confirm input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.sign-box .btn { width: 100%; }
.sign-box .sig-ink { clip-path: none; margin: 0; }
.audit { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.audit li { padding-left: 16px; position: relative; }
.audit li::before { content: ''; position: absolute; left: 0; top: 7px; width: 8px; height: 5px; border-left: 1.5px solid var(--accent); border-bottom: 1.5px solid var(--accent); transform: rotate(-45deg); }

/* Prescription paper */
.rx-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.rx-act { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rx-paper-wrap { padding: clamp(0px, 2vw, 24px); border-radius: var(--r-xl); background: var(--bg-2); }
.paper { position: relative; overflow: hidden; max-width: 820px; margin: 0 auto; padding: clamp(20px, 4vw, 44px); background: #fff; border-radius: 6px; box-shadow: var(--shadow-sheet); font-size: 14.5px; }
.watermark { position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%) rotate(-24deg); font-family: var(--font-mono); font-size: clamp(28px, 6vw, 56px); letter-spacing: .1em; color: rgba(138,83,0,.12); white-space: nowrap; pointer-events: none; }
.lh { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 16px; border-bottom: 2px solid var(--accent); }
.lh-clinic { display: flex; gap: 12px; align-items: flex-start; }
.lh-clinic svg { flex: none; margin-top: 2px; }
.lh .rx-clinic { font-size: 28px; }
.lh-pt { display: grid; grid-template-columns: 2fr 1.3fr 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.lh-pt span, .lh-body h4 { display: block; font-family: var(--font-mono); font-size: 10.5px; font-weight: 400; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.lh-pt b { font-weight: 600; }
.lh-body { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; padding: 16px 0; }
.lh-body .wide { grid-column: 1 / -1; }
.lh-rx { padding: 6px 0 16px; border-bottom: 1px solid var(--line); }
.rx-sym.big { display: block; font-size: 38px; margin-bottom: 6px; }
.rx-table { font-size: 14px; }
.rx-table th, .rx-table td { padding-right: 12px; }
.rx-table td:first-child { color: var(--muted); font-weight: 400; width: 24px; }
.rx-table td:nth-child(2) { font-weight: 600; }
.rx-key { margin-top: 8px; font-size: 11px; color: var(--muted); }
.adv-tr { margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: var(--bg); line-height: 1.7; }
.lh-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; padding-top: 22px; border-top: 1px solid var(--line); }
.lh-fine { font-size: 11.5px; color: var(--muted); max-width: 46ch; }
.lh-sign { text-align: center; min-width: 170px; font-size: 13.5px; font-weight: 600; }
.lh-sign .sig-ink { margin: 0 auto 2px; clip-path: none; }
.lh-sign .rx-sub { font-weight: 400; }
.sig-empty { height: 46px; display: grid; place-items: center; border: 1px dashed var(--line-2); border-radius: 8px; margin-bottom: 6px; font-size: 12px; font-weight: 400; color: var(--muted); }

/* History */
.h-tools { display: grid; gap: 10px; margin-bottom: 12px; }
.search { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line-2); color: var(--muted); max-width: 440px; transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11,122,113,.14); }
.search input { border: 0; outline: 0; background: none; width: 100%; font-size: 14px; color: var(--ink); }
.hlist { display: grid; }
.h-date { padding: 14px 10px 6px; font-size: 11.5px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.h-date:first-child { padding-top: 2px; }
.h-row { width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1.5fr) minmax(0, 1.2fr) auto; gap: 12px; align-items: center; padding: 10px; border-radius: 10px; text-align: left; transition: background-color var(--t-fast) ease, transform var(--t-press) var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .h-row:hover { background: var(--bg); } }
.h-main, .h-meds { min-width: 0; }
.h-main b { display: block; font-weight: 600; font-size: 14px; }
.h-main small, .h-meta small { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-meds { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-meta { text-align: right; font-size: 12.5px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* Dialog */
.dlg { width: min(440px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(14,36,38,.45); }
.dlg[open] { animation: dlgIn 220ms var(--ease-out); }
@keyframes dlgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dlg::backdrop { background: rgba(14,36,38,.32); }
.dlg form { display: grid; gap: 14px; padding: 24px; }
.dlg h2 { font-size: 24px; line-height: 1.2; }
.dlg label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.dlg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dlg-note { font-size: 12.5px; color: var(--amber); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Responsive */
@media (max-width: 1180px) {
  .note-grid { grid-template-columns: 1fr; }
  .sign-box { position: static; }
  .c-doc { display: none; }
}
@media (max-width: 980px) {
  body.app { grid-template-columns: 1fr; padding-bottom: 76px; }
  .side { position: fixed; z-index: 60; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
  .side-brand, .side-foot { display: none; }
  .side-nav { grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  .side-nav a { flex-direction: column; gap: 3px; padding: 7px 2px; font-size: 11px; }
  .side-badge, .side-rec { position: absolute; top: 3px; right: calc(50% - 22px); margin: 0; }
  .side-badge { min-width: 18px; height: 16px; font-size: 10px; padding: 0 4px; }
  .live { grid-template-columns: 1fr; }
  .live-script { height: 340px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  .top-title { font-size: 34px; }
  .kpi b { font-size: 32px; }
  .c-reason, .c-time, .c-tok { display: none; }
  .m-only { display: inline; }
  .qtable td { padding: 10px 8px; }
  .qtable th { padding: 8px; }
  .qtable .av { display: none; }
  .qtable .st { white-space: nowrap; }
  .q-tools .seg { width: 100%; }
  .q-tools .seg button { flex: 1; padding: 0 6px; font-size: 12px; }
  .q-tools .btn { width: 100%; }
  .med-row { grid-template-columns: 0.8fr 1.3fr 1fr 32px; }
  .med-row input:first-child { grid-column: 1 / 4; grid-row: 1; }
  .med-row .icon-btn, .med-row > span { grid-column: 4; grid-row: 1; }
  .med-row input:nth-child(2) { grid-column: 1; grid-row: 2; }
  .med-row input:nth-child(3) { grid-column: 2; grid-row: 2; }
  .med-row input:nth-child(4) { grid-column: 3 / 5; grid-row: 2; }
  .med-head { display: none; }
  .toasts { bottom: 86px; left: 12px; right: 12px; }
  .toast { max-width: none; }
  .med-row { padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
  .lh { flex-direction: column; gap: 10px; }
  .lh .rx-doc { text-align: left; }
  .lh-pt { grid-template-columns: 1fr 1fr; }
  .lh-pt > div:first-child { grid-column: 1 / -1; }
  .lh-body { grid-template-columns: 1fr; }
  .rx-table th:nth-child(4), .rx-table td:nth-child(4) { display: none; }
  .lh-foot { flex-direction: column-reverse; align-items: stretch; }
  .h-row { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .h-meds { display: none; }
  .consent-actions .btn { width: 100%; white-space: normal; height: auto; min-height: 50px; padding-block: 10px; }
  .ll-ctl { margin-left: 0; width: 100%; }
  .ll-ctl .btn { flex: 1; }
  .pt-strip { padding: 12px; }
  .rx-tools .seg { width: 100%; }
  .rx-tools .seg button { flex: 1; padding: 0 6px; }
}

/* Print: only the prescription */
@media print {
  body.app { display: block; background: #fff; padding: 0; }
  .side, .demo-banner, .top, .rx-tools, .demo-note, .toasts, [data-view]:not([data-view='rx']) { display: none !important; }
  .main { padding: 0; }
  .rx-paper-wrap { padding: 0; background: none; }
  .paper { box-shadow: none; max-width: none; padding: 0; }
}
