:root {
  /* Innovation Dynamic palette, taken from the vector logo: grey #4d4d4d, orange #f79118.
     The orange is for accents only (it fails text contrast on white); the status colours of the
     map (anomaly, artefact, not observable) keep their own hues (ADR 0002). */
  --brand: #4d4d4d; --accent: #f79118; --link: #a85800;
  --tint: #fff3e2; --tint-line: #f5d3a6;
  --ink: #2b2b2b; --muted: #666666; --line: #dddddd; --bg: #f5f5f5;
  --obs: #262626; --lim: #808080; --not: #bdbdbd;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); }
body { display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 16px; padding: 6px 16px; background: #fff; border-bottom: 3px solid var(--accent); }
.logo { display: block; flex: none; line-height: 0; }
.logo img { height: 32px; width: auto; display: block; }
.brand { font-weight: 700; font-size: 17px; color: var(--brand); letter-spacing: .02em; white-space: nowrap; }
.brand span { font-weight: 400; font-size: 14px; letter-spacing: 0; color: var(--muted); margin-left: 6px; }
header .brand { padding-left: 16px; border-left: 1px solid var(--line); }
.title { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.disclaimer { padding: 6px 16px; background: var(--tint); border-bottom: 1px solid var(--tint-line); font-size: 12.5px; }
main { flex: 1; display: flex; min-height: 0; }
#map { flex: 1; background: var(--bg); }
#panel { width: 380px; overflow-y: auto; border-left: 1px solid var(--line); padding: 4px 16px 16px; }
#panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 8px; }
#panel label { display: block; margin: 4px 0; }
.legend-title { margin-top: 8px; font-weight: 600; font-size: 12.5px; }
.legend-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.sw { display: inline-block; width: 28px; height: 0; border-top: 4px solid var(--obs); }
.sw-lim { border-top-color: var(--lim); }
.sw-not { border-top: 4px dashed var(--not); }
.ramp { height: 10px; margin-top: 6px; border-radius: 2px;
  background: linear-gradient(90deg, #b35806, #f1a340, #f7f7f7, #998ec3, #542788); }
.ramp-labels { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.note, .hint { font-size: 12px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
td, th { padding: 3px 4px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 600; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--bg); }
.kv td:first-child { color: var(--muted); width: 45%; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 9px; background: var(--bg); border: 1px solid var(--line); font-size: 11.5px; }
svg.chart { width: 100%; height: 220px; display: block; margin-top: 8px; }
svg.chart text { font-size: 10px; fill: var(--muted); }
.kpi-row { font-size: 12.5px; margin-top: 6px; }
table.kpi td, table.kpi th { text-align: center; }

/* ---- shared controls ---- */
button, select, input { font: inherit; }
button { padding: 4px 10px; border: 1px solid var(--line); border-radius: 4px; background: #fff; cursor: pointer; }
button:hover { background: var(--bg); }
button.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
button.primary:hover { background: #333333; }
a.button-link { display: inline-block; padding: 6px 12px; border-radius: 4px; background: var(--brand); color: #fff; text-decoration: none; }
a.button-link:hover { background: #333333; }
button.link { border: none; background: none; color: var(--link); padding: 0 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .5; cursor: default; }
input, select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
label input:not([type=checkbox]), label select { display: block; width: 100%; margin-top: 2px; }
code { font-size: 12px; }
a { color: var(--link); }
.msg { margin: 8px 16px; padding: 6px 10px; border-radius: 4px; font-size: 13px; }
.msg-error { background: #fdecea; border: 1px solid #f3b8b2; }
.msg-ok { background: #eef6ee; border: 1px solid #b9d7b9; }
.msg-info { background: var(--tint); border: 1px solid var(--tint-line); }
.banner { padding: 6px 16px; background: var(--tint); border-bottom: 1px solid var(--tint-line); font-size: 12.5px; }
.sw-pend { border-top: 2px solid #666666; }
/* Screening: neutral palette, never green (ADR 0002) */
.sw-scr-anom { border-top: 5px solid #d95f02; }
.sw-scr-art { border-top: 4px dashed #7570b3; }
.sw-scr-none { border-top: 3px solid #4d4d4d; }
.anom { border-left: 3px solid #d95f02; padding-left: 6px; margin: 6px 0; }
.anom.art { border-left-color: #7570b3; }
.chart-legend { font-size: 11px; color: #4d4d4d; }
.chart-legend i { display: inline-block; width: 14px; height: 0; vertical-align: middle; margin: 0 3px 0 8px; }
.chart-legend .lg-meas { border-top: 2px solid #262626; }
.chart-legend .lg-model { border-top: 2px solid #0a66c2; }
.chart-legend .lg-band { border-top: 6px solid rgba(10, 102, 194, 0.2); }
.chart-legend .lg-anom { border-top: 6px solid rgba(217, 95, 2, 0.35); }

/* ---- header on the map page ---- */
.muni-select { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.muni-select select { width: auto; margin: 0; }
.usernav { margin-left: auto; flex: none; display: flex; gap: 10px; align-items: baseline; font-size: 13px; white-space: nowrap; }
.usernav a { color: var(--link); text-decoration: none; }
#pwd-form label { margin: 6px 0; }

/* ---- login / activation ---- */
body.auth-page { align-items: center; justify-content: center; background: var(--bg); }
main.auth-box { display: block; flex: none; width: 380px; max-width: 92vw; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 8px; padding: 28px 28px 24px; margin: auto; }
.auth-box .logo { margin: 0 0 18px; }
.auth-box .logo img { height: 52px; }
.auth-box .brand { padding-top: 14px; border-top: 1px solid var(--line); }
.auth-box h1 { font-size: 18px; margin: 16px 0 12px; }
.auth-box label { display: block; margin: 10px 0; font-size: 13px; }
.auth-box button { margin-top: 8px; width: 100%; padding: 8px; }
.auth-box .msg { margin: 10px 0 0; }

/* ---- administration ---- */
body.admin-page { display: block; height: auto; }
body.admin-page header { position: sticky; top: 0; background: #fff; z-index: 2; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 6px 10px; }
.tabs button.active { border-bottom-color: var(--accent); font-weight: 600; }
.tab { padding: 4px 16px 24px; }
.tab h2 { font-size: 16px; margin: 12px 0 6px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.inline-form input:not([type=file]) { min-width: 260px; }
table.admin { margin-top: 10px; font-size: 13px; }
table.admin td { vertical-align: top; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 1px 2px 1px 8px; margin: 1px 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.chip .x { border: none; background: none; padding: 0 6px; color: var(--muted); }
.assign select { width: auto; margin-top: 4px; }
label.addon { display: flex; gap: 4px; align-items: center; margin: 0; white-space: nowrap; }
.linkbox { margin: 10px 0; padding: 10px; border: 1px solid var(--tint-line); background: var(--tint); border-radius: 6px; }
.linkbox input { width: 70%; min-width: 280px; }
.status { padding: 1px 6px; border-radius: 9px; border: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
.st-errore { border-color: #f3b8b2; background: #fdecea; }
.st-in_attesa_dati_insar, .st-in_coda, .st-in_elaborazione { background: var(--tint); border-color: var(--tint-line); }
.sw-stretch { border-top: 8px solid rgba(106, 61, 154, 0.35); }
.sw-gm-unobs { border-top: 8px solid rgba(154, 154, 154, 0.5); }
.note-limit { border-left: 3px solid var(--accent); padding-left: 8px; }
.sw-gm-frana { border-top: 8px solid rgba(140, 81, 10, 0.55); }
.sw-gm-cedimento { border-top: 8px solid rgba(67, 147, 195, 0.55); }
.sw-gm-subsidenza { border-top: 8px solid rgba(5, 48, 97, 0.55); }
.sw-gm-sollevamento { border-top: 8px solid rgba(118, 42, 131, 0.55); }
.sw-gm-orizzontale { border-top: 8px solid rgba(82, 82, 82, 0.55); }
.sw-gm-indeterminato { border-top: 8px solid rgba(150, 150, 150, 0.55); }
.chart-legend .lg-comp-up { display: inline-block; width: 16px; border-top: 2px solid #053061; vertical-align: middle; margin: 0 3px 0 6px; }
.chart-legend .lg-comp-east { display: inline-block; width: 16px; border-top: 2px dashed #b35806; vertical-align: middle; margin: 0 3px 0 6px; }
.chart-legend .lg-comp-los { display: inline-block; width: 16px; border-top: 2px dotted #808080; vertical-align: middle; margin: 0 3px 0 6px; }
#detail a.button-link { margin: 4px 0 8px; }
.seg-link { font-family: monospace; font-size: 12px; padding: 2px 0; color: var(--link); cursor: pointer; }
.stretch-link { color: #6a3d9a; font-weight: bold; cursor: pointer; }

@media (max-width: 1280px) {
  body:not(.admin-page) header .brand span { display: none; }
}
.sat-big { font-size: 13px; margin: 2px 0 6px; }
.sat-big b { font-size: 22px; color: var(--brand); margin-right: 4px; }
