/* Cadena — estilos de la app web. Paleta 2026 (paridad con las apps nativas). */
:root {
  --evergreen: #002a19;
  --evergreen-700: #013a24;
  --cream: #f2f4f3; /* white smoke — fondo */
  --platinum: #e2e7ea; /* superficie elevada */
  --purple: #531253;
  --rose: #ce5374;
  --lava: #6f1a07;
  --ink: #1a0f0a;
  --white: #ffffff;
  --muted: #5b6b63;
  --line: #e3e7e4;
  --shadow: 0 8px 30px rgba(0, 42, 25, 0.08);
  --radius: 16px;
  --maxw: 680px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--purple); text-decoration: none; }
h1, h2, h3, p { margin: 0; }

/* -------- Arranque / spinner -------- */
.boot {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
}
.boot-logo { font-size: 34px; font-weight: 800; color: var(--evergreen); letter-spacing: .5px; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--platinum); border-top-color: var(--evergreen);
  animation: spin 0.8s linear infinite;
}
.loading { display: flex; justify-content: center; padding: 40px 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* -------- Layout shell -------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--evergreen); color: var(--cream);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 19px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--cream); color: var(--evergreen); font-weight: 800; font-size: 16px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.role-pill {
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: rgba(242, 244, 243, 0.16); color: var(--cream);
}
.content {
  max-width: var(--maxw); margin: 0 auto;
  padding: 16px 16px 96px; /* espacio para el tabbar */
}
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: var(--white); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; color: var(--muted); font-size: 11px; font-weight: 600;
}
.tab.active { color: var(--evergreen); }
.tab .icon { display: inline-flex; }

/* -------- Pantallas de auth -------- */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(120% 80% at 50% -10%, #06422a 0%, var(--evergreen) 55%, #001b10 100%);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--white);
  border-radius: 22px; padding: 28px 24px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}
