/* ─── Admin panel — same palette as the public site ───────────── */
:root {
  --cream: #F6F0EB;
  --paper: #FFFFFF;
  --sand: #EFE4DC;
  --sand-deep: #DCCABA;
  --ink: #2F2427;
  --ink-soft: #66575B;
  --ink-faint: #9A8A8D;
  --wine: #63242F;
  --wine-deep: #4A1A23;
  --wine-tint: #F1E0E0;
  --rose: #E6CECE;
  --taupe-deep: #7D6043;
  --border: #E7DAD1;
  --error: #A3303A;
  --ok: #3F6A3A;
  --ok-tint: #E3EDDF;
  --warn: #8A5A12;
  --warn-tint: #F6EAD2;
  --font-serif: "Lora", Georgia, serif;
  --font-sans: "Raleway", "Segoe UI", system-ui, sans-serif;
  --radius: 14px;
  color-scheme: light;
}
@font-face { font-family: "Lora"; font-weight: 400 700; font-display: swap; src: url("/fonts/lora-latin.woff2") format("woff2"); }
@font-face { font-family: "Raleway"; font-weight: 100 900; font-display: swap; src: url("/fonts/raleway-latin.woff2") format("woff2"); }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 15px/1.55 var(--font-sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-serif); font-weight: 500; margin: 0 0 .6em; line-height: 1.2; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
a { color: var(--wine); }
:focus-visible { outline: 3px solid var(--wine); outline-offset: 2px; border-radius: 4px; }

/* ─── Controls ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 2.6rem; padding: .5rem 1.1rem; border-radius: 999px;
  border: 1.5px solid transparent; font: 600 .93rem var(--font-sans);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn--primary { background: var(--wine); color: #fff; }
.btn--primary:hover { background: var(--wine-deep); }
.btn--ghost { background: var(--paper); color: var(--ink); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--sand-deep); }
.btn--danger { background: var(--paper); color: var(--error); border-color: var(--rose); }
.btn--danger:hover { background: var(--wine-tint); }
.btn--sm { min-height: 2.2rem; padding: .3rem .9rem; font-size: .88rem; }
.btn[disabled] { opacity: .6; cursor: progress; }
.link { color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: .9rem; }
.link:hover { color: var(--wine); }

.field { display: grid; gap: .35rem; font-weight: 600; font-size: .9rem; }
input, select, textarea {
  width: 100%; font: 400 .95rem var(--font-sans); color: var(--ink);
  background: var(--paper); border: 1.5px solid var(--border); border-radius: 10px;
  padding: .6rem .8rem; min-height: 2.6rem;
}
textarea { min-height: 8rem; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--wine); box-shadow: 0 0 0 3px var(--wine-tint); }

.alert { margin: 0; padding: .7rem .9rem; border-radius: 10px; background: var(--wine-tint); color: var(--error); font-weight: 500; }
.alert--ok { background: var(--ok-tint); color: var(--ok); }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }

/* ─── Login ─────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 16px; }
.login__card {
  width: min(100%, 380px); background: var(--paper); border: 1px solid var(--border);
  border-radius: 20px; padding: 2rem; display: grid; gap: 1rem;
  box-shadow: 0 20px 50px -30px rgba(47, 36, 39, .35);
}
.login__card h1 { margin: .5rem 0 0; }

.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 600; font-size: .9rem; color: var(--ink-soft); }
.brand__mark {
  display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%;
  background: var(--wine); color: var(--cream); font: 600 .8rem var(--font-serif); letter-spacing: .04em;
}

/* ─── Shell ─────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.5rem;
  padding: .75rem 16px; background: color-mix(in srgb, var(--cream) 92%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs a {
  padding: .45rem .9rem; border-radius: 999px; text-decoration: none; color: var(--ink);
  font-weight: 600; font-size: .92rem;
}
.tabs a:hover { background: var(--sand); }
.tabs a[aria-current="page"] { background: var(--wine); color: #fff; }
.badge { display: inline-block; min-width: 1.3rem; padding: 0 .35rem; border-radius: 999px; background: var(--rose); color: var(--wine-deep); font-size: .75rem; text-align: center; }
.tabs a[aria-current="page"] .badge { background: var(--cream); }
@media (max-width: 640px) { .brand__text { display: none; } }

.content { max-width: 1120px; margin: 0 auto; padding: 1.75rem 16px 4rem; outline: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }

.panel { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.grid { display: grid; gap: 1rem; }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1rem; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-top: 1rem; }

/* ─── Stat tiles ────────────────────────────────────────────── */
.kpi { display: grid; gap: .15rem; }
.kpi__label { font-size: .85rem; color: var(--ink-soft); font-weight: 600; }
.kpi__value { font: 500 2rem/1.1 var(--font-serif); color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi__hint { font-size: .8rem; color: var(--ink-faint); }

/* ─── Bar chart (single series: daily visits) ──────────────── */
.chart__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem; }
.chart__scroll { overflow-x: auto; }
.chart { display: block; width: 100%; min-width: 520px; height: 200px; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--ink-faint); font: 11px var(--font-sans); }
.chart .bar { fill: var(--wine); }
.chart .bar-hit { fill: transparent; cursor: default; }
.chart .bar-hit:hover + .bar, .chart .bar.is-active { fill: var(--wine-deep); }
.chart .lead-dot { fill: var(--taupe-deep); stroke: var(--paper); stroke-width: 2; }
.legend { display: flex; gap: 1rem; font-size: .82rem; color: var(--ink-soft); margin: .25rem 0 .75rem; }
.legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.legend .l-views { background: var(--wine); }
.legend .l-leads { background: var(--taupe-deep); border-radius: 50%; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--cream);
  padding: .5rem .7rem; border-radius: 8px; font-size: .82rem; line-height: 1.45;
  box-shadow: 0 10px 24px -12px rgba(0,0,0,.4); white-space: nowrap;
}
.tooltip strong { color: #fff; }

/* ─── Ranked lists ──────────────────────────────────────────── */
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.rank li { display: grid; grid-template-columns: 1fr auto; gap: .2rem .75rem; font-size: .9rem; }
.rank__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank__n { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-weight: 600; }
.rank__bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--sand); overflow: hidden; }
.rank__bar span { display: block; height: 100%; background: var(--rose); border-radius: 3px; }
.empty { color: var(--ink-faint); font-size: .9rem; margin: 0; }

