:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #2a2118;
  --muted: #8a8175;
  --accent: #d6452b;
  --accent2: #1f7a8c;
  --border: #ece6dc;
  --hairline: rgba(0, 0, 0, 0.08);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --gap: 24px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---- Full-screen map ---- */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg);
}
.leaflet-container { background: var(--bg); font: inherit; }
.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.7) !important;
  font-size: 10px;
}
.price-pill {
  background: #fff; border: 1px solid var(--border); border-radius: 999px;
  padding: .3rem .7rem; font-weight: 700; font-size: .85rem; white-space: nowrap;
  box-shadow: var(--shadow); color: var(--ink);
}

/* ---- Shared overlay-card chrome (one radius, one hairline, one shadow) ---- */
.panel, .graph-card, .zoom-card, .settings {
  position: fixed;
  z-index: 500;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: saturate(1.1) blur(10px);
  backdrop-filter: saturate(1.1) blur(10px);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---- Panel header: logo + title + actions ---- */
.panel-head {
  display: flex; align-items: center; gap: .55rem; margin-bottom: 14px;
}
.panel-head .logo {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  display: block; flex: none;
}
.panel-head .title {
  font-size: 1.05rem; font-weight: 800; letter-spacing: -0.3px; line-height: 1;
}
.brand-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.panel-head #info-btn { margin-left: auto; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; flex: none;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn svg { width: 19px; height: 19px; }
.settings {
  bottom: var(--gap); right: var(--gap); border-radius: 999px;
  display: flex; flex-direction: column; align-items: center; padding: 2px;
}
.menu-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 700; padding: 4px 8px 6px;
}
.lang-menu {
  position: absolute; bottom: calc(100% + 8px); right: 0; min-width: 150px;
  background: #fff; border: 1px solid var(--hairline); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 4px; z-index: 600;
}
.lang-menu[hidden] { display: none; }
.lang-opt {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: .5rem .7rem; border-radius: 8px; font: inherit; color: var(--ink); cursor: pointer;
}
.lang-opt:hover { background: var(--bg); }
.lang-opt.active { color: var(--accent); font-weight: 700; }

/* ---- Top-left panel: brand + search + filters ---- */
.panel {
  top: var(--gap); left: var(--gap); width: 280px;
  max-width: calc(100vw - 2 * var(--gap));
  padding: 14px 16px 16px;
}
.filters { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 600;
}
.readout { color: var(--ink); font-weight: 700; text-transform: none; letter-spacing: 0; }

.toggle {
  display: inline-flex; border: 1px solid var(--border); border-radius: 999px;
  background: #fff; overflow: hidden; padding: 2px;
}
.toggle button {
  flex: 1; border: 0; background: transparent; padding: .45rem .6rem; cursor: pointer;
  font-size: .9rem; color: var(--muted); border-radius: 999px; transition: .15s;
}
.toggle button.active {
  background: rgba(214, 69, 43, 0.1); color: var(--accent); font-weight: 700;
}

select {
  appearance: none; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; padding: .5rem .7rem; font: inherit; color: var(--ink);
  cursor: pointer; width: 100%;
}

