/* ─── Variables ───────────────────────────────────────────────────────────── */
:root {
  --blue-dark:    #1e3a5f;
  --blue:         #2563eb;
  --blue-mid:     #3b82f6;
  --blue-light:   #60a5fa;
  --blue-pale:    #dbeafe;
  --blue-xpale:   #eff6ff;
  --accent:       #3b82f6;
  --danger:       #dc2626;
  --warn:         #f59e0b;
  --green-ok:     #16a34a;

  --bg:           #f8fafc;
  --surface:      #ffffff;
  --surface-alt:  #f1f5f9;
  --border:       #e2e8f0;
  --border-focus: #93c5fd;

  --text:         #1e293b;
  --text-mid:     #475569;
  --text-muted:   #94a3b8;

  --radius:       10px;
  --radius-sm:    7px;
  --shadow:       0 1px 8px rgba(37,99,235,.08);
  --shadow-md:    0 4px 20px rgba(37,99,235,.12);

  --font-head:    'Inter', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
}

/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); text-decoration: underline; }

/* ─── Navbar ──────────────────────────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 2rem;
  height: 58px;
  background: var(--blue-dark);
  border-bottom: 1px solid rgba(255,255,255,.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  letter-spacing: -.01em;
  margin-right: .75rem;
}
.nav-brand svg { color: var(--blue-light); }
.nav-brand:hover { text-decoration: none; color: #fff; }

.nav-links {
  display: flex;
  align-items: center;
  gap: .15rem;
  flex: 1;
}

.nav-link {
  padding: .38rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  color: rgba(255,255,255,.75);
  transition: all .15s;
  text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(255,255,255,.15); color: #fff; }

.nav-link--cta {
  background: var(--blue);
  color: #fff !important;
  margin-left: .5rem;
}
.nav-link--cta:hover { background: var(--blue-mid); text-decoration: none; }

.nav-link--admin { color: #fde68a !important; }
.nav-link--admin:hover { background: rgba(253,230,138,.12); color: #fde68a !important; }

.nav-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-left: auto;
}
.nav-username {
  font-size: .85rem;
  font-weight: 500;
  color: rgba(255,255,255,.7);
}
.nav-logout {
  font-size: .85rem;
  color: rgba(255,255,255,.5);
  text-decoration: none;
}
.nav-logout:hover { color: #fca5a5; text-decoration: none; }

/* ─── Layout ──────────────────────────────────────────────────────────────── */
.main-content {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.25rem 2rem;
}
.main-content--auth {
  max-width: 100%;
  padding: 0;
}

/* ─── Auth Layout ─────────────────────────────────────────────────────────── */

/* Full-page split layout – no navbar chrome */
.auth-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

/* ── Left side: form ─────────────────────────────────────────────────── */
.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  padding: 2.5rem 1.5rem;
}

.auth-form-inner {
  width: 100%;
  max-width: 400px;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 2.5rem;
}
.auth-brand span { letter-spacing: -.01em; }

.auth-heading { margin-bottom: 2rem; }
.auth-heading h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.03em;
  margin-bottom: .35rem;
  font-family: var(--font-head);
}
.auth-heading p {
  color: var(--text-muted);
  font-size: .95rem;
}

.auth-fields { display: flex; flex-direction: column; gap: 1rem; }

.auth-forgot {
  font-size: .82rem;
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}
.auth-forgot:hover { text-decoration: underline; }

.auth-switch-line {
  text-align: center;
  margin-top: 1.75rem;
  color: var(--text-muted);
  font-size: .9rem;
}
.auth-switch-line a { color: var(--blue); font-weight: 600; text-decoration: none; }
.auth-switch-line a:hover { text-decoration: underline; }

/* ── Right side: hero ─────────────────────────────────────────────────── */
.auth-hero {
  background: linear-gradient(150deg, #0f1e35 0%, #1d4ed8 55%, #2563eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 3.5rem;
  position: relative;
  overflow: hidden;
}

/* Subtle mountain shapes */
.auth-hero::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40%;
  background:
    polygon(0 80%, 18% 40%, 36% 72%, 54% 30%, 72% 65%, 90% 25%, 100% 50%, 100% 100%, 0 100%);
  opacity: .12;
}
.auth-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 70% 30%, rgba(96,165,250,.15) 0%, transparent 60%);
  pointer-events: none;
}

.auth-hero-content {
  position: relative;
  z-index: 1;
  color: #fff;
  max-width: 380px;
}

.auth-hero-icon {
  margin-bottom: 1.75rem;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,.3));
}

.auth-hero-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.03em;
  margin-bottom: .75rem;
  line-height: 1.15;
  font-family: var(--font-head);
}

.auth-hero-sub {
  font-size: .95rem;
  opacity: .75;
  line-height: 1.65;
  margin-bottom: 2rem;
}

.auth-feature-list {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.auth-feature-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm);
  padding: .65rem 1rem;
  font-size: .875rem;
  line-height: 1.4;
}

.auth-feature-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

/* Forgot / reset password simple page */
.auth-simple-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 2rem 1rem;
}
.auth-simple-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 24px rgba(0,0,0,.07);
}
.auth-simple-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2rem;
  text-decoration: none;
}