/* ─── Leads ─────────────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters input { max-width: 260px; }
.chip {
  border: 1.5px solid var(--border); background: var(--paper); border-radius: 999px;
  padding: .35rem .85rem; font: 600 .85rem var(--font-sans); color: var(--ink); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--wine); border-color: var(--wine); color: #fff; }
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); background: var(--cream); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--cream); }
tbody tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; min-width: 180px; }
.is-new td:first-child { box-shadow: inset 3px 0 0 var(--wine); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }

.status { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.status--nueva { background: var(--wine); color: #fff; }
.status--contactada { background: var(--warn-tint); color: var(--warn); }
.status--primera_charla { background: var(--rose); color: var(--wine-deep); }
.status--en_terapia { background: var(--ok-tint); color: var(--ok); }
.status--descartada { background: var(--sand); color: var(--ink-soft); }

.detail { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 820px) { .detail { grid-template-columns: 1fr; } }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1rem; margin: 0; }
.dl dt { color: var(--ink-soft); font-size: .85rem; font-weight: 600; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.message { white-space: pre-wrap; background: var(--cream); border-radius: 10px; padding: .9rem 1rem; margin: 1rem 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 0; }
.stack { display: grid; gap: .9rem; }
.confirm { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .75rem; border-radius: 10px; background: var(--wine-tint); }
.back { display: inline-block; margin-bottom: .75rem; }
.m0 { margin: 0 !important; }
.narrow { max-width: 460px; }

/* ─── Agenda ─────────────────────────────────────────────────── */
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--wine); text-decoration: underline; cursor: pointer; }
.notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.notice--cta { border-color: var(--rose); background: #FBF3F2; }
.cal-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin: 1rem 0 .25rem; }
.cal-title { font-family: var(--font-serif); font-weight: 500; font-size: 1.15rem; margin-left: .5rem; }
.legend .l-appt { background: var(--wine); }
.legend .l-other { background: var(--sand-deep); }
.cal-panel { padding: 0; overflow: hidden; }
.cal-scroll { overflow-x: auto; }

