/* ═══════════════════════════════════════════════
   GONRAM STUDIO — Sistema base · crema + salvia
   Editorial y sobrio: serif moderna para títulos,
   sans para todo lo demás, superficies planas.
   Compartido por /i/, /dashboard/, /admin/, /scan/,
   /cuestionario/, /guia/ y offline.
   Los nombres --gold* se conservan por compatibilidad:
   hoy significan "acento salvia".
   ═══════════════════════════════════════════════ */

/* Instrument Serif para títulos (las páginas también la precargan con <link>) */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }

:root {
  /* Superficies */
  --bg-0: #F7F4ED;   /* papel */
  --bg-1: #FFFEFB;   /* tarjeta */
  --bg-2: #FBF8F1;
  --bg-3: #F2EEE5;
  --bg-4: #E9E3D6;

  /* Acento salvia */
  --gold:     #557A4C;
  --gold-hi:  #466640;
  --gold-lo:  rgba(85,122,76,.38);
  --gold-dim: rgba(107,148,96,.13);
  --sage-ink: #3F5E38;

  /* Champaña para detalles puntuales */
  --champagne:     #B8934A;
  --champagne-dim: rgba(184,147,74,.14);

  /* Texto */
  --text-hi: #24211A;
  --text-md: #5B5547;
  --text-lo: #857D6D;

  /* Semánticos (siempre acompañados de texto, nunca solo color) */
  --green:     #4E7047;
  --green-bg:  rgba(107,148,96,.13);
  --orange:    #94742A;
  --orange-bg: rgba(184,147,74,.15);
  --red:       #A4553D;
  --red-bg:    rgba(181,101,74,.12);

  /* Líneas */
  --border:    rgba(46,42,32,.10);
  --border-md: rgba(46,42,32,.18);
  --border-hi: rgba(85,122,76,.55);

  /* Compatibilidad con el tema "glass" anterior (ya sin vidrio) */
  --glass-bg:     #FFFEFB;
  --glass-bg-hi:  #FFFEFB;
  --glass-border: rgba(46,42,32,.10);
  --glass-hi:     rgba(255,255,255,.6);
  --blur: 0px;

  /* Elevación */
  --shadow:   0 1px 2px rgba(46,42,32,.04), 0 2px 8px rgba(46,42,32,.04);
  --shadow-2: 0 1px 2px rgba(46,42,32,.05), 0 12px 32px rgba(46,42,32,.08);

  /* Tipografía */
  --font-d: 'Instrument Serif', 'Cormorant Garamond', Georgia, serif;
  --font-b: 'DM Sans', system-ui, -apple-system, sans-serif;

  /* Radios */
  --radius:    16px;
  --radius-sm: 10px;

  --ease: cubic-bezier(.22,1,.36,1);
}

