/* ============================================================
   SONRISABOT — ADMIN CSS v2 · Premium SaaS 2026
   Fuente: DM Sans (display) + Geist Mono (datos)
   Paleta: verde esmeralda / blanco nieve / navy oscuro
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300..900;1,9..40,300..900&family=Geist+Mono:wght@400;500;600&display=swap");

/* ── TOKENS ─────────────────────────────────────────────── */
:root {
  color-scheme: light;
  font-family: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  color: #17201d;
  background: #f0f5f3;

  /* Marca */
  --brand:        #0b7567;
  --brand-strong: #065c51;
  --brand-light:  #1a9e8c;
  --brand-soft:   #e0f4f0;
  --brand-glow:   rgba(11, 117, 103, 0.18);
  --brand-rim:    rgba(11, 117, 103, 0.28);

  /* Neutrales */
  --ink:    #14201c;
  --ink-2:  #263730;
  --muted:  #5e6f6a;
  --soft:   #edf3f1;
  --line:   #dce5e2;
  --panel:  #ffffff;
  --navy:   #192a3a;

  /* Semánticos */
  --amber:  #b7791f;
  --danger: #b3261e;
  --info:   #254d78;

  /* Superficies glass */
  --glass-bg:     rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.55);
  --glass-blur:   saturate(1.8) blur(20px);

  /* Sidebar */
  --sidebar-bg:     rgba(250, 253, 252, 0.95);
  --sidebar-w:      268px;

  /* Sombras */
  --shadow-xs:  0 1px 2px rgba(20,32,28,.05);
  --shadow-sm:  0 2px 8px rgba(20,32,28,.07), 0 1px 2px rgba(20,32,28,.04);
  --shadow-md:  0 8px 24px rgba(20,32,28,.09), 0 2px 6px rgba(20,32,28,.05);
  --shadow-lg:  0 20px 48px rgba(20,32,28,.12), 0 4px 12px rgba(20,32,28,.06);
  --shadow-xl:  0 32px 80px rgba(20,32,28,.18), 0 8px 24px rgba(20,32,28,.08);
  --shadow-brand: 0 8px 24px rgba(11,117,103,.22);

  /* Radios */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  /* Timings */
  --ease-out-quart: cubic-bezier(.25,.46,.45,.94);
  --ease-spring:    cubic-bezier(.34,1.56,.64,1);
  --t-fast:  120ms;
  --t-mid:   200ms;
  --t-slow:  320ms;

  /* Espaciado */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
}

/* ── RESET / BASE ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 60% at 10% -5%, rgba(11,117,103,.10) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 90% 100%, rgba(25,42,58,.07) 0%, transparent 50%),
    #f0f5f3;
}

/* Scrollbar personalizada */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(11,117,103,.22);
  transition: background var(--t-mid);
}
::-webkit-scrollbar-thumb:hover { background: rgba(11,117,103,.42); }

/* ── TIPOGRAFÍA ──────────────────────────────────────────── */
h1, h2, h3 {
  margin: 0;
  line-height: 1.08;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0 0 var(--sp-1);
  color: var(--brand);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.mono {
  font-family: "Geist Mono", monospace;
  font-size: .88em;
}

/* ── UTILIDADES ──────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

/* ── BOTONES ─────────────────────────────────────────────── */
button, input, select, textarea { font: inherit; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 38px;
  padding: 0 var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: #fff;
  background: linear-gradient(145deg, var(--brand-light), var(--brand-strong));
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: -.01em;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    background var(--t-mid) var(--ease-out-quart),
    box-shadow var(--t-mid) var(--ease-out-quart),
    transform var(--t-fast) var(--ease-spring),
    opacity var(--t-fast);
}

button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.15) 0%, transparent 60%);
  pointer-events: none;
}

button:hover {
  background: linear-gradient(145deg, var(--brand), var(--brand-strong));
  box-shadow: var(--shadow-brand);
  transform: translateY(-1px);
}

button:active { transform: translateY(0) scale(.98); }
button:disabled { cursor: wait; opacity: .55; }

