:root {
  --ink: #18221e;
  --muted: #68756f;
  --brand: #176b4d;
  --brand-dark: #0f4a35;
  --brand-soft: #e9f4ef;
  --line: #d9e1dd;
  --workspace: #e9eeeb;
  --paper: #fffefc;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--workspace);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--workspace); }

body { margin: 0; min-height: 100vh; }

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

svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar {
  min-height: 76px;
  padding: 12px clamp(16px, 3vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--brand);
  border-radius: 12px;
  box-shadow: 0 5px 14px rgba(23, 107, 77, .2);
}

.brand-mark svg { width: 23px; height: 23px; }
.brand h1 { font-family: Georgia, "Times New Roman", serif; font-size: 1.32rem; line-height: 1.1; margin: 2px 0 0; }
.eyebrow { margin: 0; color: var(--brand); font-size: .69rem; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }

.header-actions, .tool-group, .toolbar { display: flex; align-items: center; }
.header-actions { gap: 8px; }

.record-count {
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  color: var(--brand-dark);
  background: var(--brand-soft);
  border-radius: 999px;
  font-size: .69rem;
}

.user-control {
  min-height: 38px;
  padding: 3px 4px 3px 7px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #46534d;
  background: #f5f7f6;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: .77rem;
  font-weight: 650;
}

.user-avatar {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--brand);
  border-radius: 50%;
  font-size: .72rem;
}