body {
  background: var(--bg-0);
  color: var(--text-hi);
  font-family: var(--font-b);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100%;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -.003em;
}
strong, b { font-weight: 600; }
::selection { background: rgba(107,148,96,.22); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ── TIPOGRAFÍA ── */
.display {
  font-family: var(--font-d);
  font-weight: 400;
  font-style: normal;
  color: var(--text-hi);
  line-height: 1.04;
  letter-spacing: -.015em;
}
.display em, .heading em { font-style: italic; color: var(--gold); }
.heading { font-family: var(--font-d); font-weight: 400; color: var(--text-hi); line-height: 1.1; letter-spacing: -.01em; }
.label {
  font-size: .8rem; color: var(--text-lo); font-weight: 500;
}
.label-gold {
  font-size: .95rem; color: var(--text-hi); font-weight: 600;
}

/* ── LOGO ── */
.logo-sm  { height: 32px; width: auto; object-fit: contain; display: block; }
.logo-md  { height: 48px; width: auto; object-fit: contain; display: block; }
.logo-lg  { height: 68px; width: auto; object-fit: contain; display: block; }

/* ── BOTONES ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: var(--font-b); font-size: .875rem; font-weight: 500;
  letter-spacing: 0; text-transform: none; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .62rem 1.05rem; min-height: 40px;
  transition: background .18s, border-color .18s, color .18s, box-shadow .18s, transform .12s;
  -webkit-appearance: none; text-decoration: none; white-space: nowrap;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { flex-shrink: 0; }

.btn-gold {
  background: var(--gold); border-color: var(--gold);
  color: #FFFFFF; font-weight: 500;
  box-shadow: 0 1px 2px rgba(46,42,32,.12);
}
.btn-gold:hover:not(:disabled) { background: var(--gold-hi); border-color: var(--gold-hi); box-shadow: 0 2px 10px rgba(70,102,64,.22); }

.btn-outline,
.btn-ghost {
  background: var(--bg-1); border: 1px solid var(--border-md); color: var(--text-hi);
}
.btn-outline:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) { border-color: var(--text-lo); color: var(--text-hi); }

.btn-danger { background: transparent; border: 1px solid var(--border-md); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: var(--red-bg); border-color: rgba(164,85,61,.35); }

.btn-sm { padding: .42rem .75rem; font-size: .8rem; min-height: 34px; }
.btn-lg { padding: .8rem 1.4rem; font-size: .95rem; min-height: 48px; }
.btn-full { width: 100%; }

.btn-loading { color: transparent !important; position: relative; }
.btn-loading::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%); width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #FFFFFF;
  border-radius: 50%; animation: spin .7s linear infinite;
}

/* ── INPUTS ── */
.input, .select {
  width: 100%; min-height: 44px;
  background: var(--bg-1);
  border: 1px solid var(--border-md); color: var(--text-hi);
  font-family: var(--font-b); font-size: .95rem; font-weight: 400;
  padding: .7rem .95rem; outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
  border-radius: var(--radius-sm); -webkit-appearance: none;
}
.input::placeholder { color: var(--text-lo); opacity: .8; }
.input:focus, .select:focus {
  border-color: var(--gold); background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(85,122,76,.15);
}
.select { cursor: pointer; padding-right: 2.4rem;
  background: var(--bg-1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23857D6D' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right .9rem center; }
.select option { background: #FFFFFF; color: var(--text-hi); }
textarea.input { line-height: 1.5; }

.field { margin-bottom: 1rem; }
.field-label {
  display: block; font-size: .8rem; font-weight: 500;
  letter-spacing: 0; text-transform: none;
  color: var(--text-md); margin-bottom: .4rem;
}
.field-hint { font-size: .78rem; color: var(--text-lo); margin-top: .35rem; line-height: 1.5; }

/* ── CONTRASEÑA CON OJO ── */
.pass-wrap { position: relative; }
.pass-wrap .input { padding-right: 2.9rem; }
.eye-btn {
  position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; display: grid; place-items: center;
  background: none; border: none; border-radius: 8px; cursor: pointer;
  color: var(--text-lo); transition: color .18s, background .18s;
}
.eye-btn:hover { color: var(--text-hi); background: var(--bg-3); }

/* ── CARDS ── */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem; position: relative;
  box-shadow: var(--shadow);
}
.card-accent { box-shadow: inset 0 3px 0 var(--gold), var(--shadow); }

/* ── BADGES (punto + texto) ── */
.badge {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .25rem .65rem .25rem .55rem; font-size: .78rem; font-weight: 500;
  letter-spacing: 0; text-transform: none; border-radius: 999px; border: 0;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-green  { background: var(--green-bg);  color: var(--sage-ink); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-gold   { background: var(--gold-dim);  color: var(--sage-ink); }

/* ── DIVIDER ── */
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }
.divider-gold { height: 1px; background: var(--border-md); margin: 1.5rem 0; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(36,33,26,.42);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 500; padding: 1rem;
}
.modal-overlay.open { display: flex; animation: fadeIn .2s ease; }
.modal-overlay.open .modal { animation: modalIn .28s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 1.75rem; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto;
  position: relative; box-shadow: 0 24px 60px rgba(46,42,32,.18);
}
.modal-title {
  font-family: var(--font-d); font-size: 1.75rem; font-weight: 400; font-style: normal;
  color: var(--text-hi); margin-bottom: 1.25rem; letter-spacing: -.01em; line-height: 1.1;
  padding-right: 2rem;
}
.modal-close {
  position: absolute; top: .9rem; right: .9rem; width: 36px; height: 36px;
  display: grid; place-items: center; background: none; border: none; border-radius: 50%;
  color: var(--text-lo); cursor: pointer; font-size: 1.05rem; line-height: 1;
  transition: background .18s, color .18s;
}
.modal-close:hover { color: var(--text-hi); background: var(--bg-3); }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: calc(1.5rem + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--text-hi); color: #FFFFFF;
  border: 0; border-radius: 18px;
  padding: .75rem 1.25rem; font-size: .875rem; font-weight: 500;
  display: flex; align-items: center; gap: .5rem;
  transition: transform .4s var(--ease); z-index: 999;
  white-space: normal; text-align: center; line-height: 1.35; width: max-content;
  max-width: min(calc(100vw - 2rem), 440px); box-shadow: 0 10px 30px rgba(36,33,26,.25);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { color: #FFFFFF; }
.toast.error   { background: var(--red); color: #FFFFFF; }

/* ── SPINNER ── */
.spinner {
  width: 28px; height: 28px; border: 2px solid var(--bg-4);
  border-top-color: var(--gold); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 3rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center; padding: 3rem 2rem;
  background: var(--bg-1);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.empty-state p { font-size: .9rem; color: var(--text-lo); margin-top: .5rem; }

/* ── TOPNAV ── */
.topnav {
  background: rgba(247,244,237,.86);
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--border);
  padding: env(safe-area-inset-top) max(clamp(1rem, 4vw, 2rem), env(safe-area-inset-right)) 0 max(clamp(1rem, 4vw, 2rem), env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between;
  height: calc(58px + env(safe-area-inset-top)); position: sticky; top: 0; z-index: 100;
}
.topnav-right { display: flex; align-items: center; gap: .75rem; }
.topnav-user { font-size: .8rem; color: var(--text-lo); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── TABS ── */
.tabs {
  background: rgba(247,244,237,.9);
  border-bottom: 1px solid var(--border);
  padding: 0 clamp(1rem, 4vw, 2rem); display: flex; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: .85rem .95rem; font-size: .86rem; font-weight: 500; letter-spacing: 0; text-transform: none;
  color: var(--text-lo); background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; transition: color .18s, border-color .18s; font-family: var(--font-b); white-space: nowrap;
}
.tab-btn.activo { color: var(--text-hi); border-bottom-color: var(--text-hi); }
.tab-btn:hover:not(.activo) { color: var(--text-md); }

/* ── TABLA ── */
.tabla { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tabla thead tr { border-bottom: 1px solid var(--border-md); }
.tabla th { font-size: .78rem; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text-lo); padding: .65rem .9rem; text-align: left; }
.tabla td { padding: .8rem .9rem; font-size: .9rem; color: var(--text-md); border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabla tr:last-child td { border-bottom: none; }
.tabla tr:hover td { background: rgba(242,238,229,.55); }
.tabla td.hi { color: var(--text-hi); font-weight: 500; }
.tabla td.gold { color: var(--text-hi); font-weight: 600; }

/* ── STATS ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .75rem; }
.stat-box {
  background: var(--bg-1);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1rem; text-align: left;
}
.stat-val { font-family: var(--font-b); font-size: 1.75rem; font-weight: 600; color: var(--text-hi); line-height: 1.1; display: block; margin-bottom: .2rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-val.green  { color: var(--green); }
.stat-val.orange { color: var(--orange); }
.stat-val.red    { color: var(--red); }
.stat-lbl { font-size: .8rem; letter-spacing: 0; text-transform: none; color: var(--text-lo); }

/* ── PROGRESS ── */
.progress-wrap {
  background: var(--bg-1);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem;
}
.progress-head { display: flex; justify-content: space-between; font-size: .8rem; color: var(--text-lo); margin-bottom: .55rem; }
.progress-bg { height: 6px; background: var(--bg-4); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--gold); border-radius: 999px; transition: width .8s var(--ease); }

/* ── UTILIDADES ── */
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.wrap { flex-wrap: wrap; }
.main-wrap { padding: 1.5rem clamp(1rem, 4vw, 2rem); max-width: 1000px; margin: 0 auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