.secondary-button {
  color: var(--ink-2);
  border-color: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-xs);
}

.secondary-button::after { display: none; }

.secondary-button:hover {
  color: var(--brand-strong);
  border-color: rgba(11,117,103,.35);
  background: var(--brand-soft);
  box-shadow: var(--shadow-sm);
}

.danger-button {
  color: var(--danger);
  border-color: #f4c7c3;
  background: #fff4f2;
  box-shadow: none;
}

.danger-button::after { display: none; }

.danger-button:hover {
  color: #8f1d17;
  background: #ffe7e3;
  border-color: #f0a09a;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  border-color: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-xs);
  font-size: 15px;
  font-weight: 600;
}

.icon-button::after { display: none; }

/* ── INPUTS ──────────────────────────────────────────────── */
label {
  display: grid;
  gap: var(--sp-1);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -.005em;
}

input, select, textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  color: var(--ink);
  background: #fafcfb;
  transition:
    border-color var(--t-mid),
    box-shadow var(--t-mid),
    background var(--t-mid);
  font-size: 13.5px;
}

textarea { resize: vertical; }

input:hover, select:hover, textarea:hover {
  border-color: rgba(11,117,103,.35);
  background: #fff;
}

input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3.5px var(--brand-glow);
}

.form-error {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid #f4c7c3;
  border-radius: var(--r-sm);
  color: var(--danger);
  background: #fff4f2;
  font-size: 13px;
  font-weight: 600;
  animation: shake .3s var(--ease-spring);
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-5px); }
  75%      { transform: translateX(5px); }
}

/* ══════════════════════════════════════════════════════════
   LOGIN
══════════════════════════════════════════════════════════ */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-8);
  background:
    radial-gradient(ellipse 90% 70% at 15% 0%, rgba(11,117,103,.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 60% at 85% 100%, rgba(25,42,58,.12) 0%, transparent 55%),
    #f0f5f3;
}

.login-panel {
  width: min(460px, 100%);
  padding: var(--sp-8);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-xl);
  animation: panel-in .5s var(--ease-out-quart) both;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.brand-row, .sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.brand-mark {
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: #fff;
  background: linear-gradient(135deg, var(--brand-light) 0%, var(--navy) 100%);
  font-weight: 900;
  font-size: 15px;
  letter-spacing: -.03em;
  box-shadow: 0 4px 14px rgba(11,117,103,.3), inset 0 1px 0 rgba(255,255,255,.2);
  flex-shrink: 0;
}

.login-panel h1 { font-size: 28px; }

.login-copy {
  margin: var(--sp-4) 0 var(--sp-6);
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}

.login-form, .appointment-form {
  display: grid;
  gap: var(--sp-4);
}

.login-proof {
  display: grid;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--line);
}

.login-proof span {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #43534f;
  font-size: 12.5px;
  font-weight: 650;
}

.login-proof span::before,
.sidebar-status span {
  content: "";
  width: 7px; height: 7px;
  border-radius: 99px;
  background: #22a06b;
  box-shadow: 0 0 0 3px rgba(34,160,107,.18);
  animation: pulse-dot 2.2s ease infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%,100% { box-shadow: 0 0 0 3px rgba(34,160,107,.18); }
  50%      { box-shadow: 0 0 0 6px rgba(34,160,107,.06); }
}

/* ══════════════════════════════════════════════════════════
   LAYOUT ADMIN
══════════════════════════════════════════════════════════ */
.admin-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0,1fr);
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: var(--sp-5);
  padding: var(--sp-5);
  border-right: 1px solid rgba(220,229,226,.6);
  background: var(--sidebar-bg);
  backdrop-filter: saturate(1.6) blur(24px);
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}

.sidebar-brand { margin-bottom: var(--sp-2); }

.sidebar-brand strong {
  display: block;
  color: var(--navy);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.sidebar-brand span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  align-content: start;
  gap: var(--sp-1);
}

