/* Consulta design system: clinical, calm, trustworthy. Shared by the public pages (practice, booking, patient link),
   the staff app and the admin. Public pages override --accent with the practice's brand colour.
   Fonts: Source Serif 4 (headings: the editorial trust of a doctor's letterhead) + Inter (interface). */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Source+Serif+4:opsz,wght@8..60,500;8..60,600;8..60,700&display=swap');

:root {
  --bg: #f4f7f9; --surface: #ffffff; --surface2: #eef3f6; --surface3: #e4ecf1;
  --line: #dbe4ea; --line2: #c9d5dd;
  --ink: #0f2a3d; --ink2: #3c5466; --ink3: #64798a;
  --accent: #0b6e8a; --accent2: #08566c; --accent-ink: #ffffff; --accent-soft: #0b6e8a14; --accent-soft2: #0b6e8a26;
  --ok: #1f7a52; --ok-soft: #1f7a5214; --warn: #9a6512; --warn-soft: #c9861a1c; --bad: #b3362b; --bad-soft: #b3362b14; --info: #2a63a8; --info-soft: #2a63a814;
  --verified: #0f7d5c;
  --shadow-sm: 0 1px 2px #0f2a3d0d; --shadow: 0 1px 2px #0f2a3d0f, 0 6px 20px #0f2a3d0d; --shadow-lg: 0 24px 60px #0f2a3d2e;
  --r: 12px; --r-sm: 8px; --r-lg: 18px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root.app-dark:not([data-theme="light"]) {
    --bg: #0d1820; --surface: #13222c; --surface2: #182a36; --surface3: #1e3341; --line: #24394a; --line2: #2f4759;
    --ink: #e6eef3; --ink2: #b3c3ce; --ink3: #8aa0b0; --accent: #3fa9c6; --accent2: #2b8fac; --accent-ink: #06202a; --accent-soft: #3fa9c61f; --accent-soft2: #3fa9c633;
    --ok: #4cc08b; --ok-soft: #4cc08b1f; --warn: #e2a64a; --warn-soft: #e2a64a1f; --bad: #ef7b6f; --bad-soft: #ef7b6f1f; --info: #6aa5ea; --info-soft: #6aa5ea1f; --verified: #4cc08b;
    color-scheme: dark;
  }
}
:root.app-dark[data-theme="dark"] {
  --bg: #0d1820; --surface: #13222c; --surface2: #182a36; --surface3: #1e3341; --line: #24394a; --line2: #2f4759;
  --ink: #e6eef3; --ink2: #b3c3ce; --ink3: #8aa0b0; --accent: #3fa9c6; --accent2: #2b8fac; --accent-ink: #06202a; --accent-soft: #3fa9c61f; --accent-soft2: #3fa9c633;
  --ok: #4cc08b; --ok-soft: #4cc08b1f; --warn: #e2a64a; --warn-soft: #e2a64a1f; --bad: #ef7b6f; --bad-soft: #ef7b6f1f; --info: #6aa5ea; --info-soft: #6aa5ea1f; --verified: #4cc08b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; line-height: 1.2; margin: 0; color: var(--ink); }
h1 { font-size: clamp(26px, 5vw, 38px); } h2 { font-size: 21px; } h3 { font-size: 17px; }
p { margin: 0 0 10px; }
a { color: var(--accent); text-underline-offset: 2px; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--ink3); } .small { font-size: 13px; } .tiny { font-size: 12px; } .center { text-align: center; }
.ltr { direction: ltr; unicode-bidi: isolate; } .num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; } .row.wrap { flex-wrap: wrap; } .row.top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 10px; min-width: 0; } .gap-s { gap: 6px; } .gap-l { gap: 18px; }
.grow { flex: 1; min-width: 0; } .spacer { flex: 1; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.hide-m { } @media (max-width: 720px) { .hide-m { display: none !important; } }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow-sm); min-width: 0; }
.card.pad-s { padding: 12px 14px; } .card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; } .card-h h2, .card-h h3 { flex: 1; }
.card-h .ic { color: var(--accent); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: var(--r-sm);
  border: 1px solid var(--line2); background: var(--surface); color: var(--ink); font: 600 14px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--ink3); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink2); } .btn.ghost:hover { background: var(--surface2); }
.btn.danger { color: var(--bad); } .btn.danger.primary { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.wa { background: #1fa855; border-color: #1fa855; color: #fff; } .btn.wa:hover { background: #178a45; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; } .btn.block { width: 100%; } .btn.big { min-height: 50px; font-size: 16px; }
.btn .ic { width: 18px; height: 18px; flex: none; }
.btn.icon { width: 42px; padding: 0; } .btn.icon.small { width: 34px; }
.ic { width: 20px; height: 20px; flex: none; } .ic.dir { } html[dir="rtl"] .ic.dir { transform: scaleX(-1); }

/* forms */
.f { display: block; font-size: 13px; font-weight: 600; color: var(--ink2); margin-bottom: 6px; }
.field { margin-bottom: 14px; min-width: 0; } .field .hint { font-size: 12px; color: var(--ink3); margin-top: 5px; } .field .err { font-size: 12.5px; color: var(--bad); margin-top: 5px; font-weight: 500; }
.field.has-err .i { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.i { width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line2); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: 400 15px var(--font); }
textarea.i { min-height: 88px; resize: vertical; line-height: 1.5; }
select.i { appearance: none; -webkit-appearance: none; padding-inline-end: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--ink3) 50%), linear-gradient(135deg, var(--ink3) 50%, transparent 50%); background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px; background-repeat: no-repeat; }
html[dir="rtl"] select.i { background-position: 18px 19px, 13px 19px; }
input[type="date"].i, input[type="time"].i { -webkit-appearance: none; appearance: none; }
.i:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft2); }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; line-height: 1.45; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }

