:root {
  --brand-bg: #0f172a; /* slate-900 */
  --brand-surface: #111827; /* gray-900 */
  --brand-accent: #38bdf8; /* sky-400 */
  --brand-accent-strong: #0ea5e9; /* sky-500 */
  --text: #e5e7eb; /* gray-200 */
  --muted: #9ca3af; /* gray-400 */
  --ring: 2px;
}

html, body {
  background: var(--brand-bg);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  margin: 0;
  padding: 0;
  overflow: hidden; /* Prevent scrollbars */
}

/* Loading screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--brand-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20000; /* Above everything including header (10001) */
  transition: opacity 0.5s ease-out;
}

.loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Password prompt overlay */
.password-prompt-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--brand-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10001; /* Above loading screen */
}

.password-prompt-box {
  background: var(--brand-surface);
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  min-width: 350px;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.password-prompt-title {
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
}

.password-prompt-box .form-group {
  width: 100%;
  margin-bottom: 0;
}

.password-prompt-box input[type="password"] {
  width: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: var(--text);
  font-size: 16px;
}

.password-prompt-box input[type="password"]:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.password-submit-btn {
  background: var(--brand-accent);
  color: var(--brand-bg);
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.password-submit-btn:hover {
  background: var(--brand-accent-strong);
}

.password-error {
  text-align: center;
  font-size: 14px;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(56, 189, 248, 0.2);
  border-top: 4px solid var(--brand-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

.loading-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.loading-logo {
  height: 40px;
  width: auto;
  display: block;
}

.loading-title {
  font-size: 54px;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text);
  margin-left: 20px;
  line-height: 1;
  transform: translateY(-1px); /* try -2px or -3px to move text up */
}

.loading-message {
  color: var(--text);
  font-size: 34px;
  font-weight: 500;
  text-align: center;
  margin-bottom: 10px;
}

/* Password section on loading screen */
#password-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#password-input-row {
  width: 100%;
}

#password-section .form-group {
  width: 100%;
  margin-bottom: 0;
}

#password-section input[type="password"] {
  width: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: var(--text);
  font-size: 16px;
}

#password-section input[type="password"]:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.password-submit-btn {
  background: var(--brand-accent);
  color: var(--brand-bg);
  border: none;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  height: fit-content;
}

.password-submit-btn:hover {
  background: var(--brand-accent-strong);
}

#loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.loading-subtitle {
  color: var(--muted);
  font-size: 28px;
  text-align: center;
  width: 100%;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.app-container {
  display: grid;
  grid-template-columns: 0 1fr; /* hide structural sidebar column; we overlay sidebar absolutely */
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "header header"
    "main main";
  height: 100vh;
  position: relative;
}

/* Full-canvas map behind the UI */
#map_canvas, #map_main {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2;
  overflow: hidden;
}

.lhs-floating {
  position: absolute;
  left: 5px;
  top: 60px;
  width: 230px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 8px;
  z-index: 2000;
  display: block;
}

/* Stack the dynamic left buttons vertically */
#lhs_ui { display: flex; flex-direction: column; gap: 5px; }

.lhs-floating .btn:not(.button-pill) { display: none; }
.lhs-floating .button-pill { display: flex; width: 100%; height: 36px; }

.sidebar .btn.active, .sidebar .btn:focus, .sidebar .btn:hover {
  color: var(--text);
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 var(--ring) rgba(56,189,248,0.25);
}

/* --- Top Trump: Profit Calculator sheet --- */
.site-info-sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.site-info-sheet-table td {
  padding: 3px 6px;
}

/* Column widths: bring figures closer to text column */
.site-info-sheet-table td:first-child {
  width: 40%;
  text-align: left;
}

.site-info-sheet-table td:nth-child(2),
.site-info-sheet-table td:nth-child(3) {
  width: 30%;
}

/* Centre align figure columns B and C */
.site-info-sheet-table td:nth-child(2),
.site-info-sheet-table td:nth-child(3) {
  text-align: center;
}

/* Input cell styling */
.site-info-input-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.site-info-input-prefix {
  font-weight: 600;
  color: #01061C; /* black prefix text */
}

.site-info-input-wrapper .form-group {
  margin-bottom: 0;
}