/* Nav icons via data attribute */
.nav-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  color: #425751;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 650;
  position: relative;
  transition:
    background var(--t-mid),
    color var(--t-mid),
    transform var(--t-fast) var(--ease-spring);
}

.nav-list a::before {
  content: attr(data-icon);
  font-size: 15px;
  opacity: .75;
  flex-shrink: 0;
}

.nav-list a:hover {
  color: var(--brand-strong);
  background: rgba(11,117,103,.07);
  transform: translateX(2px);
}

.nav-list a.active {
  color: var(--brand-strong);
  background: linear-gradient(90deg, var(--brand-soft), rgba(224,244,240,.5));
  font-weight: 750;
  box-shadow: inset 3px 0 0 var(--brand);
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: #344944;
  background: linear-gradient(135deg, #f8fdfb, #f3f8f6);
  font-size: 12.5px;
  font-weight: 700;
}

/* ── WORKSPACE ───────────────────────────────────────────── */
.workspace {
  min-width: 0;
  padding: var(--sp-6);
  height: 100dvh;
  overflow-y: auto;
}

.workspace-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-5);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid rgba(220,229,226,.5);
}

.workspace-header h1 { font-size: 30px; }

.header-copy {
  margin: var(--sp-2) 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13.5px;
}

.header-actions { display: flex; gap: var(--sp-2); flex-shrink: 0; align-items: center; }

/* ── MÉTRICAS ────────────────────────────────────────────── */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.metrics article {
  position: relative;
  min-height: 108px;
  padding: var(--sp-4) var(--sp-5);
  overflow: hidden;
  border: 1px solid rgba(220,229,226,.7);
  border-radius: var(--r-md);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  cursor: default;
  transition:
    transform var(--t-mid) var(--ease-spring),
    box-shadow var(--t-mid),
    border-color var(--t-mid);
}

.metrics article:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(11,117,103,.2);
}

/* Fondo decorativo por card */
.metrics article::before {
  content: "";
  position: absolute;
  top: -20px; right: -20px;
  width: 90px; height: 90px;
  border-radius: 50%;
  opacity: .5;
  pointer-events: none;
}

.metrics article:nth-child(1)::before { background: radial-gradient(circle, rgba(11,117,103,.14), transparent 70%); }
.metrics article:nth-child(2)::before { background: radial-gradient(circle, rgba(183,121,31,.14), transparent 70%); }
.metrics article:nth-child(3)::before { background: radial-gradient(circle, rgba(37,77,120,.12), transparent 70%); }
.metrics article:nth-child(4)::before { background: radial-gradient(circle, rgba(107,58,185,.12), transparent 70%); }

.metrics article::after {
  content: attr(data-icon);
  position: absolute;
  right: var(--sp-4);
  top: var(--sp-4);
  font-size: 22px;
  opacity: .18;
  line-height: 1;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.metrics strong {
  display: block;
  margin-top: var(--sp-2);
  color: var(--navy);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: color var(--t-slow);
}

/* Animación de número al cargar */
.metrics strong.animate-in {
  animation: count-up .5s var(--ease-out-quart) both;
}

@keyframes count-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── TOOLBAR ─────────────────────────────────────────────── */
.toolbar {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 170px 170px;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid rgba(220,229,226,.7);
  border-radius: var(--r-md);
  background: var(--panel);
  box-shadow: var(--shadow-xs);
}

/* ── DAY STRIP ───────────────────────────────────────────── */
.day-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}

.day-strip button {
  min-height: 68px;
  display: grid;
  gap: 4px;
  align-content: center;
  border: 1.5px solid rgba(220,229,226,.7);
  color: var(--ink-2);
  background: var(--panel);
  box-shadow: var(--shadow-xs);
  border-radius: var(--r-md);
  font-size: 13px;
  padding: 0 var(--sp-3);
  transition:
    background var(--t-mid),
    border-color var(--t-mid),
    transform var(--t-fast) var(--ease-spring),
    box-shadow var(--t-mid);
}

