:root {
  --lm-card: #ffffff;
  --lm-border: #dfe4ea;
  --lm-muted: #5d6b7c;
  --lm-accent: #1f9e92;
  --lm-warn: #d9731a;
}
[data-bs-theme="dark"] {
  --lm-card: #161d27;
  --lm-border: #2b3646;
  --lm-muted: #9aa8b8;
  --lm-accent: #3cc6b8;
  --lm-warn: #f28c38;
}
body { background: var(--bs-body-bg); }
.lm-nav { background: var(--lm-card); }
.lm-logo { height: 28px; max-width: 120px; object-fit: contain; }
.lm-user { max-width: 280px; }
.lm-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
:focus-visible { outline: 2px solid var(--lm-accent) !important; outline-offset: 2px; }

/* ---- Pagina mappa ---- */
.lm-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.lm-eyebrow { font-family: ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--lm-accent); font-size: .8rem; }
.lm-kpis { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: 0; }
.lm-kpis > div { text-align: left; }
.lm-kpis dd { font-family: ui-monospace, monospace; font-size: 1.5rem; margin: 0; line-height: 1.1; }
.lm-kpis dt { font-weight: 400; text-transform: uppercase; font-size: .72rem; letter-spacing: .06em; color: var(--lm-muted); }
.lm-kpis .lm-warn dd { color: var(--lm-warn); }

.lm-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1rem; align-items: start; }
.lm-side { display: flex; flex-direction: column; gap: .75rem; position: sticky; top: .75rem; max-height: calc(100vh - 1.5rem); overflow: auto; }
.lm-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.lm-card { background: var(--lm-card); border: 1px solid var(--lm-border); border-radius: .6rem; }

.lm-facet { padding: .75rem 1rem; border-bottom: 1px solid var(--lm-border); }
.lm-facet:last-child { border-bottom: 0; }
.lm-facet-head { display: flex; justify-content: space-between; font-family: ui-monospace, monospace; text-transform: uppercase; letter-spacing: .1em; font-size: .78rem; color: var(--lm-muted); margin-bottom: .4rem; }
.lm-facet-head a { color: var(--lm-accent); text-decoration: none; text-transform: none; letter-spacing: 0; }
.lm-facet-row { display: flex; align-items: center; gap: .45rem; padding: .18rem 0; cursor: pointer; font-size: .9rem; }
.lm-facet-row .form-check-input { margin: 0; flex: none; }
.lm-facet-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lm-facet-n { color: var(--lm-muted); font-family: ui-monospace, monospace; font-size: .82rem; }
.lm-zero { opacity: .45; }
.lm-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.lm-kind { font-size: .62rem; font-weight: 500; }
.lm-scroll { max-height: 290px; overflow-y: auto; padding-right: .25rem; }

.lm-timeline { padding: 1rem 1.25rem .5rem; }
.lm-hist { display: flex; align-items: flex-end; gap: 2px; height: 64px; }
.lm-bar { flex: 1; height: 100%; display: flex; flex-direction: column-reverse; border: 0; padding: 0; background: transparent; cursor: pointer; min-width: 2px; }
.lm-bar span { display: block; width: 100%; }
.lm-bar.lm-out { opacity: .3; }
.lm-bar.lm-deleted { background: repeating-linear-gradient(45deg, transparent 0 4px, rgba(229, 83, 75, .35) 4px 6px); }
.lm-slider { position: relative; height: 28px; }
.lm-slider input[type=range] { position: absolute; left: 0; right: 0; top: 4px; width: 100%; pointer-events: none; -webkit-appearance: none; appearance: none; background: transparent; }
.lm-slider input[type=range]::-webkit-slider-runnable-track { height: 4px; background: var(--lm-accent); border-radius: 2px; }
.lm-slider input[type=range]::-moz-range-track { height: 4px; background: var(--lm-accent); border-radius: 2px; }
.lm-slider input[type=range]::-webkit-slider-thumb { pointer-events: auto; -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: var(--lm-card); border: 2px solid var(--lm-accent); cursor: pointer; }
.lm-slider input[type=range]::-moz-range-thumb { pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: var(--lm-card); border: 2px solid var(--lm-accent); cursor: pointer; }
.lm-slider #lm-to::-webkit-slider-runnable-track, .lm-slider #lm-to::-moz-range-track { background: transparent; }
.lm-ticks { position: relative; height: 1.4rem; font-size: .75rem; color: var(--lm-muted); }
.lm-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.lm-ticks span:first-child { transform: none; }

.lm-mapwrap { overflow: hidden; }
.lm-map { height: 560px; }
.leaflet-container { font: inherit; }
.lm-label span { font-family: ui-monospace, monospace; font-size: 12px; font-weight: 600; white-space: nowrap; color: #11161d;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff; }
[data-bs-theme="dark"] .lm-label span { color: #eef2f6; text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 2px #000; }
.lm-legend { background: var(--lm-card); color: var(--bs-body-color); border: 1px solid var(--lm-border); border-radius: .5rem; padding: .5rem .75rem; font-size: .8rem; max-width: 240px; }
.lm-legend-row { display: flex; align-items: center; gap: .4rem; margin: .15rem 0; }
.lm-grad { width: 34px; height: 8px; border-radius: 4px; flex: none; }
[data-bs-theme="dark"] .leaflet-bar a, [data-bs-theme="dark"] .leaflet-popup-content-wrapper, [data-bs-theme="dark"] .leaflet-popup-tip { background: var(--lm-card); color: var(--bs-body-color); }
[data-bs-theme="dark"] .leaflet-control-scale-line { background: rgba(22, 29, 39, .8); color: #eef2f6; border-color: #9aa8b8; }
.lm-pop ul { padding-left: 1rem; margin: 0 0 .25rem; }
.lm-pop-sec { margin-top: .35rem; }

.lm-log { position: relative; height: 520px; overflow: auto; }
.lm-log-inner { min-width: 100%; }
.lm-log-head { position: sticky; top: 0; z-index: 2; display: flex; background: var(--lm-card); border-bottom: 1px solid var(--lm-border); }
.lm-log-body { position: relative; }
.lm-row { position: absolute; left: 0; right: 0; height: 30px; display: flex; cursor: pointer; border-bottom: 1px solid var(--lm-border); font-size: .82rem; }
.lm-row:hover { background: rgba(127, 140, 154, .12); }
.lm-row-fail .lm-cell:last-child { color: var(--lm-warn); }
.lm-cell { flex: none; padding: 0 .5rem; line-height: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lm-th { border: 0; background: transparent; text-align: left; font-weight: 600; font-size: .8rem; color: var(--bs-body-color); }

@media (max-width: 900px) {
  .lm-grid { grid-template-columns: 1fr; }
  .lm-side { position: static; max-height: none; }
  .lm-map { height: 420px; }
  .lm-kpis { gap: 1rem; }
  /* su schermi stretti la legenda tiene solo gli interruttori: i colori sono già nelle faccette */
  .lm-legend { max-width: 180px; font-size: .75rem; }
  .lm-legend-dev, .lm-legend hr { display: none !important; }
}

/* ---- Superuser: selezione sedi ---- */
.lm-office-map { height: 360px; border-radius: .5rem; border: 1px solid var(--lm-border); }
.lm-pre { white-space: pre-wrap; }
