/* ============================================================
   Statistiche del log · ARI Rivarolo — logbook statistics in ARI palette
   Adapted by IW1GEU FOR IQ1GP from the standalone logstats site.
   Loaded after the shared ../styles.css; everything is scoped to
   main.ls so the site brand, nav and footer are left untouched.
   The variables live on :root because the map canvas reads them.
   ============================================================ */

:root {
	--bg:      #D6E7F2;
	--surface: #ffffff;
	--ink:     #33475c;
	--ink2:    #5a7289;
	--muted:   #7a8b9a;
	--line:    #cfe0ee;
	--accent:  #004086;
	--accent-hi: #002a5c;
	--s1:      #004086;
	--s2:      #c47a00;
	--s3:      #2d9c50;
	--h0:      #dbe8f4;
	--h1:      #002a5c;
	--cell0:   #eef5fa;
	--ht1:     #ffffff;
	--mapbg:   #eef5fa;
	--hover:   rgba(0, 64, 134, 0.07);
	--tint:    #9fbad6;
	--mono:    ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html { scroll-behavior: smooth; scroll-padding-top: 120px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* ---------- Page-scope baseline ---------- */
.ls { color: var(--ink); font-size: 14px; line-height: 1.5; }
.ls *, .ls *::before, .ls *::after { box-sizing: border-box; }
.ls td, .ls th { font-size: inherit; }
.ls [hidden] { display: none !important; }
.ls .wrap { max-width: 1200px; margin: 0 auto; padding: 0 14px; }
.ls .vh { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.ls :focus-visible, .ls .btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Header ---------- */
.ls header.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5em; flex-wrap: wrap; padding-top: 0.6em; padding-bottom: 1.1em; }
.ls h1 { margin: 0; color: var(--accent); font-size: clamp(1.8rem, 5vw, 3rem); line-height: 1.05; font-weight: 750; letter-spacing: -0.02em; }
.ls #sub { margin: 0.6em 0 0; color: #556b7a; font-size: 1em; max-width: 70ch; }
.ls .acts { display: flex; gap: 0.6em; flex-wrap: wrap; }

/* ---------- Buttons and inputs ---------- */
.ls button, .ls .btn { font: inherit; font-weight: 600; color: var(--accent); background: #fff; border: 1px solid var(--accent); border-radius: 6px; padding: 0.55em 1em; cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s; }
.ls button:hover, .ls .btn:hover { background: #edf3f9; }
.ls select, .ls input[type=search], .ls #home input { font: inherit; color: var(--ink); background: #fff; border: 1px solid #b4cce0; border-radius: 6px; padding: 0.4em 0.7em; }
.ls select { cursor: pointer; }
.ls select:hover, .ls input[type=search]:hover { border-color: var(--accent); }
.ls .big { display: inline-block; font-size: 1.05em; padding: 0.9em 1.8em; background: var(--accent); color: #fff; }
.ls .big:hover { background: var(--accent-hi); transform: translateY(-1px); }

/* ---------- Sticky filter bar ---------- */
.ls .bar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-top: 1px solid #aac4d8; border-bottom: 1px solid #aac4d8; }
.ls .bar .wrap { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; padding-top: 10px; padding-bottom: 10px; }
.ls .filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ls .filters label { display: flex; gap: 6px; align-items: center; color: var(--ink2); font-size: 0.9rem; }
.ls #shown { color: var(--ink2); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.ls #nav { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-left: auto; }
.ls #nav a { color: var(--accent); text-decoration: none; font-size: 0.9rem; font-weight: 600; border-bottom: 2px solid transparent; }
.ls #nav a:hover { color: var(--accent-hi); border-color: var(--accent); }

/* ---------- Sections and cards ---------- */
.ls section { padding: 1.6em 0 0.3em; margin: 0; }
.ls h2 { font-size: 1.4em; line-height: 1.2; margin: 0 0 0.6em; color: #000; border-bottom: 1px solid #aac4d8; padding-bottom: 0.15em; }
.ls .grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1em; }
.ls .card { grid-column: span 12; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1em 1.2em; }
.ls .s3 { grid-column: span 3; } .ls .s4 { grid-column: span 4; } .ls .s5 { grid-column: span 5; }
.ls .s6 { grid-column: span 6; } .ls .s7 { grid-column: span 7; } .ls .s8 { grid-column: span 8; }
@media (max-width: 1020px) { .ls .card { grid-column: 1 / -1; } }
.ls h3 { font-size: 1.1em; line-height: 1.3; font-weight: 700; color: var(--accent); margin: 0 0 0.7em; }
.ls .note { color: var(--muted); font-size: 0.82rem; margin: 10px 0 0; max-width: 80ch; }
.ls .empty { color: var(--muted); padding: 20px 0; }
.ls .card.stale .body { opacity: 0.35; }

/* ---------- Key numbers ---------- */
.ls .keys { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.ls .keys div { border-top: 1px solid var(--line); padding: 9px 0 10px; }
.ls .keys b { display: block; font-size: 1.8em; font-weight: 700; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.ls .keys span { color: #556b7a; font-size: 0.86rem; }
.ls .tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 18px; }
.ls .tiles div { border-top: 1px solid var(--line); padding: 9px 0 10px; min-width: 0; }
.ls .tiles b { display: block; font-size: 1.45em; font-weight: 700; line-height: 1.15; color: var(--accent); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ls .tiles span { color: #556b7a; font-size: 0.86rem; display: block; }
.ls .tiles small { color: var(--muted); font-size: 0.8rem; display: block; }

/* ---------- Bars ---------- */
.ls .bars { display: grid; gap: 5px; }
.ls .barr { display: grid; grid-template-columns: var(--lw, 7.5rem) minmax(40px, 1fr) auto; gap: 10px; align-items: center; font-size: 0.86rem; }
.ls .barr:hover { background: var(--hover); }
.ls .bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ls .bt { display: flex; gap: 2px; height: 10px; }
.ls .bt i { background: var(--s1); border-radius: 0 4px 4px 0; min-width: 1px; }
.ls .bt i.x { background: var(--tint); }
.ls .bt i:not(:last-child) { border-radius: 0; }
.ls .bv { font-variant-numeric: tabular-nums; color: var(--ink2); min-width: 3.2rem; text-align: right; }

/* ---------- SVG charts ---------- */
.ls .chart { overflow-x: auto; }
.ls .chart svg { display: block; width: 100%; height: auto; }
.ls svg .gridl { stroke: var(--line); stroke-width: 1; }
.ls svg .ax { fill: var(--ink2); font: 11px system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.ls svg .hc { fill: transparent; }
.ls svg .hc:hover { fill: var(--hover); }
.ls svg .ln { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; }
.ls svg .ar { fill: var(--s1); opacity: 0.12; }
.ls .legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.84rem; color: var(--ink2); margin: 0 0 8px; }
.ls .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.ls .legend i.ring { background: none !important; border: 2px solid var(--s1); }

/* ---------- Heat maps ---------- */
.ls table.heat { border-collapse: separate; border-spacing: 2px; font-size: 0.72rem; width: 100%; min-width: 430px; table-layout: fixed; }
.ls .heat thead th { padding: 0; overflow: hidden; }
.ls .heat th { font-weight: 400; color: var(--ink2); padding: 0 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ls .heat tbody th { text-align: right; }
.ls .heat td { background: color-mix(in oklab, var(--h1) calc(var(--v) * 100%), var(--h0)); height: 19px; overflow: hidden; border-radius: 2px; text-align: center; color: var(--ink); font-variant-numeric: tabular-nums; }
.ls .heat td.z { background: var(--cell0); }
.ls .heat td.hi { color: var(--ht1); }
.ls .heat td:hover { outline: 2px solid var(--accent-hi); outline-offset: -1px; }
.ls .hleg { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.8rem; margin-top: 8px; }
.ls .hleg i { width: 120px; height: 8px; border-radius: 2px; background: linear-gradient(90deg, var(--h0), var(--h1)); }
.ls .cal { margin-bottom: 8px; }
.ls .cal h4 { margin: 6px 0 2px; font-size: 0.86rem; font-weight: 600; color: var(--ink2); }
.ls .cal rect { fill: color-mix(in oklab, var(--h1) calc(var(--v) * 100%), var(--h0)); }
.ls .cal rect.z { fill: var(--cell0); }
.ls .cal rect:hover { stroke: var(--accent-hi); stroke-width: 1.5; }

/* ---------- Tables ---------- */
.ls .tw { overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.ls table.dt { border-collapse: collapse; width: 100%; font-size: 0.84rem; }
.ls .dt th { position: sticky; top: 0; background: var(--cell0); text-align: left; padding: 0; border-bottom: 1px solid var(--line); z-index: 1; }
.ls .dt th button { all: unset; display: block; width: 100%; box-sizing: border-box; padding: 6px 10px; cursor: pointer; font-weight: 600; color: var(--accent); white-space: nowrap; }
.ls .dt th button:hover { background: var(--hover); }
.ls .dt th button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ls .dt td { padding: 4px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ls .dt tr:last-child td { border-bottom: 0; }
.ls .dt .num { text-align: right; font-variant-numeric: tabular-nums; }
.ls .dt th.num button { text-align: right; }
.ls .dt tbody tr:hover { background: var(--hover); }
.ls .mx td.m { text-align: center; padding: 4px 6px; color: var(--s1); }
.ls .mx th.num button { text-align: center; padding: 6px; }

/* ---------- Zones and chips ---------- */
.ls .zones { display: flex; flex-wrap: wrap; gap: 4px; }
.ls .zones span { min-width: 30px; padding: 2px 4px; text-align: center; border-radius: 3px; font-size: 0.8rem; font-variant-numeric: tabular-nums; border: 1.5px solid transparent; }
.ls .zones .c { background: var(--s1); color: #fff; }
.ls .zones .w { border-color: var(--s1); }
.ls .zones .n { border: 1.5px dashed #b4cce0; color: var(--muted); }
.ls .chips { display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: 0.84rem; }
.ls .chips span { border: 1px solid var(--line); background: var(--cell0); border-radius: 3px; padding: 1px 7px; }
.ls .chips em { font-style: normal; color: var(--muted); margin-left: 4px; }

/* ---------- Map ---------- */
.ls .mapctl { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 10px; font-size: 0.86rem; color: var(--ink2); align-items: center; }
.ls .seg { display: inline-flex; margin-left: 6px; }
.ls .seg button { border-radius: 0; margin-left: -1px; padding: 3px 10px; font-size: 0.84rem; }
.ls .seg button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.ls .seg button:last-child { border-radius: 0 6px 6px 0; }
.ls .seg button[aria-pressed=true] { background: var(--accent); color: #fff; }
.ls .mapwrap { display: flex; justify-content: center; }
.ls canvas { max-width: 100%; touch-action: none; }

/* ---------- Records ---------- */
.ls dl.rec { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0 24px; margin: 0; }
.ls dl.rec div { border-top: 1px solid var(--line); padding: 9px 0; }
.ls dl.rec dt { color: #556b7a; font-size: 0.86rem; }
.ls dl.rec dd { margin: 0; font-size: 1.25em; font-weight: 700; line-height: 1.2; color: var(--accent); }
.ls dl.rec small { display: block; font-size: 0.82rem; font-weight: 400; line-height: 1.3; color: var(--muted); }

/* ---------- Tooltip, drop overlay, closing note ---------- */
.ls #tip { position: fixed; z-index: 50; pointer-events: none; background: var(--accent-hi); color: #fff; font-size: 0.8rem; line-height: 1.35; padding: 6px 9px; border-radius: 4px; white-space: pre-line; max-width: 300px; display: none; font-variant-numeric: tabular-nums; }
.ls #drop { position: fixed; inset: 0; z-index: 60; display: none; place-items: center; background: rgba(214, 231, 242, 0.9); color: var(--accent); font-size: 1.8rem; font-weight: 700; border: 4px dashed var(--accent); }
.ls .ls-foot { color: #5a7289; font-size: 0.85em; margin-top: 2em; margin-bottom: 0; }

/* ---------- Landing ---------- */
.ls #landing { padding-top: 0.4em; padding-bottom: 2em; }
.ls #landing > * { max-width: 720px; }
.ls #landing h2 { font-size: 1.4em; margin-bottom: 0.7em; }
.ls #landing p { font-size: 1em; margin: 0 0 1em; }
.ls #landing ul { padding-left: 1.2em; margin: 0 0 1.5em; line-height: 1.6; }
.ls #msg { color: #b13a3a; font-weight: 600; }
.ls #progress { margin-top: 12px; color: var(--ink2); }
.ls progress { width: 260px; max-width: 60vw; vertical-align: middle; margin-right: 10px; accent-color: var(--accent); }

/* ---------- Own-locator prompt ---------- */
.ls #home { background: #fff7e0; border-left: 5px solid #e0a200; border-radius: 0 6px 6px 0; color: #5a3e00; padding: 0.9em 1.2em; margin-top: 1.2em; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.ls #home input { width: 9rem; }
.ls #homeErr { color: #b13a3a; font-weight: 600; }