/* Responsive */
@media (max-width: 768px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero  { display: none; }
  .auth-form-side { padding: 2rem 1.25rem; min-height: 100vh; }
}

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.form-label {
  font-size: .825rem;
  font-weight: 600;
  color: var(--text-mid);
  display: flex;
  justify-content: space-between;
  letter-spacing: .005em;
}
.form-label-link { font-weight: 400; color: var(--blue); font-size: .825rem; }
.form-optional { font-weight: 400; color: var(--text-muted); }

.form-input {
  padding: .6rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: .95rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  line-height: 1.5;
}
.form-input:focus {
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 80px; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .15s;
  text-decoration: none;
  line-height: 1.5;
}
.btn--primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn--primary:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; text-decoration: none; }
.btn--outline { border-color: var(--border); background: transparent; color: var(--text-mid); }
.btn--outline:hover { border-color: var(--blue-mid); color: var(--blue); text-decoration: none; }
.btn--danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--danger:hover { background: #b91c1c; color: #fff; text-decoration: none; }
.btn--warn { background: var(--warn); color: #fff; border-color: transparent; }
.btn--full { width: 100%; justify-content: center; }
.btn--large { padding: .7rem 1.4rem; font-size: .95rem; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-sm {
  display: inline-flex;
  padding: .28rem .6rem;
  border-radius: 5px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn-sm--green  { background: #dcfce7; color: #15803d; }
.btn-sm--green:hover { background: #16a34a; color: #fff; }
.btn-sm--warn   { background: #fef3c7; color: #b45309; }
.btn-sm--warn:hover { background: var(--warn); color: #fff; }
.btn-sm--blue   { background: var(--blue-pale); color: #1d4ed8; }
.btn-sm--blue:hover { background: var(--blue); color: #fff; }
.btn-sm--danger { background: #fee2e2; color: var(--danger); }
.btn-sm--danger:hover { background: var(--danger); color: #fff; }

/* ─── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.alert--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.alert--success {
  background: #f0fdf4;
  color: #14532d;
  border: 1px solid #bbf7d0;
}

/* ─── Page Header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
}
.page-subtitle { color: var(--text-muted); margin-top: .2rem; font-size: .9rem; }
.page-actions { display: flex; gap: .6rem; }

/* ─── Stats ───────────────────────────────────────────────────────────────── */
.stats-grid, .admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.stat-icon { font-size: 1.5rem; margin-bottom: .5rem; }
.stat-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--blue-dark);
  letter-spacing: -.02em;
}
.stat-label {
  font-size: .775rem;
  color: var(--text-muted);
  margin-top: .2rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 500;
}

/* ─── Section ─────────────────────────────────────────────────────────────── */
.section { margin-top: 2rem; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .85rem; }
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .85rem;
  letter-spacing: -.01em;
}
.section-link { font-size: .85rem; color: var(--blue); }
.section-link:hover { color: var(--blue-dark); }

/* ─── Track List ──────────────────────────────────────────────────────────── */
.track-list { display: flex; flex-direction: column; gap: .4rem; }

.track-card {
  display: flex;
  align-items: center;
  gap: .9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1.1rem;
  text-decoration: none;
  color: var(--text);
  transition: all .15s;
}
.track-card:hover {
  border-color: var(--blue-mid);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
}
.track-card-icon { font-size: 1.2rem; flex-shrink: 0; }
.track-card-info { flex: 1; min-width: 0; }
.track-card-name { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; }
.track-card-meta { font-size: .8rem; color: var(--text-muted); margin-top: .1rem; }
.track-card-date { font-size: .78rem; color: var(--text-muted); flex-shrink: 0; }

/* ─── Track Grid ──────────────────────────────────────────────────────────── */
.track-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
}

.track-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
}
.track-tile:hover { box-shadow: var(--shadow-md); border-color: var(--blue-light); }

.track-tile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .65rem .9rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}
.track-tile-icon { font-size: 1.1rem; }
.track-tile-actions { display: flex; gap: .2rem; }

.tile-action {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .95rem;
  padding: .2rem .35rem;
  border-radius: 4px;
  transition: background .15s;
  text-decoration: none;
}
.tile-action:hover { background: var(--border); }
.tile-action--danger:hover { background: #fee2e2; }

.track-tile-link { display: block; padding: .9rem 1rem; text-decoration: none; color: var(--text); }
.track-tile-link:hover { text-decoration: none; color: var(--text); }
.track-tile-name { font-weight: 700; margin-bottom: .35rem; color: var(--blue-dark); font-size: .95rem; }
.track-tile-desc { font-size: .825rem; color: var(--text-muted); margin-bottom: .65rem; }
.track-tile-stats { display: flex; gap: .65rem; flex-wrap: wrap; margin-bottom: .65rem; }
.tile-stat { font-size: .825rem; color: var(--text-mid); }
.tile-stat strong { color: var(--text); }
.track-tile-date { font-size: .775rem; color: var(--text-muted); }

/* ─── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2.75rem; margin-bottom: .85rem; }
.empty-state h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .4rem;
}
.empty-state p { margin-bottom: 1.5rem; font-size: .9rem; }

/* ─── Upload ──────────────────────────────────────────────────────────────── */
.upload-container { max-width: 580px; }
.upload-form { display: flex; flex-direction: column; gap: 1.25rem; }

.drop-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  transition: all .2s;
  background: var(--surface);
}
.drop-zone.drag-over { border-color: var(--blue); background: var(--blue-xpale); }
.drop-zone-input {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.drop-zone-content, .drop-zone-selected {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .45rem;
}
.drop-zone-icon { font-size: 2.25rem; }
.drop-zone-text { font-weight: 600; color: var(--text); font-size: .95rem; }
.drop-zone-sub { color: var(--text-muted); font-size: .875rem; pointer-events: auto; }
.drop-zone-hint { font-size: .78rem; color: var(--text-muted); }
.drop-zone-filename { font-weight: 600; color: var(--blue-dark); }
.drop-zone-browse { color: var(--blue); cursor: pointer; text-decoration: underline; }

.upload-actions { display: flex; gap: .75rem; }

/* ─── GPX Detail ──────────────────────────────────────────────────────────── */
.track-description {
  background: var(--blue-xpale);
  border-left: 3px solid var(--blue-light);
  padding: .7rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 1.75rem;
  color: var(--text-mid);
  font-size: .9rem;
}

.detail-stats {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.75rem;
  background: var(--surface);
}
.detail-stat {
  flex: 1;
  text-align: center;
  padding: 1.1rem 1rem;
  border-right: 1px solid var(--border);
}
.detail-stat:last-child { border-right: none; }
.detail-stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--blue-dark);
  letter-spacing: -.02em;
}
.detail-stat-label {
  font-size: .72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: .2rem;
  font-weight: 500;
}

.map-container {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
  height: 400px;
}
#map { width: 100%; height: 100%; }

.elevation-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
}

/* ─── Admin Table ─────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: .875rem;
}
.admin-table th {
  background: var(--surface-alt);
  padding: .65rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-mid);
  font-size: .775rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: var(--bg); }
.row--inactive td { opacity: .5; }
.table-actions { display: flex; gap: .35rem; }

.user-link { color: var(--text); text-decoration: none; }
.user-link:hover { color: var(--blue); }
.user-link small { color: var(--text-muted); font-weight: 400; }

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .01em;
}
.badge--green  { background: #dcfce7; color: #15803d; }
.badge--gray   { background: #f1f5f9; color: #64748b; }
.badge--yellow { background: #fef9c3; color: #854d0e; }
.badge--blue   { background: var(--blue-pale); color: #1d4ed8; }

.admin-actions-bar { display: flex; gap: .6rem; margin-bottom: 1.75rem; }

.text-muted { color: var(--text-muted); font-size: .875rem; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .auth-container { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-panel { padding: 2rem 1.5rem; }
  .navbar { padding: 0 1rem; }
  .main-content { padding: 1.5rem 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .detail-stats { flex-wrap: wrap; }
  .detail-stat { min-width: 45%; }
  .page-header { flex-direction: column; }
}


/* ═══════════════════════════════════════════════════════
   TOUR CARDS (list view)
   ═══════════════════════════════════════════════════════ */
.tour-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.tour-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .15s, border-color .15s;
}
.tour-card:hover { box-shadow: var(--shadow-md); border-color: var(--blue-light); }

.tour-card-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .9rem;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  font-size: .8rem;
}
.ml-auto { margin-left: auto; }

.tour-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-planning  { background: var(--warn); }
.status-active    { background: var(--green-ok); }
.status-completed { background: var(--blue); }

.tour-status-label { color: var(--text-muted); font-size: .78rem; font-weight: 500; }

.tour-card-body {
  padding: 1rem;
  text-decoration: none;
  color: var(--text);
  flex: 1;
}
.tour-card-body:hover { text-decoration: none; color: var(--text); }
.tour-card-name { font-size: 1rem; font-weight: 700; color: var(--blue-dark); margin-bottom: .3rem; }
.tour-card-desc { font-size: .825rem; color: var(--text-muted); margin-bottom: .6rem; }
.tour-card-meta { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .8rem; color: var(--text-mid); }

.tour-card-footer { padding: .75rem 1rem; border-top: 1px solid var(--border); }
.btn--sm-full { width: 100%; justify-content: center; }

/* ═══════════════════════════════════════════════════════
   NEW TOUR FORM
   ═══════════════════════════════════════════════════════ */
.form-container { max-width: 640px; }
.tour-form { display: flex; flex-direction: column; gap: 0; }
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.form-section-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 1rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--border);
}
.form-hint { font-size: .75rem; color: var(--text-muted); font-weight: 400; }
.form-actions { display: flex; gap: .75rem; margin-top: .5rem; }