.logout-button {
  width: 29px;
  height: 29px;
  padding: 0;
  display: grid;
  place-items: center;
  color: #65716b;
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}
.logout-button:hover { color: var(--danger); background: #feeceb; }

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 6px;
  color: var(--muted);
  font-size: .78rem;
  white-space: nowrap;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #22a06b; box-shadow: 0 0 0 3px #e5f6ef; }
.save-status.saving .status-dot { background: #c88800; box-shadow: 0 0 0 3px #fff1c2; }

.button, .icon-button, .tool {
  border: 0;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, border-color .16s ease, transform .16s ease;
}

.button {
  min-height: 38px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 9px;
  font-size: .84rem;
  font-weight: 650;
  white-space: nowrap;
}

.button:hover, .icon-button:hover, .tool:hover { transform: translateY(-1px); }
.button-ghost { background: #fff; border: 1px solid var(--line); }
.button-ghost:hover { background: #f7f9f8; border-color: #bcc9c3; }
.button-primary { color: #fff; background: var(--brand); box-shadow: 0 4px 12px rgba(23,107,77,.18); }
.button-primary:hover { background: var(--brand-dark); }
.button-quiet { min-height: 34px; background: #f1f4f2; }
.button-quiet:hover { background: #e7ece9; }
.file-button input { display: none; }

.toolbar {
  min-height: 58px;
  padding: 8px clamp(12px, 3vw, 40px);
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 25;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(22, 41, 33, .04);
  backdrop-filter: blur(12px);
}

.tool-group { gap: 4px; }
.toolbar-spacer { flex: 1; }

.tool {
  min-width: 64px;
  min-height: 40px;
  padding: 5px 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px;
  background: transparent;
  color: #52605a;
  font-size: .77rem;
  font-weight: 650;
}

.tool.active { color: var(--brand-dark); background: var(--brand-soft); }

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: transparent;
}

.icon-button:hover { background: #eff3f1; }
.icon-button.danger { color: var(--danger); }
.icon-button:disabled { cursor: default; color: #b8c0bc; opacity: .65; transform: none; }

.color-control {
  height: 34px;
  padding: 0 8px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: .73rem;
  font-weight: 650;
}

.color-control input { width: 24px; height: 24px; padding: 2px; border: 0; background: transparent; cursor: pointer; }

.workspace { min-height: calc(100vh - 134px); padding: 18px 16px 60px; }

.document-notice {
  max-width: 794px;
  margin: 0 auto 14px;
  min-height: 46px;
  padding: 9px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #52605a;
  background: rgba(255,255,255,.7);
  border: 1px solid rgba(204,214,209,.9);
  border-radius: 10px;
  font-size: .76rem;
}

.document-notice strong { color: var(--ink); }
.document-notice p { margin: 0; text-align: right; }

.document-stack { display: grid; justify-content: center; gap: 24px; }

.paper {
  width: min(794px, calc(100vw - 24px));
  aspect-ratio: 210 / 297;
  position: relative;
  overflow: hidden;
  color: #151917;
  background: var(--paper);
  box-shadow: 0 10px 32px rgba(28, 46, 38, .14), 0 1px 3px rgba(28,46,38,.16);
}

.page-content {
  position: absolute;
  inset: 0;
  padding: 8.7% 9.5% 7.5%;
  z-index: 1;
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(7px, 1.95vw, 15.4px);
  line-height: 1.33;
}

.document-heading { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .75em; margin-bottom: 1.25em; }
.document-heading span { height: 1px; background: #56605b; }
.document-heading h2, .document-heading h3 { margin: 0; font-size: 1.04em; font-weight: 650; letter-spacing: .035em; text-transform: uppercase; }
.small-heading { margin: .2em 0 .8em; }

.patient-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: .66em 1.4em; margin-bottom: 1.1em; }
.field { display: grid; grid-template-columns: auto 1fr; align-items: end; gap: .55em; min-width: 0; }
.field.wide { grid-column: span 1; }
.field span, .line-field span, .system-grid label span, .block-field > span { font-weight: 650; white-space: nowrap; }

.paper input, .paper textarea {
  min-width: 0;
  color: #111815;
  background: rgba(236, 247, 242, .45);
  border: 0;
  border-bottom: 1px solid #8da69b;
  border-radius: 2px 2px 0 0;
  outline: none;
  transition: background .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.paper input { width: 100%; height: 1.55em; padding: .08em .28em; }
.paper textarea { width: 100%; padding: .28em .4em; resize: none; overflow: hidden; line-height: 1.28; }
.paper input:hover, .paper textarea:hover { background: rgba(220, 241, 231, .62); }
.paper input:focus, .paper textarea:focus { background: #effaf5; border-color: var(--brand); box-shadow: 0 2px 0 var(--brand); }

.clinical-section { margin-top: 1em; }
.clinical-section h3 { margin: 0 0 .32em; font-size: 1em; font-weight: 650; text-transform: uppercase; }
.hint { margin: .12em 0 .42em; font-size: .9em; }
.hint.red { color: #b51212; }
.hint.orange { color: #d77300; }
.hint.green { color: #008e32; }
.hint-row { display: flex; gap: 1.8em; }

.writing-area { display: block; border: 1px solid #aebdb6 !important; background-image: repeating-linear-gradient(transparent, transparent 1.45em, rgba(102,123,113,.18) 1.49em) !important; }
.writing-area.medium { height: 4.35em; }
.writing-area.large { height: 7.6em; }
.writing-area.evolution { height: 8em; }

.compact-section { margin-top: .8em; }
.line-fields { display: grid; gap: .28em; }
.line-field { display: grid; grid-template-columns: 12.7em 1fr; align-items: end; gap: .5em; }
.system-section { margin-top: .8em; }
.system-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .43em 1.2em; }
.system-grid label { display: grid; grid-template-columns: 6.4em 1fr; align-items: end; gap: .35em; }
.system-grid-top { margin: .2em 0 1em; gap: .6em 1.4em; }
.system-grid-top label { grid-template-columns: 7.5em 1fr; }

.guidance { padding: .68em .8em; display: grid; gap: .24em; border-left: .28em solid currentColor; border-radius: 0 .35em .35em 0; font-size: .9em; }
.guidance.cyan { color: #007e89; background: #e9fbfc; }
.guidance span { color: #263b3d; }

.exam-section { margin-top: 1em; }
.block-field { display: grid; grid-template-columns: 8.6em 1fr; align-items: start; gap: .55em; margin: .34em 0; }
.block-field textarea { height: 2.7em; }
.block-field textarea[data-field="inspeccion-general"],
.block-field textarea[data-field="respiratorio"],
.block-field textarea[data-field="cardiovascular"] { height: 3.8em; }
.exam-section .hint { margin-left: 0; }

.exam-continuation { margin-top: 0; }
.exam-continuation .block-field textarea { height: 4.3em; }
.large-section { margin-top: 1.4em; }
.evolution-section { margin-top: 1.45em; }

.page-number { position: absolute; right: 5.2%; bottom: 3.2%; z-index: 2; color: #87918c; font: 600 clamp(6px, 1.4vw, 10px)/1 Arial, sans-serif; letter-spacing: .08em; }

.annotation-layer { position: absolute; inset: 0; z-index: 10; pointer-events: none; touch-action: none; }
.annotation-layer.tool-text, .annotation-layer.tool-rectangle, .annotation-layer.tool-check, .annotation-layer.tool-draw, .annotation-layer.tool-eraser { pointer-events: auto; }
.annotation-layer.tool-text { cursor: text; }
.annotation-layer.tool-rectangle { cursor: crosshair; }
.annotation-layer.tool-check { cursor: cell; }
.annotation-layer.tool-draw { cursor: crosshair; }
.annotation-layer.tool-eraser { cursor: not-allowed; }

.annotation {
  position: absolute;
  pointer-events: auto;
  color: var(--annotation-color, var(--brand));
  touch-action: none;
}

.annotation.selected { outline: 1px dashed #177ddc; outline-offset: 3px; }
.annotation-rectangle { border: 2px solid currentColor; background: color-mix(in srgb, currentColor 5%, transparent); cursor: move; }
.annotation-text { min-width: 80px; min-height: 28px; border: 1.5px solid currentColor; background: rgba(255,255,255,.92); cursor: move; }
.annotation-text textarea { width: 100%; height: 100%; padding: .7em .4em .25em !important; border: 0 !important; box-shadow: none !important; background: transparent !important; color: currentColor; resize: none; cursor: text; font: 500 clamp(7px, 1.9vw, 14px)/1.25 Arial, sans-serif; }
.move-handle { position: absolute; left: 2px; top: 1px; z-index: 2; font: bold 9px/1 Arial, sans-serif; letter-spacing: -1px; cursor: move; opacity: .7; }
.resize-handle { position: absolute; width: 9px; height: 9px; right: -5px; bottom: -5px; border: 1px solid #fff; background: currentColor; cursor: nwse-resize; }
.annotation-check {
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid currentColor;
  background: rgba(255,255,255,.9);
  font: 800 clamp(9px, 2.5vw, 19px)/1 Arial, sans-serif;
  cursor: move;
}
.annotation-ink { inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.annotation-ink polyline { fill: none; stroke: currentColor; stroke-width: 2.2; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; pointer-events: stroke; cursor: pointer; }
.annotation-draft { position: absolute; border: 2px dashed currentColor; background: color-mix(in srgb, currentColor 7%, transparent); pointer-events: none; }
.draft-ink { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  grid-template-columns: minmax(340px, 1.05fr) minmax(420px, .95fr);
  background: #f2f7f8;
  overflow: auto;
}

.auth-mascot-panel {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at 42% 34%, #eaf7f5 0%, #d3eae7 55%, #baddd9 100%);
}
.auth-mascot-halo {
  position: absolute;
  width: min(98%, 94vh, 900px);
  aspect-ratio: 1;
  border: 3px solid rgba(255,255,255,.9);
  border-radius: 50%;
  box-shadow: 0 0 90px rgba(47,184,166,.18) inset;
}
.auth-mascot {
  position: relative;
  z-index: 1;
  width: min(88%, 610px);
  height: min(88vh, 850px);
  object-fit: contain;
}

.auth-card {
  width: min(500px, calc(100% - 64px));
  margin: auto;
  padding: 48px 40px;
  color: var(--ink);
  text-align: left;
}

.auth-brand { margin-bottom: 36px; display: flex; align-items: center; gap: 12px; color: #123a3a; font-size: 1.12rem; }
.auth-brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(140deg, #3fccb8, #159b8b);
  border-radius: 13px;
  box-shadow: 0 8px 20px rgba(21,155,139,.22);
}
.auth-brand-mark svg { width: 24px; height: 24px; fill: currentColor; stroke: none; }
.auth-card h2 { margin: 0; color: #10312f; font-size: clamp(1.8rem, 3vw, 2.15rem); font-weight: 800; letter-spacing: -.04em; }
.auth-copy { margin: 10px 0 28px; color: #5c7b7a; font-size: .95rem; font-weight: 550; line-height: 1.5; }
.auth-card form { display: grid; gap: 16px; text-align: left; }
.auth-field { display: grid; gap: 8px; color: #123a3a; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.auth-field input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  color: #10312f;
  background: #fff;
  border: 2px solid #d5e4e5;
  border-radius: 13px;
  outline: none;
  font-size: 1rem;
  font-weight: 600;
  transition: border-color .2s, box-shadow .2s;
}
.auth-field input:focus { border-color: #2fb8a6; box-shadow: 0 0 0 4px rgba(47,184,166,.16); }
.auth-submit { width: 100%; min-height: 52px; margin-top: 3px; border-radius: 14px; background: linear-gradient(140deg, #35c2af, #12897b); box-shadow: 0 10px 22px rgba(18,137,123,.25); font-weight: 800; }
.auth-submit:hover { filter: brightness(1.06); box-shadow: 0 12px 26px rgba(18,137,123,.32); }
.form-error { min-height: 1.2em; margin: -2px 0 0; color: var(--danger); font-size: .76rem; font-weight: 600; }
.auth-pulse { margin-top: 24px; display: flex; align-items: center; gap: 0; color: #ff7a85; }
.auth-pulse svg { width: calc(100% - 40px); height: 42px; fill: none; stroke: #b6d6d4; stroke-width: 3; }
.auth-pulse .auth-pulse-runner { stroke: #2fb8a6; stroke-width: 3.5; stroke-dasharray: 70 610; animation: authPulse 3.4s linear infinite; }
.auth-pulse span {
  position: relative;
  left: 4px;
  top: -6px;
  display: inline-grid;
  place-items: center;
  min-width: 64px;
  font-size: 3.25rem;
  line-height: 1;
  transform-origin: right center;
  animation: authHeartbeat 1.6s ease-in-out infinite;
}
.auth-security { margin: 8px 0 0; color: #6b8988; font-size: .7rem; line-height: 1.45; }
.server-help { margin-top: 20px; }
.server-help code { display: block; padding: 12px; color: #eafff5; background: #14231d; border-radius: 8px; font-size: .9rem; }
.server-help p { color: var(--muted); font-size: .8rem; line-height: 1.45; }

@keyframes authPulse { from { stroke-dashoffset: 340; } to { stroke-dashoffset: -340; } }
@keyframes authHeartbeat { 0%,100% { transform: scale(1); } 30% { transform: scale(1.16); } 45% { transform: scale(1); } }

.modal-shell { position: fixed; inset: 0; z-index: 150; display: grid; justify-items: end; }
.modal-scrim { position: absolute; inset: 0; width: 100%; height: 100%; background: rgba(11,25,19,.54); border: 0; backdrop-filter: blur(3px); cursor: default; }
.records-panel {
  width: min(620px, 100%);
  height: 100%;
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  color: var(--ink);
  background: #fff;
  box-shadow: -18px 0 50px rgba(0,0,0,.16);
  animation: slide-in .2s ease-out;
}
@keyframes slide-in { from { transform: translateX(25px); opacity: .65; } }
.records-header { padding: 24px 25px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.records-header h2 { margin: 3px 0 0; font: 700 1.55rem/1.15 Georgia, "Times New Roman", serif; }
.records-tools { padding: 15px 20px 10px; display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.search-field {
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #728079;
  border: 1px solid #cbd6d0;
  border-radius: 9px;
}
.search-field svg { flex: 0 0 auto; }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: .83rem; }
.records-tools select { min-height: 40px; padding: 0 28px 0 10px; color: #46534d; background: #fff; border: 1px solid #cbd6d0; border-radius: 9px; font-size: .78rem; }
.database-summary { padding: 2px 22px 10px; display: flex; gap: 16px; color: var(--muted); font-size: .75rem; }
.database-summary strong { color: var(--brand-dark); }
.records-list { min-height: 0; padding: 4px 18px 18px; overflow-y: auto; }
.records-empty { padding: 60px 20px; color: var(--muted); text-align: center; }
.records-empty strong { display: block; margin-bottom: 5px; color: var(--ink); }
.record-row {
  width: 100%;
  padding: 12px 10px 12px 13px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.record-row + .record-row { margin-top: 8px; }
.record-row.current { border-color: #71a991; box-shadow: 0 0 0 2px var(--brand-soft); }
.record-main { min-width: 0; }
.record-name { display: block; overflow: hidden; color: var(--ink); font-size: .87rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.record-meta { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 5px 12px; color: var(--muted); font-size: .7rem; }
.record-actions { display: flex; gap: 5px; }
.record-action { min-height: 32px; padding: 0 10px; color: var(--brand-dark); background: var(--brand-soft); border: 0; border-radius: 7px; font-size: .72rem; font-weight: 700; cursor: pointer; }
.record-action.secondary { color: #6b514c; background: #f7efed; }
.records-footer { padding: 14px 20px; display: flex; align-items: center; gap: 8px; background: #f8faf9; border-top: 1px solid var(--line); }
.records-footer > div { min-width: 0; margin-right: auto; display: grid; }
.records-footer strong { font-size: .77rem; }
.records-footer span { color: var(--muted); font-size: .67rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  padding: 10px 15px;
  color: #fff;
  background: #1e2924;
  border-radius: 9px;
  box-shadow: 0 8px 25px rgba(0,0,0,.2);
  font-size: .82rem;
  opacity: 0;
  transform: translate(-50%, 15px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 920px) {
  .auth-overlay { grid-template-columns: minmax(260px, .75fr) minmax(400px, 1.25fr); }
  .auth-mascot { width: 96%; }
  .auth-card { width: min(500px, calc(100% - 32px)); padding: 36px 24px; }
  .topbar { align-items: flex-start; }
  .save-status { display: none; }
  .header-actions > .button-ghost > span:not(.record-count) { display: none; }
  .header-actions > .button-ghost { min-width: 38px; padding: 0 8px; }
  .user-control > #current-user { display: none; }
  .toolbar { overflow-x: auto; }
  .tool-group { flex: 0 0 auto; }
  .toolbar-spacer { min-width: 8px; }
}

@media (max-width: 620px) {
  .auth-overlay { display: block; background: linear-gradient(180deg, #d8eeeb 0, #f2f7f8 245px); }
  .auth-mascot-panel { min-height: 210px; height: 210px; align-items: start; }
  .auth-mascot-halo { width: 300px; height: auto; top: -42px; }
  .auth-mascot { width: 210px; height: 260px; margin-top: -16px; object-position: top; }
  .auth-card { width: 100%; margin: 0; padding: 25px 22px 32px; }
  .auth-brand { margin-bottom: 22px; }
  .auth-card h2 { font-size: 1.75rem; }
  .auth-copy { margin-bottom: 22px; }
  .topbar { min-height: 66px; padding: 10px 12px; gap: 10px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
  .brand h1 { font-size: 1rem; }
  .eyebrow { font-size: .58rem; }
  .header-actions { gap: 5px; }
  .header-actions .button { min-height: 36px; }
  .header-actions .button-primary { padding: 0 10px; font-size: .72rem; }
  .header-actions .button-primary svg { display: none; }
  .header-actions .button-primary span { display: none; }
  .header-actions .button-primary::after { content: "Guardar"; }
  .user-control { padding-left: 4px; }
  .user-avatar { display: none; }
  .toolbar { min-height: 54px; padding: 6px 8px; gap: 10px; }
  .tool { min-width: 49px; padding: 5px; display: grid; gap: 1px; font-size: .61rem; }
  .tool svg { width: 1rem; height: 1rem; margin: auto; }
  .compact .color-control span, .compact .button-quiet { display: none; }
  .color-control { padding: 0 4px; }
  .workspace { padding: 10px 6px 36px; }
  .document-notice { margin: 0 6px 10px; padding: 8px 10px; display: block; font-size: .69rem; }
  .document-notice p { margin-top: 3px; text-align: left; }
  .document-stack { gap: 12px; }
  .patient-grid { gap: .52em .9em; }
  .auth-overlay { padding: 12px; }
  .auth-card { padding: 27px 20px; }
  .records-tools { grid-template-columns: 1fr auto; }
  .records-tools .button { grid-column: 1 / -1; }
  .records-footer { flex-wrap: wrap; }
  .records-footer > div { flex: 1 0 100%; }
}

@media print {
  @page { size: A4 portrait; margin: 0; }
  :root, html, body { background: #fff !important; }
  .topbar, .toolbar, .document-notice, .toast, .auth-overlay, .modal-shell { display: none !important; }
  .workspace { padding: 0; min-height: 0; }
  .document-stack { display: block; }
  .paper {
    width: 210mm;
    height: 297mm;
    aspect-ratio: auto;
    overflow: hidden;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }
  .paper:last-child { break-after: auto; page-break-after: auto; }
  .page-content { font-size: 11.55pt; }
  .paper input, .paper textarea { background-color: transparent !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .annotation.selected { outline: none; }
  .resize-handle, .move-handle { display: none; }
  .annotation-text { background: transparent; }
}
