/* Agenda Tu Psicolaboral — hoja de estilos única, sin build.
   Agenda profesional: sobria, ejecutiva, mobile-first. Independiente del CRM. */

:root {
  --ink: #0f1729;
  --ink-2: #475467;
  --muted: #8a94a6;
  --line: #e7e9ee;
  --bg: #f6f7f9;
  --card: #ffffff;
  --navy: #14213d;
  --accent: #2f5bea;
  --accent-soft: #eef2fe;
  --ok: #12805c;
  --ok-soft: #e7f5ef;
  --warn: #b45309;
  --warn-soft: #fdf3e5;
  --bad: #c2362b;
  --bad-soft: #fcecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px rgba(16, 24, 40, .04);
  --side-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8ebf2;
    --ink-2: #b3bccb;
    --muted: #7d889b;
    --line: #262d3b;
    --bg: #0e121a;
    --card: #161b26;
    --navy: #0b0f17;
    --accent: #7c9bff;
    --accent-soft: #1c2540;
    --ok: #4cc79a;
    --ok-soft: #12261f;
    --warn: #f0a85a;
    --warn-soft: #2a2012;
    --bad: #f07a70;
    --bad-soft: #2c1716;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1rem; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.ic { width: 20px; height: 20px; flex: none; }

/* ---------- Layout ---------- */
.side {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--side-w);
  background: var(--navy);
  color: #c9d2e3;
  padding: 22px 14px;
  display: none;
  flex-direction: column;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.side .brand strong { color: #fff; font-size: 1rem; }
.side .brand small { color: #8e9ab3; font-size: .75rem; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: #c9d2e3;
  font-weight: 500;
}
.side-nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.side-nav a.on { background: rgba(255, 255, 255, .12); color: #fff; }
.side-nav a:last-child { margin-top: 14px; }

.side-foot { margin-top: auto; font-size: .82rem; color: #8e9ab3; }
.side-foot .who { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { background: none; border: 0; padding: 0; font: inherit; color: #c9d2e3; cursor: pointer; }
.link:hover { text-decoration: underline; }

.main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px calc(88px + env(safe-area-inset-bottom));
}

.mob-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 4px;
}
.mob-head .brand { color: var(--ink); gap: 8px; }
.mob-head .brand img { width: 26px; height: 26px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; color: var(--ink-2);
}
.icon-btn.on, .icon-btn:hover { background: var(--card); color: var(--ink); }

.tabbar {
  position: fixed; inset: auto 0 0 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 20;
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0; font-size: .7rem; font-weight: 500; color: var(--muted);
}
.tabbar a:hover { text-decoration: none; }
.tabbar a.on { color: var(--accent); }

@media (min-width: 900px) {
  .side { display: flex; }
  .main { margin-left: var(--side-w); padding: 0 40px 48px; }
  .mob-head, .tabbar { display: none; }
}

/* ---------- Encabezado de página ---------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
  padding: 18px 0 20px;
}
@media (min-width: 900px) { .page-head { padding-top: 36px; } }
.eyebrow {
  font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
}
.eyebrow:empty { display: none; }
.page-actions { display: flex; gap: 8px; }

/* ---------- Botones y formularios ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit; font-weight: 600; font-size: .9rem;
  cursor: pointer;
}
.btn .ic { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.field input {
  font: inherit; font-weight: 400; color: var(--ink);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.messages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.msg { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); font-size: .9rem; }
.msg.success { background: var(--ok-soft); color: var(--ok); }
.msg.error { background: var(--bad-soft); color: var(--bad); margin-bottom: 14px; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head a { font-size: .85rem; font-weight: 500; }
.card.tone-bad h2 { color: var(--bad); }
.label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.next-session { border-left: 4px solid var(--accent); }
.next-session .label { color: var(--accent); margin-bottom: 4px; }

.grid-2 { display: grid; gap: 0 16px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1.15fr 1fr; } }
.stack { display: flex; flex-direction: column; }

.empty { padding: 6px 0; }
.empty-title { font-weight: 600; color: var(--ink-2); }
.empty-hint { margin-top: 4px; color: var(--muted); font-size: .9rem; max-width: 60ch; }

/* ---------- Semana ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { padding: 10px; border-radius: 10px; background: var(--bg); min-height: 72px; }
.day.weekend { opacity: .6; }
.day.today { background: var(--accent-soft); outline: 1px solid var(--accent); }
.day-name { font-size: .75rem; font-weight: 600; text-transform: uppercase; color: var(--muted); }
.day-name span { display: block; font-size: 1.1rem; color: var(--ink); text-transform: none; }
.day.today .day-name span { color: var(--accent); }
.day-empty { font-size: .78rem; color: var(--muted); margin-top: 4px; }
@media (max-width: 599px) {
  .week { grid-template-columns: 1fr; gap: 6px; }
  .day { display: flex; align-items: baseline; justify-content: space-between; min-height: 0; }
  .day-name span { display: inline; margin-left: 4px; }
  .day-empty { margin: 0; }
}

/* ---------- Login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
}
.login-logo { height: 40px; margin-bottom: 20px; }
.login-card h1 { margin-bottom: 2px; }
.login-card .muted { margin-bottom: 22px; }

/* ---------- Utilidades ---------- */
[hidden] { display: none !important; }
.small { font-size: .85rem; }
.pad { padding: 18px 20px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.section-title { margin: 28px 0 12px; font-size: 1.1rem; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: .85rem; color: var(--muted); cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: var(--ink); }
@media (max-width: 599px) { .hide-sm { display: none; } }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; white-space: nowrap;
  background: var(--bg); color: var(--ink-2); border: 1px solid var(--line);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.late { color: var(--bad); font-weight: 600; }

/* ---------- Buscador, filtros, tabla ---------- */
.toolbar { margin-bottom: 12px; }
.search {
  width: 100%; font: inherit; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink);
}
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 6px 14px; border-radius: 999px; font-size: .85rem; font-weight: 500;
  color: var(--ink-2); background: var(--card); border: 1px solid var(--line);
}
.chip:hover { text-decoration: none; border-color: var(--muted); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--card); }

.card.flush { padding: 0; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: .75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .92rem; }
.table tr:last-child td { border-bottom: 0; }
.table .strong { font-weight: 600; color: var(--ink); }
.table .sub { display: block; font-size: .8rem; color: var(--muted); }
.table .sub-line { display: block; }
.count { font-weight: 700; }
@media (max-width: 599px) { .table th, .table td { padding: 10px 12px; } }

/* ---------- Ficha ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 20px; margin: 0; }
.facts dt { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.notes { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: .92rem; }

.service h3 { font-size: 1.12rem; letter-spacing: -.01em; margin: 0; }
.service .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-size: .85rem; color: var(--muted); }
.service.closed { opacity: .85; }
.progress { margin: 14px 0 6px; }
.bar { height: 8px; border-radius: 999px; background: var(--bg); overflow: hidden; border: 1px solid var(--line); }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .25s ease; }
.service.closed .bar > span { background: var(--ok); }
.progress p { margin-top: 6px; font-size: .85rem; color: var(--ink-2); }

.done-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 12px 0; padding: 12px 14px; border-radius: 12px;
  background: var(--ok-soft); color: var(--ok);
}

.checklist { margin-top: 10px; }
.checklist summary { cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--ink-2); padding: 6px 0; }
.checklist h4 {
  margin: 14px 0 4px; font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
}
.service-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }

.tasks { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task.busy { opacity: .55; }
.task-status { display: flex; gap: 2px; flex: none; }
.st {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  font-size: .85rem; line-height: 1; cursor: pointer; padding: 0;
}
.st:hover { border-color: var(--muted); color: var(--ink); }
.st-pendiente[aria-pressed="true"] { border-color: var(--ink-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink-2); }
.st-en_proceso[aria-pressed="true"] { background: var(--warn); border-color: var(--warn); color: #fff; }
.st-completada[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.st-no_aplica[aria-pressed="true"] { background: var(--muted); border-color: var(--muted); color: #fff; }
.task-body { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 10px; }
.task-title { font-size: .94rem; }
.task-meta { display: flex; align-items: center; gap: 8px; font-size: .8rem; }
.task[data-status="completada"] .task-title { color: var(--muted); text-decoration: line-through; }
.task[data-status="no_aplica"] .task-title { color: var(--muted); font-style: italic; }
.task[data-status="completada"] .late, .task[data-status="no_aplica"] .late { display: none; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 14px; padding: 6px 0; font-size: .92rem; }
.timeline time { flex: none; width: 44px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Formularios ---------- */
.form-card { max-width: 860px; }
.form-grid { display: grid; gap: 0 18px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .field.wide { grid-column: 1 / -1; } }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
.field select, .field textarea, .tt-row input, .tt-row select {
  font: inherit; font-weight: 400; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
.field textarea { resize: vertical; }
.field.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; color: var(--ink); }
.field.check input { width: 18px; height: 18px; padding: 0; }
.field.has-error input, .field.has-error select { border-color: var(--bad); }
.help { font-weight: 400; color: var(--muted); }
.err { font-weight: 500; color: var(--bad); }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.form-actions.sticky { position: sticky; bottom: 76px; padding: 12px 0; }
@media (min-width: 900px) { .form-actions.sticky { bottom: 0; } }

.preview-list { list-style: none; margin: 0; padding: 0; font-size: .92rem; }
.preview-list li { padding: 3px 0; }
#preview h4 { margin: 14px 0 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* Editor de checklist de la plantilla */
.tt-table { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.tt-row { display: grid; grid-template-columns: 64px 1fr; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.tt-row label { display: flex; flex-direction: column; min-width: 0; }
.tt-row input, .tt-row select { width: 100%; padding: 8px 10px; font-size: .9rem; }
.tt-row .tt-title { grid-column: 1 / -1; order: -1; }
.tt-row.has-error { border-color: var(--bad); }
.tt-head { display: none; }
.tt-del { flex-direction: row !important; align-items: center; gap: 6px; }
.tt-del input { width: 18px; height: 18px; }
@media (min-width: 900px) {
  .tt-row { grid-template-columns: 64px 140px minmax(0, 1fr) 150px 110px 72px 52px; align-items: start; padding: 0; border: 0; border-radius: 0; }
  .tt-row .tt-title { grid-column: auto; order: 0; }
  .tt-head { display: grid; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
  .tt-del { justify-content: center; padding-top: 10px; }
}

/* ---------- Servicios ---------- */
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.tile { display: block; margin: 0; color: var(--ink); transition: border-color .15s; }
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile.inactive { opacity: .6; }
.tile-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.tile h3 { margin: 0; font-size: 1.02rem; }
.tile .clamp { margin-top: 6px; font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 12px; font-size: .8rem; color: var(--muted); }

/* ---------- Pendientes y HOY ---------- */
.n {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; text-align: center; line-height: 18px;
  background: var(--bg); color: var(--ink-2);
}
.chip .n { margin-left: 4px; background: rgba(127, 127, 127, .14); color: inherit; }
.chip.alert { color: var(--bad); border-color: var(--bad); }
.chip.alert.on { background: var(--bad); color: #fff; }
.chips.subtle .chip { padding: 4px 12px; font-size: .8rem; }
.card.tone-bad .n, .group-atrasados .n { background: var(--bad-soft); color: var(--bad); }
.group-atrasados h2 { color: var(--bad); }

.task-main { display: flex; flex-direction: column; min-width: 0; }
.task-who { font-size: .8rem; color: var(--muted); }
.task-who a { color: var(--ink-2); font-weight: 500; }
.task-meta .edit { color: var(--muted); padding: 2px 4px; border-radius: 6px; font-size: .9rem; }
.task-meta .edit:hover { color: var(--ink); background: var(--bg); text-decoration: none; }
.today-tag { color: var(--accent); font-weight: 600; }
@media (max-width: 599px) {
  .task { align-items: flex-start; }
  .task-body { flex-direction: column; align-items: flex-start; gap: 2px; }
}
.lead { margin: -8px 0 16px; }
.link-btn.danger { color: var(--bad); }

.btn.alert-btn { color: var(--bad); border-color: var(--bad); }
.btn.alert-btn:hover { background: var(--bad-soft); text-decoration: none; }

.day.past { opacity: .55; }
.day-pending { display: flex; flex-direction: column; margin-top: 6px; font-size: .78rem; color: var(--ink-2); }
.day-pending:hover { text-decoration: none; color: var(--accent); }
@media (max-width: 599px) { .day-pending { flex-direction: row; flex-wrap: wrap; gap: 0 8px; margin: 0; justify-content: flex-end; } }
.day-appts { list-style: none; margin: 6px 0 0; padding: 0; font-size: .78rem; }
.day-appts li { margin-bottom: 3px; }
.day-appts a { color: var(--ink); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-appts b { color: var(--accent); font-weight: 600; }
@media (max-width: 599px) {
  .day { flex-wrap: wrap; }
  .day-appts { flex-basis: 100%; order: 3; }
}

/* ---------- Próxima sesión (HOY) ---------- */
.ns-main { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.ns-title { font-size: 1.15rem; font-weight: 600; letter-spacing: -.01em; }
.ns-title a { color: var(--ink); }
.ns-time { color: var(--accent); font-variant-numeric: tabular-nums; margin-right: 4px; }
.ns-meta { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.ns-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ns-prep-label { margin-top: 14px; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ns-prep { list-style: none; margin: 4px 0 0; padding: 0; font-size: .9rem; color: var(--ink-2); }

/* ---------- Lista de citas ---------- */
.appts { list-style: none; margin: 0; padding: 0; }
.appt { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.appt:last-child { border-bottom: 0; }
.appt-time { flex: none; width: 62px; display: flex; flex-direction: column; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.appt-time:hover { text-decoration: none; }
.appt-time small { font-weight: 400; font-size: .75rem; color: var(--muted); }
.appt-time .appt-date { order: -1; color: var(--ink-2); }
.appt-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.appt-who { font-weight: 600; color: var(--ink); }
.appt-what { font-size: .88rem; color: var(--ink-2); }
.appt-meta { font-size: .78rem; color: var(--muted); }
.appt.s-cancelada .appt-who, .appt.s-cancelada .appt-what { text-decoration: line-through; color: var(--muted); }
.btn.meet { padding: 6px 12px; font-size: .82rem; }
details.past { margin-top: 10px; }
details.past summary { cursor: pointer; font-size: .85rem; color: var(--muted); }

.sched { font-size: .78rem; font-weight: 600; color: var(--accent); white-space: nowrap; }
.agendar {
  font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 6px; border: 1px solid var(--accent); color: var(--accent);
}
.agendar:hover { background: var(--accent); color: #fff; text-decoration: none; }

/* ---------- Calendario ---------- */
.cal-bar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; margin-left: -1px; padding: 7px 14px; }
.seg .btn:first-child { border-radius: 10px 0 0 10px; margin-left: 0; }
.seg .btn:last-child { border-radius: 0 10px 10px 0; }
.seg .btn:hover { text-decoration: none; background: var(--bg); }
.seg .btn.on { background: var(--ink); border-color: var(--ink); color: var(--card); position: relative; }

.cal { --row: 52px; }
.cal-head, .cal-body { display: grid; grid-template-columns: 52px repeat(var(--cols), minmax(0, 1fr)); }
.cal-head { border-bottom: 1px solid var(--line); }
.cal-dayname { padding: 10px 6px; text-align: center; font-size: .75rem; font-weight: 600; text-transform: uppercase; color: var(--muted); }
.cal-dayname strong { display: block; font-size: 1.1rem; color: var(--ink); text-transform: none; }
.cal-dayname:hover { text-decoration: none; background: var(--bg); }
.cal-dayname.today strong { color: var(--accent); }
.cal-body { height: calc(var(--hours) * var(--row)); }
.cal-hours { display: flex; flex-direction: column; }
.cal-hours span { flex: 1; font-size: .7rem; color: var(--muted); text-align: right; padding: 2px 8px 0 0; font-variant-numeric: tabular-nums; }
.cal-col {
  position: relative; border-left: 1px solid var(--line);
  background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 100% var(--row);
}
.cal-col.today { background-color: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.cal-open { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--ok-soft) 55%, transparent); }
.cal-block {
  position: absolute; left: 0; right: 0;
  background: repeating-linear-gradient(45deg, var(--bg), var(--bg) 6px, var(--line) 6px, var(--line) 8px);
  opacity: .9;
}
.cal-event {
  position: absolute; left: 3px; right: 3px; overflow: hidden;
  padding: 3px 6px; border-radius: 8px; min-height: 20px;
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  color: var(--ink); font-size: .75rem; line-height: 1.25;
  display: flex; flex-direction: column;
}
.cal-event:hover { text-decoration: none; filter: brightness(.97); z-index: 2; }
.ev-time { font-weight: 700; color: var(--accent); }
.ev-who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-what { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event.s-realizada { background: var(--ok-soft); border-left-color: var(--ok); }
.cal-event.s-realizada .ev-time { color: var(--ok); }
.cal-event.s-no_asistio { background: var(--warn-soft); border-left-color: var(--warn); }
.cal-event.s-no_asistio .ev-time { color: var(--warn); }
.cal-event.s-cancelada { background: var(--bg); border-left-color: var(--muted); text-decoration: line-through; opacity: .7; }
.cal-event.s-cancelada .ev-time { color: var(--muted); }
.cal-day .cal-event { font-size: .85rem; flex-direction: row; flex-wrap: wrap; gap: 0 8px; align-content: flex-start; }

.cal-list { display: none; }
@media (max-width: 699px) {
  .cal:not(.cal-day) { display: none; }
  .cal-list { display: block; }
  .today-card { outline: 1px solid var(--accent); }
}

.month-head, .month-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-head span { padding: 8px; text-align: center; font-size: .72rem; font-weight: 600; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
.mday {
  min-height: 96px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px; color: var(--ink); overflow: hidden;
}
.month-row .mday:last-child { border-right: 0; }
.mday:hover { text-decoration: none; background: var(--bg); }
.mday.out { color: var(--muted); background: color-mix(in srgb, var(--bg) 60%, transparent); }
.mday.today .mnum { background: var(--accent); color: #fff; border-radius: 999px; }
.mday.blocked { background-image: repeating-linear-gradient(45deg, transparent, transparent 6px, var(--bg) 6px, var(--bg) 8px); }
.mnum { align-self: flex-start; min-width: 24px; padding: 1px 6px; font-size: .82rem; font-weight: 600; text-align: center; }
.mchip { font-size: .72rem; padding: 1px 5px; border-radius: 5px; background: var(--accent-soft); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mchip.s-realizada { background: var(--ok-soft); }
.mchip.s-no_asistio { background: var(--warn-soft); }
.mmore { font-size: .7rem; color: var(--muted); }
.mdots { display: none; color: var(--accent); letter-spacing: 1px; }
@media (max-width: 699px) {
  .mday { min-height: 54px; padding: 4px; }
  .mchip, .mmore { display: none; }
  .mdots { display: block; }
}

/* ---------- Formulario de cita ---------- */
.slots-box { margin: 4px 0 14px; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 14px; }
.slot {
  font: inherit; font-size: .88rem; font-variant-numeric: tabular-nums;
  padding: 6px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer;
}
.slot:hover { border-color: var(--accent); color: var(--accent); }
.slot.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Vista de cita ---------- */
.session { border-left: 4px solid var(--accent); }
.session.s-realizada { border-left-color: var(--ok); }
.session.s-no_asistio { border-left-color: var(--warn); }
.session.s-cancelada { border-left-color: var(--muted); }
.session-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.session-time { font-size: 1.8rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.session-time span { display: block; font-size: .85rem; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.session-links { display: flex; gap: 16px; margin-top: 14px; font-size: .9rem; }
.ask { font-weight: 600; margin: 4px 0 10px; }
.form-actions.wrap { flex-wrap: wrap; }
.secondary-actions { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.btn.danger-outline { color: var(--bad); border-color: var(--bad); }
.btn.danger-outline:hover { background: var(--bad-soft); text-decoration: none; }
.next-step { border-left: 4px solid var(--ok); }

/* ---------- Disponibilidad ---------- */
.week-summary { display: grid; gap: 6px; margin-bottom: 16px; font-size: .9rem; }
.week-summary strong { display: inline-block; width: 92px; }
.pill { display: inline-block; padding: 1px 8px; margin-right: 4px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .8rem; font-weight: 600; }
.rule-rows { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.rule-row { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr 1fr 48px; gap: 8px; align-items: center; }
.rule-row label { display: flex; flex-direction: column; min-width: 0; }
.rule-row select, .rule-row input {
  font: inherit; color: var(--ink); padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--card); width: 100%;
}
.rule-head { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.rule-row.has-error select, .rule-row.has-error input { border-color: var(--bad); }
.plain-list { list-style: none; margin: 0 0 14px; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.sub-form { margin-top: 10px; padding-top: 14px; border-top: 1px dashed var(--line); }

/* ---------- Google ---------- */
.bullets, .steps { margin: 8px 0 0; padding-left: 20px; font-size: .92rem; color: var(--ink-2); }
.bullets li, .steps li { margin-bottom: 6px; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .82rem; background: var(--bg); padding: 1px 6px; border-radius: 6px; }
code.copy { display: inline-block; margin-top: 4px; padding: 6px 10px; user-select: all; overflow-wrap: anywhere; }
.sync-line { margin-top: 12px; font-size: .85rem; color: var(--ink-2); }
.ok-text { color: var(--ok); font-weight: 600; }
form.inline { display: inline; }

/* ---------- Mensajes ---------- */
.vars summary { cursor: pointer; font-weight: 600; }
.var-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; font-size: .88rem; color: var(--ink-2); }
@media (min-width: 640px) { .var-list { grid-template-columns: 1fr 1fr; } }
.tpl-grid { display: grid; gap: 18px; }
@media (min-width: 900px) { .tpl-grid { grid-template-columns: 1fr 1fr; } }
.preview { background: var(--bg); border-radius: 12px; padding: 14px 16px; font-size: .9rem; }
.preview-subject { font-weight: 600; margin: 4px 0 10px; }
.preview-body { color: var(--ink-2); line-height: 1.55; }
.comm { align-items: flex-start !important; }

/* ---------- Recordatorios ---------- */
.row-actions { display: flex; align-items: center; gap: 12px; font-size: .88rem; flex: none; }
fieldset.checks { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 6px; margin: 0 0 14px; }
fieldset.checks legend { font-size: .85rem; font-weight: 600; color: var(--ink-2); padding: 0 4px; }
fieldset.checks div { display: grid; gap: 4px; }
fieldset.checks label { display: flex; align-items: center; gap: 8px; font-size: .9rem; }

/* ---------- WhatsApp ---------- */
.meta-text {
  white-space: pre-wrap; font-family: inherit; font-size: .9rem; color: var(--ink);
  background: var(--bg); border: 1px dashed var(--line); border-radius: 10px;
  padding: 10px 12px; margin: 6px 0 14px; user-select: all;
}

/* ---------- Páginas públicas (Reservas) ---------- */
body.public { min-height: 100vh; display: flex; flex-direction: column; }
.pub-head { background: var(--navy); padding: 14px 16px calc(14px + env(safe-area-inset-top) * 0); }
.pub-head .brand { color: #fff; max-width: 640px; margin: 0 auto; }
.pub-head .brand strong { color: #fff; }
.pub-head .brand small { color: #8e9ab3; font-size: .75rem; }
.pub-main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 20px 16px 32px; }
.pub-main h1 { margin: 6px 0 6px; }
.pub-main .eyebrow a { color: var(--muted); }
.pub-foot { text-align: center; padding: 16px; }
.steps-bar { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0 0 18px; padding: 0; }
.steps-bar li { font-size: .72rem; font-weight: 600; color: var(--muted); padding-top: 8px; border-top: 3px solid var(--line); }
.steps-bar li.on { color: var(--accent); border-top-color: var(--accent); }
.pub-service { margin-bottom: 12px; }
.pub-service h3 { margin: 0 0 4px; }
.pager { display: flex; gap: 12px; font-size: .85rem; }
.day-picker { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.dpick {
  flex: none; width: 64px; padding: 8px 0; border-radius: 12px; text-align: center;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: flex; flex-direction: column; line-height: 1.2;
}
.dpick:hover { text-decoration: none; border-color: var(--accent); }
.dpick.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.dpick.off { opacity: .4; }
.dpick .dw { font-size: .72rem; text-transform: uppercase; font-weight: 600; }
.dpick .dn { font-size: 1.3rem; font-weight: 700; }
.dpick .dm { font-size: .72rem; }
.summary { border-left: 4px solid var(--accent); }
.sum-main { font-size: 1.1rem; font-weight: 600; margin-top: 4px; }
.sum-when { color: var(--ink-2); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
a.slot { display: inline-block; }
a.slot:hover { text-decoration: none; }
.card.tone-new { border-left: 4px solid var(--ok); }