/* ═══════════════════════════════════════════════════════
   PLANNER SHELL
   ═══════════════════════════════════════════════════════ */
.planner-shell {
  display: flex;
  height: calc(100vh - 58px);  /* subtract navbar */
  overflow: hidden;
  position: relative;
}

/* ─── Sidebar ─────────────────────────────────────────── */
.planner-sidebar {
  width: 340px;
  min-width: 340px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .25s, min-width .25s;
  z-index: 10;
}
.planner-sidebar.sidebar--collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
  padding: .9rem 1rem .7rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-back { font-size: .78rem; color: var(--text-muted); text-decoration: none; display: block; margin-bottom: .2rem; }
.sidebar-back:hover { color: var(--blue); text-decoration: none; }
.sidebar-title { font-size: 1rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.sidebar-toggle {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 28px; height: 28px;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--text-mid);
}
.sidebar-toggle:hover { background: var(--blue-pale); color: var(--blue); }

/* Stats bar */
.sidebar-stats {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sstat {
  flex: 1;
  text-align: center;
  padding: .55rem .25rem;
  border-right: 1px solid var(--border);
  font-size: .82rem;
}
.sstat:last-child { border-right: none; }
.sstat span { display: block; font-size: 1rem; font-weight: 700; color: var(--blue-dark); }
.sstat small { color: var(--text-muted); font-size: .7rem; }

/* Tabs */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sidebar-tabs::-webkit-scrollbar { display: none; }
.stab {
  flex: 1;
  padding: .6rem .4rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.stab:hover { color: var(--blue); }
.stab--active { color: var(--blue); border-bottom-color: var(--blue); }

/* Tab panels */
.tab-panel {
  flex: 1;
  overflow-y: auto;
  padding: .75rem 1rem;
}

.panel-section { margin-bottom: 1rem; }
.panel-label { font-size: .78rem; font-weight: 600; color: var(--text-mid); display: block; margin-bottom: .35rem; }
.panel-hint { font-size: .8rem; color: var(--text-muted); margin-bottom: .75rem; }
.panel-actions { display: flex; gap: .5rem; margin-top: .75rem; flex-wrap: wrap; }

.form-input--sm { font-size: .85rem; padding: .45rem .7rem; }

/* Waypoints */
.waypoint-list { display: flex; flex-direction: column; gap: .3rem; }
.wp-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .4rem .6rem;
  font-size: .82rem;
}
.wp-num {
  background: var(--blue);
  color: #fff;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.wp-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-mid); }
.wp-remove {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: .8rem;
  width: 18px; height: 18px; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.wp-remove:hover { color: var(--danger); }

/* Route status */
.route-status {
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  margin-top: .5rem;
}
.route-status--loading { background: var(--blue-xpale); color: var(--blue-dark); }
.route-status--success { background: #f0fdf4; color: #14532d; }
.route-status--error   { background: #fef2f2; color: #991b1b; }

/* Input row */
.input-row { display: flex; align-items: center; gap: .5rem; }
.input-unit { font-size: .82rem; color: var(--text-muted); white-space: nowrap; }

/* Stage list */
.stages-list { display: flex; flex-direction: column; gap: .35rem; }
.stage-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s;
}
.stage-item:hover { border-color: var(--blue-mid); }
.stage-item-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stage-item-name { font-size: .85rem; font-weight: 600; color: var(--text); }
.stage-item-meta { font-size: .75rem; color: var(--text-muted); }

/* ─── Map ─────────────────────────────────────────────── */
.planner-map { flex: 1; }

/* Waypoint icon */
.wp-dot {
  width: 28px; height: 28px;
  background: var(--blue);
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  cursor: move;
}

/* Stage markers */
.stage-marker {
  width: 26px; height: 26px;
  border-radius: 50%;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  cursor: pointer;
}
.stage-marker--start { background: #16a34a; }

/* ─── Stage Popup ─────────────────────────────────────── */
.stage-popup {
  position: absolute;
  top: 60px;
  right: 16px;
  transform: none;
  width: 280px;
  max-height: calc(100% - 130px);
  overflow: visible;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 500;
  flex-direction: column;
}
.stage-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.stage-popup-title { font-size: .9rem; font-weight: 700; color: var(--text); }
.stage-popup-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: .9rem;
}
.stage-popup-close:hover { color: var(--danger); }
.stage-popup-body { padding: .85rem 1rem; display: flex; flex-direction: column; gap: .65rem;   overflow-y: auto;
  max-height: calc(100vh - 220px);
}
.sp-stats { display: flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.sp-stat {
  flex: 1;
  text-align: center;
  padding: .5rem .25rem;
  border-right: 1px solid var(--border);
  font-size: .82rem;
}
.sp-stat:last-child { border-right: none; }
.sp-stat strong { display: block; font-size: 1rem; font-weight: 700; color: var(--blue-dark); }
.sp-stat small { color: var(--text-muted); font-size: .7rem; }
.sp-actions { display: flex; gap: .4rem; flex-wrap: wrap; }


/* ═══════════════════════════════════════════════════════
   ACCOMMODATION LAYER
   ═══════════════════════════════════════════════════════ */
.acc-marker {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  border: 2.5px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  cursor: pointer;
  transition: transform .15s;
}
.acc-marker:hover { transform: scale(1.15); }

.acc-types { display: flex; flex-direction: column; gap: .4rem; }
.acc-type-label {
  display: flex; align-items: center; gap: .5rem;
  font-size: .85rem; color: var(--text-mid); cursor: pointer;
}
.acc-type-label input { cursor: pointer; }

/* ─── Waypoint buttons ───────────────────────────────── */
.wp-btns { display: flex; gap: .15rem; }
.wp-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer;
  font-size: .72rem; padding: .1rem .3rem;
  color: var(--text-muted);
  line-height: 1;
}
.wp-btn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.wp-btn:disabled { opacity: .3; cursor: not-allowed; }
.wp-btn--del:hover { border-color: var(--danger) !important; color: var(--danger) !important; }

/* ─── Stage popup improvements ───────────────────────── */
.sp-route-info {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem .65rem;
  display: flex; flex-direction: column; gap: .35rem;
}
.sp-route-row { display: flex; align-items: center; gap: .5rem; }
.sp-route-dot {
  width: 20px; height: 20px; border-radius: 50%;
  font-size: .65rem; font-weight: 700; color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sp-route-dot--start { background: #16a34a; }
.sp-route-dot--end   { background: #dc2626; }
.sp-route-label { font-size: .78rem; color: var(--text-mid); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Accommodation in stage popup ──────────────────── */
.sp-acc-section {
  border-top: 1px solid var(--border);
  padding-top: .65rem;
  margin-top: .25rem;
}
.sp-acc-header {
  display: flex; flex-direction: column; gap: .4rem;
  margin-bottom: .5rem;
}
.sp-acc-results { display: flex; flex-direction: column; gap: .35rem; max-height: 180px; overflow-y: auto; }
.sp-acc-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .35rem .5rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.sp-acc-icon {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; flex-shrink: 0;
}
.sp-acc-name { font-size: .8rem; font-weight: 600; color: var(--text); }
.sp-acc-meta { font-size: .72rem; color: var(--text-muted); }
.sp-acc-meta a { color: var(--blue); }


/* ═══════════════════════════════════════════════════════
   STAGE END MARKERS (draggable)
   ═══════════════════════════════════════════════════════ */
.stage-marker--end {
  cursor: grab;
  transition: transform .12s, box-shadow .12s;
  font-size: .75rem;
}
.stage-marker--end:hover {
  transform: scale(1.25);
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.stage-marker--end:active { cursor: grabbing; transform: scale(1.1); }
.stage-marker--finish {
  font-size: 1rem;
  background: #1e293b !important;
}

/* ═══════════════════════════════════════════════════════
   INSERT MODE
   ═══════════════════════════════════════════════════════ */
.insert-cancel-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--blue-dark);
  color: #fff;
  padding: .65rem 1.25rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .875rem;
  font-weight: 500;
  z-index: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  pointer-events: auto;
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { transform: translateX(-50%) translateY(20px); opacity:0; }
  to   { transform: translateX(-50%) translateY(0);    opacity:1; }
}

/* ═══════════════════════════════════════════════════════
   STAGE LIST ITEM – drag hint icon
   ═══════════════════════════════════════════════════════ */
.stage-item-drag-hint {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .9rem;
  cursor: default;
  padding: 0 .25rem;
  flex-shrink: 0;
  opacity: .5;
  font-style: normal;
  pointer-events: none;
}


/* ═══════════════════════════════════════════════════════
   WEATHER WIDGET
   ═══════════════════════════════════════════════════════ */
.weather-list { display: flex; flex-direction: column; gap: .4rem; max-height: 320px; overflow-y: auto; }

.weather-item {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .55rem .7rem;
}
.weather-item--na { opacity: .5; }
.weather-icon-large { font-size: 1.5rem; flex-shrink: 0; line-height: 1.4; }
.weather-stage-name { font-size: .8rem; font-weight: 700; color: var(--text); }
.weather-desc       { font-size: .75rem; color: var(--text-muted); }
.weather-temps      { font-size: .8rem; font-weight: 600; color: var(--blue-dark); margin-top: .15rem; }
.weather-extra      { font-size: .72rem; color: var(--text-muted); }
.weather-na         { font-size: .75rem; color: var(--text-muted); }

/* Overview table weather cell */
.weather-badge { display: flex; align-items: center; gap: .25rem; font-size: .82rem; }
.weather-icon  { font-size: 1rem; }
.weather-temp  { font-weight: 600; color: var(--text); }
.weather-rain  { color: #2563eb; font-size: .72rem; }
.weather-loading { color: var(--text-muted); font-size: .75rem; }

/* ═══════════════════════════════════════════════════════
   OVERVIEW / PRINT TABLE
   ═══════════════════════════════════════════════════════ */
.overview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
  background: var(--surface);
}
.overview-table th {
  background: var(--surface-alt);
  padding: .6rem .8rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-mid);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--border);
}
.overview-table td {
  padding: .75rem .8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.overview-table .totals-row td {
  background: var(--surface-alt);
  border-top: 2px solid var(--border);
  border-bottom: none;
}
.stage-num-badge {
  width: 24px; height: 24px; border-radius: 50%;
  color: #fff; font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.location-cell { max-width: 160px; color: var(--text-mid); }
.num-cell      { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.notes-cell    { color: var(--text-muted); font-size: .8rem; max-width: 180px; }
.weather-cell  { white-space: nowrap; }

/* ═══════════════════════════════════════════════════════
   BILLING / PLAN PAGE
   ═══════════════════════════════════════════════════════ */
.plan-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 2rem;
  border: 2px solid;
}
.plan-banner--pro  { background: var(--blue-xpale); border-color: var(--blue-light); }
.plan-banner--free { background: var(--surface-alt); border-color: var(--border); }
.plan-banner-icon  { font-size: 1.75rem; flex-shrink: 0; }
.plan-banner-name  { font-weight: 700; font-size: 1rem; color: var(--text); }
.plan-banner-status { font-size: .85rem; color: var(--text-muted); margin-top: .1rem; }

.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  max-width: 760px;
  margin-bottom: 2rem;
}
.plan-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.plan-card--pro     { border-color: var(--blue-mid); }
.plan-card--current { box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

.plan-card-badge {
  position: absolute;
  top: -12px; left: 50%;
  transform: translateX(-50%);
  background: var(--blue);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: .2rem .75rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.plan-card-header { display: flex; justify-content: space-between; align-items: baseline; }
.plan-name  { font-size: 1.2rem; font-weight: 800; color: var(--text); font-family: var(--font-head); }
.plan-price { font-size: 1.35rem; font-weight: 700; color: var(--blue-dark); }
.plan-price span { font-size: .8rem; font-weight: 400; color: var(--text-muted); }

.plan-features { list-style: none; display: flex; flex-direction: column; gap: .45rem; flex: 1; }
.feat          { font-size: .875rem; color: var(--text-mid); }
.feat--ok      { color: var(--text); }
.feat--no      { opacity: .55; }

.plan-card-footer    { margin-top: .5rem; }
.plan-current-badge  { display: inline-block; background: var(--green-pale); color: #14532d; font-size: .75rem; font-weight: 600; padding: .25rem .65rem; border-radius: 999px; }
.plan-hint           { font-size: .82rem; color: var(--text-muted); }

.billing-note {
  max-width: 760px;
  font-size: .85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

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


/* ═══════════════════════════════════════════════════════
   UPGRADE MODAL
   ═══════════════════════════════════════════════════════ */
.upgrade-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }

.upgrade-modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.25rem 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: slideUp .2s ease;
}
.upgrade-modal-icon  { font-size: 2.5rem; margin-bottom: .75rem; }
.upgrade-modal-title { font-size: 1.25rem; font-weight: 700; color: var(--text); margin-bottom: .6rem; }
.upgrade-modal-msg   { color: var(--text-muted); font-size: .9rem; line-height: 1.6; margin-bottom: 1.5rem; }
.upgrade-modal-actions { display: flex; gap: .75rem; justify-content: center; }


/* Plan usage bar */
.plan-usage-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: .5rem;
}
.plan-usage-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 999px;
  transition: width .4s ease;
}

/* Pro feature highlight */
.feat--highlight { font-size: .9rem !important; }

/* Upgrade hint in accommodation results */
.sp-acc-upgrade {
  font-size: .8rem;
  color: var(--text-mid);
  padding: .5rem;
  line-height: 1.6;
}


/* ═══════════════════════════════════════════════════════
   VIA-POINT MARKERS
   ═══════════════════════════════════════════════════════ */
.via-marker {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  transform: rotate(45deg);   /* diamond shape */
  border: 2px solid;
  background: white;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  cursor: grab;
  transition: transform .12s, box-shadow .12s;
}
.via-marker:hover {
  transform: rotate(45deg) scale(1.4);
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
}
.via-marker:active { cursor: grabbing; }

/* Polyline hover hint */
.leaflet-interactive:hover {
  cursor: copy;
}


/* ═══════════════════════════════════════════════════════
   TOUR CARD MINI-MAP
   ═══════════════════════════════════════════════════════ */
.tour-minimap {
  height: 130px;
  background: var(--surface-alt);
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.tour-minimap--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--border);
}
.tour-minimap .leaflet-container {
  background: #e8f4e8;
}

/* Preview distance hint */
#preview-distance:not(:empty) {
  display: block !important;
}


/* ═══════════════════════════════════════════════════════
   MAP SEARCH BOX
   ═══════════════════════════════════════════════════════ */
.map-search-box {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  z-index: 500;
}
.map-search-input {
  width: 100%;
  padding: .55rem .9rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: var(--font-body);
  box-shadow: 0 2px 12px rgba(0,0,0,.2);
  outline: none;
  background: #fff;
}
.map-search-input:focus {
  box-shadow: 0 2px 16px rgba(37,99,235,.25);
}
.map-search-results {
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  margin-top: 4px;
  overflow: hidden;
  max-height: 260px;
  overflow-y: auto;
}
.search-result-item {
  padding: .6rem .9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--blue-xpale); }
.search-result-name { font-size: .875rem; font-weight: 600; color: var(--text); }
.search-result-sub  { font-size: .75rem; color: var(--text-muted); margin-top: .1rem; }
.search-result-empty { color: var(--text-muted); font-size: .85rem; font-style: italic; cursor: default; }
.search-result-empty:hover { background: none; }
.search-pin { font-size: 1.4rem; line-height: 1; }
.leaflet-add-wp-btn {
  margin-top: .4rem;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: .3rem .7rem;
  font-size: .8rem;
  cursor: pointer;
  font-family: var(--font-body);
}
.leaflet-add-wp-btn:hover { background: var(--blue-dark); }


/* ═══════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 3000;
  pointer-events: none;
}
.toast {
  padding: .75rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  font-family: var(--font-body);
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  transform: translateY(12px);
  opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
  max-width: 320px;
  pointer-events: auto;
}
.toast--visible {
  transform: translateY(0);
  opacity: 1;
}
.toast--success { background: #1a3a2a; color: #86efac; }
.toast--error   { background: #3a1a1a; color: #fca5a5; }
.toast--info    { background: var(--blue-dark); color: #bfdbfe; }


/* ═══════════════════════════════════════════════════════
   STAGE LIST – INSERT DIVIDER
   ═══════════════════════════════════════════════════════ */
.stage-insert-divider {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .1rem .2rem;
  opacity: .35;
  transition: opacity .15s;
}
.stage-insert-divider:hover,
.stage-insert-divider--active {
  opacity: 1;
}
.stage-insert-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.stage-insert-divider--active .stage-insert-line {
  background: var(--blue);
}
.stage-insert-btn {
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  padding: .2rem .65rem;
  white-space: nowrap;
  transition: all .15s;
  font-family: var(--font-body);
}
.stage-insert-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-xpale);
}
.stage-insert-divider--active .stage-insert-btn {
  border-color: var(--blue);
  border-style: solid;
  color: var(--blue);
  background: var(--blue-pale);
  animation: pulse-border .8s ease infinite alternate;
}
@keyframes pulse-border {
  from { box-shadow: 0 0 0 0 rgba(37,99,235,.3); }
  to   { box-shadow: 0 0 0 4px rgba(37,99,235,.0); }
}

/* Stage item action buttons */
.stage-item-actions {
  display: flex;
  gap: .15rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity .15s;
}
.stage-item:hover .stage-item-actions { opacity: 1; }
.stage-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .85rem;
  padding: .15rem .3rem;
  border-radius: 4px;
  transition: background .12s;
  line-height: 1;
}
.stage-action-btn:hover { background: var(--border); }


