:root {
  --bg: #dfe7e2;
  --app: #f4f6f3;
  --ink: #14211c;
  --muted: #5c6b64;
  --line: #e2e8e4;
  --green: #0e3b32;
  --green-2: #145244;
  --gold: #e4b84a;
  --coral: #b42318;
  --card: #fff;
  --safe-t: env(safe-area-inset-top);
  --safe-b: env(safe-area-inset-bottom);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.4;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
[hidden] { display: none !important; }

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(420px 220px at 90% -10%, rgba(228, 184, 74, 0.28), transparent 60%),
    #10211c;
}
.auth-overlay-inner {
  width: 100%;
  max-width: 480px;
  flex: 1;
  min-height: 0;
  margin: 0 auto;
  display: flex;
  align-items: center;
  overflow: auto;
  padding: calc(20px + var(--safe-t)) 16px 16px;
}
.auth-bar {
  flex: none;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 12px 20px calc(12px + var(--safe-b));
  box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.22);
}
.auth-card {
  width: 100%;
  background: #fff;
  border-radius: 28px;
  padding: 28px 22px 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}
.auth-mark {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
  background: #0b6fbe;
}
.auth-sisgd {
  display: block;
  width: min(168px, 48vw);
  height: auto;
}
.auth-eyebrow {
  margin: 12px 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.auth-card h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.auth-lead {
  margin: 8px 0 18px;
  color: #3e4c45;
}
.auth-field label,
.entry-form label,
.sheet-card label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  font-size: 0.92rem;
}
.auth-field input,
.entry-form input,
.entry-form textarea,
.sheet-card input {
  width: 100%;
  border: 1.5px solid #d5ddd8;
  border-radius: 16px;
  background: #fff;
  padding: 0 16px;
  height: 52px;
  font-size: 16px;
  outline: none;
}
.entry-form textarea {
  height: auto;
  padding: 12px 16px;
  resize: vertical;
}
.auth-field input:focus,
.entry-form input:focus,
.entry-form textarea:focus,
.sheet-card input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(14, 59, 50, 0.12);
}
.data-row { position: relative; }
.data-row input[type="text"] { padding-right: 52px; }
.data-cal {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--green);
  display: grid;
  place-items: center;
  padding: 0;
}
.entry-form .data-picker,
.sheet-card .data-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
  opacity: 0;
  pointer-events: none;
}
#authEnterBtn,
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-danger-solid,
.btn-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 54px;
  margin-top: 10px;
  border-radius: 16px;
  font-weight: 750;
  font-weight: 700;
  font-size: 1.02rem;
}
#authEnterBtn,
.btn-primary {
  border: 0;
  background: var(--green);
  color: #fff;
}
#authEnterBtn:disabled,
.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-secondary {
  border: 1.5px solid #c9d4ce;
  background: #fff;
  color: var(--green);
}
.btn-danger {
  border: 0;
  background: transparent;
  color: var(--coral);
  height: 44px;
}
.btn-danger-solid {
  border: 0;
  background: var(--coral);
  color: #fff;
}
.btn-ghost {
  border: 0;
  background: transparent;
  color: var(--muted);
}
.auth-error {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--coral);
  font-size: 0.92rem;
  font-weight: 650;
  font-weight: 600;
}
.auth-foot {
  margin: 18px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--app);
  position: relative;
}
@media (min-width: 540px) {
  body { padding: 18px 0; }
  .app-shell {
    min-height: calc(100dvh - 36px);
    border-radius: 28px;
    overflow: clip;
    box-shadow: 0 18px 50px rgba(16, 40, 32, 0.14);
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  background: rgba(244, 246, 243, 0.92);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
  background: #0b6fbe;
}
.brand strong { display: block; letter-spacing: -0.03em; }
.brand small { color: var(--muted); font-size: 12px; }
.user-btn {
  border: 0;
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(20, 33, 28, 0.06);
}
.user-menu {
  position: absolute;
  top: calc(100% - 8px);
  right: 16px;
  width: min(240px, calc(100% - 32px));
  background: #fff;
  border-radius: 18px;
  padding: 8px;
  box-shadow: 0 16px 40px rgba(16, 40, 32, 0.16);
  z-index: 6;
}
.user-role {
  margin: 4px 8px 8px;
  color: var(--muted);
  font-size: 13px;
}
.user-menu button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 12px;
  font-weight: 700;
}
.user-menu button:hover,
.user-menu button:focus-visible { background: #f3f6f4; }

.hero {
  margin: 4px 16px 8px;
  padding: 20px 18px 16px;
  border-radius: 28px;
  color: #f6f8f6;
  background:
    radial-gradient(140px 90px at 100% 0%, rgba(228, 184, 74, 0.38), transparent 62%),
    linear-gradient(165deg, #1a6a58, #0e3b32 42%, #0a2822);
  box-shadow: 0 14px 30px rgba(14, 59, 50, 0.18);
}
.hero-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.kicker {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 700;
}
.balance {
  margin: 4px 0 0;
  font-size: clamp(2.15rem, 9vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.balance.is-negative { color: #ffd0c8; }
.balance-sub { margin: 8px 0 0; color: rgba(255, 255, 255, 0.78); font-size: 0.95rem; }
.ring {
  width: 84px;
  height: 84px;
  flex: 0 0 84px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--gold) calc(var(--p) * 1%), rgba(255, 255, 255, 0.16) 0);
}
.ring.is-hot { background: conic-gradient(#ffb4a8 calc(var(--p) * 1%), rgba(255, 255, 255, 0.16) 0); }
.ring span {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #0c2e27;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.used-line { margin: 14px 0 0; color: rgba(255, 255, 255, 0.8); font-size: 0.92rem; }
.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 14px; }
.stats div { background: rgba(255, 255, 255, 0.08); border-radius: 14px; padding: 10px 8px; }
.stats span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.66);
}
.stats strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.wa-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 16px 0;
}
.wa-row.is-single { grid-template-columns: 1fr; }
.wa-row.is-trio #mapaBtn { grid-column: 1 / -1; }
.wa-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 10px;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(20, 33, 28, 0.05);
}
.wa-btn:active { transform: scale(0.98); }
.wa-ico {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #1fa855;
}
.wa-ico-maps {
  background: #fff;
  box-shadow: inset 0 0 0 1px #e3ebe6;
}
.wa-btn-maps small { color: #1a73e8; }
.wa-btn small {
  display: block;
  color: #128c7e;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.wa-btn strong { display: block; font-size: 13px; line-height: 1.2; letter-spacing: -0.02em; }
.wa-btn em { display: block; margin-top: 1px; color: var(--muted); font-size: 11px; font-style: normal; }

.feed { padding: 8px 16px calc(108px + var(--safe-b)); }
.feed-head h2 { margin: 12px 0 0; font-size: 1.25rem; letter-spacing: -0.03em; }
.feed-head p { margin: 4px 0 12px; color: var(--muted); font-size: 0.92rem; }
.month {
  margin: 18px 4px 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}
.post {
  background: #fff;
  border-radius: 16px;
  margin: 0 0 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(20, 33, 28, 0.08);
}
.post-open, .post-caption {
  width: 100%;
  border: 0;
  background: #fff;
  text-align: left;
  color: inherit;
}
.post-open {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 8px;
}
.avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #f4d56a;
  font-weight: 800;
  font-size: 14px;
}
.post-id { min-width: 0; }
.post-id strong, .post-sub { display: block; }
.post-id strong { font-size: 15px; letter-spacing: -0.02em; }
.post-sub {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-val {
  font-weight: 800;
  color: var(--coral);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.post-open .tx-val { margin-left: auto; font-size: 14px; }
.post-caption {
  padding: 0 12px 10px;
  font-size: 15px;
  line-height: 1.35;
}
.reel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scrollbar-width: none;
  background: #111;
  height: 340px;
}
.reel::-webkit-scrollbar { display: none; }
.reel-slide {
  flex: 0 0 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.reel-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.reel-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 8px 0 10px;
  background: #fff;
}
.reel-dots i, .ig-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d5ddd8;
}
.reel-dots i.is-on, .ig-dots i.is-on {
  background: #0e3b32;
  transform: scale(1.15);
}
.empty {
  background: #fff;
  border-radius: 16px;
  padding: 22px 16px;
  color: var(--muted);
}

.cta-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  z-index: 4;
  padding: 18px 16px calc(12px + var(--safe-b));
  background: linear-gradient(transparent, var(--app) 28%);
  pointer-events: none;
}
.cta-bar .btn-primary { pointer-events: auto; margin-top: 0; box-shadow: 0 10px 24px rgba(14, 59, 50, 0.22); }
body.screen-open .cta-bar { display: none; }

.screen {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 8;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--app);
  overflow: auto;
}
@media (min-width: 540px) {
  .screen {
    top: 18px;
    bottom: 18px;
    border-radius: 28px;
    box-shadow: 0 18px 50px rgba(16, 40, 32, 0.14);
  }
}
.screen-bar {
  position: sticky;
  top: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--safe-t)) 12px 10px;
  background: #f4f6f3;
}
.back-btn {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  border: 0;
  background: var(--green);
  color: #fff;
  border-radius: 999px;
  padding: 0 16px 0 12px;
  font-weight: 800;
  font-size: 16px;
}
.back-btn span { font-size: 1.35rem; line-height: 1; }
.screen-title { margin: 0; font-weight: 800; }
.gallery-count, .swipe-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.swipe-hint { padding: 8px 16px 0; }
.gallery-stage {
  position: relative;
  margin-top: 8px;
  background: #101614;
}
.gallery-count {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-weight: 700;
}
.gallery {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scrollbar-width: none;
  height: 62vh;
}
.gallery::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 100%;
  height: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: grid;
  place-items: center;
}
.slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.ig-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}
.ig-dots i { background: rgba(255, 255, 255, 0.45); }
.ig-dots i.is-on { background: #fff; }
.ig-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #14211c;
  font-size: 28px;
  line-height: 1;
  font-weight: 700;
}
.ig-arrow-prev { left: 10px; }
.ig-arrow-next { right: 10px; }
.detail-body { padding: 16px 16px 8px; }
.detail-backbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(transparent, var(--app) 28%);
}
.detail-backbar .btn-primary { margin-top: 0; box-shadow: 0 10px 24px rgba(14, 59, 50, 0.22); }
#detail { scroll-padding-bottom: calc(88px + var(--safe-b)); }
#detail .detail-body { padding-bottom: calc(96px + var(--safe-b)); }
@media (min-width: 540px) {
  .detail-backbar { bottom: 18px; border-radius: 0 0 28px 28px; }
}
.detail-date { margin: 0; color: var(--muted); font-weight: 700; font-size: 13px; }
.detail-who { margin: 4px 0 0; font-size: 1.45rem; letter-spacing: -0.03em; }
.detail-amount {
  margin: 6px 0 0;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--coral);
  font-variant-numeric: tabular-nums;
}
.detail-note { white-space: pre-wrap; }
.detail-owner { color: var(--muted); font-size: 0.92rem; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.detail-actions .btn-danger,
.detail-actions .btn-secondary { margin-top: 0; }
.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin-top: 18px;
}
.pager button {
  border: 0;
  background: #fff;
  border-radius: 14px;
  padding: 12px 8px;
  font-weight: 700;
}
.pager button:disabled { opacity: 0.35; }
.pager span { color: var(--muted); font-size: 13px; font-weight: 700; text-align: center; }

