/* Medesthetique — panel de la clínica */

.admin { --side-w: 248px; background: var(--admin-bg); }

/* Acceso */
.login { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: radial-gradient(70% 80% at 80% 10%, rgba(79, 151, 179, 0.45), transparent 60%), linear-gradient(140deg, var(--brand-navy), var(--navy-ink)); }
.login.is-hidden { display: none; }
.login-card { width: min(410px, 100%); display: grid; gap: 14px; padding: 34px 28px; border-radius: var(--radius); background: var(--pearl); text-align: center; box-shadow: var(--shadow); }
.login-card .wordmark { margin: 0 auto 6px; }
.login-card h1 { font-size: 2.2rem; color: var(--navy); }
.login-card .field { text-align: left; }

/* Barra lateral */
.side { position: fixed; inset: 0 auto 0 0; z-index: 60; width: var(--side-w); display: flex; flex-direction: column; gap: 26px; padding: 24px 14px; background: var(--navy-ink); color: #fff; transition: transform 0.35s var(--ease); }
.side-brand { align-items: flex-start; padding-left: 10px; }
.side-brand b { font-size: 1.3rem; }
.side-nav { display: grid; gap: 3px; align-content: start; flex: 1; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; text-decoration: none; font-size: 0.92rem; font-weight: 500; color: rgba(255, 255, 255, 0.74); transition: 0.2s; }
.side-nav a svg { width: 19px; height: 19px; flex: none; }
.side-nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side-nav a[aria-current='page'] { background: rgba(155, 201, 216, 0.16); color: #fff; box-shadow: inset 2px 0 0 var(--powder); }
.side-nav .count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--powder); color: var(--navy-ink); font-size: 0.72rem; font-weight: 700; text-align: center; }
.side-foot { display: grid; gap: 12px; justify-items: start; }
.side-site { background: rgba(255, 255, 255, 0.08); color: #fff; border-color: rgba(255, 255, 255, 0.16); }

.main { margin-left: var(--side-w); min-height: 100dvh; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 16px clamp(16px, 3vw, 34px); background: var(--admin-top); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.top h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); color: var(--navy-ink); line-height: 1; }
.top .note::first-letter { text-transform: uppercase; }
.top-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.side-toggle { display: none; }
.view { display: grid; gap: 18px; align-content: start; padding: clamp(16px, 3vw, 34px); }
@media (max-width: 920px) {
  .side { transform: translateX(-105%); box-shadow: var(--shadow); }
  .side.is-open { transform: none; }
  .main { margin-left: 0; }
  .side-toggle { display: inline-grid; }
}

