:root {
  --primary: #004e92;
  --primary-light: #3b82f6;
  --secondary: #1b5e20;
  --secondary-light: #4ade80;
  --accent: #0ea5e9;
  --bg-body: #f8fafc;
  --bg-white: #ffffff;
  --bg-dark: #0f172a;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #f1f5f9;
  --line: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  background: var(--bg-body);
}

body {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: 92px;
  color: var(--text-main);
  background: var(--bg-body);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

main {
  flex: 1;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
h4 {
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.2;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
}

h2 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
}

h3 {
  font-size: clamp(1.2rem, 3vw, 1.5rem);
}

p {
  margin-bottom: 1.5rem;
  color: var(--text-muted);
}

.container,
.shell {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.section {
  width: 100%;
  padding: 80px 0;
  overflow-x: hidden;
}

.section-alt {
  background: var(--bg-white);
}

.navbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 1000;
  padding: 1rem 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--primary);
  font-size: 1.5rem;
  font-weight: 800;
}

.logo img {
  width: 150px;
  height: auto;
  max-height: 60px;
  object-fit: contain;
}

.logo span {
  color: var(--primary);
  border-left: 1px solid #cbd5e1;
  padding-left: 0.75rem;
}

.portal-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.portal-nav form {
  margin: 0;
}

.nav-link,
.portal-nav button {
  color: var(--text-main);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary);
}

.nav-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 6px;
  padding: 0.5rem 1.25rem;
  background: var(--primary) !important;
  color: #ffffff !important;
  font-weight: 600;
}

.nav-cta:hover {
  background: var(--primary-light) !important;
  color: #ffffff !important;
}

.alerts {
  padding-top: 1.25rem;
}

.alert {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0.875rem 1rem;
  margin-bottom: 1rem;
  background: #ffffff;
  box-shadow: var(--shadow-md);
}

.alert-success {
  border-left: 4px solid var(--secondary);
}

.alert-danger {
  border-left: 4px solid #dc2626;
}

.alert-info {
  border-left: 4px solid var(--accent);
}

.hero {
  position: relative;
  min-height: 68vh;
  padding: 150px 0 96px;
  overflow: hidden;
  color: #ffffff;
  background: linear-gradient(135deg, var(--bg-dark), #1e3a8a);
}

.portal-hero {
  background-image:
    linear-gradient(135deg, rgba(0, 78, 146, 0.9), rgba(27, 94, 32, 0.82)),
    url("../assets/modelo-3d-troncos.webp");
  background-position: center;
  background-size: cover;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 75% 15%, rgba(14, 165, 233, 0.2), transparent 34%);
  z-index: 0;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 860px;
}

.hero-content h1 {
  margin-bottom: 1.5rem;
  color: #ffffff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);
}

.hero-content p {
  max-width: 760px;
  color: #e5edf7;
  font-size: clamp(1rem, 2vw, 1.2rem);
}

.hero-tagline {
  display: inline-block;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50px;
  padding: 0.5rem 1.25rem;
  background: rgba(255, 255, 255, 0.15);
  color: var(--secondary-light);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  backdrop-filter: blur(4px);
}

.hero-cta,
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.btn,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.btn-primary,
.button-primary {
  background: var(--secondary);
  color: #ffffff;
}

.btn-primary:hover,
.button-primary:hover {
  background: #0f7a3d;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  backdrop-filter: blur(4px);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.button-muted {
  background: #e2e8f0;
  color: var(--text-main);
}

.button-muted:hover {
  background: #cbd5e1;
}

.button-danger {
  background: #dc2626;
  color: #ffffff;
}

.button-danger:hover {
  background: #b91c1c;
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 0.85rem;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.section-intro {
  max-width: 800px;
  margin: 0 auto 3rem;
  text-align: center;
}

.section-intro h2 {
  margin-bottom: 0.75rem;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 2rem;
  align-items: center;
}

.overview-grid h2 {
  margin-bottom: 0.75rem;
}

.metric-card,
.panel-card,
.model-card,
.empty-state {
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow-md);
}

.metric-card {
  padding: 2rem;
  border-top: 4px solid var(--secondary);
}

.metric-card strong {
  display: block;
  color: var(--primary);
  font-size: 3.2rem;
  line-height: 1;
}

.metric-card span {
  color: var(--text-muted);
  font-weight: 600;
}

.model-section {
  background: var(--bg-body);
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.75rem;
}

.model-card {
  overflow: hidden;
  border-top: 4px solid var(--primary);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.model-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-xl);
}

.preview-link {
  display: block;
  height: 236px;
  background: #e2e8f0;
}

.preview-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-fallback {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--primary);
  background:
    radial-gradient(circle at 50% 42%, rgba(14, 165, 233, 0.16), transparent 32%),
    linear-gradient(135deg, #e8f1f6, #d9e7ee);
}

.preview-fallback svg {
  width: 92px;
  height: 92px;
  color: var(--primary);
  opacity: 0.78;
}

.model-body {
  padding: 1.5rem;
}

.model-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.model-meta span {
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  background: #e0f2fe;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
}

.model-body h3 {
  margin-bottom: 0.75rem;
}

.model-body p {
  min-height: 3.2rem;
  margin-bottom: 1.5rem;
}

.admin-shell,
.auth-shell,
.error-shell {
  background: #f1f5f9;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: 1.75rem;
  align-items: start;
}

.panel-card {
  padding: 2rem;
  border-top: 4px solid var(--primary);
}

.admin-card h1,
.auth-card h1,
.error-card h1 {
  margin-bottom: 1.5rem;
}

