:root {
  --bg: #F7F3ED;
  --panel: rgba(255, 252, 248, 0.92);
  --panel-strong: #FDFBF8;
  --ink: #2E2A25;
  --ink-soft: #7A756E;
  --accent: #B85C38;
  --accent-deep: #9A4C2E;
  --accent-glow: rgba(184, 92, 56, 0.14);
  --sage: #6B8068;
  --sage-soft: rgba(107, 128, 104, 0.13);
  --line: rgba(46, 42, 37, 0.09);
  --shadow: 0 16px 48px rgba(46, 42, 37, 0.08);
  --shadow-sm: 0 4px 16px rgba(46, 42, 37, 0.06);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: linear-gradient(175deg, #F7F3ED 0%, #EDE8DF 100%);
  line-height: 1.6;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

/* ── Layout shell ──────────────────────────────────────────────────────── */

.page-shell {
  position: relative;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.hero,
.control-panel,
.map-panel,
.panel-block,
.visit-card {
  animation: lift-in 0.6s ease both;
}

/* ── Hero ───────────────────────────────────────────────────────────────── */

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 340px);
  gap: 28px;
  margin-bottom: 24px;
  padding: 32px 36px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(255, 252, 248, 0.96), rgba(247, 243, 237, 0.8));
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero-top {
  margin-bottom: 10px;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}

.lang-toggle {
  position: absolute;
  top: 28px;
  right: 32px;
  padding: 7px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.lang-toggle:hover {
  transform: translateY(-1px);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.hero h1,
.panel-heading h2,
.status-block h2,
.inline-heading h2 {
  font-family: "Fraunces", serif;
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(2rem, 3.6vw, 3.6rem);
  line-height: 1;
  max-width: 14ch;
  color: var(--ink);
}

.hero-text {
  margin: 0;
  max-width: 52ch;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.7;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-self: end;
}

.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 120px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #fff 0%, #FAF7F2 100%);
  border: 1px solid rgba(46, 42, 37, 0.06);
  box-shadow: var(--shadow-sm);
}

.stat-label {
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.stat-value {
  font-size: clamp(2rem, 3.6vw, 2.8rem);
  color: var(--accent);
}

/* ── App grid ──────────────────────────────────────────────────────────── */

.app-grid {
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 24px;
  min-height: calc(100vh - 220px);
}

.control-panel,
.map-panel {
  position: relative;
  padding: 16px;
  border-radius: var(--radius-xl);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.control-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

/* ── Panel blocks ──────────────────────────────────────────────────────── */

.panel-block {
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.panel-heading {
  margin-bottom: 16px;
}

.panel-heading h2,
.status-block h2,
.inline-heading h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
}

.panel-heading p,
.inline-heading p,
.status-text {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.55;
}

/* ── Form elements ─────────────────────────────────────────────────────── */

.stack {
  display: grid;
  gap: 14px;
}

.field-grid,
.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

.field small {
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.5;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(46, 42, 37, 0.14);
  background: #fff;
  color: var(--ink);
  font-size: 0.95rem;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.field textarea[readonly] {
  background: rgba(46, 42, 37, 0.03);
  color: var(--ink-soft);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Buttons ───────────────────────────────────────────────────────────── */

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 46px;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled,
.danger-button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.primary-button {
  color: #FDFAF7;
  background: linear-gradient(135deg, var(--accent), #CC7A56);
  box-shadow: 0 8px 24px rgba(184, 92, 56, 0.22);
}

.primary-button:hover {
  box-shadow: 0 12px 28px rgba(184, 92, 56, 0.30);
}

.secondary-button {
  color: var(--ink);
  background: linear-gradient(135deg, var(--sage-soft), rgba(107, 128, 104, 0.22));
}

.ghost-button {
  color: var(--ink);
  background: rgba(46, 42, 37, 0.05);
}

.ghost-button:hover {
  background: rgba(46, 42, 37, 0.09);
}

.danger-button {
  width: 100%;
  margin-top: 10px;
  color: #FDFAF7;
  background: linear-gradient(135deg, #B54A3A, #9E3E30);
  box-shadow: 0 6px 18px rgba(181, 74, 58, 0.18);
}

/* ── Status ────────────────────────────────────────────────────────────── */

.status-block {
  background:
    linear-gradient(135deg, rgba(107, 128, 104, 0.08), rgba(184, 92, 56, 0.05)),
    var(--panel-strong);
}

.status-text.is-warning {
  color: #8A6B1A;
}

.status-text.is-error {
  color: #A6392A;
}

.status-text.is-success {
  color: #3D7A5A;
}

/* ── Map panel ─────────────────────────────────────────────────────────── */

.map-panel {
  display: grid;
  gap: 16px;
}

.map-frame {
  overflow: hidden;
  min-height: 520px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: #E4E1DA;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 520px;
}

/* ── Visit list ────────────────────────────────────────────────────────── */

.visit-list-panel {
  padding: 4px 4px 0;
}

.inline-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 14px;
}

.visit-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  padding-right: 4px;
  overflow: auto;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 140px;
  border: 1px dashed rgba(46, 42, 37, 0.14);
  border-radius: var(--radius-lg);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.45);
  font-size: 0.92rem;
}

/* ── Visit cards ───────────────────────────────────────────────────────── */

.visit-card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #fff 0%, #FAF8F4 100%);
  border: 1px solid var(--line);
}

.visit-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.visit-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.visit-card h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
}

.visit-card p {
  margin: 0;
}

.visit-meta {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.source-badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--sage-soft);
  color: var(--sage);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.visit-card-actions button {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(46, 42, 37, 0.05);
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.visit-card-actions button:hover {
  background: rgba(46, 42, 37, 0.1);
  color: var(--ink);
}

.visit-card-actions button[data-action="delete"] {
  color: #A6392A;
}

.visit-card-actions button[data-action="delete"]:hover {
  background: rgba(166, 57, 42, 0.08);
}

/* ── Map popups ────────────────────────────────────────────────────────── */

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #FDFBF8;
  color: var(--ink);
}

.map-popup {
  font-family: "Space Grotesk", sans-serif;
}

.map-popup strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

/* ── Animation ─────────────────────────────────────────────────────────── */

@keyframes lift-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Responsive: tablet ────────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .hero {
    grid-template-columns: 1fr;
  }

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

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

  .control-panel {
    order: 2;
  }

  .map-panel {
    order: 1;
  }
}

/* ── Responsive: mobile ────────────────────────────────────────────────── */

@media (max-width: 720px) {
  body {
    font-size: 14px;
  }

  .page-shell {
    padding: 16px 14px 28px;
  }

  .hero {
    padding: 22px 20px;
    gap: 20px;
  }

  .lang-toggle {
    top: 20px;
    right: 20px;
  }

  .hero h1 {
    font-size: clamp(1.6rem, 6vw, 2.2rem);
    max-width: 16ch;
  }

  .hero-text {
    font-size: 0.92rem;
  }

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

  .stat-card {
    min-height: 96px;
    padding: 16px;
  }

  .stat-value {
    font-size: clamp(1.6rem, 6vw, 2.2rem);
  }

  .field-grid,
  .button-row {
    grid-template-columns: 1fr;
  }

  .inline-heading {
    flex-direction: column;
    gap: 4px;
  }

  .map-frame,
  #map {
    min-height: 380px;
  }

  .panel-block {
    padding: 16px;
  }

  .panel-heading h2,
  .status-block h2,
  .inline-heading h2 {
    font-size: 1.2rem;
  }
}