.site-info-input-wrapper input[type="number"] {
  background: rgba(15, 23, 42, 0.9); /* darker panel-style background */
  border: 1px solid rgba(148, 163, 184, 0.9); /* clearer border */
  border-radius: 4px;
  color: #f9fafb; /* near-white for strong contrast */
  font-family: inherit; /* match IBM Plex Sans used in the app */
  padding: 4px 6px;
  font-size: 13px;
  width: 80px;
  text-align: center; /* centre the numerics in the cell */
}

.site-info-input-wrapper input[type="number"]:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);
}

/* Section gradient panels */
.site-info-section-1 td {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--status-color, #3272EA) 40%, white 60%) 0%,
    rgba(255, 255, 255, 0.4) 100%
  );
  color: #01061C; /* black text */
}

.site-info-section-2 td {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--status-color, #3272EA) 40%, white 60%) 0%,
    rgba(255, 255, 255, 0.4) 100%
  );
  color: #01061C; /* black text */
}

.site-info-section-3 td {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--status-color, #3272EA) 40%, white 60%) 0%,
    rgba(255, 255, 255, 0.4) 100%
  );
  color: #01061C; /* black text */
}

.site-info-section-4 td {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--status-color, #3272EA) 40%, white 60%) 0%,
    rgba(255, 255, 255, 0.4) 100%
  );
  color: #01061C; /* black text */
}

/* Emphasis rows */
.site-info-row-strong td {
  font-weight: 600;
}

/* Negative numbers */
.site-info-neg {
  color: #f97373;
}

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  padding: 8px 12px;
  border: none;
  z-index: 10001;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 20px;
}

.app-branding {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-left: 20px;
}

.app-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.app-title {
  color: #01061C;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}

.top-tabs {
  position: absolute;
  top: 10px;
  left: 300px; /* align with floating sidebar edge */
  display: flex;
  gap: 12px;
}

.top-tabs .tab-btn { display: none; }

.main {
  grid-area: main;
  padding: 16px;
  position: relative;
  z-index: 1;
}

.content-card {
  background: transparent; /* allow map canvas to show through */
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px;
}

/* Main content area for image/video/chart content above the map canvas */
.overlay {
  position: absolute;
  top: 80px;
  left: 300px;
  right: 20px;
  bottom: 20px;
  pointer-events: none; /* let clicks pass through unless on card */
  z-index: 2100;
}
.overlay-card {
  position: relative;
  max-width: 80vw;
  max-height: 80vh;
  overflow: auto;
  background: rgba(255,255,255,0.92);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.35);
  pointer-events: auto;
  z-index: 2200; /* Above site overlay panel */
}

/* Help panel (Ask Molior) should be above all other content panels */
.help-panel-card {
  z-index: 10000 !important; /* Above all other overlays but below loading/password screens */
}

/* Ensure the overlay wrapper containing the help panel also has high z-index */
.help-panel-overlay {
  z-index: 10000 !important;
}

.overlay:has(.help-panel-card),
.overlay .help-panel-card {
  z-index: 10000 !important;
}

/* Fallback for browsers that don't support :has() */
.overlay > .help-panel-card {
  z-index: 10000 !important;
}

/* Shiny bindings alignment */
.shiny-input-container { color: var(--text); }
label { color: var(--muted); }

/* Imported look from other-project.html */
.button-pill {
  background-color: #01061C; /* navy */
  color: white;
  border-radius: 50px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  font-size: 10pt;
  font-family: "IBM Plex Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: bold;
  padding: 0 16px;
  margin: 5px;
  text-align: center;
  cursor: pointer;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  position: relative;
  z-index: 1001;
}