.day-strip button:hover {
  border-color: rgba(11,117,103,.3);
  background: var(--brand-soft);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.day-strip button span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.day-strip button strong { font-size: 14px; font-weight: 700; }

.day-strip button.active {
  border-color: var(--brand);
  color: #fff;
  background: linear-gradient(145deg, var(--brand-light), var(--brand-strong));
  box-shadow: var(--shadow-brand);
  transform: translateY(-2px);
}

.day-strip button.active span { color: rgba(255,255,255,.75); }

/* ── CONTENT GRID ────────────────────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0,1fr) 340px;
  gap: var(--sp-4);
  align-items: start;
}

/* ── TABLE ───────────────────────────────────────────────── */
.table-shell, .detail-panel, .section-card {
  border: 1px solid rgba(220,229,226,.7);
  border-radius: var(--r-md);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.table-shell { overflow: auto; }

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf3f1;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: linear-gradient(180deg, #f7fbf9, #f4f9f7);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

td {
  color: var(--ink-2);
  line-height: 1.4;
  font-size: 13.5px;
}

tbody tr {
  cursor: pointer;
  transition: background var(--t-fast);
}

tbody tr:hover { background: #f5fbf8; }

tbody tr.selected {
  background: linear-gradient(90deg, rgba(11,117,103,.06), transparent);
  box-shadow: inset 3px 0 0 var(--brand);
}

.patient-cell strong {
  display: block;
  color: var(--navy);
  font-weight: 700;
  font-size: 14px;
}

.patient-cell span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-family: "Geist Mono", monospace;
}

/* ── STATUS PILLS ────────────────────────────────────────── */
.status-pill, .channel-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 750;
  letter-spacing: .01em;
}

.status-pill::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
  flex-shrink: 0;
}

.channel-pill {
  color: #31564f;
  background: #edf5f3;
  border: 1px solid rgba(11,117,103,.12);
}

.status-pendiente  { color: #79520b; background: #fff8e1; border: 1px solid rgba(183,121,31,.18); }
.status-confirmada { color: var(--brand-strong); background: var(--brand-soft); border: 1px solid var(--brand-rim); }
.status-atendida   { color: var(--info); background: #e8f0fb; border: 1px solid rgba(37,77,120,.15); }
.status-cancelada  { color: var(--danger); background: #fff1f1; border: 1px solid rgba(179,38,30,.15); }

/* ── ROW ACTIONS ─────────────────────────────────────────── */
.row-actions { display: flex; gap: var(--sp-2); }

.row-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--r-xs);
  color: var(--ink-2);
  border-color: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-xs);
}

/* ── DETAIL PANEL ────────────────────────────────────────── */
.detail-panel {
  display: grid;
  gap: var(--sp-4);
  padding: var(--sp-5);
  position: sticky;
  top: var(--sp-4);
}

.detail-panel h2, .section-card h2 {
  font-size: 18px;
  letter-spacing: -.025em;
}

.detail-list {
  display: grid;
  gap: var(--sp-2);
  margin: 0;
}

.detail-list div {
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid #edf3f1;
}

.detail-list dt {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 3px;
}

.detail-list dd {
  margin: 0;
  color: var(--ink-2);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--sp-2);
}

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
  margin: 0;
  padding: var(--sp-10) var(--sp-8);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.empty-state::before {
  content: "📭";
  display: block;
  font-size: 32px;
  margin-bottom: var(--sp-3);
  opacity: .5;
}