/* ---- Hero: the headline median for the current scope ---- */
.hero { display: flex; align-items: center; gap: 12px; margin: 2px 2px 12px; }
.hero-value {
  font-size: 2.1rem; font-weight: 800; letter-spacing: -1px; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hero-meta { display: flex; flex-direction: column; gap: 1px; line-height: 1.3; min-width: 0; }
.hero-scope {
  font-size: .72rem; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hero-yoy { font-size: .74rem; font-weight: 700; }
.hero-yoy.up { color: var(--accent); }
.hero-yoy.down { color: #2e8b57; }

/* aggregation-level pill: mirrors the zoom-derived level, click to pin */
.level-toggle button {
  font-size: .78rem; padding: .38rem .3rem;
  color: var(--muted); font-weight: 600;
}
.level-toggle button.active {
  background: rgba(31, 122, 140, 0.12); color: var(--accent2);
}

/* ---- Area / shop search with autocomplete ---- */
.search-field { position: relative; }
#area-search {
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
  padding: .5rem .7rem; font: inherit; color: var(--ink); width: 100%;
}
#area-search:focus { outline: 2px solid rgba(31, 122, 140, .35); }
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 700;
  background: #fff; border: 1px solid var(--hairline); border-radius: 10px;
  box-shadow: var(--shadow); overflow-y: auto; max-height: 262px;
}
.search-results[hidden] { display: none; }
.search-results button {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: .45rem .7rem; font: inherit; font-size: .88rem; color: var(--ink);
  cursor: pointer;
}
.search-results button:hover, .search-results button.sel { background: var(--bg); }
.search-results .type {
  color: var(--muted); font-size: .66rem; text-transform: uppercase;
  letter-spacing: .4px; flex: none;
}

/* ---- Breadcrumb: Ελλάδα › region › municipality ---- */
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: .8rem; }
.breadcrumb[hidden] { display: none; }
.breadcrumb button {
  border: 0; background: transparent; color: var(--accent2); cursor: pointer;
  font: inherit; font-size: .8rem; padding: 2px 5px; border-radius: 6px;
}
.breadcrumb button:hover { background: var(--bg); }
.breadcrumb button:last-child { color: var(--ink); font-weight: 700; cursor: default; }
.breadcrumb button:last-child:hover { background: transparent; }
.breadcrumb .sep { color: var(--muted); }

input[type=range]#time-slider {
  width: 100%; accent-color: var(--ink); cursor: pointer;
}

/* ---- Right zoom card (50% larger, higher up) ---- */
.zoom-card {
  right: var(--gap); top: 32%; transform: translateY(-50%);
  display: flex; flex-direction: column; overflow: hidden; padding: 0;
}
.zoom-card button {
  width: 60px; height: 60px; border: 0; background: transparent;
  font-size: 2.1rem; color: var(--ink); cursor: pointer; line-height: 1;
}
.zoom-card button:hover { background: var(--bg); }
.zoom-card button:first-child { border-bottom: 1px solid var(--hairline); }

/* ---- Bottom-left graph: compact sparkline strip, expands to overlay ---- */
.graph-card {
  left: var(--gap); bottom: var(--gap); width: 300px;
  max-width: calc(100vw - 2 * var(--gap)); padding: 10px 12px 12px;
}
.graph-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .8rem; font-weight: 700; color: var(--ink); margin-bottom: 4px;
}
.graph-actions { display: flex; gap: 2px; }
.graph-actions button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 1rem; padding: 2px 5px; border-radius: 6px;
}
.graph-actions button:hover { background: var(--bg); color: var(--ink); }
.graph-body { width: 100%; }
.graph-card .graph-body { height: 56px; }          /* docked = short sparkline */
.graph-card.collapsed .graph-body,
.graph-card.collapsed .spark-values { display: none; }
.graph-card.collapsed .graph-collapse { transform: rotate(180deg); }

/* docked value readout (used when there's a single month -> a sparkline is useless) */
.spark-values { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 4px 2px 2px; }
.spark-values .sv { display: flex; align-items: center; gap: 7px; font-size: .95rem; }
.spark-values .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.spark-values .sv b { font-variant-numeric: tabular-nums; }
.spark-values .sv span { color: var(--muted); }

/* expanded graph overlay (mirrors the about modal) */
.graph-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(40, 30, 15, 0.35); padding: 1rem;
}
.graph-overlay[hidden] { display: none; }
.graph-modal {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(960px, 94vw); padding: 1rem 1.3rem 1.3rem;
}
.graph-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 1rem; font-weight: 700; color: var(--ink); margin-bottom: .6rem;
}
.graph-modal-body { height: min(620px, 68vh); }
.graph-modal-body .graph-body { height: 100%; }     /* expanded = full chart */

