/* Todeus Clínicas · paleta inspirada en twind.io */
:root {
  --primary: #0177b5;
  --primary-700: #015a9c;
  --primary-50: #e8f3fa;
  --primary-100: #cfe6f4;
  --accent: #ec162c;
  --accent-50: #fdeaec;
  --ink: #171716;
  --ink-2: #32373c;
  --muted: #6b7178;
  --bg: #f4f7fa;
  --surface: #ffffff;
  --border: #e3e8ee;
  --success: #0e9f6e;
  --success-50: #e7f6f0;
  --warning: #d98a00;
  --warning-50: #fdf3e1;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(23, 23, 22, .06), 0 4px 16px rgba(23, 23, 22, .05);
  --font-head: "Poppins", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* Marca */
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 700; font-size: 20px; color: var(--ink); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-700) 100%);
  display: grid; place-items: center; color: #fff; font-size: 17px; position: relative;
}
.brand-mark::after { content: ""; position: absolute; right: -3px; top: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.brand small { display: block; font-family: var(--font-body); font-weight: 600; font-size: 11px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin-top: -3px; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 700; font-size: 14px;
  transition: background .15s, border-color .15s, transform .05s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-700); border-color: var(--primary-700); color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #c80f22; border-color: #c80f22; color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--primary-50); border-color: transparent; }
.btn-danger { color: var(--accent); }
.btn-danger:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-50); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label, .label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  padding: 9px 11px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
textarea.input { min-height: 80px; resize: vertical; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; padding: 4px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

/* Tarjetas y tablas */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi { padding: 16px 18px; }
.kpi .label { margin-bottom: 6px; display: block; }
.kpi .value { font-family: var(--font-head); font-size: 26px; font-weight: 600; }
.kpi .sub { font-size: 13px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--primary-50); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--bg); color: var(--ink-2); white-space: nowrap; }
.badge-blue { background: var(--primary-50); color: var(--primary-700); }
.badge-green { background: var(--success-50); color: var(--success); }
.badge-orange { background: var(--warning-50); color: var(--warning); }
.badge-red { background: var(--accent-50); color: var(--accent); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 10px 14px; border: 0; background: none; cursor: pointer; font-weight: 700; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 999px; cursor: pointer; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; background: var(--primary-50); color: var(--primary-700); }
.alert-warn { background: var(--warning-50); color: #8a5800; }
.alert-red { background: var(--accent-50); color: #a30d1d; }
.alert-ok { background: var(--success-50); color: #0a6b4b; }

/* Layout del panel */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.sidebar .brand { padding: 2px 8px 6px; }
.clinic-switch { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); font-size: 13px; }
.clinic-switch .avatar { width: 28px; height: 28px; border-radius: 8px; font-size: 12px; }
.clinic-switch b { display: block; font-size: 13.5px; line-height: 1.2; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--ink-2); padding: 8px 10px; border-radius: 9px; font-weight: 600; font-size: 14.5px; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: var(--primary-50); color: var(--primary-700); }
.nav a.active svg { color: var(--primary); }
.nav svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 10px 4px; font-weight: 700; }
.sidebar-foot { margin-top: auto; }
.plan-box { border-radius: 12px; padding: 14px; background: linear-gradient(135deg, var(--primary-50), #fff); border: 1px solid var(--primary-100); font-size: 13px; }
.plan-box b { font-family: var(--font-head); font-size: 14px; }
.plan-bar { height: 6px; border-radius: 6px; background: var(--primary-100); margin: 8px 0; overflow: hidden; }
.plan-bar span { display: block; height: 100%; background: var(--primary); border-radius: 6px; }
/* Barra lateral simplificada */
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.collapse-btn { width: 32px; height: 32px; color: var(--muted); }
.ia-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; font-weight: 700; color: #fff; background: linear-gradient(120deg, var(--primary) 0%, #4b5fd6 100%); box-shadow: 0 6px 18px rgba(1, 119, 181, .25); }
.ia-link svg { width: 19px; height: 19px; flex: none; }
.ia-link:hover { filter: brightness(1.06); color: #fff; }
.ia-link.active { outline: 3px solid var(--primary-100); }
.ia-kbd { margin-left: auto; font-size: 10.5px; background: rgba(255, 255, 255, .22); padding: 2px 7px; border-radius: 999px; }
.nav-line { display: none; height: 1px; background: var(--border); margin: 8px 10px; }
.trial-pill { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--bg); font-size: 12.5px; color: var(--muted); }
.trial-pill b { color: var(--primary); font-size: 13px; }
.sidebar-foot .nav { border-top: 1px solid var(--border); padding-top: 8px; }
.app.collapsed { grid-template-columns: 72px 1fr; }
.app.collapsed .sidebar { padding: 16px 10px; align-items: center; }
.app.collapsed .hide-c { display: none !important; }
.app.collapsed .side-top { flex-direction: column; }
.app.collapsed .nav a, .app.collapsed .ia-link { justify-content: center; padding: 10px; }
.app.collapsed .nav-line { display: block; }
.app.collapsed .sidebar-foot { width: 100%; }

/* Todeus IA */
.view.view-ia { max-width: none; padding: 0; height: calc(100vh - 59px); overflow: hidden; }
.ia-wrap { display: flex; flex-direction: column; height: 100%; max-width: 860px; margin: 0 auto; padding: 18px 24px 12px; }
.ia-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.ia-orb { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--primary), #4b5fd6); flex: none; }
.ia-orb svg { width: 20px; height: 20px; }
.ia-orb.sm { width: 30px; height: 30px; border-radius: 10px; }
.ia-orb.sm svg { width: 16px; height: 16px; }
.ia-orb.lg { width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 14px; }
.ia-orb.lg svg { width: 30px; height: 30px; }
.ia-log { flex: 1; overflow-y: auto; padding: 20px 2px; display: flex; flex-direction: column; gap: 12px; }
.ia-empty { margin: auto 0; text-align: center; padding: 20px 0; }
.ia-empty h2 { font-size: 24px; }
.ia-sugs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 22px; text-align: left; }
.ia-sug { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 12px 14px; cursor: pointer; font-weight: 600; color: var(--ink-2); text-align: left; }
.ia-sug:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.msg { display: flex; gap: 10px; align-items: flex-end; }
.msg.me { justify-content: flex-end; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 16px; line-height: 1.5; }
.msg.me .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.err { background: var(--accent-50) !important; color: #a30d1d; border-color: transparent !important; }
.typing { display: flex; gap: 4px; padding: 14px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .4; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: 1; } }
.ia-tool { align-self: flex-start; margin-left: 40px; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 700; background: var(--bg); padding: 4px 10px; border-radius: 999px; }
.ia-tool.done svg { color: var(--success); }
.spin { width: 12px; height: 12px; border: 2px solid var(--primary-100); border-top-color: var(--primary); border-radius: 50%; animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.ia-confirm { margin-left: 40px; max-width: 520px; border: 1px solid var(--primary-100); background: var(--surface); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.ia-confirm.pending { border: 2px solid var(--primary); }
.ia-confirm.rejected { opacity: .6; }
.ia-confirm-head { font-family: var(--font-head); font-weight: 600; margin-bottom: 10px; display: flex; gap: 8px; align-items: center; }
.ia-confirm .kv { grid-template-columns: 110px 1fr; font-size: 14px; }
.ia-composer { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 16px; padding: 8px 8px 8px 14px; box-shadow: var(--shadow); }
.ia-composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.ia-composer textarea { flex: 1; border: 0; outline: none; resize: none; font: inherit; padding: 8px 0; max-height: 160px; background: transparent; }
.ia-composer .btn { border-radius: 12px; padding: 9px 12px; }
.icon-btn.rec { color: var(--accent); background: var(--accent-50); }
.ia-foot { text-align: center; padding-top: 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 24px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.search { position: relative; flex: 1; max-width: 420px; }
.search #searchIcon { display: contents; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 17px; height: 17px; }
.search input { padding-left: 36px; background: var(--bg); border-color: transparent; border-radius: 10px; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); max-height: 360px; overflow-y: auto; z-index: 40; }
.search-results a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; color: var(--ink); border-bottom: 1px solid var(--border); }
.search-results a:hover { background: var(--primary-50); }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent; background: none; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); position: relative; }
.icon-btn:hover { background: var(--bg); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .pip { position: absolute; top: 6px; right: 7px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; border: 2px solid #fff; }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 300px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, .12); z-index: 50; overflow: hidden; }
.dropdown .dd-head { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.dropdown a, .dropdown button.dd-item { display: flex; width: 100%; gap: 10px; align-items: center; padding: 10px 16px; color: var(--ink); background: none; border: 0; text-align: left; cursor: pointer; font-weight: 600; font-size: 14px; }
.dropdown a:hover, .dropdown button.dd-item:hover { background: var(--bg); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 700; font-size: 13.5px; }
.trial-bar { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px; background: var(--ink); color: #fff; font-size: 13.5px; font-weight: 600; }
.trial-bar a { color: #fff; text-decoration: underline; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.view { padding: 24px; max-width: 1400px; width: 100%; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: var(--primary); flex: none; }

/* Agenda */
.ag-wrap { overflow: auto; max-height: calc(100vh - 210px); border-radius: var(--radius); }
.ag-grid { display: grid; min-width: 100%; position: relative; }
.ag-head { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px; font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.ag-head.corner { left: 0; z-index: 6; }
.ag-times { position: sticky; left: 0; z-index: 4; background: var(--surface); border-right: 1px solid var(--border); }
.ag-time { font-size: 11px; color: var(--muted); text-align: right; padding-right: 8px; transform: translateY(-7px); }
.ag-col { position: relative; border-right: 1px solid var(--border); cursor: crosshair; }
.ag-col:last-child { border-right: 0; }
.ag-ev {
  position: absolute; left: 4px; right: 4px; border-radius: 8px; padding: 5px 8px; font-size: 12px; overflow: hidden; cursor: pointer;
  background: var(--primary-50); border-left: 4px solid var(--primary); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.ag-ev:hover { filter: brightness(.97); z-index: 3; }
.ag-ev b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-ev .t { color: var(--muted); font-size: 11px; }
.ag-ev.completada { opacity: .65; }
.ag-ev.pendiente { border-left-style: dashed; }
.ag-ev.cancelada, .ag-ev.no-show { background: repeating-linear-gradient(45deg, #fafafa, #fafafa 6px, #f1f1f1 6px, #f1f1f1 12px); border-left-color: #b9bec4; color: var(--muted); text-decoration: line-through; }
.ag-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--accent); z-index: 2; pointer-events: none; }
.ag-now::before { content: ""; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.ag-col ~ .ag-col .ag-now::before { display: none; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(23, 23, 22, .45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); animation: pop .18s; }
.modal.wide { max-width: 860px; }
.modal.full { max-width: 980px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

.toast-box { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 600; font-size: 14px; animation: pop .2s; max-width: 360px; }
.toast.err { background: var(--accent); }

/* Firma y fotos */
.sign-pad { width: 100%; height: 200px; border: 2px dashed var(--border); border-radius: var(--radius-sm); background: #fff; touch-action: none; cursor: crosshair; display: block; }
.consent-text { max-height: 260px; overflow-y: auto; background: var(--bg); border-radius: var(--radius-sm); padding: 14px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; margin-bottom: 14px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.photo { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.photo img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.photo .cap { padding: 6px 8px; font-size: 12px; }
.photo.sel { outline: 3px solid var(--primary); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare img { width: 100%; border-radius: var(--radius-sm); }

.patient-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.patient-head .avatar { width: 56px; height: 56px; font-size: 20px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 700; }
.kv dd { margin: 0; }
.timeline { border-left: 2px solid var(--primary-100); margin-left: 8px; padding-left: 18px; }
.timeline .item { position: relative; padding-bottom: 18px; }
.timeline .item::before { content: ""; position: absolute; left: -25px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface); }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; background: var(--ink); color: #e6e6e6; padding: 12px; border-radius: var(--radius-sm); white-space: pre-wrap; word-break: break-all; }
.stack > * + * { margin-top: 16px; }

/* Portal paciente */
.portal { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: 84px; }
.portal-top { display: flex; align-items: center; justify-content: space-between; padding: 16px; }
.portal-hero { margin: 0 16px 16px; padding: 20px; border-radius: 18px; color: #fff; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-700) 100%); position: relative; overflow: hidden; }
.portal-hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.portal-hero .btn { background: #fff; color: var(--primary); border-color: #fff; }
.portal-body { padding: 0 16px; }
.portal-body > * + * { margin-top: 14px; }
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); display: flex; justify-content: center; z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav .inner { display: flex; max-width: 560px; width: 100%; }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 10px; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav svg { width: 22px; height: 22px; }
.choice { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: left; width: 100%; transition: border-color .15s; }
.choice:hover, .choice.active { border-color: var(--primary); background: var(--primary-50); }
.choice .grow { flex: 1; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 8px 12px; text-align: center; cursor: pointer; min-width: 62px; }
.chip b { display: block; font-family: var(--font-head); font-size: 17px; }
.chip span { font-size: 11px; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.active span { color: #dbeefa; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.slot { border: 1px solid var(--border); border-radius: 10px; padding: 9px 0; text-align: center; font-weight: 700; background: var(--surface); cursor: pointer; }
.slot:hover { border-color: var(--primary); color: var(--primary); }
.slot.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.steps { display: flex; gap: 6px; margin-bottom: 14px; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--border); }
.steps span.on { background: var(--primary); }

/* Acceso */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 500px at 10% -10%, var(--primary-100), transparent), var(--bg); }
.login-card { width: 100%; max-width: 980px; display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; }
.login-side { background: var(--ink); color: #fff; padding: 36px; display: flex; flex-direction: column; gap: 18px; }
.login-side .brand { color: #fff; }
.login-side ul { margin: 0; padding-left: 18px; color: #c9ccd1; line-height: 1.8; }
.login-main { padding: 36px; }

/* Web pública */
.site { background: #fff; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.site-nav { position: sticky; top: 0; z-index: 50; background: rgba(255, 255, 255, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.site-nav .wrap { display: flex; align-items: center; gap: 28px; height: 68px; }
.site-nav nav { display: flex; gap: 22px; flex: 1; }
.site-nav nav a { color: var(--ink-2); font-weight: 700; font-size: 14.5px; }
.site-nav nav a:hover { color: var(--primary); }
.hero { padding: 72px 0 40px; text-align: center; background: radial-gradient(900px 420px at 50% -10%, var(--primary-50), transparent 70%); }
.hero h1 { font-size: clamp(32px, 5vw, 54px); line-height: 1.08; font-weight: 700; max-width: 860px; margin: 0 auto; letter-spacing: -.02em; }
.hero h1 em { font-style: normal; color: var(--primary); }
.hero p.lead { font-size: 19px; color: var(--muted); max-width: 640px; margin: 18px auto 28px; line-height: 1.5; }
.hero .cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn-lg { padding: 13px 22px; font-size: 15.5px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; border-radius: 999px; background: #fff; border: 1px solid var(--border); font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 22px; }
.eyebrow span { background: var(--accent); color: #fff; border-radius: 999px; padding: 2px 8px; font-size: 11.5px; }
.ia-spotlight h2 { font-size: 28px; }
.ia-card { background: #fff; border-radius: 20px; box-shadow: 0 24px 60px rgba(1, 90, 156, .16); border: 1px solid var(--border); overflow: hidden; }
.ia-card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.ia-card-chat { padding: 20px; display: flex; flex-direction: column; gap: 12px; background: var(--bg); }
.ia-card-rows { padding: 6px 12px; }
.ia-row { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-top: 1px solid var(--border); }
.ia-row:first-child { border-top: 0; }
.ia-row-ic { width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.ia-row-ic svg { width: 17px; height: 17px; }

.ia-card-confirm { padding: 0 20px 18px; background: var(--bg); }
@keyframes iaRise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.ia-card-chat .msg, .ia-card-confirm, .ia-card-rows .ia-row { opacity: 0; }
.ia-card.play .ia-card-chat .msg:nth-child(1) { animation: iaRise .5s ease forwards .1s; }
.ia-card.play .ia-card-chat .msg:nth-child(2) { animation: iaRise .5s ease forwards .7s; }
.ia-card.play .ia-card-confirm { animation: iaRise .5s ease forwards 1.3s; }
.ia-card.play .ia-card-rows .ia-row:nth-child(1) { animation: iaRise .45s ease forwards 1.8s; }
.ia-card.play .ia-card-rows .ia-row:nth-child(2) { animation: iaRise .45s ease forwards 2.05s; }
.ia-card.play .ia-card-rows .ia-row:nth-child(3) { animation: iaRise .45s ease forwards 2.3s; }
.trust { padding: 34px 0 10px; text-align: center; color: var(--muted); font-weight: 700; font-size: 14px; }
.section { padding: 84px 0; }
.section.alt { background: var(--bg); }
.section-head { text-align: center; max-width: 700px; margin: 0 auto 44px; }
.section-head h2 { font-size: clamp(26px, 3.4vw, 38px); line-height: 1.15; font-weight: 700; }
.section-head p { color: var(--muted); font-size: 17px; margin: 12px 0 0; }
.feat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.feat { padding: 24px; border-radius: 16px; border: 1px solid var(--border); background: #fff; }
.feat .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; margin-bottom: 14px; }
.feat .ic svg { width: 22px; height: 22px; }
.feat h3 { font-size: 17px; margin-bottom: 6px; }
.feat p { color: var(--muted); margin: 0; line-height: 1.5; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: center; }
.split > * { min-width: 0; }
.split + .split { margin-top: 80px; }
.split h3 { font-size: 28px; line-height: 1.2; font-weight: 700; margin-bottom: 12px; }
.split p { color: var(--muted); font-size: 16.5px; line-height: 1.55; }
.ticks { list-style: none; padding: 0; margin: 18px 0 0; }
.ticks li { padding-left: 28px; position: relative; margin-bottom: 10px; font-weight: 600; }
.ticks li::before { content: ""; position: absolute; left: 0; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--primary-50) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230177b5' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center/12px no-repeat; }
.mock { border-radius: 18px; background: linear-gradient(135deg, var(--primary-50), #fff); border: 1px solid var(--border); padding: 22px; }
.mock .card { box-shadow: 0 10px 30px rgba(0, 0, 0, .06); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; text-align: center; }
.stats b { display: block; font-family: var(--font-head); font-size: 40px; color: var(--primary); }
.stats span { color: var(--muted); font-weight: 600; }
.price-toggle { display: flex; justify-content: center; margin-bottom: 30px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 18px; align-items: stretch; }
.plan { border: 1px solid var(--border); border-radius: 18px; padding: 28px; background: #fff; display: flex; flex-direction: column; position: relative; }
.plan.pop { border: 2px solid var(--primary); box-shadow: 0 20px 50px rgba(1, 119, 181, .15); }
.plan .tag { position: absolute; top: -12px; left: 28px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.plan h3 { font-size: 20px; }
.plan .desc { color: var(--muted); min-height: 44px; margin: 6px 0 16px; }
.plan .price { font-family: var(--font-head); font-size: 42px; font-weight: 700; }
.plan .price small { font-size: 15px; color: var(--muted); font-weight: 500; }
.plan ul { list-style: none; padding: 0; margin: 20px 0 24px; flex: 1; }
.plan li { padding: 6px 0 6px 26px; position: relative; font-size: 14.5px; }
.plan li::before { content: "✓"; position: absolute; left: 0; color: var(--primary); font-weight: 700; }
.faq details { border-bottom: 1px solid var(--border); padding: 18px 0; }
.faq summary { font-weight: 700; font-size: 16.5px; cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.faq summary::after { content: "+"; color: var(--primary); font-size: 22px; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq p { color: var(--muted); margin: 10px 0 0; line-height: 1.55; }
.cta-band { background: var(--ink); color: #fff; border-radius: 24px; padding: 56px 32px; text-align: center; position: relative; overflow: hidden; }
.cta-band::after { content: ""; position: absolute; width: 380px; height: 380px; border-radius: 50%; background: var(--primary); opacity: .25; right: -120px; top: -160px; }
.cta-band h2 { color: #fff; font-size: clamp(26px, 3.4vw, 38px); position: relative; }
.cta-band p { color: #c9ccd1; position: relative; }
.footer { padding: 48px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; }
.footer .wrap { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

/* Acceso y alta */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: 40px clamp(20px, 6vw, 80px); max-width: 560px; width: 100%; margin: 0 auto; }
.auth-side { background: linear-gradient(160deg, var(--primary) 0%, var(--primary-700) 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: center; gap: 22px; position: relative; overflow: hidden; }
.auth-side::after { content: ""; position: absolute; width: 300px; height: 300px; border-radius: 50%; background: rgba(255, 255, 255, .07); right: -80px; bottom: -80px; }
.auth-side h2 { color: #fff; font-size: 30px; line-height: 1.2; }
.auth-side blockquote { margin: 0; padding: 20px; background: rgba(255, 255, 255, .1); border-radius: 14px; line-height: 1.55; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.wizard { max-width: 720px; margin: 0 auto; padding: 32px 20px 60px; }
.wizard-steps { display: flex; gap: 8px; margin: 22px 0 26px; }
.wizard-steps div { flex: 1; }
.wizard-steps span { display: block; height: 5px; border-radius: 5px; background: var(--border); margin-bottom: 8px; }
.wizard-steps .on span { background: var(--primary); }
.wizard-steps small { font-weight: 700; color: var(--muted); font-size: 12px; }
.wizard-steps .on small { color: var(--primary); }
.pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.pick label { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: #fff; }
.pick label:has(input:checked) { border-color: var(--primary); background: var(--primary-50); }
.pick input { margin-top: 3px; accent-color: var(--primary); }

@media (max-width: 900px) {
  .site-nav nav { display: none; }
  .split { grid-template-columns: 1fr; gap: 28px; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .search { display: none; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 90; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-btn { display: inline-flex; }
  .view { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .login-card { grid-template-columns: 1fr; }
  .login-side { padding: 24px; }
  .login-main { padding: 24px; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
}

/* ---------- Facturas ---------- */
.invoice { color: var(--ink); font-size: 14px; line-height: 1.45; }
.inv-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.inv-kind { font-family: var(--font-head); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.inv-num { font-family: var(--font-head); font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.inv-dates { display: grid; grid-template-columns: auto auto; gap: 2px 12px; margin: 0; font-size: 13px; }
.inv-dates dt { color: var(--muted); } .inv-dates dd { margin: 0; text-align: right; }
.inv-parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
.inv-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.inv-note { background: var(--warning-50); color: #8a5800; padding: 8px 12px; border-radius: var(--radius-sm); margin-bottom: 14px; }
.inv-lines, .inv-tax { width: 100%; border-collapse: collapse; }
.inv-lines th, .inv-tax th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.inv-lines td, .inv-tax td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
.inv-lines th.num, .inv-tax th.num { text-align: right; }
.inv-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-top: 16px; }
.inv-tax { max-width: 340px; }
.inv-totals { display: grid; grid-template-columns: auto auto; gap: 4px 20px; margin: 0; min-width: 220px; }
.inv-totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.inv-totals .grand { font-family: var(--font-head); font-weight: 600; font-size: 17px; padding-top: 6px; border-top: 1px solid var(--border); }
.inv-legal { font-size: 12px; color: var(--muted); margin: 14px 0 0; }
.invoice-page { max-width: 820px; margin: 24px auto; background: var(--surface); padding: 36px; border-radius: var(--radius); box-shadow: var(--shadow); }
@media (max-width: 600px) { .invoice-page { margin: 0; padding: 20px 16px; border-radius: 0; } .inv-lines { font-size: 13px; } }
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .invoice-page { box-shadow: none; margin: 0; padding: 0; max-width: none; }
}
.inv-opt { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin: 4px 0 12px; display: flex; flex-direction: column; gap: 6px; }
.inv-opt [data-rcpt] { margin-top: 6px; }

/* Buscador de pacientes (cobro, bono y cita) */
.psearch { position: relative; }
.psearch-list { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 4px; }
.psearch-item { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.psearch-item:hover, .psearch-item.active { background: var(--bg); }
.psearch-empty { padding: 8px 10px; }

/* Respuesta al recordatorio de WhatsApp (agenda e inicio) */
.wa-mark { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 4px; border-radius: 50%; font-size: 10px; font-weight: 800; line-height: 1; vertical-align: 1px; color: #fff; }
.wa-mark.ok { background: var(--success); }
.wa-mark.warn { background: var(--accent); }

/* Conversación de WhatsApp */
.wa-chat { display: flex; flex-direction: column; gap: 8px; max-height: 55vh; overflow-y: auto; padding: 12px; background: var(--bg); border-radius: var(--radius-sm); }
.wa-msg { max-width: 80%; padding: 8px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); align-self: flex-start; }
.wa-msg.out { align-self: flex-end; background: #e7f6ee; border-color: #cdebd9; }
.wa-msg.tpl { background: #eef5fb; border-color: #d4e6f4; }
.wa-msg.sys { align-self: center; max-width: 95%; background: none; border: 1px dashed var(--border); font-size: 12px; color: var(--muted); }
.wa-msg.typing { opacity: .6; font-style: italic; }
.wa-tag { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.wa-text { font-size: 14px; line-height: 1.4; color: var(--ink); overflow-wrap: anywhere; }
.wa-meta { font-size: 11px; color: var(--muted); margin-top: 4px; text-align: right; }
.wa-sim { display: flex; gap: 8px; margin-top: 10px; }
.wa-sim .input { flex: 1; }

/* Horarios: zona fuera de horario en la agenda y editor semanal */
.ag-off { position: absolute; left: 0; right: 0; pointer-events: none; background: repeating-linear-gradient(135deg, rgba(23, 23, 22, .045) 0 6px, transparent 6px 12px); }
.wk { display: flex; flex-direction: column; gap: 6px; }
.wk-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 40px; }
.wk-day { width: 110px; margin: 0; }
.wk-t, .wk-2 { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wk-t.hidden, .wk-2.hidden { display: none; }

/* Informes: ingresos por mes */
.rep-bars { display: flex; align-items: flex-end; gap: 2px; height: 200px; padding: 16px 20px 8px; }
.rep-col { position: relative; flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 20px; outline: none; }
.rep-bar { position: relative; width: min(36px, 70%); background: var(--primary-100); border-radius: 4px 4px 0 0; transition: background .15s; }
.rep-bar.sel { background: var(--primary); }
.rep-col:hover .rep-bar, .rep-col:focus .rep-bar { background: var(--primary-700); }
.rep-lab { position: absolute; bottom: 0; font-size: 11.5px; color: var(--muted); }
.rep-tip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 12px; padding: 5px 8px; border-radius: 6px; white-space: nowrap; z-index: 2; text-align: center; pointer-events: none; }
.rep-tip b { display: block; }
.rep-col:hover .rep-tip, .rep-col:focus .rep-tip { display: block; }
.rep-data { padding: 0 20px 14px; }
.rep-data summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }

/* Verifactu: QR al inicio de la factura (entre 30 y 40 mm al imprimir) */
.inv-vf { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.inv-qr { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; color: var(--ink); text-decoration: none; }
.inv-qr svg { width: 120px; height: 120px; display: block; }
.inv-qr span { font-size: 11px; font-weight: 700; letter-spacing: .04em; }
@media print { .inv-qr svg { width: 35mm; height: 35mm; } }
