:root {
  --bg-main: #0b1120;
  --bg-card: #151f32;
  --bg-card-hover: #1e293b;
  --border-color: #27354a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-cyan: #38bdf8;
  --accent-blue: #3b82f6;
  --color-safe: #10b981;
  --color-caution: #f59e0b;
  --color-danger: #ef4444;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.brand-badge {
  font-size: 0.8rem;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-weight: 600;
  white-space: nowrap;
}

nav.tabs {
  display: flex;
  gap: 0.5rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn:active {
  transform: scale(0.97);
}

.tab-btn.active {
  color: var(--text-main);
  background: var(--accent-blue);
}

.tab-text-short {
  display: none;
}

.tab-text-full {
  display: inline;
}

main {
  flex: 1;
  padding: clamp(0.75rem, 2.5vw, 2rem);
  max-width: 1300px;
  margin: 0 auto;
  width: 100%;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Card components */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Form controls */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.65rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  border-color: var(--accent-cyan);
}

.btn {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:hover {
  background: #2563eb;
}

.btn:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: #334155;
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #475569;
}

.btn-danger {
  background: var(--color-danger);
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: var(--color-safe);
}

.btn-success:hover {
  background: #059669;
}

.btn-sm {
  padding: 0.35rem 0.7rem !important;
  font-size: 0.8rem !important;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-safe { background: #065f46; color: #6ee7b7; border: 1px solid #059669; }
.badge-good { background: #064e3b; color: #a7f3d0; border: 1px solid #10b981; }
.badge-caution { background: #78350f; color: #fde68a; border: 1px solid #d97706; }
.badge-danger { background: #7f1d1d; color: #fca5a5; border: 1px solid #dc2626; }
.badge-open { background: #1e293b; color: #94a3b8; border: 1px solid #475569; }

/* Table styling */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

table.data-table th {
  background: #1e293b;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.65rem 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

table.data-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
  vertical-align: middle;
}

table.data-table .cell-main {
  font-size: 0.92rem;
  line-height: 1.25;
  white-space: nowrap;
}

table.data-table .cell-sub {
  color: var(--text-dim);
  font-size: 0.76rem;
  margin-top: 0.2rem;
  line-height: 1.2;
  white-space: nowrap;
}

table.data-table tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* Map container */
#map {
  height: 520px;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  z-index: 1;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Results section */
.results-header-banner {
  background: #182235;
  border: 1px solid #2d3d57;
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.lake-stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-item .label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.stat-item .val {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

.hazards-box {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin-top: 1.25rem;
}

.hazards-box h4 {
  color: #f87171;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hazards-box ul {
  list-style: none;
}

.hazards-box li {
  font-size: 0.85rem;
  color: #e2e8f0;
  margin-bottom: 0.3rem;
  padding-left: 1.2rem;
  position: relative;
}

.hazards-box li::before {
  content: "•";
  color: #f87171;
  position: absolute;
  left: 0;
}

.spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Map Pointing Mode & Crosshair */
.btn-primary {
  background: var(--accent-blue);
  color: #fff;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-pointing-active {
  background: #ea580c !important;
  color: #fff !important;
  border: 1px solid #f97316 !important;
  animation: pulse-border 1.5s infinite;
}

#map.crosshair-cursor,
#map.crosshair-cursor .leaflet-container,
#map.crosshair-cursor .leaflet-pane,
#map.crosshair-cursor .leaflet-interactive {
  cursor: crosshair !important;
}

.map-helper-banner {
  background: rgba(30, 58, 138, 0.35);
  border: 1px solid #3b82f6;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  animation: fadeIn 0.25s ease-out;
}

.pulse-indicator {
  font-size: 1.3rem;
  animation: pulse-icon 1s infinite alternate;
}

.modal-auto-alert {
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 0.5rem;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
}

.toast-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #fff;
  border: 1px solid var(--accent-cyan);
  padding: 0.8rem 1.2rem;
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  z-index: 3000;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  animation: slideUp 0.3s ease-out;
}

@keyframes pulse-icon {
  from { transform: scale(1); }
  to { transform: scale(1.25); }
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(234, 88, 12, 0); }
  100% { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* Responsive Component Helpers */
.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
  display: block;
}

.analysis-action-bar {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.res-title-group h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

.res-title-group p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.table-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.table-scroll-hint-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.4rem;
}

.table-scroll-hint {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  display: none;
  align-items: center;
  gap: 0.35rem;
  user-select: none;
  font-weight: 600;
}

.map-card-header,
.manage-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.map-header-actions,
.manage-actions-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.map-banner-content {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.map-banner-sub {
  color: var(--text-muted);
  display: block;
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.modal-buttons-row {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Leaflet mobile popup styling */
.leaflet-popup-content-wrapper {
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

.leaflet-popup-content {
  margin: 12px 14px !important;
  line-height: 1.4 !important;
}

/* ==========================================================================
   MOBILE RESPONSIVENESS & MEDIA QUERIES
   ========================================================================== */

/* Tablet & Smaller Screens (max-width: 860px) */
@media (max-width: 860px) {
  .table-scroll-hint {
    display: inline-flex;
  }

  header {
    padding: 0.85rem 1.25rem;
  }

  main {
    padding: 1.25rem 1rem;
  }

  #map {
    height: 440px;
  }
}

/* Mobile Screens (max-width: 768px) */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }

  .brand {
    justify-content: space-between;
    width: 100%;
  }

  .brand h1 {
    font-size: 1.15rem;
  }

  nav.tabs {
    width: 100%;
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  nav.tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    flex: 1 1 auto;
    justify-content: center;
    padding: 0.5rem 0.5rem;
    font-size: 0.82rem;
    min-height: 42px;
    border-radius: 0.4rem;
    text-align: center;
    white-space: nowrap;
  }

  main {
    padding: 0.85rem 0.65rem;
  }

  .card {
    padding: 1rem 0.85rem;
    margin-bottom: 1rem;
    border-radius: 0.65rem;
  }

  .card-title {
    font-size: 1.05rem;
  }

  #map {
    height: 380px;
  }

  .results-header-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    padding: 0.85rem;
  }

  .lake-stats {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }

  .stat-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 0.45rem 0.65rem;
    border-radius: 0.4rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
  }

  table.data-table th {
    padding: 0.55rem 0.65rem;
    font-size: 0.72rem;
  }

  table.data-table td {
    padding: 0.55rem 0.65rem;
  }

  table.data-table .cell-main {
    font-size: 0.85rem;
  }

  table.data-table .cell-sub {
    font-size: 0.72rem;
  }

  .modal-overlay {
    padding: 0.5rem;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 94vh;
    padding: 1.25rem 1rem;
    border-radius: 0.75rem;
  }

  .toast-notice {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    width: auto;
    max-width: calc(100vw - 2rem);
    justify-content: center;
    text-align: center;
    font-size: 0.85rem;
    padding: 0.7rem 1rem;
  }
}

/* Small Mobile Screens (max-width: 600px) */
@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  /* Prevent iOS Safari auto-zooming on focus by ensuring font-size >= 16px */
  .form-control {
    font-size: 16px;
    padding: 0.65rem 0.75rem;
  }

  .analysis-action-bar {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .analysis-action-bar button,
  #btn-run-analysis {
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
  }

  #analysis-status {
    width: 100%;
    text-align: center;
  }

  .map-card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .map-header-actions,
  .map-header-actions button,
  #btn-toggle-add-mode {
    width: 100%;
    min-height: 44px;
  }

  .map-helper-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .map-helper-banner button {
    width: 100%;
    min-height: 40px;
  }

  .manage-card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .manage-actions-group {
    width: 100%;
    flex-direction: column;
  }

  .manage-actions-group button {
    width: 100%;
    min-height: 44px;
  }

  #res-download-image {
    width: 100%;
    min-height: 44px;
  }

  table.data-table th {
    padding: 0.45rem 0.45rem;
    font-size: 0.68rem;
    letter-spacing: 0;
  }

  table.data-table td {
    padding: 0.45rem 0.45rem;
  }

  table.data-table .cell-main {
    font-size: 0.8rem;
  }

  table.data-table .cell-sub {
    font-size: 0.68rem;
  }

  .badge {
    padding: 0.2rem 0.4rem;
    font-size: 0.74rem;
  }
}

/* Extra Small Mobile Screens (max-width: 480px) */
@media (max-width: 480px) {
  main {
    padding: 0.65rem 0.4rem;
  }

  .card {
    padding: 0.75rem 0.5rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
    gap: 0.5rem;
  }

  .table-toggle-btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
  .tab-text-full {
    display: none;
  }

  .tab-text-short {
    display: inline;
    font-size: 0.82rem;
    font-weight: 700;
  }

  .brand-badge {
    display: none; /* Hide long badge to keep tiny screen clean */
  }

  .brand h1 {
    font-size: 1.1rem;
  }

  #map {
    height: 330px;
  }

  .lake-stats {
    grid-template-columns: 1fr;
  }

  .modal-buttons-row {
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  .modal-buttons-row button {
    width: 100%;
    min-height: 44px;
  }

  .modal-title {
    font-size: 1.1rem;
  }
}

/* ==========================================================================
   New Feature Styles: Mode Selector, Chips, Season KPIs & Download Actions
   ========================================================================== */

/* Mode Selector Pills */
.mode-selector {
  display: flex;
  gap: 0.5rem;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.35rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  margin-bottom: 1.25rem;
}

.mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  user-select: none;
}