/* tags & badges */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface2); color: var(--ink2); white-space: nowrap; }
.tag.accent { background: var(--accent-soft); color: var(--accent); } .tag.ok { background: var(--ok-soft); color: var(--ok); } .tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); } .tag.info { background: var(--info-soft); color: var(--info); }
.verified { display: inline-flex; align-items: center; gap: 6px; color: var(--verified); font-weight: 600; font-size: 13px; }
.verified .ic { width: 16px; height: 16px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line2); background: var(--surface); border-radius: 999px; padding: 6px 13px; font: 500 13px var(--font); color: var(--ink2); cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }

/* banners */
.banner { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm); font-size: 14px; background: var(--surface2); }
.banner .ic { margin-top: 1px; } .banner.info { background: var(--info-soft); } .banner.ok { background: var(--ok-soft); } .banner.warn { background: var(--warn-soft); }
.banner.bad { background: var(--bad-soft); } .banner.bad .ic { color: var(--bad); } .banner.ok .ic { color: var(--ok); } .banner.warn .ic { color: var(--warn); }

/* lists */
.list > * + * { border-top: 1px solid var(--line); }
.li { display: flex; align-items: center; gap: 12px; padding: 13px 16px; min-width: 0; text-decoration: none; color: inherit; background: none; border-inline: 0; border-bottom: 0; width: 100%; text-align: start; font: inherit; }
button.li, a.li { cursor: pointer; } button.li:hover, a.li:hover { background: var(--surface2); }
.li .main-t { font-weight: 600; } .li .sub-t { font-size: 13px; color: var(--ink3); }

/* engine UI kit pieces (modals, drawers, toasts, switches, avatars, spinner) */
.overlay { position: fixed; inset: 0; background: #0f2a3d66; display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--r-lg); width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal.wide { max-width: 760px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); } .modal-h h2 { flex: 1; font-size: 19px; }
.modal-b { padding: 18px; overflow-y: auto; overflow-x: hidden; } .modal-f { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.drawer-wrap { position: fixed; inset: 0; background: #0f2a3d55; z-index: 50; display: flex; justify-content: flex-end; }
.drawer { background: var(--surface); width: min(520px, 100%); height: 100%; overflow-y: auto; box-shadow: var(--shadow-lg); }
@media (max-width: 600px) { .overlay { padding: 0; align-items: end; } .modal { border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92dvh; } }
.toasts { position: fixed; bottom: 18px; inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 80; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: var(--surface); padding: 11px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg); pointer-events: auto; display: flex; gap: 12px; align-items: center; max-width: 520px; }
.toast.err, .toast.error { background: var(--bad); color: #fff; } .toast button { background: none; border: 0; color: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; } .switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line2); border-radius: 999px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 20px; height: 20px; inset-inline-start: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px #0003; }
.switch input:checked + span { background: var(--accent); } .switch input:checked + span::before { transform: translateX(18px); } html[dir="rtl"] .switch input:checked + span::before { transform: translateX(-18px); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; } .avatar.l { width: 72px; height: 72px; font-size: 24px; } .avatar.s { width: 32px; height: 32px; font-size: 13px; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; min-height: 40vh; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 16px; color: var(--ink3); text-align: center; } .empty .ic { width: 28px; height: 28px; }
.seg { display: inline-flex; background: var(--surface2); border-radius: 10px; padding: 3px; gap: 2px; max-width: 100%; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 13px; border-radius: 8px; font: 600 13px var(--font); color: var(--ink2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.more-toggle { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--accent); font: 600 14px var(--font); cursor: pointer; padding: 8px 0; }
.link-box { display: flex; align-items: center; gap: 8px; background: var(--surface2); border-radius: var(--r-sm); padding: 8px 8px 8px 12px; min-width: 0; }
.link-box code, .link-box a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.menu { position: absolute; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 6px; z-index: 40; min-width: 200px; }
.menu > * { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 8px; font: 500 14px var(--font); color: var(--ink); text-decoration: none; cursor: pointer; text-align: start; }
.menu > *:hover { background: var(--surface2); }
select.langpick { appearance: none; -webkit-appearance: none; font: 600 13px var(--font); color: inherit; background: none; border: 1px solid var(--line2); border-radius: 999px; padding: 6px 12px; cursor: pointer; }

/* print: agenda, receta, patient file */
@media print {
  body { background: #fff; } .no-print, .tabbar, .sidebar, .topbar .btn { display: none !important; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}

/* engine kit: field errors, "more options", QR, drawers as bottom sheets on phones */
.field.err .i, .field.err input, .field.err select, .field.err textarea { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.field .err-msg { color: var(--bad); font-weight: 500; }
.more { margin: 4px 0 10px; } .more-t { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--accent); font: 600 14px var(--font); cursor: pointer; padding: 8px 0; min-height: 40px; }
.more-t .ic { width: 16px; height: 16px; } .more-b { padding-top: 6px; }
.qr { background: #fff; padding: 10px; border-radius: 12px; display: inline-block; line-height: 0; }
.menu-wrap { position: relative; }
.drawer { display: flex; flex-direction: column; }
html[dir="rtl"] .drawer-wrap { justify-content: flex-start; }
@media (max-width: 600px) { .drawer-wrap { align-items: flex-end; } .drawer { height: 94dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; } }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger.solid:hover { filter: brightness(.92); }