.button-pill.navy { background-color: #01061C; }
.button-pill:hover { background-color: #1A1F3D; box-shadow: 0 0 15px rgba(1, 6, 28, 0.8), 0 0 30px rgba(1, 6, 28, 0.6); }
.button-pill.active { background-color: #46C691; }
.button-pill:disabled { opacity: 0.55; cursor: not-allowed; animation: none; filter: grayscale(10%); }

.paired-tab-group .button-pill.paired-tab {
  border-radius: 0 !important;
  border-left-width: 1px;
  border-right-width: 1px;
}

.button-pill.paired-tab.paired-left {
  border-radius: 50px 0 0 50px !important;
}

.button-pill.paired-tab.paired-right {
  border-radius: 0 50px 50px 0 !important;
}

.button-pill.paired-tab.paired-middle {
  border-radius: 0 !important;
}

/* Button with dropdown arrow for location1 */
.button-pill-with-dropdown {
  display: flex;
  width: 100%;
  gap: 0;
  margin: 5px;
}

.button-pill-with-dropdown .button-pill {
  margin: 0;
  flex: 1;
}

.button-pill-dropdown {
  background-color: #01061C;
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-left: none;
  border-radius: 0 50px 50px 0;
  cursor: pointer;
  font-size: 10pt;
  padding: 0 12px;
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  font-weight: bold;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.button-pill-dropdown:hover {
  background-color: #1A1F3D;
  box-shadow: 0 0 15px rgba(1, 6, 28, 0.8), 0 0 30px rgba(1, 6, 28, 0.6);
}

.button-pill-dropdown.active {
  background-color: #46C691;
}

/* CSS arrow for dropdown - right pointing */
.dropdown-arrow {
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid white;
  vertical-align: middle;
}

/* Site selection panel */
.site-selection-overlay {
  z-index: 10000 !important; /* Same as help panel */
}

.site-selection-card {
  max-width: 900px;
  max-height: 80vh;
  overflow-y: auto;
}

.site-selection-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.site-selection-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.site-selection-item {
  display: block;
  color: #01061C;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 8px 6px 12px;
  text-decoration: none;
  transition: all 0.2s;
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  border-left: 3px solid;
  border-radius: 4px;
  background-color: rgba(1, 6, 28, 0.08);
}

/* Enabled sites (in_use) - yellow left border */
.site-selection-item.enabled {
  border-left-color: #FFD700;
  cursor: pointer;
}

.site-selection-item.enabled:hover {
  background-color: rgba(1, 6, 28, 0.15);
  border-left-color: #FFD700;
  padding-left: 16px;
}

/* Disabled sites (not in_use) - navy left border, not clickable */
.site-selection-item.disabled {
  border-left-color: #01061C;
  cursor: not-allowed;
  opacity: 0.6;
  pointer-events: none;
}

.button-pill.paired-tab[data-pair-group]:not(.active) {
  background-color: #0C1228;
}

.paired-tab-group {
  display: inline-flex;
  gap: 0;
  margin: 5px;
  border-radius: 50px;
}

.paired-tab-group .button-pill {
  margin: 0;
}

.floating-buttons { display: flex; gap: 12px; width: 100%; justify-content: flex-start; flex-wrap: wrap; }
.floating-button { border-radius: 50px !important; border: 2px solid rgba(255, 255, 255, 0.5); padding: 0 20px; }

.floating-button.paired-tab { border-radius: 0 !important; }
.floating-button.paired-tab.paired-left { border-radius: 50px 0 0 50px !important; }
.floating-button.paired-tab.paired-right { border-radius: 0 50px 50px 0 !important; }
.floating-button.paired-tab.paired-middle { border-radius: 0 !important; }

/* Site details overlay panel (appears under top row, right of LHS buttons) */
.overlay-text-panel {
  position: fixed; /* anchor to viewport to avoid layout shifts */
  top: 80px; /* move down below top tabs */
  right: auto; /* anchor on the right to avoid LHS overlap */
  left: 300px;
  padding: 20px;
  background-color: rgba(255, 255, 255, 0.85); /* 85% opaque */
  border-radius: 10px;
  /* Card stroke is always dark navy, independent of ds status */
  border: 5px solid #01061C;
  z-index: 3000; /* above map controls (2000) and LHS (2000) and header (10001) */
  width: 25vw; /* Original width: left-hand Top Trump only */
  max-height: 88vh;         /* Original max height */
  overflow-y: hidden;       /* never show a vertical scrollbar */
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
}

.overlay-text-panel.photo-expanded {
  width: 60vw; /* Wider when expanded: two equal halves like an open book */
}

.overlay-text-panel .developer {
  margin-top: 0;
  margin-bottom: 0px;
  font-size: 16pt;   /* larger for hierarchy */
  color: #01061C;    /* black text on status-colour gradient */
  font-weight: 600;
  padding: 2px 6px;  /* tighter horizontal padding so it aligns closer to name */
  border-radius: 6px;
  /* Company band uses a lighter, subtle status-colour gradient */
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--status-color, #102347) 40%, white 60%) 0%,
    rgba(255, 255, 255, 0.4) 100%
  );
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
}

.overlay-text-panel .site-name {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 16pt;   /* match company size */
  color: #01061C;    /* black text on status-colour gradient */
  font-weight: 600;
}

.overlay-text-panel .local-authority {
  font-size: 8pt;
  margin-top: 0;
  margin-bottom: 6px;
  color: #01061C;    /* black text on status-colour gradient */
}

.overlay-text-panel .site-name-row {
  display: flex;
  align-items: center;       /* vertically centre site + local authority */
  gap: 6px;
  padding: 4px 8px;          /* align left edge with company text */
  border-radius: 6px;
  /* Site name band uses a lighter, subtle status-colour gradient */
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--status-color, #102347) 40%, white 60%) 0%,
    rgba(255, 255, 255, 0.4) 100%
  );
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
}

.overlay-text-panel .site-overlay-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.overlay-text-panel .site-overlay-info-column {
  flex: 1; /* Default: take all available width when photo panel is hidden */
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  position: relative;
  box-sizing: border-box;
}

/* When expanded, split overlay content into two visually equal halves without causing overflow */
.overlay-text-panel.photo-expanded .site-overlay-info-column {
  flex: 1 1 0;
}

.overlay-text-panel .site-overlay-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.overlay-text-panel .site-overlay-body {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.overlay-text-panel .site-overlay-photo-inline-frame {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 26vh;          /* allow image to shrink on very short viewports */
  border-radius: 10px;
  margin: 4px 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Background frame uses a lighter, subtle status-colour gradient */
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--status-color, #102347) 40%, white 60%) 0%,
    rgba(255, 255, 255, 0.4) 100%
  );
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
}

.overlay-text-panel .site-overlay-photo-inline-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.overlay-text-panel .site-overlay-stats {
  margin-top: 0px;
}

.overlay-text-panel .site-overlay-stats-3col {
  display: flex;
  gap: 8px;  /* reduced gap to prevent overhang */
  width: 100%;
  margin: 8px 0 4px 0;
  align-items: stretch;
}

.overlay-text-panel .site-overlay-stats-3col .stats-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;  /* include padding/border in width calculation */
}

.overlay-text-panel .site-overlay-stats-3col .stats-col-labels {
  flex: 0 0 calc(50% - 4px);  /* stats (labels + values) take 50% minus half gap */
}

.overlay-text-panel .site-overlay-stats-3col .stats-col-values {
  display: none;  /* values are now inside stats-row, not separate column */
}

.overlay-text-panel .site-overlay-stats-3col .stats-col-status {
  flex: 0 0 calc(50% - 4px);  /* DS circle panel takes the other 50% minus half gap */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;  /* move padding from inline style to CSS */
  border-radius: 6px;
  /* Status panel behind the circle uses the same lighter, subtle status-colour gradient */
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--status-color, #102347) 40%, white 60%) 0%,
    rgba(255, 255, 255, 0.4) 100%
  );
  box-shadow: 0 2px 6px rgba(0,0,0,0.10);
}

