/* ===========================================================================
   ESTÉTICA INTEGRAL — SISTEMA DE DISEÑO (mobile-first, fondo claro / spa)
   ⚠️ ERROR #4: el color de texto SOBRE el acento es UNA sola variable
   (--accent-text). Ningún botón escribe color:#fff literal. Si el cliente
   cambia el acento, se tocan SOLO las 3 variables de abajo.
   =========================================================================== */

:root {
  /* —— Acento (las 3 que importan) —— */
  --accent:      #cda07e;   /* nude durazno */
  --accent-h:    #b8895f;   /* hover (más oscuro) */
  --accent-text: #4a3526;   /* SIEMPRE el texto SOBRE --accent (contraste OK) */

  /* —— Paleta clara —— */
  --bg:        #faf6f4;
  --surface:   #ffffff;
  --surface2:  #f3ece9;
  --accent-soft:#f4e7da;
  --border:    #e7dcd7;
  --text:      #2e2622;
  --muted:     #9b8a82;
  --success:   #5fa777;
  --success-soft:#e6f1ea;
  --danger:    #c0556a;
  --danger-soft:#f7e6ea;
  --info:      #6b8aa5;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 2px rgba(74,53,38,.04), 0 4px 16px rgba(74,53,38,.05);
  --shadow-lg: 0 12px 32px rgba(74,53,38,.14);

  /* Tipografía: serif elegante para títulos, sans neutro para el resto */
  --font:       'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;

  --nav-w:     236px;
  --topbar-h:  64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
a   { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* Títulos en serif elegante (look editorial, no genérico) */
h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; letter-spacing: .2px; }
h1 { font-size: 1.95rem; line-height: 1.15; }
h2 { font-size: 1.4rem;  line-height: 1.2; }
h3 { font-size: 1.12rem; line-height: 1.25; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: var(--accent-text);
  padding: 10px 16px; z-index: 200; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ——— TOPBAR ——— */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.nav-toggle {
  background: none; border: 0; color: var(--text);
  display: inline-flex; padding: 8px; border-radius: var(--radius-sm);
}
.nav-toggle:hover { background: var(--surface2); }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand-logo {
  height: 30px; width: auto;
  background: var(--accent-text);          /* café oscuro #4a3526 (el logo es blanco) */
  padding: 7px 9px; border-radius: var(--radius-sm);
  box-sizing: content-box;
}
.brand-name {
  font-family: var(--font-serif);
  font-weight: 600; font-size: 1.5rem; color: var(--accent-h);
  letter-spacing: .3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-name { color: var(--muted); font-size: .9rem; display: none; }
.btn-logout {
  display: inline-flex; padding: 9px; border-radius: var(--radius-sm);
  color: var(--muted);
}
.btn-logout:hover { background: var(--danger-soft); color: var(--danger); }

/* ——— SIDENAV (drawer en móvil, riel fijo en escritorio) ——— */
.sidenav {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--nav-w); z-index: 90;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  transform: translateX(-100%);
  transition: transform .25s ease;
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidenav.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
.sidenav ul { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.sidenav-brand {
  display: block;
  padding: 4px 2px 14px; margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
/* En el menú lateral el logo ya incluye el nombre: ocupa todo el ancho y sin texto. */
.sidenav-brand .brand-logo {
  box-sizing: border-box; width: 100%; height: auto; padding: 12px;
}
.sidenav-brand .brand-name { display: none; }
.sidenav-user {
  margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
}
.sidenav-user-info { display: flex; flex-direction: column; min-width: 0; padding: 6px 8px; }
.sidenav-user-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidenav-user-rol { color: var(--muted); font-size: .76rem; text-transform: capitalize; }
.sidenav a {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 500; font-size: .92rem;
  min-height: 44px; transition: background .15s, color .15s;
}
.sidenav a:hover { background: var(--surface2); color: var(--text); }
.sidenav a.is-active {
  background: var(--accent-soft); color: var(--accent-h); font-weight: 600;
}
.sidenav a.is-active::before {
  content: ''; position: absolute; left: 0; top: 9px; bottom: 9px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.sidenav a.is-upsell { color: var(--accent-h); }
.sidenav a.is-active svg, .sidenav a:hover svg { opacity: 1; }
.sidenav a svg { flex-shrink: 0; opacity: .85; }

.nav-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(46,38,34,.42);
}

/* ——— CONTENIDO ——— */
.contenido {
  padding: 18px 16px 40px;
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
}
.pie {
  text-align: center; color: var(--muted); font-size: .8rem;
  padding: 26px 16px; display: flex; flex-direction: column; gap: 4px;
  border-top: 1px solid var(--border);
}

/* ——— BOTONES ——— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 11px 18px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .95rem; line-height: 1;
  transition: background .15s, transform .05s;
  text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary   { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover:not(:disabled)   { background: var(--accent-h); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface2); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled)    { filter: brightness(.93); }
.btn-ghost     { background: transparent; color: var(--accent-h); }
.btn-ghost:hover:not(:disabled)     { background: var(--accent-soft); }
.btn-success   { background: var(--success); color: #fff; }
.btn-block     { display: flex; width: 100%; }
.btn-sm        { min-height: 38px; padding: 8px 12px; font-size: .85rem; }
.btn-icon      { padding: 11px; min-width: 46px; }

/* Spinner: usa --accent-text si va sobre acento; oscuro sobre claro (⚠️#4). */
.spinner {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.18);
  border-top-color: currentColor;
  animation: girar .7s linear infinite;
  display: inline-block;
}
.btn-primary .spinner,
.btn-danger .spinner,
.btn-success .spinner { border-color: rgba(255,255,255,.4); border-top-color: currentColor; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ——— TARJETAS ——— */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }

.stat-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
  text-align: left; box-shadow: var(--shadow);
}
button.stat-card, a.stat-card { cursor: pointer; transition: border-color .15s, transform .05s; }
button.stat-card:hover, a.stat-card:hover { border-color: var(--accent); }
.stat-card.is-active { border-color: var(--accent); background: var(--accent-soft); }
.stat-card .num { font-size: 1.85rem; font-weight: 700; letter-spacing: -.5px; line-height: 1.1; }
.stat-card .lbl {
  color: var(--muted); font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}

/* ——— FORMULARIOS ——— */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px;
}
.field .req { color: var(--danger); }
input, select, textarea {
  width: 100%; font-family: inherit; font-size: 1rem; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px 14px; min-height: 50px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input.invalid, select.invalid, textarea.invalid {
  border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft);
}
.form-error {
  display: none; color: var(--danger); font-size: .82rem; margin-top: 6px;
}
.form-error.show { display: block; }
.input-pass { position: relative; }
.input-pass input { padding-right: 48px; }
.input-pass .toggle-pass {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--muted); padding: 9px;
  border-radius: var(--radius-sm);
}
.input-pass .toggle-pass:hover { background: var(--surface2); }

/* ——— CHIPS / BADGES ——— */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.chip.is-on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 600;
}
.badge-pendiente { background: var(--accent-soft); color: var(--accent-h); }
.badge-activo    { background: var(--success-soft); color: var(--success); }
.badge-cancelada { background: var(--danger-soft); color: var(--danger); }