/* ---- Shop count (above the filters) ---- */
.shop-count {
  display: flex; align-items: center; gap: .45rem;
  font-size: .8rem; color: var(--muted);
}
.shop-count .scale {
  display: inline-block; width: 60px; height: 8px; border-radius: 6px;
  background: linear-gradient(90deg, #2e8b57, #e0a526, #c0392b); flex: none;
}

/* ---- Estimate state: back-cast months only fade the data colors (fill
   opacity set from JS); the basemap stays untouched. A one-time toast
   explains that these months are CPI estimates. ---- */
.estimate-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px);
  max-width: 340px; padding: 12px 36px 12px 14px;
  background: var(--card, #fff); border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
  font-size: .82rem; line-height: 1.4; color: var(--ink, #222);
  opacity: 0; pointer-events: none; z-index: 1200;
  transition: opacity .3s, transform .3s;
}
.estimate-toast.on { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.estimate-toast b { display: block; margin-bottom: 2px; }
.estimate-toast .toast-close {
  position: absolute; top: 6px; right: 8px; border: 0; background: none;
  font-size: 1rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px;
}

/* ---- Live state: latest month = gently pulsing data + last-updated stamp ---- */
body.live .leaflet-overlay-pane,
body.live .leaflet-marker-pane { animation: livePulseMap 3s ease-in-out infinite; }
@keyframes livePulseMap { 0%, 100% { opacity: 1; } 50% { opacity: 0.84; } }

.live-badge {
  position: fixed; right: var(--gap); bottom: 5px;
  z-index: 500; display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; color: var(--muted); pointer-events: none;
  opacity: 0; transition: opacity 0.3s;
}
.live-badge.on { opacity: 0.85; }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #2e8b57; flex: none;
  animation: livePulseDot 2s ease-out infinite;
}
@keyframes livePulseDot {
  0% { box-shadow: 0 0 0 0 rgba(46, 139, 87, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(46, 139, 87, 0); }
  100% { box-shadow: 0 0 0 0 rgba(46, 139, 87, 0); }
}

/* ---- Marker cluster pins (low-zoom restaurants view) ---- */
.cluster-pin { background: transparent; }
.cluster-pin .cl {
  border-radius: 50%; color: #fff; text-align: center; font-weight: 700;
  font-size: 12px; border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
}
/* aggregate bubble per region / municipality */
.group-pin { background: transparent; }
.group-pin .grp {
  border-radius: 50%; color: #fff; text-align: center; font-weight: 700;
  font-size: 12px; border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.28);
}
/* choropleth polygons: smooth "pop" on hover + click-to-drill */
.leaflet-interactive { transition: fill-opacity .15s ease, stroke-width .15s ease; cursor: pointer; }
/* ---- About overlay ---- */
.about-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(40, 30, 15, 0.35); padding: 1rem;
}
.about-overlay[hidden] { display: none; }
.about-shell { position: relative; max-width: 460px; width: 100%; }
.about-shell .about-card { max-width: none; }
.about-logo {
  position: absolute; top: -32px; left: -32px; width: 92px; height: 92px;
  z-index: 1; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.18));
  transition: transform .18s ease;
}
.about-logo:hover { transform: scale(1.18) rotate(-4deg); }
.about-card {
  position: relative; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); max-width: 460px; width: 100%;
  padding: 1.6rem 1.7rem; max-height: 86vh; overflow: auto;
}
.about-card h2 { margin: 0 0 .6rem; font-size: 1.35rem; }
#about-content h2 { margin-left: 58px; min-height: 44px; display: flex; align-items: center; }
.about-card p { margin: 0 0 .8rem; color: #4a4136; }
.about-card a {
  color: var(--accent2); font-weight: 600; text-decoration: underline;
  text-decoration-color: rgba(31, 122, 140, 0.35); text-underline-offset: 2px;
}
.about-card a:hover { color: var(--accent); text-decoration-color: rgba(214, 69, 43, 0.4); }
@media (max-width: 640px) {
  .about-logo { top: -16px; left: -16px; width: 72px; height: 72px; }
  #about-content h2 { margin-left: 44px; }
}
.about-meta { font-size: .82rem; color: var(--muted) !important; }
.about-close {
  position: absolute; top: 10px; right: 12px; border: 0; background: transparent;
  font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer;
}
code { background: #f1ece3; padding: .1rem .35rem; border-radius: 5px; }

/* ---- Mobile: the filter panel becomes a bottom sheet ---- */
@media (max-width: 640px) {
  :root { --gap: 12px; }

  /* sheet docked to the bottom edge; header stays visible, filters expand on tap */
  .panel {
    top: auto; left: 0; bottom: 0; width: 100%; max-width: none;
    border-radius: 16px 16px 0 0; border-bottom: 0;
    padding: 22px 16px calc(12px + env(safe-area-inset-bottom));
  }
  .panel::before { /* grab handle */
    content: ""; position: absolute; top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 42px; height: 4px; border-radius: 2px; background: var(--border);
  }
  .panel-head { margin-bottom: 0; cursor: pointer; }
  /* hero stays visible on the collapsed sheet, slightly tightened */
  .hero { margin: 10px 2px 0; }
  .filters {
    max-height: 0; overflow: hidden;
    transition: max-height 0.25s ease, margin-top 0.25s ease;
  }
  .panel.open .filters {
    max-height: min(62vh, 480px); overflow-y: auto; margin-top: 14px;
  }

  /* graph sits just above the collapsed sheet; hides while the sheet is open */
  .graph-card {
    left: var(--gap); right: var(--gap); bottom: 96px;
    width: auto; max-width: none;
    transition: opacity 0.2s;
  }
  .panel.open ~ .graph-card { opacity: 0; pointer-events: none; }

  /* pinch-zoom is native on touch; drop the zoom buttons */
  .zoom-card { display: none; }

  /* settings move to the top-right, menu opens downward */
  .settings { top: var(--gap); right: var(--gap); bottom: auto; }
  /* live stamp tucks under the settings column (two buttons tall: + and gear) */
  .live-badge { top: calc(var(--gap) + 82px); right: var(--gap); bottom: auto; }
  .lang-menu { top: calc(100% + 8px); bottom: auto; }
}

/* ---- Crowdsourced price submission ("+" button) ---- */
.submit-card { width: 340px; }
.submit-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.submit-card input[type="text"],
.submit-card input[type="number"] {
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
  padding: .5rem .7rem; font: inherit; color: var(--ink); width: 100%;
}
.submit-card input:focus { outline: 2px solid rgba(31, 122, 140, .35); }
.submit-card input[type="file"] { font-size: .82rem; color: var(--muted); }
.shop-field { position: relative; }
.shop-suggest {
  position: absolute; top: calc(100% - 20px); left: 0; right: 0; z-index: 700;
  background: #fff; border: 1px solid var(--hairline); border-radius: 10px;
  box-shadow: var(--shadow); overflow-y: auto; max-height: 220px;
}
.shop-suggest[hidden] { display: none; }
.shop-suggest button {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: .45rem .7rem; font: inherit; font-size: .88rem; color: var(--ink);
  cursor: pointer;
}
.shop-suggest button:hover { background: var(--bg); }
.shop-suggest .type {
  color: var(--muted); font-size: .66rem; text-transform: uppercase;
  letter-spacing: .4px; flex: none;
}
.shop-matched { font-size: .72rem; color: var(--muted); min-height: 1.1em; }
.shop-matched.is-match { color: #2e8b57; font-weight: 700; }
.submit-note { font-size: .75rem; color: var(--muted); margin: 0; }
.submit-send {
  border: 0; border-radius: 999px; background: var(--accent); color: #fff;
  padding: .55rem .9rem; font: inherit; font-weight: 700; cursor: pointer;
}
.submit-send:hover { filter: brightness(1.06); }
.submit-send:disabled { opacity: .6; cursor: default; }
.submit-status { min-height: 1.2em; font-size: .85rem; margin: 0; color: #2e8b57; }
.submit-status.is-err { color: var(--accent); }