.entry-form { padding: 8px 16px calc(28px + var(--safe-b)); }
.entry-form label, .photo-label { margin-top: 14px; }
.valor-label { margin-top: 6px !important; font-size: 1rem; }
.valor-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 88px;
  margin-top: 8px;
  padding: 8px 16px;
  border: 2px solid var(--green);
  border-radius: 20px;
  background: #fff;
}
.valor-row.is-empty {
  animation: valor-pulse 1.2s ease-in-out infinite;
}
.valor-prefix { font-size: 1.7rem; font-weight: 800; color: var(--green); }
.valor-caret {
  width: 3px;
  height: 46px;
  flex: 0 0 3px;
  border-radius: 2px;
  background: var(--green);
  animation: caret-blink 1s steps(1) infinite;
}
.valor-row:not(.is-empty) .valor-caret,
.valor-row:focus-within .valor-caret { display: none; }
.valor-row input {
  flex: 1;
  min-width: 0;
  border: 0;
  height: 64px;
  padding: 0;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: transparent;
  box-shadow: none;
  caret-color: var(--green);
}
.valor-row input:focus { box-shadow: none; }
.valor-hint {
  margin: 8px 2px 0;
  color: var(--green);
  font-weight: 800;
  animation: hint-blink 1.2s ease-in-out infinite;
}
.valor-row:not(.is-empty) + .valor-hint { visibility: hidden; }
@keyframes valor-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(14, 59, 50, 0.35); }
  50% { box-shadow: 0 0 0 10px rgba(14, 59, 50, 0); }
}
@keyframes caret-blink {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}
@keyframes hint-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
.photo-label { font-weight: 700; margin-bottom: 8px; }
.photo-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.photo-card { position: relative; }
.photo-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 14px;
  background: #e7eeea;
  display: block;
}
.photo-card.is-removed { opacity: 0.35; }
.photo-card button {
  position: absolute;
  top: 6px;
  right: 6px;
  border: 0;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.78);
  color: #fff;
  width: 32px;
  height: 32px;
  font-weight: 700;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(16, 33, 28, 0.46);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow-y: auto;
}
.sheet-card {
  width: 100%;
  max-width: 480px;
  max-height: 100%;
  overflow-y: auto;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 22px 16px calc(18px + var(--safe-b));
}
@media (min-width: 540px) {
  .sheet { align-items: center; }
  .sheet-card { border-radius: 24px; margin: 16px; }
}
.sheet-card h2 { margin: 0 0 8px; letter-spacing: -0.03em; }
.sheet-card p { margin: 0 0 12px; color: #3e4c45; }
#visitaSheet label { margin-top: 12px; }
.visita-preview {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #f3f7f4;
  color: #1c2b26;
  line-height: 1.45;
}
.visita-preview strong { color: var(--green); font-weight: 800; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 30;
  max-width: min(420px, calc(100% - 32px));
  background: #14211c;
  color: #fff;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 700;
  text-align: center;
}
body.auth-locked { overflow: hidden; }