/* ——— TABLAS ——— */
.tabla { width: 100%; border-collapse: collapse; }
.tabla th, .tabla td {
  text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border);
  font-size: .92rem;
}
.tabla th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }

/* ——— MODAL ——— */
.modal-bg {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(46,38,34,.5);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal-bg[hidden] { display: none; }
.modal {
  background: var(--surface); width: 100%; max-width: 520px;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 22px; max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal h2 { margin-bottom: 14px; }
.modal-close {
  float: right; background: none; border: 0; color: var(--muted);
  padding: 6px; border-radius: var(--radius-sm); margin: -6px -6px 0 0;
}

/* ——— TOAST ——— */
.toast-wrap {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 10px;
  width: calc(100% - 32px); max-width: 420px; pointer-events: none;
}
.toast {
  background: var(--text); color: #fff;
  padding: 13px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: .92rem; font-weight: 500;
  opacity: 0; transform: translateY(14px); transition: opacity .3s, transform .3s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--info); }

/* ——— ESTADO VACÍO ——— */
.vacio {
  text-align: center; color: var(--muted);
  padding: 48px 18px; display: flex; flex-direction: column;
  align-items: center; gap: 10px;
}
.vacio svg { color: var(--border); }

/* ——— AVISO DE MIGRACIÓN (⚠️ ERROR #3) ——— */
.aviso-migracion {
  border: 1px solid var(--danger); background: var(--danger-soft);
  color: var(--text); border-radius: var(--radius);
  padding: 20px; margin: 24px auto; max-width: 640px;
}
.aviso-migracion h2 { color: var(--danger); margin-bottom: 8px; }
.aviso-migracion code {
  background: var(--surface); padding: 2px 6px; border-radius: 6px;
  font-size: .85rem; word-break: break-all;
}
.aviso-migracion ol { margin: 12px 0 0 20px; }

/* ——— UTILIDADES ——— */
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row-2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head { margin-bottom: 22px; }
.page-head h1 { color: var(--text); }
.page-head p { color: var(--muted); font-size: .92rem; margin-top: 4px; }

/* ——— ACCESOS RÁPIDOS (tarjetas con icono + título + subtítulo) ——— */
.quick-grid {
  display: grid; gap: 12px; margin-bottom: 22px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.quick-card {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 16px 15px;
  box-shadow: var(--shadow); color: var(--text);
  transition: border-color .15s, transform .08s, box-shadow .15s;
  cursor: pointer; text-align: left; width: 100%;
}
.quick-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.quick-card .qc-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent-h);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.quick-card .qc-title { font-weight: 600; font-size: .98rem; }
.quick-card .qc-sub   { color: var(--muted); font-size: .82rem; line-height: 1.4; }
.muted { color: var(--muted); }
.mt { margin-top: 14px; }
.mt-lg { margin-top: 24px; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ——— RESPONSIVE ——— */
@media (min-width: 480px) {
  .row-2 { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 960px) {
  .topbar, .nav-toggle, .nav-backdrop { display: none; }
  .sidenav { transform: none; box-shadow: none; }
  body { padding-left: var(--nav-w); }
  .contenido { padding: 28px 28px 48px; }
}

/* ——— PANEL LATERAL DERECHO "Tu día" (global) ——— */
.rail { display: none; }
@media (min-width: 1366px) {
  body:has(.rail) { padding-right: 320px; }
  .rail {
    display: block; position: fixed; top: 0; right: 0; bottom: 0;
    width: 320px; z-index: 40;
    background: var(--surface); border-left: 1px solid var(--border);
    padding: 22px 16px 40px; overflow-y: auto;
  }
}
.rail-head { margin-bottom: 14px; }
.rail-saludo { font-family: var(--font-serif); font-size: 1.5rem; line-height: 1.1; }
.rail-fecha { color: var(--muted); font-size: .8rem; text-transform: capitalize; margin-top: 2px; }
.rail-reloj { font-weight: 700; font-size: 1.7rem; letter-spacing: .5px; margin-top: 4px; }

.rail-prox {
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 16px;
}
.rail-prox-lbl { font-size: .66rem; text-transform: uppercase; letter-spacing: .07em; color: var(--accent-h); font-weight: 700; }
.rail-prox-hora { font-weight: 700; margin-top: 3px; }
.rail-prox-cli { font-weight: 600; }
.rail-prox-trat { color: var(--muted); font-size: .85rem; }
.rail-prox-vacio { color: var(--muted); font-size: .85rem; background: var(--surface2); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px; }

.rail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.rail-card-tit { font-weight: 600; font-size: .9rem; margin-bottom: 11px; display: flex; align-items: center; gap: 6px; }
.rail-help {
  width: 17px; height: 17px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface2); color: var(--muted);
  font-size: .7rem; font-weight: 700; line-height: 1;
  display: inline-grid; place-items: center; cursor: pointer; flex-shrink: 0;
}
.rail-help:hover { border-color: var(--accent); color: var(--accent-h); }

.meta-ring-wrap { display: flex; align-items: center; gap: 16px; }
.meta-ring {
  position: relative; width: 76px; height: 76px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--pct, 0) * 1%), var(--surface2) calc(var(--pct, 0) * 1%));
}
.meta-ring span { width: 56px; height: 56px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: .92rem; }
.meta-ing { font-weight: 700; font-size: 1.3rem; }
.meta-sub { color: var(--muted); font-size: .82rem; }

