:root {
  --green-900: #12361d;
  --green-800: #1f5c2e;
  --green-700: #2d7a41;
  --green-200: #dcead8;
  --green-100: #edf5eb;
  --cream: #f4f7f2;
  --text: #1f2721;
  --muted: #60706a;
  --white: #ffffff;
  --danger-bg: #fdecec;
  --danger-text: #8a2323;
  --shadow: 0 16px 40px rgba(26, 55, 34, 0.12);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

body.dark-mode {
  --green-900: #dff5e5;
  --green-800: #2d7a41;
  --green-700: #7cd090;
  --green-200: #1f2f24;
  --green-100: #18231b;
  --cream: #0f1511;
  --text: #eef6f0;
  --muted: #a6b5ab;
  --white: #151d18;
  --danger-bg: #3a1c1c;
  --danger-text: #ffb2b2;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: Inter, Arial, sans-serif;
  background: var(--cream);
  color: var(--text);
}

body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: none; }
img { max-width: 100%; display: block; }
a { text-decoration: none; color: inherit; }

.app-shell {
  max-width: 540px;
  min-height: 100vh;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(247,251,246,1) 0%, rgba(239,245,237,1) 100%);
  position: relative;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.03);
}

body.dark-mode .app-shell {
  background: linear-gradient(180deg, #131b15 0%, #101712 100%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px 14px;
  background: rgba(247, 251, 246, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(18, 54, 29, 0.06);
}

body.dark-mode .topbar {
  background: rgba(15, 21, 17, 0.92);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-header {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex-shrink: 0;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.eyebrow, .section-kicker, .mini-label, .stat-label {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: var(--green-700);
  font-weight: 700;
}

.topbar h1, .section-header h2 { margin: 4px 0 0; }
.topbar h1 { font-size: 1.6rem; }

.main-content { padding: 18px 18px 110px; }
.screen { display: none; animation: fade 220ms ease; }
.screen.active { display: block; }

@keyframes fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  min-height: 330px;
  background:
    linear-gradient(rgba(18,54,29,.45), rgba(18,54,29,.68)),
    url("img/bosqueurbano.jpg") center/cover no-repeat,
    linear-gradient(135deg, #1f5c2e 0%, #12361d 100%);
  box-shadow: var(--shadow);
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.15);
}

.hero-content {
  position: relative;
  z-index: 1;
  padding: 24px;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 330px;
  gap: 12px;
}

.logo-hero {
  width: 92px;
  height: 92px;
  object-fit: contain;
  margin-bottom: 6px;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.28));
}

.hero-content h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.1;
}

.hero-content p {
  margin: 0;
  color: rgba(255,255,255,.92);
}

.badge {
  width: fit-content;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 700;
}

.hero-actions, .grid-2, .stats-grid, .quick-grid {
  display: grid;
  gap: 12px;
}

.hero-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 6px; }
.stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 18px; }
.stats-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.brand-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 10px 25px rgba(0,0,0,.08);
}

.brand-card-text { flex: 1; }

.brand-card-text h3 {
  margin: 6px 0 8px;
  color: var(--green-900);
}

.brand-card-text p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.brand-card-logo img {
  width: 92px;
  height: 92px;
  object-fit: contain;
}

.stat-card, .quick-card, .form-card, .toolbar-card, .map-card, .edu-card, .empty-card, .report-card, .modal-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-card strong {
  font-size: 1.6rem;
  color: var(--green-900);
}

.quick-card {
  padding: 18px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform .2s ease, box-shadow .2s ease;
}

.quick-card:hover { transform: translateY(-2px); }
.quick-card span { font-size: 1.6rem; }
.quick-card strong { font-size: 1rem; color: var(--green-900); }
.quick-card small { color: var(--muted); line-height: 1.45; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-grid {
  display: grid;
  gap: 12px;
}

.form-card, .toolbar-card, .map-card { padding: 18px; }
.form-card { display: grid; gap: 14px; }
.form-card label { display: grid; gap: 8px; }
.form-card span { font-weight: 700; color: var(--green-900); }

input, select, textarea {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(18,54,29,.12);
  background: #f9fcf8;
  padding: 14px;
  color: var(--text);
  outline: none;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background: #0f1712;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--green-700);
  box-shadow: 0 0 0 4px rgba(45,122,65,.12);
}

.primary-btn, .secondary-btn, .ghost-btn {
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 700;
}

.primary-btn { background: var(--green-800); color: white; }
.secondary-btn { background: var(--green-200); color: var(--green-900); }
.ghost-btn { background: rgba(31,92,46,.08); color: var(--green-900); }
.full-btn { width: 100%; }
.link-btn { display: inline-flex; justify-content: center; align-items: center; }

.location-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--green-100);
  border: 1px solid rgba(31,92,46,.08);
}