/* ═══════════════════════════════════════════════════════
   BROUTER TOGGLE BAR
   ═══════════════════════════════════════════════════════ */
.brouter-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .85rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.brouter-toggle {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .75rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid;
  font-family: var(--font-body);
  transition: all .2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.brouter-toggle--on {
  background: #f0fdf4;
  border-color: #16a34a;
  color: #14532d;
}
.brouter-toggle--on:hover {
  background: #dcfce7;
}
.brouter-toggle--off {
  background: #fef2f2;
  border-color: #dc2626;
  color: #7f1d1d;
}
.brouter-toggle--off:hover {
  background: #fee2e2;
}
.brouter-label {
  font-size: .72rem;
  color: var(--text-muted);
  line-height: 1.3;
}


/* ═══════════════════════════════════════════════════════
   PROFILE HINT
   ═══════════════════════════════════════════════════════ */
.profile-hint {
  font-size: .75rem;
  color: var(--text-muted);
  line-height: 1.4;
  padding: .35rem .5rem;
  background: var(--blue-xpale);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--blue-light);
  display: none;
}


/* ═══════════════════════════════════════════════════════
   REFERENCE TRACK SIDEBAR
   ═══════════════════════════════════════════════════════ */
.ref-tracks-list { display: flex; flex-direction: column; gap: .3rem; }