/* ── SKELETON LOADER ─────────────────────────────────────── */
.skeleton {
  display: block;
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, #e8efed 25%, #f0f5f3 50%, #e8efed 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ══════════════════════════════════════════════════════════
   MENSAJES — Chat WhatsApp Desktop Premium
══════════════════════════════════════════════════════════ */

/* Layout fijo cuando estamos en mensajes */
body[data-active-section="messages-section"] { overflow: hidden; }

body[data-active-section="messages-section"] .admin-view {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

body[data-active-section="messages-section"] .sidebar {
  height: 100vh;
  min-height: 0;
}

body[data-active-section="messages-section"] .workspace {
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  overflow: hidden;
  padding-bottom: 0;
}

body[data-active-section="messages-section"] #messages-section {
  min-height: 0;
  display: grid;
  overflow: hidden;
}

body[data-active-section="messages-section"] .chat-panel {
  height: 100%;
  min-height: 0;
}

body[data-active-section="messages-section"] .chat-window {
  min-height: 0;
  height: 100%;
}

body[data-active-section="messages-section"] .chat-messages {
  min-height: 0;
  overflow-y: auto;
}

/* Chat panel */
.chat-panel {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(0,1fr);
  overflow: hidden;
  border: 1px solid rgba(220,229,226,.7);
  border-radius: var(--r-md);
  background: var(--panel);
  box-shadow: var(--shadow-md);
}

.chat-list {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  border-right: 1px solid var(--line);
  background: #f6faf8;
}

.chat-list-header, .chat-window-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border-bottom: 1px solid rgba(220,229,226,.6);
  background: rgba(255,255,255,.8);
  backdrop-filter: blur(10px);
}

.chat-list-header strong {
  min-width: 30px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 99px;
  color: var(--brand-strong);
  background: var(--brand-soft);
  font-size: 12px;
  padding: 0 7px;
}

.chat-list-body, .chat-messages { min-height: 0; overflow: auto; }

.chat-list-item {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: 42px minmax(0,1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid rgba(232,239,237,.8);
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  text-align: left;
  transform: none;
  transition: background var(--t-fast), transform var(--t-fast);
}

.chat-list-item::after { display: none; }

.chat-list-item:hover {
  color: var(--ink);
  background: rgba(11,117,103,.06);
  box-shadow: inset 3px 0 0 rgba(11,117,103,.4);
  transform: none;
}

.chat-list-item.active {
  background: linear-gradient(90deg, rgba(11,117,103,.1), rgba(11,117,103,.04));
  box-shadow: inset 3px 0 0 var(--brand);
}

.chat-avatar {
  width: 42px; height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-light), var(--navy));
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(11,117,103,.25);
}

.chat-list-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.chat-list-copy strong,
.chat-list-copy small,
.chat-list-copy em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-copy strong {
  color: var(--navy);
  font-size: 13.5px;
  font-weight: 700;
}

.chat-list-copy small,
.chat-list-copy em,
.chat-window-header span {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 500;
}

.chat-list-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.chat-list-meta time {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
}

.chat-list-meta b {
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 99px;
  color: #fff;
  background: var(--brand);
  font-size: 10.5px;
  padding: 0 5px;
}

.chat-empty {
  margin: var(--sp-4);
  color: var(--muted);
  font-size: 13px;
}

/* Chat window */
.chat-window {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(11,117,103,.05), transparent 60%),
    #edf4f1;
}

.chat-window-header { justify-content: flex-start; }

.chat-window-header h2 {
  font-size: 17px;
  margin-bottom: 2px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
}

/* Burbujas */
.chat-day {
  align-self: center;
  margin: var(--sp-2) 0;
  padding: 5px 12px;
  border-radius: 99px;
  color: #50605d;
  background: rgba(255,255,255,.85);
  box-shadow: var(--shadow-sm);
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(6px);
}

.chat-bubble {
  max-width: min(580px, 72%);
  display: grid;
  gap: 4px;
  padding: 10px 13px 8px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  animation: bubble-in .22s var(--ease-spring) both;
  will-change: transform;
}