/* Week */
.wk { display: grid; grid-template-columns: 3.5rem repeat(7, minmax(110px, 1fr)); min-width: 820px; }
.wk__head { height: 2.6rem; display: flex; align-items: center; justify-content: center; gap: .3rem; font-size: .85rem; color: var(--ink-soft); border-bottom: 1px solid var(--border); text-transform: capitalize; }
.wk__head strong { font: 500 1.05rem var(--font-serif); color: var(--ink); }
.is-today .wk__head strong { background: var(--wine); color: #fff; border-radius: 999px; padding: 0 .45rem; }
.wk__allday { min-height: 1.6rem; padding: 2px; border-bottom: 1px solid var(--border); display: grid; gap: 2px; }
.wk__col { border-left: 1px solid var(--border); }
.wk__col.is-today { background: #FBF3F2; }
.wk__body { position: relative; background-image: linear-gradient(var(--border) 1px, transparent 1px); background-size: 100% 48px; }
.wk__gutter .wk__body { background: none; }
.wk__hour { display: block; height: 48px; font-size: .72rem; color: var(--ink-faint); text-align: right; padding-right: .4rem; transform: translateY(-.5em); }

.ev {
  position: absolute; left: 3px; right: 3px; overflow: hidden; border-radius: 6px;
  padding: 2px 6px; font-size: .78rem; line-height: 1.3; text-decoration: none;
  background: var(--sand); color: var(--ink); border-left: 3px solid var(--sand-deep);
}
.ev:hover { filter: brightness(.97); }
.ev__time { font-weight: 700; }
.ev--appt { background: var(--wine); color: #fff; border-left-color: var(--wine-deep); }
.ev--appt.ev--realizada { background: var(--ok-tint); color: var(--ok); border-left-color: var(--ok); }
.ev--appt.ev--no_asistio { background: var(--warn-tint); color: var(--warn); border-left-color: var(--warn); }
.ev--allday, .ev--chip { position: static; display: block; white-space: nowrap; text-overflow: ellipsis; }

/* Month */
.mo { display: grid; grid-template-columns: repeat(7, minmax(100px, 1fr)); min-width: 720px; }
.mo__dow { padding: .5rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); background: var(--cream); border-bottom: 1px solid var(--border); }
.mo__cell { min-height: 6.5rem; padding: .35rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: grid; align-content: start; gap: 3px; }
.mo__cell:nth-child(7n + 7) { border-right: 0; }
.mo__cell.is-out { background: #FAF6F3; }
.mo__cell.is-out .mo__num { color: var(--ink-faint); }
.mo__cell.is-today { background: #FBF3F2; }
.mo__num { font-size: .82rem; font-weight: 600; }
.is-today .mo__num { color: var(--wine); }

/* Appointments inside a lead */
.appt-panel { margin-top: 1rem; }
.appt-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .75rem; }
.appt { display: grid; gap: .5rem; padding: .8rem .9rem; border: 1px solid var(--border); border-radius: 10px; }
.appt__main { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.appt__move { display: flex; gap: .5rem; flex-wrap: wrap; }
.appt__move input { max-width: 240px; }
.appt-form { display: grid; gap: .9rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.appt-form h3 { margin: 0; font-size: 1.05rem; }
.appt-form__row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.check input { width: auto; min-height: 0; }
.status--appt-programada { background: var(--rose); color: var(--wine-deep); }
.status--appt-realizada { background: var(--ok-tint); color: var(--ok); }
.status--appt-cancelada { background: var(--sand); color: var(--ink-soft); }
.status--appt-no_asistio { background: var(--warn-tint); color: var(--warn); }