.overlay-text-panel .site-overlay-stats-3col .stats-label {
  font-size: 10pt;
  font-weight: 600;
  color: #01061C;      /* black text on status-colour stat rows */
  margin: 1px 0;
}

.overlay-text-panel .site-overlay-stats-3col .stats-value {
  font-size: 10pt;
  font-weight: 600;
  color: #01061C;      /* black text on status-colour stat rows */
  margin: 1px 0;
}

.overlay-text-panel .site-overlay-stats-3col .status-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  background: transparent;
  box-shadow: none;
}

.overlay-text-panel .site-overlay-stats-3col .stats-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 2px 6px;      /* tighter vertical and horizontal spacing */
  margin-bottom: 2px;    /* pack rows closer together */
  border-radius: 6px;
  /* Stat rows use a lighter, subtle status-colour gradient */
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--status-color, #102347) 40%, white 60%) 0%,
    rgba(255, 255, 255, 0.4) 100%
  );
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
}

.overlay-text-panel .site-overlay-stats-3col .status-badge-circle {
  width: 48px;  /* much larger circle */
  height: 48px;
  border-radius: 50%;
  border: 3px solid #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay-text-panel .site-overlay-stats-3col .status-badge-letter {
  font-size: 20pt;  /* much larger letter */
  font-weight: 800;
  color: #FFFFFF; /* white letter inside coloured circle */
}