.admin-card h2 {
  margin-bottom: 1rem;
}

.stack-form {
  display: grid;
  gap: 1.15rem;
}

.stack-form label {
  display: grid;
  gap: 0.5rem;
}

.stack-form span {
  color: var(--text-main);
  font-weight: 700;
}

.stack-form input,
.stack-form textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  background: #ffffff;
  color: var(--text-main);
  font: inherit;
}

.stack-form input:focus,
.stack-form textarea:focus {
  outline: 3px solid rgba(59, 130, 246, 0.18);
  border-color: var(--primary-light);
}

.stack-form textarea {
  resize: vertical;
}

.admin-list {
  display: grid;
  gap: 1rem;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: #f8fafc;
}

.admin-row div {
  display: grid;
  gap: 0.25rem;
}

.admin-row strong {
  color: var(--text-main);
}

.admin-row span {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.admin-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: flex-end;
}

.admin-actions form {
  margin: 0;
}

.check-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 0.7rem !important;
}

.check-row input {
  width: auto;
}

.edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1.75rem;
  align-items: start;
}

.edit-preview {
  height: 220px;
  overflow: hidden;
  border-radius: 10px;
  background: #e2e8f0;
}

.edit-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.edit-preview .preview-fallback {
  height: 100%;
}

.edit-facts {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.25rem;
}

.edit-facts div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.75rem;
}

.edit-facts dt {
  color: var(--text-muted);
}

.edit-facts dd {
  margin: 0;
  color: var(--text-main);
  font-weight: 700;
}

.auth-wrap {
  display: grid;
  place-items: center;
}

.auth-card,
.error-card {
  width: min(100%, 460px);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 2rem;
  text-align: center;
}

.detail-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: calc(100vh - 92px);
}

.viewer-stage {
  position: relative;
  min-height: calc(100vh - 92px);
  background: #0c1620;
}

.viewer-surface {
  position: absolute;
  inset: 0;
  background: #3f4858;
  background-image: none !important;
}

#potree_sidebar_container {
  position: absolute;
  inset: 0 auto 0 0;
}

.viewer-status {
  position: absolute;
  left: 24px;
  bottom: 24px;
  z-index: 5;
  border-radius: 8px;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
}

.viewer-status.is-hidden {
  display: none;
}

.potree_menu_toggle,
#potree_map_toggle {
  max-width: none;
  width: 2.5em;
  height: 2.5em;
  display: inline-block;
}

.immersive-viewer-page {
  height: 100vh;
  padding-top: 0;
  overflow: hidden;
  background: #0c1620;
}

.immersive-viewer-page main {
  height: 100vh;
}

.viewer-stage-full {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
}

footer {
  padding: 4rem 0 2rem;
  background: var(--bg-dark);
  color: #e5edf7;
}

footer h3,
footer h4 {
  margin-bottom: 1rem;
  color: #ffffff;
}

footer p,
footer li,
footer a {
  color: #cfe2ff;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-links {
  list-style: none;
}

.footer-links li {
  margin-bottom: 0.75rem;
}

.footer-links a:hover {
  color: #ffffff;
}

.copyright {
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  padding-top: 2rem;
  text-align: center;
}

.copyright p {
  margin: 0;
}

.home-contact-widget {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 80;
  font-family: inherit;
}

.home-contact-actions {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.home-whatsapp-btn {
  position: relative;
  width: 58px;
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.24);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.home-whatsapp-btn {
  background: #1f9d55;
}

.home-whatsapp-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.3);
}

.home-whatsapp-btn svg {
  width: 29px;
  height: 29px;
  fill: currentColor;
}

@media (max-width: 980px) {
  .overview-grid,
  .admin-grid,
  .edit-grid {
    grid-template-columns: 1fr;
  }

  .model-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  body {
    padding-top: 128px;
  }

  .navbar {
    padding: 0.75rem 0;
  }

  .nav-container {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.9rem;
  }

  .logo img {
    width: 132px;
  }

  .logo span {
    font-size: 1.1rem;
  }

  .portal-nav {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .portal-nav .nav-link,
  .portal-nav form,
  .portal-nav button {
    flex: 1 1 140px;
  }

  .portal-nav .nav-link,
  .portal-nav button {
    display: flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #f1f5f9;
  }

  .portal-nav .nav-cta {
    background: var(--primary) !important;
  }

  .hero {
    min-height: 620px;
    padding: 96px 0 72px;
  }

  .portal-hero {
    background-image:
      linear-gradient(135deg, rgba(0, 78, 146, 0.92), rgba(27, 94, 32, 0.85)),
      url("../assets/ortofoto-aerea.webp");
  }

  .hero-cta {
    flex-direction: column;
  }

  .hero-cta .btn {
    width: 100%;
  }

  .section {
    padding: 60px 0;
  }

  .model-grid {
    grid-template-columns: 1fr;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .immersive-viewer-page {
    padding-top: 0;
  }

  .home-contact-widget {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
  }

}

@media (max-width: 520px) {
  .container,
  .shell {
    padding: 0 16px;
  }

  .panel-card,
  .model-body,
  .metric-card {
    padding: 1.25rem;
  }

  .preview-link {
    height: 220px;
  }

  .admin-row {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-row .button,
  .admin-actions,
  .admin-actions form,
  .admin-actions .button,
  .admin-actions button,
  .form-actions,
  .form-actions .button {
    width: 100%;
  }

  .admin-actions {
    justify-content: stretch;
  }
}
