:root {
  --bg: #FCF9F7;
  --surface: #FFFFFF;
  --surface-soft: #F6EFEA;
  --surface-rose: #FDF2F6;
  --ink: #23181D;
  --ink-muted: #6E5D65;
  --border: #EADFD9;
  --rose: #9D3C63;
  --rose-hover: #832D50;
  --rose-soft: #FCE8F0;
  --gold: #A86F24;
  --gold-soft: #FEF5E4;
  --emerald: #1B7553;
  --emerald-soft: #E6F6EF;
  --danger: #B92B3A;
  --danger-soft: #FDECEE;
  --shadow-sm: 0 2px 10px rgba(35, 24, 29, 0.04);
  --shadow-md: 0 12px 32px rgba(35, 24, 29, 0.08);
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: clip;
}

.serif {
  font-family: 'Cormorant Garamond', Georgia, serif;
}

.nums {
  font-variant-numeric: tabular-nums;
}

/* ---------- Pantalla de Login ---------- */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top right, #FCECF2 0%, #FCF9F7 55%, #F7EFEA 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 32px 26px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.brand-monogram {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: #23161D;
  color: #FAF2EE;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 32px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(35, 22, 29, 0.22);
}

/* ---------- Layout Principal ---------- */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(252, 249, 247, 0.94);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.topbar-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #23161D;
  color: #FAF2EE;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  flex-shrink: 0;
}

.topbar-title {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-sub {
  font-size: 11.5px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot-status {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}
.dot-ok { background: var(--emerald); }
.dot-warn { background: var(--gold); }

.main-container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px;
  flex: 1;
}

/* ---------- Navegación Inferior Móvil / Superior Escritorio ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 35;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 20px rgba(35, 24, 29, 0.05);
}

.nav-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  min-height: 48px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: background 0.15s, color 0.15s;
}

.nav-btn svg {
  width: 21px;
  height: 21px;
}

.nav-btn.active {
  color: var(--rose);
  background: var(--rose-soft);
  font-weight: 600;
}

.nav-badge {
  position: absolute;
  top: 3px;
  right: calc(50% - 20px);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 900px) {
  .app-shell {
    padding-bottom: 32px;
  }
  .bottom-nav {
    position: static;
    max-width: 720px;
    margin: 14px auto 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px;
    box-shadow: var(--shadow-sm);
  }
  .nav-btn {
    flex-direction: row;
    gap: 8px;
    font-size: 13px;
    min-height: 42px;
    border-radius: 999px;
  }
  .nav-badge {
    position: static;
  }
}

/* ---------- Tarjetas, Botones y Controles ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.card-rose {
  background: var(--surface-rose);
  border-color: #F4D5E2;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 720px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }
}

.kpi-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 12px;
  color: var(--ink-muted);
}

.kpi-val {
  font-size: 24px;
  font-weight: 600;
  margin-top: 4px;
  letter-spacing: -0.02em;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 13px;
  min-height: 44px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
  transition: transform 0.1s, background 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--rose);
  color: #FFFFFF;
}
.btn-primary:hover { background: var(--rose-hover); }

.btn-soft {
  background: var(--rose-soft);
  color: var(--rose);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

.btn-wa {
  background: #1B7553;
  color: #FFFFFF;
}

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: 10px;
}

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  font-family: inherit;
  font-size: 16px; /* evita zoom automático en iPhone */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(157, 60, 99, 0.12);
}
.textarea {
  min-height: 82px;
  resize: vertical;
}

.label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 5px;
}

/* ---------- Badges y Chips ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.b-ok { background: var(--emerald-soft); color: var(--emerald); }
.b-warn { background: var(--gold-soft); color: var(--gold); }
.b-danger { background: var(--danger-soft); color: var(--danger); }
.b-rose { background: var(--rose-soft); color: var(--rose); }
.b-neutral { background: var(--surface-soft); color: var(--ink-muted); }

.chips-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.chips-bar::-webkit-scrollbar { display: none; }

.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  border-radius: 999px;
  min-height: 38px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.chip.active {
  background: var(--ink);
  color: #FFF;
  border-color: var(--ink);
}

/* ---------- Calendario Mensual ---------- */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-head {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  padding: 6px 0;
}
.cal-day {
  min-height: 52px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
}
.cal-day.today {
  border-color: var(--rose);
  color: var(--rose);
  font-weight: 700;
}
.cal-day.selected {
  background: var(--rose);
  color: #FFF;
  font-weight: 700;
}
.cal-dots {
  display: flex;
  gap: 3px;
}
.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--rose);
}
.cal-day.selected .cal-dot {
  background: #FFF;
}

/* ---------- Burbujas de Conversación WhatsApp ---------- */
.chat-box {
  max-height: 430px;
  overflow-y: auto;
  background: #F5EEEA;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.msg-bubble {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 15px;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
}
.msg-in {
  align-self: flex-start;
  background: #FFFFFF;
  border-bottom-left-radius: 4px;
}
.msg-out {
  align-self: flex-end;
  background: #FCE6F0;
  color: #2B1520;
  border-bottom-right-radius: 4px;
}
.msg-meta {
  font-size: 10.5px;
  color: var(--ink-muted);
  margin-top: 4px;
  text-align: right;
}

/* ---------- Galería de Fotos de Referencia ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
.gallery-item {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  position: relative;
}
.gallery-item img {
  width: 100%;
  height: 165px;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

/* ---------- Modales ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(26, 16, 21, 0.52);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
@media (min-width: 680px) {
  .modal-backdrop {
    align-items: center;
    padding: 20px;
  }
}

.modal-panel {
  width: 100%;
  max-width: 640px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-md);
}
@media (min-width: 680px) {
  .modal-panel {
    border-radius: 24px;
    padding: 24px;
  }
}

.fab-edith {
  position: fixed;
  right: 16px;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  z-index: 32;
  background: #23161D;
  color: #FAF2EE;
  border: 1px solid rgba(217, 167, 184, 0.45);
  border-radius: 999px;
  height: 48px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(35, 22, 29, 0.28);
  cursor: pointer;
}
@media (min-width: 900px) {
  .fab-edith {
    bottom: 24px;
    right: 24px;
  }
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  background: #23161D;
  color: #FFF;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}
