/* ============ Buttons & chips ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--tx-0);
  border-radius: var(--r); padding: 8px 12px; min-height: 36px;
  transition: background .15s ease-out, border-color .15s ease-out, transform .05s;
}
.btn:hover { background: #2a2f39; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
.btn.primary:hover { background: #63b1ff; }
.btn.icon { padding: 0; width: 36px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; font-size: var(--f-xs); font-weight: 600; letter-spacing: .3px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--tx-1); white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--tx-2); }
.chip.ok .dot { background: var(--ok); } .chip.ok { color: var(--ok); }
.chip.warn .dot { background: var(--warn); } .chip.warn { color: var(--warn); }
.chip.err .dot { background: var(--danger); } .chip.err { color: var(--danger); }
.chip.demo { color: var(--warn); border-color: #4a3a12; background: #241d0c; }

/* ============ Search combobox ============ */
.search-box { position: relative; flex: 1; max-width: 420px; }
.search-box input {
  width: 100%; box-sizing: border-box; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: var(--r); padding: 9px 12px 9px 36px; min-height: 38px; color: var(--tx-0);
}
.search-box input::placeholder { color: var(--tx-2); }
.search-box input:focus { border-color: var(--accent-dim); outline: none; box-shadow: 0 0 0 3px rgba(74,163,255,.18); }
.search-box .s-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--tx-2); pointer-events: none; }
.search-list {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 1300;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-2); overflow: hidden; list-style: none; margin: 0; padding: 4px;
}
.search-list li {
  padding: 9px 10px; border-radius: 7px; cursor: pointer; display: flex; gap: 8px;
  align-items: baseline; min-height: 40px;
}
.search-list li .cc { margin-left: auto; color: var(--tx-2); font-size: var(--f-xs); }
.search-list li[aria-selected="true"], .search-list li:hover { background: var(--bg-3); }
.search-list .empty { padding: 10px; color: var(--tx-2); cursor: default; }