.auth-brand { text-align: center; margin-bottom: 12px; }
.auth-logo { font-size: 34px; font-weight: 800; color: var(--evergreen); }
.auth-tagline { color: var(--muted); font-size: 13px; margin-top: 2px; }
.auth-h2 { color: var(--evergreen); font-size: 22px; margin: 6px 0; text-align: center; }
.auth-lead { color: var(--muted); font-size: 14px; text-align: center; margin-bottom: 18px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.form-error {
  background: rgba(111, 26, 7, 0.08); color: var(--lava);
  border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 600;
}
.form-note { color: var(--evergreen); font-size: 13px; font-weight: 600; }
.server-config { margin-top: 16px; text-align: center; }
.server-fields { display: none; flex-direction: column; gap: 8px; margin-top: 10px; text-align: left; }
.server-fields.open { display: flex; }
.privacy-link { display: block; text-align: center; margin-top: 14px; font-size: 13px; }

/* -------- Campos -------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input {
  width: 100%; padding: 12px 14px; font-size: 15px; color: var(--ink);
  background: var(--white); border: 1px solid var(--line); border-radius: 12px;
  outline: none; transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
.input:focus { border-color: var(--evergreen); box-shadow: 0 0 0 3px rgba(0, 42, 25, 0.10); }
.textarea { resize: vertical; min-height: 84px; }
select.input { appearance: none; background-image: none; }
.phone-wrap { display: flex; align-items: stretch; }
.phone-prefix {
  display: inline-flex; align-items: center; padding: 0 12px; font-weight: 700; color: var(--evergreen);
  background: var(--platinum); border: 1px solid var(--line); border-right: none;
  border-radius: 12px 0 0 12px;
}
.phone-input { border-radius: 0 12px 12px 0; }
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 600; padding: 6px 0; }

/* -------- Botones -------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; font-size: 15px; font-weight: 700; font-family: inherit;
  border: none; border-radius: 12px; cursor: pointer; transition: transform .05s, opacity .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.small { padding: 8px 12px; font-size: 13px; }
.btn.primary { background: var(--purple); color: #fff; }
.btn.primary:hover { background: #43103f; }
.btn.purple { background: var(--purple); color: #fff; }
.btn.ghost { background: var(--platinum); color: var(--evergreen); }
.btn.danger { background: var(--lava); color: #fff; }
.btn.danger-outline { background: transparent; color: var(--lava); border: 1.5px solid var(--lava); }
.btn.whatsapp { background: #25d366; color: #04310f; }
.linklike { background: none; border: none; color: var(--purple); font-weight: 600; cursor: pointer; font-size: 14px; font-family: inherit; }
.danger-text { color: var(--lava); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; border: none; cursor: pointer;
  background: var(--platinum); color: var(--evergreen); font-size: 18px;
}
.icon-btn.small { width: 34px; height: 34px; border-radius: 9px; }
.icon-btn.danger { color: var(--lava); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon { display: inline-flex; align-items: center; }
.topbar .icon-btn { background: rgba(242,244,243,.16); color: var(--cream); }

/* -------- Utilidades -------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.screen-title { font-size: 24px; font-weight: 800; color: var(--evergreen); }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hint { font-size: 11px; color: var(--muted); }

/* -------- Segmented control -------- */
.segmented {
  display: flex; background: var(--platinum); border-radius: 12px; padding: 4px; gap: 4px;
}
.seg {
  flex: 1; padding: 9px 10px; border: none; border-radius: 9px; cursor: pointer;
  background: transparent; font-weight: 700; font-size: 14px; color: var(--muted); font-family: inherit;
}
.seg.active { background: var(--white); color: var(--evergreen); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* -------- Cards / listas -------- */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.card {
  display: block; background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  color: inherit; text-align: left; width: 100%; font-family: inherit;
}
.link-card { cursor: pointer; transition: transform .08s, box-shadow .15s; }
.link-card:hover { transform: translateY(-1px); box-shadow: 0 12px 34px rgba(0, 42, 25, 0.12); }
.plan-row-top { display: flex; align-items: center; gap: 8px; }
.plan-name { font-weight: 700; font-size: 16px; flex: 1; }
.status-label { font-size: 12px; font-weight: 800; }
.plan-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.plan-pot { font-weight: 800; margin-top: 6px; color: var(--evergreen); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot-green { background: var(--evergreen); } .status-label.dot-green { color: var(--evergreen); }
.dot-purple { background: var(--purple); } .status-label.dot-purple { color: var(--purple); }
.dot-rose { background: var(--rose); } .status-label.dot-rose { color: var(--rose); }
.dot-lava { background: var(--lava); } .status-label.dot-lava { color: var(--lava); }
.dot-gray { background: #9aa8a0; } .status-label.dot-gray { color: #9aa8a0; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty-icon { font-size: 44px; opacity: .4; }

/* -------- Detalle de plan -------- */
.back-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--evergreen); }
.hero-card {
  background: var(--evergreen); color: var(--cream);
  border-radius: 18px; padding: 18px 18px 20px; box-shadow: var(--shadow);
}
.detail-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.detail-sub { color: rgba(242, 244, 243, 0.85); font-size: 14px; }
.detail-strong { font-weight: 800; font-size: 17px; margin-top: 8px; }
.detail-line { color: rgba(242, 244, 243, 0.92); }
.section { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.section.soft { background: var(--platinum); }
.section-title { font-size: 16px; font-weight: 800; color: var(--evergreen); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.channels-text { white-space: pre-wrap; color: #38443d; }

/* -------- Piggy bank / liquid sphere -------- */
.piggy {
  display: flex; align-items: center; gap: 18px;
  background: #04052a; border-radius: 18px; padding: 18px; box-shadow: var(--shadow); color: #fff;
}
.sphere {
  position: relative; width: 128px; height: 128px; flex: none;
  border-radius: 50%; overflow: hidden;
  background: rgba(255, 255, 255, 0.08); border: 1.5px solid rgba(255, 255, 255, 0.24);
}
.sphere-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0%;
  background: linear-gradient(180deg, #7fa8ff, #476be0);
  transition: height .9s cubic-bezier(.22,.61,.36,1);
}
.wave {
  position: absolute; left: 50%; top: 0; width: 220px; height: 220px;
  transform: translate(-50%, -68%); border-radius: 43% 47% 44% 46%;
  background: rgba(120, 170, 255, 0.9); animation: wavespin 6s linear infinite;
}
.wave2 { border-radius: 47% 43% 46% 44%; background: rgba(200, 245, 255, 0.38); animation-duration: 9s; }
@keyframes wavespin { to { transform: translate(-50%, -68%) rotate(360deg); } }
.sphere-pct {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 800; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.piggy-info { display: flex; flex-direction: column; gap: 4px; }
.piggy-title { font-size: 19px; font-weight: 800; }
.piggy-amount { font-size: 16px; font-weight: 700; color: #f2eede; }
.piggy-sub { font-size: 13px; color: rgba(242, 238, 222, 0.88); }

/* -------- Participantes -------- */
.participants { display: flex; flex-direction: column; gap: 8px; }
.participant {
  display: flex; align-items: center; gap: 12px;
  background: var(--platinum); border-radius: 12px; padding: 10px 12px;
}
.participant.draggable { cursor: grab; }
.participant.dragging { opacity: .5; }
.order-badge {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  background: var(--evergreen); color: #fff; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px;
}
.p-name { flex: 1; display: flex; flex-direction: column; }
.p-name-main { font-weight: 700; font-size: 15px; }
.p-shared { font-size: 12px; color: var(--purple); }
.p-actions { display: flex; align-items: center; gap: 4px; }
.role-hint {
  font-size: 11px; font-weight: 800; padding: 4px 8px; border-radius: 999px;
  background: rgba(206, 83, 116, 0.16); color: var(--rose);
}

/* -------- Callout contraseña temporal -------- */
.callout { background: #fff5cc; border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.callout.warn { border: 1px solid #f0d98a; }
.callout-title { font-weight: 800; font-size: 14px; }
.callout-pass { font-size: 20px; font-weight: 800; letter-spacing: .5px; color: var(--ink); }
.callout-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kv { font-size: 14px; }

/* -------- Períodos -------- */
.period-card { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.period-card.current { border-color: var(--evergreen); box-shadow: 0 0 0 2px rgba(0, 42, 25, 0.08); }
.period-head { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: none; cursor: pointer; padding: 0; font-family: inherit; text-align: left; }
.period-head-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.period-title { font-weight: 700; font-size: 14.5px; }
.period-recipient { font-size: 12px; color: var(--muted); }
.period-done { color: var(--evergreen); display: inline-flex; }
.period-head .icon { color: var(--muted); transition: transform .2s; }
.period-body { padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.shared-note { font-size: 12.5px; font-weight: 700; color: var(--purple); }
.remaining-lava { font-size: 12.5px; font-weight: 700; color: var(--lava); }
.remaining-ok { font-size: 12.5px; font-weight: 700; color: var(--evergreen); }
.divider { border: none; border-top: 1px solid var(--line); margin: 4px 0; }

/* -------- Toggle de pago -------- */
.pay-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; cursor: pointer; }
.pay-row.readonly { cursor: default; }
.pay-row.saving { opacity: .5; }
.pay-info { display: flex; align-items: center; gap: 10px; }
.pay-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pay-name { font-weight: 600; display: block; }
.pay-amount { font-size: 12px; color: var(--muted); font-weight: 700; display: block; }
.switch { position: relative; display: inline-flex; flex: none; }
.switch-input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track { width: 46px; height: 28px; border-radius: 999px; background: #c3ccc6; transition: background .2s; position: relative; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch-input:checked + .switch-track { background: var(--evergreen); }
.switch-input:checked + .switch-track .switch-thumb { transform: translateX(18px); }
.switch-input:disabled + .switch-track { opacity: .55; }

/* -------- Sugerencias / stepper -------- */
.suggestions { background: var(--platinum); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.sugg-label { font-size: 12px; font-weight: 700; color: var(--muted); padding: 2px 6px; }
.sugg { display: flex; justify-content: space-between; gap: 10px; background: var(--white); border: none; border-radius: 9px; padding: 9px 12px; cursor: pointer; text-align: left; font-family: inherit; }
.sugg-name { font-weight: 600; }
.sugg-phone { color: var(--muted); font-size: 13px; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stepper-val { font-weight: 600; }
.stepper-btns { display: flex; gap: 8px; }

/* -------- Usuarios -------- */
.user-row { display: flex; align-items: center; gap: 12px; }
.user-col { flex: 1; display: flex; flex-direction: column; }
.user-name { font-weight: 700; }
.user-phone { font-size: 13px; color: var(--muted); }
.role-badge { font-size: 12px; font-weight: 800; color: var(--purple); }
.modal-danger-zone { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

/* -------- Modal -------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 20, 15, 0.5);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%; max-width: 480px; background: var(--white);
  border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto; box-shadow: 0 -10px 40px rgba(0,0,0,.25);
  animation: slideup .2s ease;
}
@keyframes slideup { from { transform: translateY(30px); } to { transform: translateY(0); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { font-size: 18px; font-weight: 800; color: var(--evergreen); }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-footer { display: flex; gap: 10px; margin-top: 18px; }
.modal-footer .btn { flex: 1; }
.error-box { text-align: center; padding: 30px 16px; display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* -------- Toast -------- */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px);
  z-index: 60; background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  max-width: 90vw; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.success { background: var(--evergreen); }
.toast.error { background: var(--lava); }
.toast.info { background: var(--purple); }

/* -------- Desktop: centra como una app -------- */
@media (min-width: 720px) {
  .modal-overlay { align-items: center; }
  .modal-card { border-radius: 20px; }
}
