:root {
  --ink: #0a3540; --ink2: #475569; --line: #e2e8f0; --bg: #f5f7f9; --card: #fff;
  --brand: #d8959c; --brand-d: #b56a73; --ok: #15803d; --err: #b91c1c;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.45; }
a { color: var(--ink); }
h1 { font-size: 24px; margin: 0; } h1 small { color: var(--ink2); font-weight: 400; font-size: 16px; }
h2 { font-size: 16px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink2); }
code { background: #eef2f5; padding: 1px 5px; border-radius: 4px; font-size: 13px; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px; background: var(--ink); color: #fff; }
.topbar a { color: #cfe0e4; text-decoration: none; }
.brand { font-size: 20px; color: #fff !important; letter-spacing: -.02em; }
.brand b { color: var(--brand); font-weight: 600; } .brand span { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; opacity: .7; margin-left: 4px; }
.brand.big { font-size: 28px; color: var(--ink) !important; text-align: center; margin-bottom: 20px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 6px 12px; border-radius: 6px; }
.topbar nav a.on, .topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.me { display: flex; gap: 14px; align-items: center; } .me form { margin: 0; }
.me .link { color: #cfe0e4; }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
main.narrow { max-width: 560px; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0 16px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.card.login { margin-top: 12vh; }
.grid2 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } .topbar { gap: 12px; padding: 0 12px; overflow-x: auto; } main { padding: 16px; } }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; background: #e8f6ee; color: var(--ok); border: 1px solid #b7e3c7; }
.flash.error { background: #fdecec; color: var(--err); border-color: #f5c2c2; }

label { display: block; font-weight: 600; font-size: 13px; color: var(--ink2); margin-bottom: 12px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; color: var(--ink); }
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid #cbd5e1; border-radius: 6px; padding: 8px 10px; background: #fff; }
label > input:not([type=checkbox]):not([type=radio]), label > select, label > textarea { display: block; width: 100%; margin-top: 4px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
input[type=color] { padding: 2px; width: 44px; height: 34px; }
input.num { width: 70px; }
.stack button { margin-top: 4px; }

.btn { display: inline-block; font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 6px; border: 1px solid #cbd5e1; background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.wide { width: 100%; }
button.link, .link { background: none; border: 0; padding: 0; font: inherit; color: var(--ink2); text-decoration: underline; cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; font-size: 13px; font-weight: 600; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chip small { color: var(--ink2); font-weight: 400; }
.chip.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters input[type=search] { min-width: 240px; flex: 1; }

.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.card .tablewrap { border: 0; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink2); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list:not(.plain) tbody tr { cursor: pointer; } table.list:not(.plain) tbody tr:hover { background: #f8fafc; }
table.list td a { text-decoration: none; font-weight: 600; }
table.plain th { background: none; }
.nowrap { white-space: nowrap; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--c); background: color-mix(in srgb, var(--c) 13%, white); border: 1px solid color-mix(in srgb, var(--c) 35%, white); white-space: nowrap; }
.badge.big { font-size: 13px; vertical-align: middle; margin-left: 8px; }

dl { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0 0 12px; }
dt { color: var(--ink2); font-size: 13px; } dd { margin: 0; }
.break { word-break: break-all; font-size: 13px; }
details summary { cursor: pointer; color: var(--ink2); margin: 8px 0; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.tab.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 16px 18px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--ink2); }
.timeline li.comment::before { background: var(--brand); }
.when { font-size: 12px; color: var(--ink2); margin-bottom: 3px; }
.comment { white-space: pre-wrap; background: #fbf4f5; border: 1px solid #f0dadd; border-radius: 8px; padding: 8px 12px; }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 16px 0; }
.empty { text-align: center; padding: 48px; color: var(--ink2); background: var(--card); border: 1px dashed var(--line); border-radius: 10px; }
.hint { color: var(--ink2); font-size: 13px; }
.meta { color: var(--ink2); font-size: 13px; margin: -4px 0 12px; }

/* --- edición rápida en el listado de leads --- */
.btn.small { padding: 4px 10px; font-size: 12px; }
.status-select { font-size: 12px; font-weight: 700; letter-spacing: .02em; padding: 4px 8px; border-radius: 999px; cursor: pointer;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, white); border: 1px solid color-mix(in srgb, var(--c) 40%, white); }
.status-select:disabled { opacity: .6; }
.lastc { min-width: 240px; max-width: 360px; }
.lastc-wrap { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.lastc-text { font-size: 13px; color: var(--ink); line-height: 1.3; }
.lastc-text small { display: block; color: var(--ink2); font-size: 11px; }
.lastc-text em { color: var(--ink2); }
.add-comment { flex: none; white-space: nowrap; }
table.list tbody tr.comment-row { cursor: default; background: #fbf4f5; }
table.list tbody tr.comment-row:hover { background: #fbf4f5; }
.comment-editor { display: flex; gap: 10px; align-items: flex-start; }
.comment-editor textarea { flex: 1; min-height: 56px; resize: vertical; }
.comment-actions { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px;
  border-radius: 8px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.18); z-index: 10; }
.toast.error { background: var(--err); }

/* --- rellamadas --- */
.callback-chip { border-color: #f5c38b; background: #fff7ed; color: #9a3412; }
.callback-chip small { color: #9a3412; font-weight: 700; }
.callback-chip.on { border-color: #c2410c; box-shadow: inset 0 0 0 1px #c2410c; }
.chip-sep { width: 1px; background: var(--line); margin: 2px 4px; }
.cb-btn { font: inherit; font-size: 13px; background: none; border: 1px dashed transparent; border-radius: 6px; padding: 3px 6px; cursor: pointer; color: var(--ink2); }
.cb-btn:hover { border-color: #cbd5e1; background: #fff; }
.cbcell[data-state="today"] .cb-btn { color: #c2410c; }
.cbcell[data-state="overdue"] .cb-btn { color: var(--err); }
.cbcell[data-state="future"] .cb-btn { color: var(--ink); }
.cb-text b { font-weight: 700; margin-right: 2px; }
.comment-editor { flex-wrap: wrap; }
.panel-title { flex-basis: 100%; font-weight: 700; font-size: 13px; color: var(--ink); }
.cb-field { margin: 0; flex: none; }
.cb-field input { display: block; margin-top: 4px; }

/* --- archivado --- */
.archived-chip { color: var(--ink2); }
.archive-btn { color: var(--ink2); }
.archive-btn:hover { color: var(--ink); border-color: var(--ink2); }
tr.leaving { opacity: 0; transition: opacity .25s; }
.toast { display: flex; align-items: center; gap: 14px; }
.toast[hidden] { display: none; }
.toast-action { font: inherit; font-weight: 700; color: var(--brand); background: none; border: 0; cursor: pointer; padding: 0; text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.badge.archived { --c: #475569; }

/* listado más compacto: landing, formulario y campaña en letra pequeña */
table.quicklist th, table.quicklist td { padding: 9px 8px; }
table.quicklist td:nth-child(7), table.quicklist td:nth-child(8), table.quicklist td.utmcell { font-size: 12px; color: var(--ink2); max-width: 130px; overflow-wrap: anywhere; }
table.quicklist .lastc { min-width: 200px; max-width: 300px; }

/* --- logo de ageclinic.es --- */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand .logo { height: 22px; width: auto; display: block; }
.brand.big { display: flex; justify-content: center; }
.brand.big .logo { height: 34px; }
.brand .logo.dark { filter: brightness(0); } /* el logo es blanco: en fondo claro se pinta en negro */
.topbar .brand span { padding-left: 10px; border-left: 1px solid rgba(255,255,255,.3); }
.brand.big span { color: var(--ink2); }

/* columnas UTM */
table.quicklist th.utm small { display: block; font-size: 10px; text-transform: none; letter-spacing: 0; font-weight: 400; color: #94a3b8; }
table.quicklist td.utmcell { max-width: 120px; }
h2.sub { margin: 18px 0 8px; font-size: 13px; }
.utm-list dt small { display: block; font-size: 11px; color: #94a3b8; }
.utm-list { padding: 10px 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; }
/* listado algo más compacto para que quepan las columnas UTM */
table.quicklist .lastc { min-width: 170px; max-width: 240px; }
table.quicklist .status-select { max-width: 130px; }
table.quicklist td:nth-child(2) { min-width: 90px; }
table.quicklist { font-size: 13.5px; }
table.quicklist th, table.quicklist td { padding: 8px 6px; }
/* el atributo hidden debe ganar a display:block de las etiquetas (campo «Rellamar el» del detalle) */
[hidden] { display: none !important; }
