:root {
  --gold: #C9A86A;
  --gold-dark: #a8894f;
  --cream: #F9F6F0;
  --navy: #0A2540;
  --navy-soft: #14365c;
  --white: #FFFFFF;
  --gray: #6B6B6B;
  --gray-light: #e8e2d6;
  --red: #b34434;
  --green: #2e7d4f;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(10, 37, 64, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--navy);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.topbar {
  background: var(--navy);
  color: var(--white);
  padding: 16px 16px 14px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--gold); font-size: 26px; line-height: 1; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.topbar h1 span { color: var(--gold); font-weight: 600; }
.tagline { margin: 2px 0 0; font-size: 12px; color: var(--gold); letter-spacing: .6px; }
.today { margin: 8px 0 0; font-size: 12px; color: #c9d2de; text-transform: capitalize; }

/* ---------- Views ---------- */
main { max-width: 640px; margin: 0 auto; padding: 16px 14px 24px; }
.view h2 { font-size: 22px; margin: 4px 0 14px; }
.view h3 { font-size: 16px; margin: 20px 0 10px; color: var(--navy-soft); }
.hidden { display: none !important; }
.view-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.view-head h2 { margin: 4px 0 14px; }

/* ---------- Cards / stats ---------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 6px; }
.stat-card {
  border-radius: var(--radius);
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.stat-card.gold { background: linear-gradient(135deg, var(--gold), #dfc08a); color: var(--navy); }
.stat-card.navy { background: var(--navy); color: var(--white); }
.stat-card.white { background: var(--white); color: var(--navy); border: 1px solid var(--gray-light); }
.stat-num { font-size: 30px; font-weight: 800; }
.stat-label { font-size: 11px; line-height: 1.3; opacity: .85; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--white);
  border-radius: var(--radius);
  padding: 13px 14px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--gold);
}
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.item-title { font-weight: 700; font-size: 15px; margin: 0 0 2px; }
.item-sub { font-size: 13px; color: var(--gray); margin: 2px 0; }
.item-notes { font-size: 13px; margin: 6px 0 0; background: var(--cream); border-radius: 8px; padding: 8px; }
.item-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 999px; white-space: nowrap;
}
.badge.ejemplo { background: #f3e7c8; color: #8a6d2f; border: 1px dashed var(--gold-dark); }
.badge.pendiente { background: #fdf0d5; color: #9a6b1a; }
.badge.confirmada { background: #dbe9fd; color: #1d4f9c; }
.badge.en-curso { background: #e2d6fb; color: #5b34a8; }
.badge.completada { background: #d9f0e2; color: var(--green); }
.badge.cancelada { background: #f6dcd6; color: var(--red); }
.badge.hecho { background: #d9f0e2; color: var(--green); }
.badge.tpo-llamada { background: #dbe9fd; color: #1d4f9c; }
.badge.tpo-visita { background: #e2d6fb; color: #5b34a8; }
.badge.tpo-recordatorio { background: #fdf0d5; color: #9a6b1a; }
.empty { text-align: center; color: var(--gray); padding: 22px 10px; font-size: 14px; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: none; cursor: pointer;
  font-size: 14px; font-weight: 600;
  padding: 10px 16px; border-radius: 10px;
  background: var(--gray-light); color: var(--navy);
  text-decoration: none; display: inline-block; text-align: center;
}
.btn.primary { background: var(--gold); color: var(--navy); }
.btn.primary:active { background: var(--gold-dark); }
.btn.ghost { background: transparent; border: 1px solid var(--gray-light); }
.btn.small { padding: 6px 12px; font-size: 12px; }
.btn.danger { background: var(--red); color: var(--white); }
.btn.whatsapp { background: #25d366; color: #07351a; flex: 1; }
.btn.call { background: var(--navy); color: var(--white); flex: 1; }
.contact-strip { display: flex; gap: 10px; margin-top: 22px; }
.contact-strip .btn { padding: 13px 8px; font-size: 13px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; font-size: 15px;
  border: 1px solid var(--gray-light); border-radius: 10px;
  background: var(--white); color: var(--navy); font-family: inherit;
}
.field textarea { min-height: 70px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.form-actions .btn { flex: 1; }

/* ---------- Filters / notice ---------- */
.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters select, .filters input {
  padding: 9px 10px; font-size: 14px; border: 1px solid var(--gray-light);
  border-radius: 10px; background: var(--white); color: var(--navy); font-family: inherit;
}
.notice {
  background: #fdf6e3; border: 1px solid var(--gold); border-radius: var(--radius);
  padding: 12px 14px; font-size: 13px; margin-bottom: 12px;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
}
.muted { color: var(--gray); font-size: 14px; }
.muted.small { font-size: 12px; }
.backup-box {
  background: var(--white); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; margin: 14px 0;
}
.danger-zone { border: 1px solid #eec5bb; }
.danger-zone h3 { margin: 0 0 4px; color: var(--red); font-size: 15px; }
.hidden-file { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,37,64,.55);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal {
  background: var(--cream); width: 100%; max-width: 560px;
  max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; }

/* ---------- Bottom nav ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: var(--white); border-top: 1px solid var(--gray-light);
  display: grid; grid-template-columns: repeat(6, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 10px rgba(10,37,64,.08);
}
.bottomnav button {
  appearance: none; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 2px 7px; font-size: 10px; color: var(--gray); font-family: inherit;
}
.bottomnav .ico { font-size: 20px; }
.bottomnav button.active { color: var(--navy); font-weight: 700; }
.bottomnav button.active .ico { filter: drop-shadow(0 0 1px var(--gold)); }

/* ---------- Detail timeline ---------- */
.timeline { border-left: 3px solid var(--gold); margin: 6px 0 0 4px; padding-left: 14px; display: flex; flex-direction: column; gap: 10px; }
.tl-item { font-size: 13px; }
.tl-item .tl-date { font-weight: 700; color: var(--navy-soft); }
.tl-item.done { opacity: .55; }

@media (min-width: 700px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 20px; }
  .bottomnav { max-width: 640px; margin: 0 auto; border-radius: 18px 18px 0 0; }
}