.wk-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.wk-day {
  position: relative; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); padding: 6px 0 7px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  cursor: pointer; min-height: 50px; transition: border-color .12s, background .12s;
}
.wk-day:hover { border-color: var(--accent); }
.wk-day.es-hoy { background: var(--accent-soft); border-color: var(--accent); }
.wk-day.is-sel { background: var(--accent); border-color: var(--accent); }
.wk-day.is-sel .wk-dow, .wk-day.is-sel .wk-num { color: var(--accent-text); }
.wk-dow { font-size: .62rem; text-transform: uppercase; color: var(--muted); letter-spacing: .02em; }
.wk-num { font-weight: 700; font-size: .95rem; }
.wk-dot { position: absolute; top: 3px; right: 4px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: .6rem; font-weight: 700; display: grid; place-items: center; line-height: 1; }
.wk-day.es-hoy .wk-dot { background: var(--accent-h); }
.wk-day.is-sel .wk-dot { background: var(--accent-text); color: var(--accent); }
.wk-list { margin-top: 11px; display: flex; flex-direction: column; gap: 6px; }
.wk-item { display: flex; align-items: center; gap: 8px; font-size: .82rem; padding: 6px 8px; background: var(--surface2); border-radius: var(--radius-sm); }
.wk-item .h { font-weight: 700; color: var(--accent-h); white-space: nowrap; }
.wk-item .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-empty { color: var(--muted); font-size: .82rem; padding: 4px 2px; }