/* ============ Segmented control (layers) ============ */
.seg { display: inline-flex; background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--r); padding: 3px; gap: 2px; }
.seg button {
  border: none; background: transparent; color: var(--tx-1); border-radius: 7px;
  padding: 6px 11px; min-height: 32px; font-weight: 600; font-size: var(--f-sm);
  display: inline-flex; align-items: center; gap: 6px; transition: background .15s ease-out, color .15s;
}
.seg button:hover { color: var(--tx-0); }
.seg button[aria-pressed="true"] { background: var(--accent-dim); color: #eaf4ff; }
.seg button .sw { width: 10px; height: 10px; border-radius: 3px; }

/* ============ Cards / metrics ============ */
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); padding: calc(var(--s) * 2); box-shadow: var(--shadow-1); }
.card + .card { margin-top: 0; }
.card h3 + * { margin-top: calc(var(--s) * 1.5); }
.place-line { display: flex; align-items: baseline; gap: var(--s); flex-wrap: wrap; }
.place-line .name { font-size: var(--f-xl); font-weight: 700; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s); }
.metric { background: var(--bg-1); border: 1px solid var(--line-soft); border-radius: 8px; padding: 10px 12px; }
.metric .k { font-size: var(--f-xs); color: var(--tx-2); letter-spacing: .4px; text-transform: uppercase; }
.metric .v { font-size: var(--f-lg); font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.metric .v small { font-size: var(--f-xs); color: var(--tx-1); font-weight: 500; }
.kv { display: flex; justify-content: space-between; gap: var(--s); font-size: var(--f-sm); padding: 4px 0; }
.kv .k { color: var(--tx-1); }
.kv .v { font-variant-numeric: tabular-nums; text-align: right; }

/* ============ Legend ============ */
.legend { display: flex; flex-direction: column; gap: 6px; }
.legend .bar { height: 12px; border-radius: 6px; border: 1px solid var(--line); }
.legend .ticks { display: flex; justify-content: space-between; font-size: var(--f-xs); color: var(--tx-1); font-variant-numeric: tabular-nums; }

/* ============ Alerts ============ */
.alert-list { display: flex; flex-direction: column; gap: var(--s); }
.alert-item {
  display: flex; gap: var(--s); align-items: flex-start; padding: 10px 12px;
  border: 1px solid #4a3a12; background: #221b0d; border-radius: 8px;
}
.alert-item.danger { border-color: #5b1f1f; background: #241012; }
.alert-item .a-ico { color: var(--warn); font-weight: 700; }
.alert-item.danger .a-ico { color: var(--danger); }
.alert-item .a-body { flex: 1; min-width: 0; }
.alert-item .a-title { font-weight: 600; font-size: var(--f-sm); }
.alert-item .a-meta { font-size: var(--f-xs); color: var(--tx-1); font-variant-numeric: tabular-nums; margin-top: 2px; }
.alert-item .btn { min-height: 30px; padding: 4px 9px; font-size: var(--f-xs); }
@keyframes pulse-border { 0%,100% { box-shadow: 0 0 0 0 rgba(240,180,41,.0);} 50% { box-shadow: 0 0 0 3px rgba(240,180,41,.25);} }
.alert-item { animation: pulse-border 2.4s ease-in-out infinite; }

/* ============ Chart ============ */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-wrap .crosshair { stroke: var(--tx-2); stroke-dasharray: 3 3; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 9px; font-size: var(--f-xs); box-shadow: var(--shadow-2);
  font-variant-numeric: tabular-nums; white-space: nowrap; transform: translate(-50%, -110%);
}
.day-cards { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day-card { background: var(--bg-1); border: 1px solid var(--line-soft); border-radius: 7px; padding: 6px 2px; text-align: center; cursor: pointer; transition: border-color .15s; }
.day-card:hover, .day-card.sel { border-color: var(--accent-dim); }
.day-card .d { font-size: 10px; color: var(--tx-2); }
.day-card .t { font-size: var(--f-xs); font-weight: 700; font-variant-numeric: tabular-nums; }
.day-card .lo { font-size: 10px; color: var(--tx-1); font-variant-numeric: tabular-nums; }

/* ============ Timeline ============ */
.timeline {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 14px; z-index: 1000;
  display: flex; align-items: center; gap: var(--s); padding: 8px 12px;
  background: rgba(21,24,30,.92); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-2); backdrop-filter: blur(6px); max-width: min(680px, calc(100% - 24px));
}
.timeline input[type=range] { width: 260px; accent-color: var(--accent); }
.timeline .t-label { font-size: var(--f-xs); font-variant-numeric: tabular-nums; color: var(--tx-1); min-width: 118px; text-align: center; }
@media (max-width: 900px) { .timeline input[type=range] { width: 130px; } .timeline .t-label { min-width: 92px; } }

/* ============ Map-adjacent UI ============ */
.map-ui { position: absolute; z-index: 1000; }
.layer-bar { top: 12px; left: 12px; }
.legend-box { bottom: 64px; left: 12px; width: 230px; padding: 10px 12px; background: rgba(21,24,30,.92); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); backdrop-filter: blur(6px); }
.hud-note { top: 12px; right: 12px; }
.leaflet-container { background: var(--bg-0); font-family: var(--font); }
/* Sötét téma OSM csempékhez: saját CSS-filter (invert+hue-rotate), nem külső stílus */
.leaflet-tile-pane .leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.8) saturate(.55); }
.leaflet-control-zoom a { background: var(--bg-2) !important; color: var(--tx-0) !important; border-color: var(--line) !important; }
.leaflet-control-zoom a:hover { background: var(--bg-3) !important; }
.leaflet-control-attribution { background: rgba(15,17,21,.8) !important; color: var(--tx-2) !important; font-size: 10px !important; }
.leaflet-control-attribution a { color: var(--tx-1) !important; }
.leaflet-bar { border: 1px solid var(--line) !important; box-shadow: var(--shadow-1) !important; }

/* ============ States ============ */
.state-box { text-align: center; color: var(--tx-1); padding: calc(var(--s) * 3) var(--s); }
.state-box .ico { font-size: 26px; margin-bottom: var(--s); }
.skeleton { position: relative; overflow: hidden; background: var(--bg-3); border-radius: 8px; color: transparent !important; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { from { transform: translateX(-100%);} to { transform: translateX(100%);} }
.toast {
  position: fixed; bottom: 48px; left: 50%; transform: translate(-50%, 8px); opacity: 0;
  background: var(--bg-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 10px 16px; border-radius: var(--r); box-shadow: var(--shadow-2); z-index: 2000;
  font-size: var(--f-sm); transition: opacity .2s ease-out, transform .2s ease-out; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-left-color: var(--danger); }
@media (min-width: 901px) { .topbar .seg button { min-height: 34px; } }
@media (max-width: 900px) { .btn, .seg button, .search-list li { min-height: 44px; } }