.ref-track-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .45rem .6rem;
}
.ref-track-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.15);
}
.ref-track-name {
  flex: 1;
  font-size: .8rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ref-track-btns {
  display: flex;
  gap: .15rem;
  flex-shrink: 0;
}


/* ═══════════════════════════════════════════════════════
   UNDO BUTTON
   ═══════════════════════════════════════════════════════ */
.undo-btn {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .3rem .65rem;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-mid);
  font-family: var(--font-body);
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.undo-btn:not(:disabled):hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-xpale);
}
.undo-btn:disabled {
  cursor: not-allowed;
}


/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE – Mobile First
   Breakpoints: sm=480px  md=768px  lg=1024px
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Navbar: hamburger menu ────────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: .4rem;
  margin-left: auto;
  background: none;
  border: none;
}
.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: rgba(255,255,255,.85);
  border-radius: 2px;
  transition: all .2s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Planner: sidebar slide-in on mobile ──────────────────────────────── */
.planner-toggle-btn {
  display: none;
  position: fixed;
  bottom: 1.25rem;
  left: 1.25rem;
  z-index: 600;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: .6rem 1.1rem;
  font-size: .85rem;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37,99,235,.4);
  gap: .4rem;
  align-items: center;
}

/* ── Dashboard grid ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Navbar */
  .nav-hamburger { display: flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 58px;
    left: 0; right: 0;
    background: var(--blue-dark);
    flex-direction: column;
    align-items: stretch;
    padding: .5rem .75rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    z-index: 200;
    gap: .15rem;
  }
  .nav-links.open { display: flex; }
  .nav-links .nav-link { padding: .65rem .9rem; font-size: .95rem; }
  .nav-user {
    flex-direction: row;
    justify-content: space-between;
    padding: .65rem .9rem 0;
    border-top: 1px solid rgba(255,255,255,.1);
    margin-top: .25rem;
  }
  .navbar { position: relative; }

  /* Layout */
  .main-content { padding: 1.25rem .9rem; }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: .75rem;
  }
  .page-actions { width: 100%; }
  .page-actions .btn { width: 100%; justify-content: center; }

  /* Stats grid */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-stats { flex-wrap: wrap; gap: .75rem; }
  .detail-stat { min-width: calc(50% - .4rem); flex: 1 1 40%; }

  /* Dashboard 2-col → 1-col */
  div[style*="grid-template-columns:1fr 1fr"] {
    display: flex !important;
    flex-direction: column !important;
  }

  /* Tour grid: 2-col → 1-col */
  .tour-grid { grid-template-columns: 1fr; }

  /* Admin stats */
  .admin-stats { grid-template-columns: repeat(2, 1fr) !important; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; }
  .form-section { padding: 1.25rem; }

  /* Tables: horizontal scroll */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .overview-table { min-width: 640px; }
  .admin-table    { min-width: 600px; }

  /* Profile grid */
  div.form-section + div.form-section { margin-top: 1rem; }
  div[style*="grid-template-columns:1fr 1fr;gap:1.5rem;max-width:760px"] {
    display: flex !important;
    flex-direction: column !important;
  }

  /* Billing plan grid */
  .plan-grid { grid-template-columns: 1fr; }

  /* Overview page actions */
  .page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

  /* Map search box */
  .map-search-box { width: calc(100vw - 4rem); max-width: 320px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: 1.4rem; }
  .tour-card-footer { flex-direction: column; }
  .admin-stats { grid-template-columns: 1fr 1fr !important; }
  .detail-stat { min-width: 100%; }

  /* Sidebar stats bar */
  .sidebar-stats { gap: 0; }
  .sstat { padding: .5rem .4rem; }
  .sstat small { font-size: .65rem; }
}