.overlay-text-panel .site-overlay-stats-3col .status-badge-name {
  font-size: 10pt;  /* same size as stats font */
  font-weight: 600;
  color: #01061C; /* keep black */
  text-align: center;
}

.overlay-text-panel .site-overlay-description {
  flex: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;      /* a little more separation from stats/status */
  padding: 8px 10px;
  border-radius: 6px;
  /* Match the modified DS colour treatment: subtle gradient fading to light */
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--status-color, #102347) 40%, white 60%) 0%,
    rgba(255, 255, 255, 0.4) 100%
  );
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
}

/* Ensure description text in the Top Trump panel is black, matching DS text */
.overlay-text-panel .site-overlay-description,
.overlay-text-panel .site-overlay-description p,
.overlay-text-panel .site-overlay-description ul,
.overlay-text-panel .site-overlay-description li {
  color: #01061C;
  font-size: 10pt;    /* match stats font size */
  font-weight: 600;   /* match stats weight */
}

.overlay-text-panel .description-v2 {
  margin: 0;
  font-size: 11pt;
  font-weight: normal;
  color: #01061C;  /* ensure black text */
  display: block;
}

.overlay-text-panel .description-v2,
.overlay-text-panel .description-v2 p,
.overlay-text-panel .description-v2 ul,
.overlay-text-panel .description-v2 li {
  font-size: 11pt;
  font-weight: normal;
  margin: 0;
}

.overlay-text-panel .description-v2 ul {
  margin: 8px 0;
  padding-left: 20px;
}

.overlay-text-panel .description-v2 li {
  margin: 4px 0;
}

.overlay-text-panel button.popup-close:hover {
  background: #f0f0f0;
  color: red;
}

.overlay-text-panel .site-overlay-content {
  display: flex;
  gap: 24px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
}

.overlay-text-panel .site-overlay-photo-panel {
  display: none;           /* hidden until expanded */
  flex: 1 1 0;             /* When visible, share space evenly with left column */
  min-width: 0;
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
  background: #D1D1D1;
  flex-direction: column; /* stack tabs above content */
}

.overlay-text-panel.photo-expanded .site-overlay-photo-panel {
  display: flex;
}

.overlay-text-panel .site-extra-tabs {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 16px; /* symmetric vertical padding for better centering */
  /* Solid navy header bar for Profit Calculator */
  background: #01061C;
  box-shadow: none;
  border-radius: 10px 10px 0 0;
}

.overlay-text-panel .site-extra-tab {
  flex: 0;
  text-align: center;
  font-size: 11pt;
  font-weight: 600;
  color: #FFFFFF;
  padding: 0;
  line-height: 1.2;
  transform: translateY(-1px); /* tiny visual nudge to centre text in the bar */
  border-radius: 0;
  background: transparent;
  border: none;
}

.overlay-text-panel .site-extra-tab.active {
  background: transparent;
  color: #FFFFFF;
  border: none;
}

.overlay-text-panel .site-extra-content {
  flex: 1;
  padding: 14px 16px;
  background: #FFFFFF;  /* clean white content panel */
  border-radius: 0 10px 10px 10px;  /* join to tabs at top */
  border: 1px solid rgba(15, 23, 42, 0.15);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08); /* very slight uplift */
  font-size: 10.5pt;
  color: #01061C;
}

.overlay-text-panel .site-extra-content h4 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 11pt;
  font-weight: 700;
}

.overlay-text-panel .site-overlay-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 8px;
}