/* Tarjetas e indicadores */
.panel-card { min-width: 0; padding: 20px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }
.panel-card > h2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted); }
.panel-card > h2 .link { font-size: 0.8rem; letter-spacing: 0; text-transform: none; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { display: grid; gap: 4px; padding: 18px 20px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }
.kpi span { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.kpi strong { font-family: var(--font-display); font-weight: 400; font-size: clamp(2rem, 3.4vw, 2.7rem); line-height: 1; color: var(--navy); }
.kpi .kpi-text { font-size: 1.8rem; }
.kpi small { font-size: 0.76rem; color: var(--muted); }
.kpi.accent { background: linear-gradient(140deg, var(--brand-navy), #14233f); border-color: transparent; }
.kpi.accent span, .kpi.accent small { color: rgba(255, 255, 255, 0.7); }
.kpi.accent strong { color: #fff; }
.cols { display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; }
.cols-even { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1180px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols, .cols-even, .cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .kpis { grid-template-columns: 1fr 1fr; gap: 10px; } .kpi { padding: 14px; } }

/* Gráficos */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-body); font-size: 10px; fill: var(--muted); }
.chart text.is-today { fill: var(--navy); font-weight: 700; }
.chart .grid { stroke: var(--line); }
.chart .today-line { stroke: var(--navy); stroke-dasharray: 3 3; opacity: 0.5; }
.legend { display: inline-flex; gap: 12px; align-items: center; font-size: 0.74rem; letter-spacing: 0; text-transform: none; font-weight: 500; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1.2fr) 1fr auto; gap: 10px; align-items: center; padding: 6px 0; font-size: 0.86rem; }
.hbar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar i { height: 8px; border-radius: 8px; background: var(--powder-100); overflow: hidden; }
.hbar b { display: block; height: 100%; border-radius: 8px; background: var(--sea); }
.hbar em { font-style: normal; font-weight: 700; color: var(--navy); min-width: 2ch; text-align: right; }

/* Listas */
.list { display: grid; gap: 6px; }
.row-btn { width: 100%; display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--pearl); text-align: left; transition: 0.2s; }
.row-btn:hover { border-color: var(--line-strong); background: var(--surface); }
.row-btn > b { min-width: 46px; color: var(--navy); }
.row-btn > span:not(.tag) { flex: 1; min-width: 0; display: grid; font-weight: 600; font-size: 0.9rem; }
.row-btn small { font-weight: 400; font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg-mini { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.seg-mini:last-child { border-bottom: 0; }
.seg-mini > span { flex: 1; min-width: 0; display: grid; font-size: 0.9rem; }
.seg-mini small { color: var(--muted); font-size: 0.78rem; }

/* Barra de herramientas */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.datenav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.datenav > div { display: grid; min-width: 210px; }
.datenav > div b { font-family: var(--font-display); font-weight: 400; font-size: 1.6rem; line-height: 1.1; }
.datenav > div b::first-letter { text-transform: uppercase; }
.datenav > div small { color: var(--muted); font-size: 0.8rem; }
.datenav .input { width: auto; }
.seg-wrap { flex-wrap: wrap; border-radius: 18px; }
.seg-scroll { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg-scroll button { flex: none; }
.search-input { max-width: 380px; border-radius: 999px; }

/* Agenda */
.agenda { display: grid; gap: 0; border-radius: 20px; overflow: clip; background: var(--surface); border: 1px solid var(--line); }
.agenda-head, .agenda-row { display: grid; grid-template-columns: 70px repeat(var(--cols), minmax(0, 1fr)); }
.agenda-head { position: sticky; top: 88px; z-index: 2; background: var(--pearl); border-bottom: 1px solid var(--line); }
.agenda-head b { padding: 12px 14px; font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--navy); border-left: 1px solid var(--line); }
.agenda-row { border-bottom: 1px solid var(--line); min-height: 58px; }
.agenda-row:last-child { border-bottom: 0; }
.agenda-time { padding: 10px 12px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.agenda-cell { display: flex; gap: 6px; padding: 6px; border-left: 1px solid var(--line); min-width: 0; }
.appt { flex: 1; min-width: 0; display: grid; gap: 1px; padding: 8px 10px; border-radius: 12px; border: 0; border-left: 3px solid var(--sea); background: var(--powder-100); text-align: left; font-size: 0.82rem; transition: transform 0.2s var(--ease), box-shadow 0.2s; }
.appt:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.appt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt small, .appt span { font-size: 0.74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt span svg { display: inline; width: 12px; height: 12px; vertical-align: -2px; }
.appt.st-pendiente { background: var(--warn-bg); border-left-color: var(--warn); }
.appt.st-atendida { background: var(--ok-bg); border-left-color: var(--ok); }
.appt.st-no-asistio { background: var(--danger-bg); border-left-color: var(--danger); }
.appt.st-cancelada { background: var(--muted-bg); border-left-color: #b9bcc6; opacity: 0.6; text-decoration: line-through; }
.appt-add { flex: none; width: 34px; border-radius: 10px; border: 1px dashed var(--line-strong); background: none; color: var(--muted); display: grid; place-items: center; opacity: 0; transition: opacity 0.2s; }
.appt-add svg { width: 16px; height: 16px; }
.agenda-cell:hover .appt-add, .appt-add:focus-visible { opacity: 1; }
.agenda-cell:not(:has(.appt)) .appt-add { flex: 1; opacity: 0.35; }
.empty-day { text-align: center; color: var(--muted); padding: 40px; }
@media (max-width: 760px) {
  .agenda-head, .agenda-row { grid-template-columns: 54px repeat(var(--cols), minmax(150px, 1fr)); }
  .agenda { overflow-x: auto; }
  .agenda-head { position: static; }
  .appt-add { opacity: 0.35; }
}

/* Tablas */
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { position: sticky; top: 0; padding: 12px 16px; text-align: left; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); background: var(--pearl); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td small { display: block; font-size: 0.78rem; color: var(--muted); }
.table tbody tr[data-paciente] { cursor: pointer; transition: background 0.15s; }
.table tbody tr[data-paciente]:hover { background: var(--pearl); }
.table .code { font-family: ui-monospace, monospace; letter-spacing: 0.04em; color: var(--navy); }
.table-edit td { vertical-align: middle; }
.table-edit td:nth-child(2) { min-width: 260px; }
.table-edit td small { margin-top: 4px; max-width: 52ch; }
.money-in { display: flex; align-items: center; gap: 6px; }
.money-in .input { width: 110px; }
.money-in span { color: var(--muted); font-size: 0.85rem; }

/* Interruptor */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background 0.25s; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.25s var(--ease); }
.switch input:checked + i { background: var(--navy); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:disabled + i { opacity: 0.5; }
.switch input:focus-visible + i { outline: 2px solid var(--sea); outline-offset: 2px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch-row > span { display: grid; font-size: 0.9rem; }
.switch-row small { font-size: 0.78rem; color: var(--muted); }

/* Seguimiento */
.follow { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.follow-card { display: grid; gap: 10px; align-content: start; }
.follow-card.is-done { opacity: 0.65; }
.follow-head { display: flex; align-items: center; gap: 10px; }
.follow-head .link { border: 0; background: none; padding: 0; font-size: 1.02rem; }
.follow-card > p { font-size: 0.88rem; }
.follow-card blockquote { margin: 0; padding: 12px 14px; border-radius: 14px; background: var(--wa-bg); font-size: 0.86rem; color: var(--wa-ink); }
.follow-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.follow-actions .link { border: 0; background: none; padding: 0; font-size: 0.82rem; }

/* Formularios del panel */
.form-card { display: grid; gap: 14px; align-content: start; }
.form-card .btn { justify-self: start; }
.sedes-edit { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.sede-edit { display: grid; gap: 8px; padding: 14px; border-radius: 16px; background: var(--pearl); border: 1px solid var(--line); }
.sede-edit .switch-row { border: 0; padding-top: 0; }
.hours { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.86rem; }
.hours span { min-width: 110px; color: var(--muted); }
.hours .input { width: auto; }
.danger-card { background: var(--pearl); }
.sculpt-pick { display: grid; gap: 8px; margin-top: 12px; }
.sculpt-pick label { cursor: pointer; }
.sculpt-pick input { position: absolute; opacity: 0; }
.sculpt-pick span { display: grid; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line-strong); transition: 0.2s; }
.sculpt-pick small { color: var(--muted); font-size: 0.78rem; }
.sculpt-pick input:checked + span { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); background: var(--powder-100); }
.sculpt-pick input:focus-visible + span { outline: 2px solid var(--sea); outline-offset: 2px; }
.top .theme-btn { margin-left: 4px; }
:root[data-theme-resolved='dark'] .side { background: #070c15; border-right: 1px solid var(--line); }
.danger-card .btn { margin-top: 12px; }

/* Cajón y fichas */
.drawer-wide { width: min(100%, 560px); }
.drawer-xl { width: min(100%, 760px); }
.detail { display: grid; gap: 18px; align-content: start; }
.detail-person { display: flex; align-items: center; gap: 12px; }
.detail-person > div { flex: 1; display: grid; }
.detail-person small { color: var(--muted); font-size: 0.82rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.detail-grid .full { grid-column: 1 / -1; }
.detail-grid dt { display: flex; align-items: center; gap: 6px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.detail-grid dt svg { width: 15px; height: 15px; color: var(--sea); }
.detail-grid dd { font-size: 0.94rem; }
.detail-grid dd .chip { margin: 0 4px 4px 0; }
.plan-list { display: grid; gap: 4px; font-size: 0.88rem; }
.plan-list b { color: var(--navy); margin-right: 4px; }
.alert-box { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--danger-bg); color: var(--danger); font-size: 0.88rem; font-weight: 600; }
.alert-box svg { width: 18px; height: 18px; flex: none; }
.avatar { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; background: linear-gradient(140deg, var(--powder-200), var(--blush)); color: var(--navy); font-weight: 700; font-size: 0.82rem; }

.ficha { display: grid; gap: 22px; align-content: start; }
.ficha-3d { position: relative; height: 320px; border-radius: 22px; overflow: hidden; background: radial-gradient(70% 80% at 50% 40%, var(--powder-200), var(--porcelain)); }
.ficha-3d canvas { width: 100%; height: 100%; opacity: 0; transition: opacity 1s var(--ease); cursor: grab; }
.ficha-3d canvas.is-ready { opacity: 1; }
.ficha-legend { position: absolute; left: 12px; bottom: 12px; right: 12px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 0.78rem; pointer-events: none; }
.ficha-legend b { margin-right: 4px; color: var(--navy); }
.ficha-legend .chip { min-height: 26px; background: var(--glass); }
.ficha-info { display: grid; gap: 14px; }
.alerts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.alerts .tag button { border: 0; background: none; color: inherit; padding: 0 0 0 4px; font-weight: 700; }
.alert-add { display: flex; gap: 6px; align-items: center; }
.alert-add .input { width: 190px; }
.sec-label { margin-bottom: 10px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted); }
.reg-form { display: grid; gap: 12px; padding: 16px; border-radius: 18px; background: var(--pearl); border: 1px solid var(--line); }
.reg-form .btn { justify-self: start; }
.zone-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.zone-pick label { cursor: pointer; }
.zone-pick input { position: absolute; opacity: 0; }
.zone-pick span { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 0.8rem; font-weight: 600; transition: 0.2s; }
.zone-pick input:checked + span { background: var(--navy); color: var(--on-accent); border-color: var(--navy); }
.zone-pick input:focus-visible + span { outline: 2px solid var(--sea); outline-offset: 2px; }
.timeline { display: grid; gap: 0; border-left: 1px solid var(--line-strong); margin-left: 6px; }
.timeline li { position: relative; display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 0 0 14px 18px; font-size: 0.9rem; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--sea); box-shadow: 0 0 0 3px var(--surface); }
.timeline li > span { font-size: 0.8rem; color: var(--muted); }
.timeline small { display: block; color: var(--muted); font-size: 0.78rem; }

.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { font-size: 2rem; }
.new-cita { display: grid; gap: 16px; }
@media (max-width: 560px) { .detail-grid { grid-template-columns: 1fr; } .timeline li { grid-template-columns: 1fr; gap: 2px; } .ficha-3d { height: 260px; } }