/* ── Planner: sidebar on mobile ────────────────────────────────────────── */
@media (max-width: 1024px) {
  /* Planner becomes stacked: map top, sidebar bottom */
  .planner-layout {
    flex-direction: column !important;
  }
  .planner-map {
    height: 55vh !important;
    min-height: 300px;
  }
  .planner-sidebar {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    max-height: 45vh;
    overflow-y: auto;
    border-left: none !important;
    border-top: 1px solid var(--border);
  }
  .planner-toggle-btn { display: inline-flex; }
  .sidebar-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .stab { white-space: nowrap; font-size: .78rem; padding: .5rem .6rem; }
  .brouter-bar { flex-wrap: wrap; gap: .4rem; }
  .stage-popup {
    max-width: calc(100vw - 2rem) !important;
    left: 1rem !important;
    right: 1rem !important;
    transform: none !important;
  }
}

@media (max-width: 768px) {
  .planner-map { height: 50vh !important; }
  .planner-sidebar { max-height: 50vh; }
  .planner-layout { height: auto !important; }
  /* Make cancel bar visible above keyboard */
  #insert-cancel-bar {
    bottom: env(safe-area-inset-bottom, 0px);
  }
  /* GPX list */
  .gpx-grid { grid-template-columns: 1fr !important; }
}