.location-box p { margin: 4px 0 0; color: var(--muted); }

.preview-wrap {
  overflow: hidden;
  border-radius: var(--radius-md);
  min-height: 180px;
  background: #dcead8;
}

.preview-wrap img {
  width: 100%;
  height: 220px;
  object-fit: cover;
}

.cards-list { display: grid; gap: 14px; }
.empty-state { display: block; }

.empty-card {
  text-align: center;
  padding: 32px 18px;
}

.empty-card span {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}

.empty-card h3, .empty-card p { margin: 0; }
.empty-card p { color: var(--muted); margin-top: 8px; }

.report-card {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.report-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.report-title-wrap h3 { margin: 0; font-size: 1.05rem; }
.report-type { margin: 6px 0 0; color: var(--green-700); font-weight: 700; }

.report-badges {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-badge, .status-badge {
  background: rgba(31,92,46,.08);
  color: var(--green-900);
  border-radius: 999px;
  padding: 8px 10px;
  height: fit-content;
  font-size: .8rem;
  font-weight: 700;
}

.status-badge.nuevo { background: #eef5ff; color: #285ea8; }
.status-badge.revision { background: #fff5df; color: #9b6b00; }
.status-badge.atendido { background: #e8f8ea; color: #236d2f; }

.report-meta {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: .92rem;
}

.report-photo {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.report-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px;
}

.report-actions button {
  padding: 12px;
  border-radius: 12px;
  font-weight: 700;
}

.report-actions .delete-btn { background: var(--danger-bg); color: var(--danger-text); }
.report-actions .copy-btn { background: var(--green-100); color: var(--green-900); }
.report-actions .edit-btn { background: #eef5ff; color: #285ea8; }
.report-actions .view-btn { background: #f4edff; color: #6b3fb8; }

.map-card { display: grid; gap: 14px; }

#realMap {
  width: 100%;
  height: 320px;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.map-info p { margin: 0 0 12px; color: var(--muted); }

.edu-stack { display: grid; gap: 14px; }
.edu-card { padding: 18px; }
.edu-card h3 { margin-top: 0; }
.edu-card p { margin-bottom: 0; color: var(--muted); line-height: 1.55; }

.tipo-stats {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.tipo-item {
  display: grid;
  gap: 6px;
}

.tipo-line {
  height: 10px;
  border-radius: 999px;
  background: var(--green-100);
  overflow: hidden;
}

.tipo-line span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green-700), var(--green-800));
  border-radius: 999px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(100%, 540px);
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 6px;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  background: rgba(250,252,249,.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(18,54,29,.08);
  z-index: 30;
}

body.dark-mode .bottom-nav {
  background: rgba(15,21,17,.96);
  border-top: 1px solid rgba(255,255,255,.06);
}

.nav-btn {
  background: transparent;
  color: var(--muted);
  border-radius: 14px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.nav-btn.active {
  background: rgba(31,92,46,.1);
  color: var(--green-900);
}

.nav-btn span { font-size: 1.2rem; }
.nav-btn small { font-size: .72rem; }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 96px;
  width: min(90%, 420px);
  padding: 14px 16px;
  border-radius: 14px;
  background: #16281b;
  color: white;
  text-align: center;
  box-shadow: var(--shadow);
  z-index: 60;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: 85vh;
  overflow: auto;
  padding: 18px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-head h3 {
  margin: 0;
}

.modal-body {
  display: grid;
  gap: 12px;
}

.modal-body img {
  width: 100%;
  border-radius: var(--radius-md);
  max-height: 260px;
  object-fit: cover;
}

.hidden { display: none !important; }

@media (max-width: 640px) {
  .brand-card {
    flex-direction: column;
    text-align: center;
  }

  .brand-card-logo img {
    width: 80px;
    height: 80px;
  }
}

@media (max-width: 430px) {
  .hero-actions,
  .grid-2,
  .stats-grid,
  .quick-grid,
  .report-actions {
    grid-template-columns: 1fr;
  }

  .location-box,
  .section-header,
  .report-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .hero-content h2 {
    font-size: 1.7rem;
  }

  .logo-hero {
    width: 78px;
    height: 78px;
  }

  .topbar h1 {
    font-size: 1.35rem;
  }

  .logo-header {
    width: 36px;
    height: 36px;
  }

  #realMap {
    height: 280px;
  }
}