.mode-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.mode-btn.active {
  color: #fff;
  background: var(--accent-blue);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

/* Preset Chips (e.g. 3, 7, 14 vrk) */
.chips-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
}

.chip.active {
  background: var(--accent-cyan);
  color: #0f172a;
  border-color: var(--accent-cyan);
  font-weight: 700;
}

/* Season KPI Summary Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0 1.5rem 0;
}

.kpi-card {
  background: #182235;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: transform 0.15s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: #475569;
}

.kpi-lbl {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.kpi-val {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
}

.kpi-val.cyan { color: #38bdf8; }
.kpi-val.green { color: #4ade80; }
.kpi-val.yellow { color: #facc15; }
.kpi-val.purple { color: #818cf8; }
.kpi-val.pink { color: #f472b6; }

/* Table View Toggle */
.table-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.table-toggle-btn {
  background: #1e293b;
  border: 1px solid var(--border-color);
  color: var(--accent-cyan);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.table-toggle-btn:hover {
  background: #334155;
}

/* Download Action Buttons */
.download-actions-row {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

@media (max-width: 600px) {
  .mode-selector {
    flex-direction: column;
    gap: 0.25rem;
  }
  .download-actions-row {
    flex-direction: column;
  }
  .download-actions-row .btn {
    width: 100%;
    min-height: 44px;
  }
}

/* ==========================================================================
   WHOLE LAKE TAB (KOKO JÄRVI) STYLES
   ========================================================================== */
.lake-card-header {
  margin-bottom: 1.5rem;
}

.lake-search-toolbar {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.lake-search-inputs {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.flex-1 {
  flex: 1;
  min-width: 240px;
}

.lake-pills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.pill-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-right: 0.25rem;
}

.btn-pill {
  background: rgba(51, 65, 85, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-pill:hover {
  background: var(--accent-blue);
  color: #ffffff;
  border-color: var(--accent-blue);
}

.lake-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.lake-stats-grid .stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lake-stats-grid .stat-icon {
  font-size: 1.8rem;
}

.lake-stats-grid .stat-meta {
  display: flex;
  flex-direction: column;
}

.lake-stats-grid .stat-title {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lake-stats-grid .stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: #f8fafc;
}

.lake-slider-box {
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.lake-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.slider-date-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.slider-badge {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
}

.slider-date-text {
  font-size: 1.1rem;
  color: #ffffff;
}

.slider-temp-badge {
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 0.25rem;
}

.lake-range-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #334155;
  outline: none;
  cursor: pointer;
  accent-color: var(--accent-cyan);
}

.lake-map-wrapper {
  position: relative;
  margin-bottom: 1.5rem;
}

.lake-map-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.6rem 1rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #cbd5e1;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.dot-water { background: transparent; border: 1.5px dashed #94a3b8; }
.dot-slush { background: #38bdf8; border: 1px solid #7dd3fc; }
.dot-skate { background: #2563eb; border: 1px solid #60a5fa; }
.dot-safe  { background: #10b981; border: 1px solid #34d399; }

.lake-bottom-info {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.freeze-dates-panel h4, .lake-downloads-panel h4 {
  font-size: 0.9rem;
  color: #f1f5f9;
  margin-bottom: 0.6rem;
}

.freeze-dates-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.freeze-date-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #cbd5e1;
}

.freeze-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

@media (max-width: 768px) {
  .lake-bottom-info {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   WHOLE LAKE MAP FULLSCREEN STYLES
   ========================================================================== */
.lake-map-section {
  position: relative;
  width: 100%;
}

.lake-map-section.is-fullscreen,
.lake-map-section:fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 99999 !important;
  background: #0f172a !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

.lake-map-section.is-fullscreen .lake-map-wrapper,
.lake-map-section:fullscreen .lake-map-wrapper {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  z-index: 1;
}

.lake-map-section.is-fullscreen #lake-leaflet-map,
.lake-map-section:fullscreen #lake-leaflet-map {
  width: 100% !important;
  height: 100% !important;
  border-radius: 0 !important;
  border: none !important;
}

.lake-map-section.is-fullscreen .lake-slider-box,
.lake-map-section:fullscreen .lake-slider-box {
  position: absolute !important;
  bottom: 24px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  width: min(92%, 780px) !important;
  z-index: 1002 !important;
  background: rgba(15, 23, 42, 0.9) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 0.75rem !important;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.7) !important;
  margin: 0 !important;
  padding: 0.85rem 1.25rem !important;
}

.lake-map-section.is-fullscreen .lake-map-legend,
.lake-map-section:fullscreen .lake-map-legend {
  position: absolute !important;
  top: 14px !important;
  left: 60px !important;
  z-index: 1001 !important;
  background: rgba(15, 23, 42, 0.88) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 0.5rem !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
  margin: 0 !important;
  padding: 0.4rem 0.85rem !important;
}

/* In-map Leaflet fullscreen button */
.leaflet-control-fullscreen-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 1.15rem !important;
  font-weight: bold !important;
  text-decoration: none !important;
  color: #334155 !important;
  background: #ffffff !important;
  cursor: pointer !important;
  line-height: 30px !important;
  width: 32px !important;
  height: 32px !important;
}

.leaflet-control-fullscreen-btn:hover {
  background: #f1f5f9 !important;
  color: #0284c7 !important;
}

/* In-map Leaflet Layer Control */
.leaflet-control-layers {
  background: rgba(15, 23, 42, 0.92) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 0.5rem !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
  padding: 0.5rem 0.75rem !important;
}

.leaflet-control-layers-expanded {
  font-family: inherit !important;
  font-size: 0.85rem !important;
}

.leaflet-control-layers label {
  color: var(--text-main) !important;
  font-size: 0.85rem !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.4rem !important;
  margin-bottom: 0.3rem !important;
}

.leaflet-control-layers-toggle {
  background-color: #ffffff !important;
  border-radius: 4px !important;
}

@media (max-width: 600px) {
  .lake-map-section.is-fullscreen .lake-slider-box,
  .lake-map-section:fullscreen .lake-slider-box {
    bottom: 10px !important;
    width: calc(100% - 20px) !important;
    padding: 0.65rem 0.85rem !important;
  }
  .lake-map-section.is-fullscreen .lake-map-legend,
  .lake-map-section:fullscreen .lake-map-legend {
    top: 55px !important;
    left: 10px !important;
    font-size: 0.72rem !important;
    gap: 0.6rem !important;
    padding: 0.3rem 0.6rem !important;
  }
}

/* ==========================================
   UNIFIED LAYOUT & DYNAMIC MAP STYLES
   ========================================== */
.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.lake-search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  max-width: 480px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.9rem;
  pointer-events: none;
}

.search-input-wrap input {
  padding-left: 2.2rem !important;
  font-size: 0.85rem !important;
}

.map-wrapper {
  position: relative;
  width: 100%;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

#map {
  width: 100%;
  height: 480px;
  background: #0f172a;
}

@media (max-width: 768px) {
  #map {
    height: 380px;
  }
}

/* Selected Basin Bar below map */
.selected-basin-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.selected-basin-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.selected-basin-pin {
  font-size: 1.35rem;
  line-height: 1;
}

.selected-basin-heading {
  font-size: 0.95rem;
  color: var(--text-main);
}

.selected-basin-heading strong {
  color: var(--accent-cyan);
}

.selected-basin-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.selected-basin-action {
  display: flex;
  align-items: center;
}

/* Options row */
.options-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.4);
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
  color: var(--text-main);
}

/* Basin Popup & Tooltip */
.basin-popup {
  padding: 0.2rem 0;
  min-width: 200px;
}

.basin-popup-title {
  font-weight: 700;
  font-size: 1rem;
  color: #0f172a;
  margin-bottom: 0.15rem;
}

.basin-popup-meta {
  font-size: 0.78rem;
  color: #64748b;
  margin-bottom: 0.6rem;
}

.basin-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.btn-block {
  width: 100%;
}

.basin-tooltip {
  background: rgba(15, 23, 42, 0.92) !important;
  border: 1px solid var(--accent-cyan) !important;
  color: #f8fafc !important;
  border-radius: 0.375rem !important;
  padding: 0.4rem 0.65rem !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4) !important;
}

/* Media preview (video & image cards) */
.media-preview-box {
  margin-top: 1.5rem;
  text-align: center;
}

.res-media-video {
  max-width: 100%;
  width: min(100%, 700px);
  max-height: 80vh;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  background: #000;
}

.res-media-image {
  max-width: 100%;
  width: min(100%, 700px);
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.4);
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 260px;
  max-width: 420px;
  padding: 0.75rem 1.15rem;
  border-radius: 0.5rem;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  animation: slideInToast 0.25s ease-out;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.toast.fade-out {
  opacity: 0;
  transform: translateY(10px);
}

.toast-info {
  background: #1e293b;
  color: var(--accent-cyan);
  border: 1px solid var(--accent-cyan);
}

.toast-success {
  background: #064e3b;
  color: #6ee7b7;
  border: 1px solid #10b981;
}

.toast-warning {
  background: #451a03;
  color: #fde68a;
  border: 1px solid #f59e0b;
}

.toast-danger {
  background: #450a0a;
  color: #fca5a5;
  border: 1px solid #ef4444;
}

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