/* ── Planner sidebar toggle (slide-in on very small screens) ──────────── */
@media (max-width: 600px) {
  .planner-layout { flex-direction: column !important; height: auto !important; }
  .planner-map    { height: 60vmax !important; min-height: 260px; }
  .planner-sidebar {
    max-height: none;
    height: auto;
  }
  .map-search-box { top: 8px; }
  .brouter-bar .brouter-label { display: none; }
}

/* ── Touch improvements ─────────────────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets */
  .btn { min-height: 44px; }
  .nav-link { min-height: 44px; display: flex; align-items: center; }
  .stab { min-height: 40px; display: flex; align-items: center; justify-content: center; }
  .stage-item { min-height: 52px; }
  .stage-insert-btn { min-height: 36px; }
  .stage-action-btn { min-height: 36px; width: 36px; }
  /* Always show stage action buttons on touch */
  .stage-item-actions { opacity: 1 !important; }
}



/* ── Reference track colour picker ─────────────────────────────────────── */
.ref-track-color-picker {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  border: 1.5px solid var(--border);
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  background: none;
}
.ref-track-color-picker::-webkit-color-swatch-wrapper { padding: 2px; }
.ref-track-color-picker::-webkit-color-swatch { border-radius: 2px; border: none; }
.ref-track-color-picker:hover { border-color: var(--blue); }