@keyframes bubble-in {
  from { opacity: 0; transform: scale(.94) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.chat-bubble p {
  margin: 0;
  color: #1e2e2a;
  line-height: 1.5;
  white-space: pre-wrap;
  font-size: 13.5px;
}

.chat-bubble time {
  justify-self: end;
  color: #6b7774;
  font-size: 10.5px;
  font-weight: 600;
}

.chat-bubble.incoming {
  align-self: flex-start;
  border-bottom-left-radius: var(--r-xs);
  background: #fff;
}

.chat-bubble.outgoing {
  align-self: flex-end;
  border-bottom-right-radius: var(--r-xs);
  background: linear-gradient(135deg, #d4f5e4, #c8f0db);
}

/* Reply form */
.chat-reply-form {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: var(--sp-2);
  align-items: end;
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid rgba(220,229,226,.7);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  box-shadow: 0 -4px 16px rgba(20,32,28,.06);
}

.chat-reply-form textarea {
  min-height: 40px;
  max-height: 120px;
  resize: none;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  line-height: 1.5;
}

.chat-reply-form button {
  min-width: 80px;
  min-height: 40px;
  font-size: 13px;
  border-radius: var(--r-sm);
}

/* ══════════════════════════════════════════════════════════
   DIALOG
══════════════════════════════════════════════════════════ */
dialog {
  width: min(700px, calc(100% - var(--sp-8)));
  border: 1px solid rgba(220,229,226,.7);
  border-radius: var(--r-xl);
  padding: 0;
  box-shadow: var(--shadow-xl);
  animation: dialog-in .28s var(--ease-out-quart) both;
}

@keyframes dialog-in {
  from { opacity: 0; transform: scale(.96) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

dialog::backdrop {
  background: rgba(20,32,28,.45);
  backdrop-filter: blur(4px);
  animation: backdrop-in .2s ease both;
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.appointment-form { padding: var(--sp-6); }

.appointment-form header,
.appointment-form footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.appointment-form footer {
  justify-content: flex-end;
  margin-top: var(--sp-2);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

/* ── SCHEDULE ────────────────────────────────────────────── */
.section-card {
  display: grid;
  gap: var(--sp-4);
  padding: var(--sp-5);
}

.schedule-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-3) var(--sp-5);
  padding: var(--sp-4);
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, #f7fbf9, #f2f8f6);
  border: 1px solid rgba(220,229,226,.5);
}

.schedule-grid span { color: var(--muted); font-size: 13.5px; }
.schedule-grid strong { color: var(--navy); font-weight: 700; }

/* ── MESSAGE CELL ────────────────────────────────────────── */
.message-cell {
  min-width: 340px;
  max-width: 600px;
  white-space: normal;
}

/* ══════════════════════════════════════════════════════════
   PANEL SECTION TRANSITION
══════════════════════════════════════════════════════════ */
.panel-section {
  animation: section-in .25s var(--ease-out-quart) both;
}

@keyframes section-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  :root { --sidebar-w: 1fr; }

  .admin-view { grid-template-columns: 1fr; }

  .sidebar {
    min-height: auto;
    height: auto;
    position: static;
    grid-template-columns: auto 1fr auto auto;
    grid-template-rows: auto;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-5);
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-brand { grid-column: 1; }

  .nav-list {
    grid-column: 2;
    grid-template-columns: repeat(5, auto);
    justify-content: center;
    gap: var(--sp-1);
  }

  .sidebar-status { grid-column: 3; }
  #logout-button  { grid-column: 4; }

  .content-grid  { grid-template-columns: 1fr; }
  .detail-panel  { position: static; }

  .chat-panel {
    height: 100%;
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .chat-list {
    max-height: 300px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .login-view    { padding: var(--sp-4); }
  .login-panel   { padding: var(--sp-5); border-radius: var(--r-lg); }
  .workspace     { padding: var(--sp-4); }

  .workspace-header,
  .appointment-form header,
  .appointment-form footer {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-header h1  { font-size: 24px; }

  .header-actions,
  .form-grid,
  .toolbar,
  .metrics,
  .day-strip,
  .nav-list { grid-template-columns: 1fr; }

  .header-actions { display: grid; }

  .sidebar {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    padding: var(--sp-3);
  }

  .nav-list { grid-column: 1 / -1; grid-template-columns: 1fr 1fr 1fr; }
  .sidebar-status { grid-column: 1; }
  #logout-button  { grid-column: 2; }

  .chat-list-item { grid-template-columns: 40px minmax(0,1fr); }
  .chat-list-meta { display: none; }
  .chat-bubble    { max-width: 88%; }
  .dialog         { border-radius: var(--r-lg); }
}