.overlay-text-panel .site-overlay-footer-right {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.overlay-text-panel .site-overlay-photo-toggle {
  background-color: #01061C;              /* match .button-pill.navy */
  color: #FFFFFF;
  border-radius: 50px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  font-size: 16pt;                         /* large bold arrow */
  font-weight: 700;
  padding: 4px 18px;
  margin: 0;
  text-align: center;
  cursor: pointer;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.overlay-text-panel .site-overlay-photo-toggle:hover {
  background-color: #1A1F3D;              /* same hover behaviour as .button-pill */
  box-shadow: 0 0 15px rgba(1, 6, 28, 0.8), 0 0 30px rgba(1, 6, 28, 0.6);
}

/* Pricing Tool Styles */
.pricing-tool-container {
  display: flex;
  gap: 12px;            /* tighter gap between sidebar and content */
  width: 100%;
  min-height: 55vh;     /* grow with viewport height */
}

.pricing-tool-sidebar {
  /* Fixed, narrow sidebar so chart/table get maximum width */
  flex: 0 0 160px;        /* slightly narrower fixed basis */
  min-width: 150px;
  max-width: 180px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  align-self: stretch;    /* use full vertical space of container */
}

/* Checkbox styling for pricing tool */
.checkbox-group {
  margin-top: -7px;
  margin-bottom: 12px;
  text-align: left;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.checkbox-group h3 {
  font-size: 11pt;
  font-weight: bold;
  color: #01061C;
  margin-bottom: 8px;
  padding: 4px 8px;
  background-color: rgba(70, 198, 145, 0.1);
  border-radius: 5px;
  border-left: 3px solid #46C691;
}

.checkbox-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin: 6px 0;
  padding: 4px 6px;
  border-radius: 5px;
  transition: background-color 0.2s ease;
}

.checkbox-item:hover {
  background-color: rgba(70, 198, 145, 0.05);
}

.checkbox-item input[type="checkbox"],
.checkbox-item input[type="radio"] {
  margin-right: 10px;
  transform: scale(1.1);
  accent-color: #01061C;
  cursor: pointer;
}

.checkbox-item label {
  font-size: 9.5pt;
  line-height: 1.2;
  color: #01061C;
  cursor: pointer;
  font-weight: 500;
  text-align: left;
  margin-left: 0;
  padding-left: 0;
}

.price-type-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.price-type-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.price-type-dot.price-type-asking {
  background-color: #46C691;
}

.price-type-dot.price-type-achieved {
  background-color: #3272EA;
}

.price-type-dot.price-type-resale {
  background-color: #F29900;
}

.checkbox-item input[type="checkbox"]:checked + label,
.checkbox-item input[type="radio"]:checked + label {
  color: #01061C;
  font-weight: bold;
}

.checkbox-item input[type="checkbox"]:checked,
.checkbox-item input[type="radio"]:checked {
  animation: checkboxPulse 0.3s ease-in-out;
}

@keyframes checkboxPulse {
  0% { transform: scale(1.1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1.1); }
}

.pricing-tool-content {
  flex: 1;
  min-width: 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 8px;
}

.pricing-tool-chart-placeholder,
.pricing-tool-table-placeholder {
  display: none; /* Hide placeholder when content is rendered */
}

.pricing-tool-wrapper {
  width: 100%;
  margin-top: 16px;
}

/* Hide mapdeck legends (not using them anymore) */
.mapdeck-legend,
.deckgl-legend {
  display: none !important;
}

/* Custom legend panel - positioned like map controls */
#map-legend {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 2000;
}

.legend-panel {
  background-color: rgba(255, 255, 255, 0.95);
  border: 3px solid #01061C;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  max-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  line-height: 1.4;
}

.legend-circle {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: 2px solid #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.legend-letter {
  font-size: 13px;
  font-weight: 800;
  color: #FFFFFF;
  line-height: 1;
}

.legend-name {
  color: #01061C;
  font-weight: 500;
  flex: 1;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

/* Ensure mapdeck/deck.gl tooltips render above header/LHS overlays */
.mapboxgl-popup { z-index: 6000; pointer-events: auto; }
.deckgl-tooltip, .mapdeck-tooltip { z-index: 6000; pointer-events: auto; }

/* Style mapdeck tooltips */
.mapdecktooltip {
  background: white !important;
  color: black !important;
  padding: 12px 16px !important;
  border: 3px solid #01061C !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  z-index: 6000 !important;
  pointer-events: none !important;
  max-width: 250px !important;
  word-wrap: break-word !important;
}

/* Also target the specific ID */
#mapdecktooltipmap_main {
  background: white !important;
  color: black !important;
  padding: 12px 16px !important;
  border: 3px solid #01061C !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  z-index: 6000 !important;
  pointer-events: none !important;
  max-width: 250px !important;
  word-wrap: break-word !important;
}

/* Responsive media styling for images and videos (1920x1080 -> fit screen) */
.responsive-media {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Ensure video elements are properly sized and fit within their container */
.responsive-media[type="video"] {
  background: #000;
  max-height: 60vh; /* Limit video height to prevent overflow */
}

/* Ensure overlay-card doesn't create scrollbars for videos */
.overlay-card video.responsive-media {
  max-height: 60vh;
  width: 100%;
  height: auto;
}

/* Force hide video controls */
.overlay-card video.responsive-media::-webkit-media-controls {
  display: none !important;
}

.overlay-card video.responsive-media::-webkit-media-controls-panel {
  display: none !important;
}

.overlay-card video.responsive-media::-webkit-media-controls-play-button {
  display: none !important;
}

.overlay-card video.responsive-media::-webkit-media-controls-timeline {
  display: none !important;
}

.overlay-card video.responsive-media::-webkit-media-controls-current-time-display {
  display: none !important;
}

.overlay-card video.responsive-media::-webkit-media-controls-time-remaining-display {
  display: none !important;
}

.overlay-card video.responsive-media::-webkit-media-controls-mute-button {
  display: none !important;
}

.overlay-card video.responsive-media::-webkit-media-controls-volume-slider {
  display: none !important;
}

.overlay-card video.responsive-media::-webkit-media-controls-fullscreen-button {
  display: none !important;
}

/* Main content area styling */
.main-content-title {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
  color: #01061C;
  text-align: center;
}

.main-content-wrapper {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.main-content-description {
  flex: 0 0 200px; /* Fixed width for description */
  font-size: 16px;
  line-height: 1.6;
  color: #01061C;
  padding: 12px;
  background: rgba(255, 255, 255, 0.8);
}

.main-content-media {
  flex: 1; /* Takes remaining space */
  min-width: 0; /* Allows flex item to shrink */
}

/* Table styling */
.main-content-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.main-content-table th {
  background: #01061C; /* Navy blue header */
  color: white;
  padding: 12px 8px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Sortable table header styles */
.sortable-header {
  position: relative;
  transition: background-color 0.2s ease;
}

.sortable-header:hover {
  background-color: #1a1f3d !important;
}

.sortable-header-content {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.sortable-header-content .header-text {
  flex: 1;
  min-width: 0;
}

/* For center-aligned headers, center the content */
.sortable-header[style*="text-align: center"] .sortable-header-content {
  justify-content: center;
  position: relative;
}

.sortable-header[style*="text-align: center"] .sort-indicator {
  position: absolute;
  right: 8px;
}

.sort-indicator {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  opacity: 0.4;
  transition: opacity 0.2s ease;
  line-height: 1;
  font-size: 10px;
}

.sortable-header:hover .sort-indicator {
  opacity: 0.7;
}

.sortable-header[data-sort="asc"] .sort-indicator,
.sortable-header[data-sort="desc"] .sort-indicator {
  opacity: 1;
}

.sort-arrow {
  display: block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  transition: opacity 0.2s ease;
  margin: 0 auto;
}

.sort-arrow-up {
  opacity: 0;
  border-bottom: 5px solid white;
  border-top: none;
  margin-bottom: 2px;
}

.sort-arrow-down {
  opacity: 0;
  border-top: 5px solid white;
  border-bottom: none;
  margin-top: 2px;
}

.sortable-header[data-sort="asc"] .sort-arrow-up {
  opacity: 1;
}

.sortable-header[data-sort="asc"] .sort-arrow-down {
  opacity: 0;
}

.sortable-header[data-sort="desc"] .sort-arrow-up {
  opacity: 0;
}

.sortable-header[data-sort="desc"] .sort-arrow-down {
  opacity: 1;
}

.sortable-header[data-sort="none"] .sort-arrow-up,
.sortable-header[data-sort="none"] .sort-arrow-down {
  opacity: 0;
}

.main-content-table td {
  padding: 12px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #01061C;
}

.main-content-table td:first-child {
  text-align: left;
}

.main-content-table td:not(:first-child) {
  text-align: center;
}

/* Restore natural column behaviour for the pricing tool table */
.pricing-tool-table-wrapper .main-content-table {
  table-layout: auto;
}

.pricing-tool-table-wrapper .main-content-table td:first-child,
.pricing-tool-table-wrapper .main-content-table td:not(:first-child) {
  width: auto;
}

.main-content-table tr:nth-child(even) {
  background: #D1D1D1; /* Darker grey for zebra striping */
}

.main-content-table tr:nth-child(odd) {
  background: white;
}

/* Ensure data rows (not header) get zebra striping */
.main-content-table tbody tr:nth-child(even) {
  background: #D1D1D1; /* Darker grey for zebra striping */
}

.main-content-table tbody tr:nth-child(odd) {
  background: white;
}

.main-content-table tr:hover {
  background: #e0f2fe; /* Light blue on hover */
  transition: background-color 0.2s ease;
}

/* Table row animation */
.main-content-table tr {
  animation: slideInRow 0.6s ease-out forwards;
  opacity: 0;
  transform: translateX(-20px);
}

@keyframes slideInRow {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.pricing-tool-table-wrapper .main-content-table {
  font-size: 13px;
}

.pricing-tool-table-wrapper .main-content-table th {
  font-size: 11px;
}

.pricing-tool-table-wrapper .main-content-table td {
  font-size: 12px;
}

/* Pricing table sortable header styles */
.pricing-table-sortable {
  position: relative;
}

.pricing-table-sortable:hover {
  background-color: #1a1f3d !important;
}

.pricing-table-sortable .sortable-header-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
}

.pricing-table-sortable[style*="text-align: left"] .sortable-header-content {
  justify-content: flex-start;
}

.pricing-table-sortable .sort-indicator {
  margin-left: 4px;
}

.price-type-square {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  display: inline-block;
}

/* Close button for overlay content */
.overlay-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 20px;
  font-weight: bold;
  border-radius: 50%;
  cursor: pointer;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.overlay-text-panel:not(.photo-expanded) .overlay-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
}

.overlay-text-panel.photo-expanded .overlay-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
}

.overlay-close-btn:hover {
  background: rgba(0, 0, 0, 0.9);
}

.overlay-close-btn:active {
  background: rgba(0, 0, 0, 1);
}

/* Map controls in bottom right */
.map-controls-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  /* Sit above the map but below content/Top Trump panels */
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.map-controls-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.map-control-btn {
  width: 40px;
  height: 40px;
  border: 2px solid #01061C;
  background-color: rgba(255, 255, 255, 0.9);
  color: #01061C;
  font-size: 18px;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.map-control-btn:hover {
  background-color: #01061C;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.map-control-btn:active {
  transform: scale(0.95);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* North button with integrated arrow */
.map-control-btn-north {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px;
}

.north-arrow-label {
  color: inherit;
  font-size: 10px;
  font-weight: bold;
  line-height: 1;
  margin: 0;
}

.north-arrow-arrow {
  color: #ff0000;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  margin: 0;
  display: block;
  transition: transform 0.3s ease;
  transform-origin: center;
  text-shadow: 0 0 2px rgba(255, 0, 0, 0.8);
  filter: drop-shadow(0 0 1px rgba(255, 0, 0, 0.5));
}

/* Table export icon button styling */
.main-content-title-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 24px; /* Increased spacing between title/button and content below for regular tables */
}

/* But keep original spacing for pricing tables */
.pricing-tool-wrapper .main-content-title-wrapper,
.overlay-card .main-content-title-wrapper {
  margin-bottom: 16px; /* Original spacing for pricing tables */
}

.main-content-title-wrapper .main-content-title {
  margin: 0; /* Remove default margin to help alignment */
}

.table-export-icon-btn {
  background: #01061C;
  color: white;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4; /* Match title line-height better */
  transition: opacity 0.2s;
  display: inline-flex;
  align-items: center;
  vertical-align: baseline; /* Align with text baseline */
  margin-top: 2px; /* Fine-tune vertical position */
}

.table-export-icon-btn:hover {
  opacity: 0.7;
}

.table-export-icon-btn:active {
  opacity: 0.5;
}