/* ── Stage popup: clear of layer controls ─────────────────────────────────── */
.stage-popup {
  top: 60px !important;
  transform: none !important;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
}

/* ── Leaflet controls: bottom-right horizontal row ────────────────────────── */
.leaflet-bottom.leaflet-right {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 6px;
  padding-bottom: 8px;
  padding-right: 8px;
}
.leaflet-bottom.leaflet-right .leaflet-control {
  margin: 0 !important;
  float: none !important;
}


/* ── Elevation panel below map ─────────────────────────────────────────────── */
.planner-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 58px);
}

.planner-main {
  display: flex;
  flex: 1;
  min-height: 0;
}

.planner-elevation-panel {
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  height: 140px;
}

.planner-elevation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .3rem .75rem .1rem;
  border-bottom: 1px solid var(--border);
}

.planner-elevation-title {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.planner-elevation-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: .8rem;
  padding: .1rem .3rem;
  border-radius: 3px;
  font-family: var(--font-body);
}
.planner-elevation-close:hover { background: var(--border); color: var(--text); }

/* ── Save progress bar ─────────────────────────────────────────────────────── */
#save-spinner { display: none; pointer-events: none; }
.save-progress-bar {
  position: absolute;
  top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  animation: progress-slide 1s ease-in-out infinite;
}
@keyframes progress-slide {
  0%   { left: -100%; }
  100% { left: 100%;  }
}
#sp-save.saving {
  opacity: .6;
  pointer-events: none;
}
#sp-save.saving::after {
  content: ' ⏳';
}