.rail-check { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.rail-check li { display: flex; align-items: center; gap: 8px; }
.chk { display: flex; align-items: center; gap: 9px; flex: 1; font-size: .85rem; cursor: pointer; min-width: 0; }
.chk input { width: 17px; height: 17px; accent-color: var(--accent); flex-shrink: 0; }
.chk input:checked + span { text-decoration: line-through; color: var(--muted); }
.chk-go { color: var(--accent-h); font-weight: 700; font-size: 1.2rem; text-decoration: none; line-height: 1; }

.rail-notas { width: 100%; min-height: 92px; resize: vertical; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; font-family: inherit; font-size: .85rem; background: #fffdf8; color: var(--text); }
.rail-notas:focus { outline: none; border-color: var(--accent); }
.rail-notas-saved { font-size: .72rem; color: var(--success); margin-top: 4px; height: 14px; }

.cumple-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cumple-row:last-child { border-bottom: 0; padding-bottom: 0; }
.cumple-nom { font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cumple-dia { color: var(--muted); font-size: .78rem; }
.rail-vacio { color: var(--muted); font-size: .85rem; }
.mini-wa { width: 34px; height: 34px; border-radius: 50%; background: #25d366; color: #fff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mini-wa:hover { filter: brightness(.95); }

/* ——— IMPRESIÓN (base; cada página afina su @media print) ——— */
@media print {
  .topbar, .sidenav, .nav-backdrop, .pie, .toast-wrap, .btn, .rail { display: none !important; }
  body { padding: 0; background: #fff; }
  .contenido { max-width: 100%; }
}
