:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --danger: #c62828;
  --wash: rgba(11, 11, 11, 0.05);
  /* series: color follows the course (matches the Excel column groups) */
  --s-ba: #eda100;
  --s-ia: #2a78d6;
  --s-tot: #2f9e44;   /* overall progress (green group of the report) */
  /* report table (Excel palette) */
  --t-head: #a5a5a5;
  --t-row: #f2f2f2;
  --t-tot-h: #92d050;
  --t-tot: #d9f2d0;
  --t-ba-h: #ffd966;
  --t-ba: #fff2cc;
  --t-ia-h: #9bc2e6;
  --t-ia: #ddebf7;
  --t-row-alt: #fafafa;
  --t-tot-alt: #edf9e8;
  --t-ba-alt: #fff9e5;
  --t-ia-alt: #eef5fb;
  --t-ink: #0b0b0b;
  --red: #e00000;
  --logo-bg: transparent;
  --logo-pad: 0;
  /* login page: blue of the Sosor logo */
  --brand: #2349ad;
  --brand-hover: #1c3b8f;
  --brand-ring: rgba(35, 73, 173, 0.22);
  --warn: #b45309;
  /* "Monitoraggio per dipendente": Excel palette of the original file */
  --x-navy: #002060;  --x-navy-ink: #ffffff;
  --x-head: #c1e4f5;  --x-head-line: #45b0e1;
  --x-list: #c6efce;  --x-list-ink: #006100;
  --x-cess: #70ad47;  --x-cess-ink: #ffffff;  --x-cess-alt: #d9f2d0;
  --x-line: #8c8b85;
  /* course status, ordinal: nothing done (neutral) -> in corso -> completato -> test superato (darkest) */
  --st-0: #cfcdc5;
  --st-ba-1: #f7d58a; --st-ba-2: #eda100; --st-ba-3: #a86f00;
  --st-ia-1: #a9c8ee; --st-ia-2: #4f8fdc; --st-ia-3: #1b4f91;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #9a9890;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --danger: #ff6b6b;
    --wash: rgba(255, 255, 255, 0.06);
    --s-ba: #c98500;
    --s-ia: #3987e5;
    --s-tot: #40b255;
    --t-head: #4a4a47;
    --t-row: #242423;
    --t-tot-h: #3d5a1f;
    --t-tot: #1f2a18;
    --t-ba-h: #6b5412;
    --t-ba: #2b2515;
    --t-ia-h: #22476b;
    --t-ia: #17222e;
    --t-row-alt: #1d1d1c;
    --t-tot-alt: #18210f;
    --t-ba-alt: #221d10;
    --t-ia-alt: #111a24;
    --t-ink: #f2f2f2;
    --red: #ff6b6b;
    --logo-bg: #f4f4f1;
    --logo-pad: 6px 10px;
    --brand: #3b63d4;
    --brand-hover: #4a70dc;
    --brand-ring: rgba(92, 130, 235, 0.38);
    --warn: #f0a33a;
    --x-navy: #1d3a7a;  --x-navy-ink: #ffffff;
    --x-head: #173a4c;  --x-head-line: #2b7699;
    --x-list: #1d3a22;  --x-list-ink: #9fdcaa;
    --x-cess: #3d6b24;  --x-cess-ink: #ffffff;  --x-cess-alt: #1c2716;
    --x-line: #4a4a46;
    /* dark: the ramp flips, more progress = brighter */
    --st-0: #4a4945;
    --st-ba-1: #6e5214; --st-ba-2: #b98200; --st-ba-3: #f2be4a;
    --st-ia-1: #22477a; --st-ia-2: #3a7fd6; --st-ia-3: #8fbdf5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #ffffff; --ink-2: #c3c2b7; --muted: #9a9890;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10); --accent: #3987e5;
  --danger: #ff6b6b; --wash: rgba(255, 255, 255, 0.06); --s-ba: #c98500; --s-ia: #3987e5; --s-tot: #40b255;
  --t-head: #4a4a47; --t-row: #242423; --t-tot-h: #3d5a1f; --t-tot: #1f2a18; --t-ba-h: #6b5412;
  --t-ba: #2b2515; --t-ia-h: #22476b; --t-ia: #17222e; --t-ink: #f2f2f2; --red: #ff6b6b;
  --t-row-alt: #1d1d1c; --t-tot-alt: #18210f; --t-ba-alt: #221d10; --t-ia-alt: #111a24;
  --logo-bg: #f4f4f1; --logo-pad: 6px 10px;
  --brand: #3b63d4; --brand-hover: #4a70dc; --brand-ring: rgba(92, 130, 235, 0.38); --warn: #f0a33a;
  --x-navy: #1d3a7a;  --x-navy-ink: #ffffff;
  --x-head: #173a4c;  --x-head-line: #2b7699;
  --x-list: #1d3a22;  --x-list-ink: #9fdcaa;
  --x-cess: #3d6b24;  --x-cess-ink: #ffffff;  --x-cess-alt: #1c2716;
  --x-line: #4a4a46;
  /* dark: the ramp flips, more progress = brighter */
  --st-0: #4a4945;
  --st-ba-1: #6e5214; --st-ba-2: #b98200; --st-ba-3: #f2be4a;
  --st-ia-1: #22477a; --st-ia-2: #3a7fd6; --st-ia-3: #8fbdf5;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* touch: no grey/black flash on tapped elements (controls have their own :active state below) */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 18px; margin: 0; font-weight: 650; }
h2 { font-size: 16px; margin: 0; font-weight: 650; }
.muted { color: var(--muted); margin: 2px 0 0; font-size: 13px; }
.alert {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--ink); padding: 8px 12px; border-radius: 8px; margin: 12px 0;
}

/* buttons & inputs */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  padding: 7px 12px; border-radius: 8px; font: inherit; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { background: var(--wash); }
.btn:active:not(:disabled) { background: color-mix(in srgb, var(--ink) 10%, var(--surface)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: progress; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 2px 4px; }
input, select {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px; min-height: 34px;
  transition: border-color .15s, box-shadow .15s;
}
/* focus ring only for keyboard users; fields get a soft glow instead of a ring */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:not([type=checkbox]):focus-visible, select:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
/* controls: no accidental text selection, no double-tap zoom */
button, [role=tab], summary, label, .legend, .ms-label {
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}

/* layout */
#app { max-width: 1480px; margin: 0 auto; padding: 16px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.logo-chip { display: inline-flex; flex: none; background: var(--logo-bg); padding: var(--logo-pad); border-radius: 8px; }
.logo-chip img { display: block; height: 40px; width: auto; }
.brand-text { min-width: 0; padding-left: 16px; border-left: 1px solid var(--border); }
/* data date + "Aggiorna" */
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
#meta { border-radius: 4px; }
#meta.flash { animation: meta-flash 1.8s ease-out; }
@keyframes meta-flash { from { background: color-mix(in srgb, var(--s-tot) 26%, transparent); color: var(--ink); } }
.refresh {
  display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 2px 10px 2px 8px;
  font: inherit; font-size: 12.5px; color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, color .15s;
}
.refresh:hover:not(:disabled), .refresh:active:not(:disabled) { background: var(--wash); color: var(--ink); }
.refresh:disabled { cursor: default; color: var(--muted); }
.refresh svg { flex: none; width: 14px; height: 14px; }
.refresh[aria-busy=true] svg { animation: spin .9s linear infinite; }
.refresh[hidden] { display: none; }
.topbar-actions { display: flex; gap: 8px 14px; flex-wrap: wrap; align-items: center; align-self: center; }
.topbar-actions form { margin: 0; }
.user-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.user-chip svg, .btn svg { flex: none; width: 16px; height: 16px; }
.user-chip svg { color: var(--muted); }

.filters {
  display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end;
  padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px;
}
.filters > label:not(.check) { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.filters .reset-filters { margin-left: auto; }
.filters .reset-filters:disabled { cursor: default; opacity: .45; }
.filters select.is-active, .filters .ms-btn.is-active {
  border-color: var(--accent); color: var(--ink); font-weight: 600;
  background-color: color-mix(in srgb, var(--accent) 9%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--accent);
}
.filters .check.is-active { color: var(--ink); font-weight: 600; }
/* "Previsioni": course, pace and deadline, on their own line of the filters bar */
.goal-opts {
  flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: flex-end;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.goal-opts[hidden] { display: none; }
.go { display: grid; gap: 4px; }
.go-label { font-size: 12px; color: var(--ink-2); }
.go-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.go .seg button { display: inline-flex; align-items: center; gap: 6px; }
.go .seg .key { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.go [data-gcourse=ba] .key { background: var(--s-ba); }
.go [data-gcourse=ia] .key { background: var(--s-ia); }
#g-pace { width: 62px; text-align: center; }
.go .inline-field span { font-size: 13px; color: var(--ink-2); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); min-height: 34px; cursor: pointer; }
.check input { min-height: 0; width: 16px; height: 16px; }

/* multi-select */
.ms { position: relative; display: grid; gap: 4px; }
.ms-label { font-size: 12px; color: var(--ink-2); }
.ms-btn {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 28px 6px 8px; min-height: 34px; min-width: 240px; max-width: 340px; text-align: left; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative;
}
.ms-btn::after { content: "▾"; position: absolute; right: 10px; color: var(--muted); }
.ms-pop {
  position: absolute; top: 100%; left: 0; z-index: 20; margin-top: 4px; width: min(360px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); padding: 8px;
}
.ms-tools { display: flex; gap: 4px; align-items: center; margin-bottom: 6px; }
.ms-tools input { flex: 1; min-width: 0; }
.ms ul { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.ms li label { display: flex; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.ms li label:hover { background: var(--wash); }
.ms li .grp { font-size: 11px; color: var(--muted); margin-left: auto; }

/* tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs [role=tab] {
  font: inherit; font-weight: 600; color: var(--ink-2); background: transparent; border: 0;
  border-bottom: 2px solid transparent; padding: 10px 14px; margin-bottom: -1px; cursor: pointer; white-space: nowrap;
}
.tabs [role=tab]:hover, .tabs [role=tab]:active { color: var(--ink); background: var(--wash); border-radius: 8px 8px 0 0; }
.tabs [role=tab][aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); }

/* tabs + filters: pinned to the top while scrolling (the pin on the right, on by default).
   Grid (not margins) so the pinned bar's background covers the gap above the first panel. */
.sticky-head { display: grid; gap: 12px; padding-bottom: 12px; }
/* grid items may shrink below their content (the tab row scrolls on phones) */
.sticky-head > * { min-width: 0; }
.sticky-head.is-pinned {
  position: sticky; top: 0; z-index: 30; background: var(--page);
  box-shadow: 0 10px 14px -12px rgb(0 0 0 / .35);
}
.tabs-bar { display: flex; align-items: stretch; gap: 8px; border-bottom: 1px solid var(--border); }
.tabs-bar .tabs { flex: 1 1 auto; border-bottom: 0; margin-bottom: 0; }
.sticky-head .filters { margin-bottom: 0; }
.pin {
  align-self: center; flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; font: inherit; color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.pin svg { width: 17px; height: 17px; flex: none; }
.pin:hover, .pin:active { background: var(--wash); color: var(--ink); }
.pin[aria-pressed=true] {
  color: var(--accent); border-color: var(--accent);
  background-color: color-mix(in srgb, var(--accent) 9%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.kpi .label { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 650; margin-top: 2px; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi .key { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.meter { height: 6px; border-radius: 3px; background: var(--grid); margin-top: 8px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 3px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 8px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; border: 0; background: transparent; color: var(--ink-2); padding: 6px 12px; cursor: pointer; transition: background-color .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button:active { background: var(--wash); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--wash); color: var(--ink); font-weight: 600; }
.seg.small button { padding: 4px 10px; font-size: 13px; }
.range { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.range-custom { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; color: var(--ink-2); }
.range-custom label { display: inline-flex; align-items: center; gap: 6px; }
.range-custom input { min-height: 30px; padding: 3px 6px; font-size: 13px; }
.chart-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.legend i.box { height: 10px; width: 10px; border-radius: 2px; }

.chart {
  position: relative; width: 100%; height: 340px; transition: opacity .15s;
  /* touch: vertical swipes scroll the page, sideways ones move along the days; no text selection / iOS callout */
  touch-action: pan-y; touch-action: pan-y pinch-zoom;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.chart.loading, .report.loading, .kpis.loading, .xl.loading { opacity: .5; }
.chart svg { display: block; width: 100%; height: 100%; }
/* browsers put a black ring on a clicked/tapped SVG: only the keyboard focus gets one */
.chart svg:focus { outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart text.endlabel { fill: var(--ink-2); font-size: 12px; font-weight: 600; }
.chart .xhair { stroke: var(--axis); stroke-width: 1; }
.chart .empty { fill: var(--muted); font-size: 13px; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
  padding: 8px 10px; font-size: 12px; min-width: 170px; max-width: calc(100vw - 16px);
}
.tooltip .t-date { color: var(--ink-2); margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; }
.tooltip .t-row i { width: 12px; height: 2px; border-radius: 1px; display: inline-block; }
.tooltip .t-row b { font-size: 13px; min-width: 42px; }
.tooltip .t-row span { color: var(--ink-2); }
.tooltip .t-total { border-top: 1px solid var(--grid); margin-top: 4px; padding-top: 4px; }
.tooltip .t-total i { background: transparent; }

details.datatable { margin-top: 8px; }
details.datatable summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
details.datatable .scroll { max-height: 320px; margin-top: 8px; }
details.datatable table { border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
details.datatable th, details.datatable td { padding: 3px 10px; border-bottom: 1px solid var(--grid); text-align: right; }
details.datatable th:first-child, details.datatable td:first-child { text-align: left; }

/* "Andamento ore" tab */
.filters[hidden] { display: none; }
.head-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.inline-field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.inline-field input { min-height: 30px; padding: 3px 6px; font-size: 13px; }
.step {
  font: inherit; font-size: 18px; line-height: 1; width: 30px; height: 30px; padding: 0 0 2px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.step:hover:not(:disabled) { background: var(--wash); color: var(--ink); }
.step:disabled { opacity: .4; cursor: default; }
.seg button:disabled { opacity: .45; cursor: default; }
.chart-note { margin: 0 0 6px; font-size: 13px; color: var(--ink-2); }
.chart-note b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart.short { height: 220px; }
.chart .future { fill: var(--wash); }
/* horizontal ranking ("Filiali più rapide") */
.chart text.rowlab { fill: var(--ink-2); font-size: 11.5px; }
.chart text.rowval { fill: var(--ink-2); font-size: 11.5px; font-weight: 600; }
.chart text.rowval.na { fill: var(--muted); font-weight: 400; }
/* value inside its bar (long bars, where there is no room at the end): the page colour contrasts with it */
.chart text.rowval.in { fill: var(--page); }
.chart .rowhl { fill: var(--wash); }
.chart .refmark { stroke: var(--ink-2); stroke-width: 2; stroke-dasharray: 2 2; stroke-linecap: round; }
.chart .target { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .marker { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 4 3; }
.chart text.mlabel { fill: var(--ink-2); font-size: 11px; font-weight: 600; }
.legend i.dash { background: none !important; border-top: 2px dashed; height: 0; }
.kpi .sub .up { color: var(--s-tot); font-weight: 600; }
.kpi .sub .down { color: var(--danger); font-weight: 600; }
.kpi.is-ok .value { color: var(--s-tot); }
.kpi.is-warn .value { color: var(--warn); }
.kpi.is-bad .value { color: var(--danger); }
.tooltip .t-row i.dash { background: none !important; border-top: 2px dashed; height: 0; }
.tooltip .t-muted { color: var(--muted); }

/* goal verdict: coloured bar on the left = status */
.verdict {
  border: 1px solid var(--border); border-left: 4px solid var(--axis); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 10px; background: var(--wash); font-size: 13.5px;
}
.verdict.is-ok { border-left-color: var(--s-tot); }
.verdict.is-warn { border-left-color: var(--warn); }
.verdict.is-bad { border-left-color: var(--danger); }
.verdict strong { display: block; font-size: 15px; margin-bottom: 2px; }
.verdict.is-ok strong { color: var(--s-tot); }
.verdict.is-warn strong { color: var(--warn); }
.verdict.is-bad strong { color: var(--danger); }
.verdict p { margin: 2px 0; }
.verdict ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 2px; }
.verdict li { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.verdict li i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; align-self: center; }
.verdict .fine { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* status chips: how many filiali per state, and a filter for the table below */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12.5px; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.chip:hover { background: var(--wash); color: var(--ink); }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--axis); }
.chip.is-done i, .chip.is-ok i { background: var(--s-tot); }
.chip.is-warn i { background: var(--warn); }
.chip.is-bad i { background: var(--danger); }
.chip.on {
  color: var(--ink); font-weight: 600; border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
/* sortable headings of the projection table */
table.stats th .th-sort {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer;
  display: inline-flex; align-items: baseline; gap: 4px;
}
table.stats th .th-sort:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
table.stats th .th-sort .arrow { font-size: 9px; color: var(--accent); }
table.stats thead th[aria-sort="ascending"], table.stats thead th[aria-sort="descending"] { color: var(--ink); }

/* per-filiale projection table */
table.stats { border-collapse: collapse; width: 100%; min-width: 880px; font-size: 13px; font-variant-numeric: tabular-nums; }
table.stats th, table.stats td { padding: 6px 8px; border-bottom: 1px solid var(--grid); text-align: right; white-space: nowrap; }
table.stats thead th { font-size: 12px; font-weight: 600; color: var(--ink-2); vertical-align: bottom; white-space: normal; }
table.stats .txt { text-align: left; }
table.stats tbody th { font-weight: 400; white-space: normal; min-width: 160px; }
table.stats tfoot th, table.stats tfoot td { font-weight: 700; border-top: 1px solid var(--axis); border-bottom: 0; }
table.stats .bar { display: inline-flex; align-items: center; gap: 8px; }
table.stats .bar .meter { width: 70px; margin: 0; }
.status { display: inline-flex; align-items: center; gap: 6px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--axis); }
.status.is-ok::before, .status.is-done::before { background: var(--s-tot); }
.status.is-warn::before { background: var(--warn); }
.status.is-bad::before { background: var(--danger); }

/* report: totals next to "Esporta Excel" */
.report-head { align-items: center; margin-bottom: 12px; }
.summary { display: flex; flex-wrap: wrap; row-gap: 8px; margin: 0; }
.summary > div { padding: 0 22px; border-left: 1px solid var(--border); }
.summary > div:first-child { padding-left: 0; border-left: 0; }
.summary dt { font-size: 12px; color: var(--ink-2); }
.summary dd { margin: 1px 0 0; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.summary dd small { font-size: 13px; font-weight: 400; color: var(--muted); }

/* report table */
.scroll { overflow: auto; -webkit-overflow-scrolling: touch; }
table.report { border-collapse: collapse; width: 100%; min-width: 1180px; font-size: 13px; color: var(--t-ink); }
table.report th, table.report td { border: 1px solid var(--axis); padding: 5px 7px; }
table.report thead th { font-size: 11.5px; font-weight: 700; text-align: center; vertical-align: middle; line-height: 1.25; }
table.report td { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.report td.txt { text-align: left; white-space: normal; }
table.report tbody th { text-align: left; font-weight: 400; white-space: normal; min-width: 190px; }
table.report td.dir { white-space: nowrap; }
table.report tr.total th { font-weight: 700; }
table.report .h-gray { background: var(--t-head); }
table.report .h-tot { background: var(--t-tot-h); }
table.report .h-ba { background: var(--t-ba-h); }
table.report .h-ia { background: var(--t-ia-h); }
table.report th.h-course { font-size: 12.5px; letter-spacing: .01em; }
table.report .c-gray { background: var(--t-row); }
table.report .c-tot { background: var(--t-tot); }
table.report .c-ba { background: var(--t-ba); }
table.report .c-ia { background: var(--t-ia); }
table.report tr.alt .c-gray { background: var(--t-row-alt); }
table.report tr.alt .c-tot { background: var(--t-tot-alt); }
table.report tr.alt .c-ba { background: var(--t-ba-alt); }
table.report tr.alt .c-ia { background: var(--t-ia-alt); }
table.report tr.total td { font-weight: 700; }
table.report tr.total td.c-tot { background: var(--t-tot-h); }
table.report tr.total td.c-ba { background: var(--t-ba-h); }
table.report tr.total td.c-ia { background: var(--t-ia-h); }
table.report .title { background: var(--t-head); font-size: 15px; padding: 10px; }

/* ---------------- "Monitoraggio per dipendente" ---------------- */
.jump { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.jump a {
  font-size: 12.5px; color: var(--ink-2); text-decoration: none; padding: 3px 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
}
.jump a:hover { background: var(--wash); color: var(--ink); }
.alert.soft {
  margin: 12px 0 0; font-size: 13px;
  background: color-mix(in srgb, var(--warn) 9%, transparent); border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}
h3 { font-size: 14.5px; margin: 0; font-weight: 650; }
.search input { width: min(380px, 100%); }
.search { flex: 0 1 380px; }

/* Excel-like tables (colours of the original file) */
table.xl { border-collapse: separate; border-spacing: 0; font-size: 13px; color: var(--t-ink); font-variant-numeric: tabular-nums; }
table.xl th, table.xl td { padding: 4px 8px; text-align: right; white-space: nowrap; }
table.xl .txt { text-align: left; }
table.xl .c { text-align: center; }
table.xl thead th { font-weight: 700; vertical-align: bottom; }
table.xl th .th-sort {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit;
  display: inline-flex; align-items: baseline; gap: 4px;
}
table.xl th .th-sort:hover { text-decoration: underline; text-underline-offset: 3px; }
table.xl th .th-sort .arrow { font-size: 9px; }

/* Elenco: green header, thin lines; the header and the Nome column stay in view while scrolling */
.e-scroll { max-height: min(70vh, 640px); border: 1px solid var(--x-line); border-radius: 4px; }
table.xl-list { width: max-content; min-width: 100%; }
table.xl-list th, table.xl-list td { border-right: 1px solid var(--x-line); border-bottom: 1px solid var(--x-line); background: var(--surface); }
table.xl-list thead th { position: sticky; top: 0; z-index: 2; background: var(--x-list); color: var(--x-list-ink); text-align: left; }
table.xl-list thead th.num { text-align: right; }
table.xl-list thead th.c { text-align: center; }
table.xl-list .col-name { position: sticky; left: 0; z-index: 1; min-width: 210px; }
table.xl-list thead .col-name { z-index: 3; }
table.xl-list td.wrap { white-space: normal; min-width: 220px; max-width: 360px; }
table.xl-list tbody tr:hover > * { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
table.xl-list td.yes { font-weight: 650; }
table.xl-list td.muted { color: var(--muted); }
table.xl-list .empty-row td { text-align: left; color: var(--muted); padding: 14px 10px; }
.st { display: inline-flex; align-items: center; gap: 6px; }
.st::before { content: ""; flex: none; width: 9px; height: 9px; border-radius: 2px; background: var(--st-c, var(--st-0)); }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.pager-nav { display: inline-flex; align-items: center; gap: 8px; }
.pager select { min-height: 30px; padding: 3px 6px; font-size: 13px; }
.pager .inline-field { margin-left: auto; }

/* Riepilogo: chart on the left, its table on the right */
.e-block {
  display: grid; grid-template-columns: minmax(260px, 380px) minmax(0, 1fr); gap: 18px 28px; align-items: start;
  padding: 16px 0; border-top: 1px solid var(--border);
}
.card-head + .e-block { border-top: 0; padding-top: 4px; }
.e-fig { margin: 0; display: grid; gap: 8px; align-content: start; }
.e-fig figcaption { font-size: 15px; font-weight: 650; text-align: center; }
.e-fig .legend { justify-content: center; gap: 6px 14px; font-size: 12.5px; }
.chart.pie { height: auto; aspect-ratio: 1 / 1; max-width: 360px; width: 100%; justify-self: center; }
.chart.pie path { transition: opacity .12s; }
.chart.pie .dim { opacity: .4; }
.chart text.pielab { font-size: 12.5px; font-weight: 650; }
.e-table { min-width: 0; }
table.xl-pivot { min-width: 620px; width: 100%; }
table.xl-pivot thead tr.xl-title th { background: var(--x-navy); color: var(--x-navy-ink); text-align: center; font-size: 13.5px; padding: 6px 8px; }
table.xl-pivot thead tr.xl-head th { background: var(--x-head); border-bottom: 1px solid var(--x-head-line); text-align: left; font-size: 13px; }
table.xl-pivot thead tr.xl-head th.num { text-align: right; }
table.xl-pivot tbody th { font-weight: 400; text-align: left; }
table.xl-pivot tbody tr:nth-child(even) > * { background: color-mix(in srgb, var(--x-head) 22%, transparent); }
table.xl-pivot tfoot th, table.xl-pivot tfoot td { background: var(--x-head); border-top: 1px solid var(--x-head-line); font-weight: 700; text-align: right; }
table.xl-pivot tfoot th { text-align: left; }
table.xl-pivot tfoot td.grand { color: var(--red); }
table.xl-pivot .key { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: -0.5px; }
.xl-note { margin: 6px 0 0; text-align: right; font-size: 12.5px; color: var(--red); }
.xl-note:empty { display: none; }
/* Nuovi accessi: every cell framed, counts centred, as in the original */
table.xl-acc { min-width: 0; width: auto; }
table.xl-acc th, table.xl-acc td { border: 1px solid var(--x-line); border-width: 0 1px 1px 0; }
table.xl-acc tr > :first-child { border-left-width: 1px; min-width: 240px; }
table.xl-acc thead tr.xl-title th { border-top-width: 1px; }
table.xl-acc thead tr.xl-head th { text-align: center; }
table.xl-acc td, table.xl-acc tfoot td { text-align: center; min-width: 150px; }
.e-acc { gap: 10px; }
.e-acc .muted { margin: 0; }
.e-acc .linkbtn { justify-self: start; padding: 0; font-size: 13px; }
.e-acc .linkbtn:disabled { color: var(--muted); cursor: default; }
.e-big { font-size: 30px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.15; }
.e-big small { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); }

/* Cessati: green table with banded rows */
table.xl-cess { width: max-content; min-width: 100%; }
table.xl-cess thead th { position: sticky; top: 0; z-index: 2; background: var(--x-cess); color: var(--x-cess-ink); text-align: left; }
table.xl-cess th, table.xl-cess td { text-align: left; border-bottom: 1px solid var(--grid); background: var(--surface); }
table.xl-cess tbody tr:nth-child(odd) > * { background: var(--x-cess-alt); }
table.xl-cess td.wrap { white-space: normal; min-width: 220px; max-width: 380px; }

/* login page (src/login.php) */
body.auth {
  min-height: 100vh; min-height: 100dvh; padding: 40px 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background-color: var(--page);
  background-image: radial-gradient(60rem 30rem at 50% -6rem, color-mix(in srgb, var(--brand) 16%, transparent), transparent 72%);
  background-repeat: no-repeat;
}
body.auth::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 13%, transparent) 1px, transparent 1.6px);
  background-size: 20px 20px;
  -webkit-mask-image: radial-gradient(ellipse 62% 58% at 50% 40%, #000, transparent 78%);
  mask-image: radial-gradient(ellipse 62% 58% at 50% 40%, #000, transparent 78%);
}
.auth [hidden] { display: none !important; }
.auth-card {
  position: relative; width: 100%; max-width: 404px; padding: 36px 32px 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 22px 48px -18px rgba(16, 24, 40, .28);
}
.auth-card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}
.auth-head { text-align: center; margin-bottom: 26px; text-wrap: balance; }
.auth-head .logo-chip img { height: 44px; }
.auth-head h1 { font-size: 21px; letter-spacing: -.01em; margin-top: 22px; }
.auth-head p { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); }
.auth-text { margin: 0; text-align: center; color: var(--ink-2); }

.auth-msg {
  display: flex; align-items: flex-start; gap: 10px; margin: 0 0 20px; padding: 10px 12px;
  border: 1px solid; border-radius: 10px; font-size: 13.5px; line-height: 1.4;
}
.auth-msg svg { flex: none; width: 18px; height: 18px; }
.auth-msg.is-error { background: color-mix(in srgb, var(--danger) 8%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.auth-msg.is-error svg { color: var(--danger); }
.auth-msg.is-info { background: color-mix(in srgb, var(--brand) 7%, var(--surface)); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.auth-msg.is-info svg { color: var(--brand); }

.field + .field { margin-top: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.control { position: relative; }
.control > svg {
  position: absolute; left: 13px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%);
  color: var(--muted); pointer-events: none; transition: color .15s;
}
.control:focus-within > svg { color: var(--brand); }
.control input {
  display: block; width: 100%; height: 46px; padding: 0 14px 0 42px; font-size: 16px;
  border: 1px solid color-mix(in srgb, var(--ink) 16%, transparent); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.control input#password { padding-right: 48px; }
.control input:hover { border-color: color-mix(in srgb, var(--ink) 30%, transparent); }
.control input:focus, .control input:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.reveal {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.reveal:hover { background: var(--wash); color: var(--ink); }
.reveal svg { width: 18px; height: 18px; }
.reveal[aria-pressed=true] .i-eye, .reveal[aria-pressed=false] .i-eye-off { display: none; }
.caps { margin: 0; font-size: 12.5px; color: var(--warn); }
.caps span { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; }
.caps svg { width: 15px; height: 15px; }
.remember { display: flex; align-items: center; gap: 10px; margin-top: 18px; font-size: 14px; cursor: pointer; }
.remember input { flex: none; width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; accent-color: var(--brand); cursor: pointer; }
.remember-hint { margin: 3px 0 0 28px; font-size: 12.5px; line-height: 1.4; color: var(--muted); }

.auth-submit {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 46px; margin-top: 24px; border: 0; border-radius: 10px;
  background: var(--brand); color: #fff; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .16), inset 0 1px 0 rgba(255, 255, 255, .14);
  transition: background-color .15s;
}
.auth-submit:hover { background: var(--brand-hover); }
.auth-submit:active { transform: translateY(1px); }
.auth-submit:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.auth-submit[aria-busy=true] { cursor: progress; }
.auth-submit .spinner {
  display: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: spin .7s linear infinite;
}
.auth-submit[aria-busy=true] .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-foot {
  display: flex; align-items: center; justify-content: center; gap: 7px; flex-wrap: wrap;
  margin: 28px -32px 0; padding: 14px 20px; border-top: 1px solid var(--border);
  background: var(--wash); font-size: 12.5px; color: var(--muted); text-align: center;
}
.auth-foot svg { flex: none; width: 15px; height: 15px; }
.auth-foot code { font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink-2); }
@media (max-width: 480px) {
  body.auth { padding: 24px 16px; }
  .auth-card { padding: 30px 20px 0; }
  .auth-foot { margin: 24px -20px 0; }
}

@media (max-width: 640px) {
  #app { padding: 12px 16px; }
  /* header: logo and the user's "Esci" on one row, the title below */
  .topbar { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px 12px; }
  .brand { display: contents; }
  .logo-chip { grid-area: 1 / 1; justify-self: start; }
  .brand-text { grid-area: 2 / 1 / 3 / -1; padding-left: 0; border-left: 0; }
  .topbar-actions { grid-area: 1 / 2; justify-self: end; flex-wrap: nowrap; min-width: 0; }
  .topbar-actions form { flex: none; }
  .user-chip { min-width: 0; }
  .user-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .logo-chip img { height: 30px; }
  /* five tabs do not fit side by side: the row scrolls sideways (the selected one is brought into view) */
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs-bar .tabs { min-width: 0; }
  .tabs [role=tab] { flex: 0 0 auto; max-width: 8.6em; white-space: normal; padding: 8px 8px; font-size: 13px; line-height: 1.25; }
  .ms-btn { min-width: 0; width: 100%; max-width: none; }
  .filters .reset-filters { margin-left: 0; width: 100%; justify-content: center; }
  .ms, .filters > label:not(.check) { width: 100%; }
  .filters select { width: 100%; }
  .chart { height: 280px; }
  .chart.short { height: 200px; }
  .kpi .value { font-size: 22px; }
  .head-tools { width: 100%; }
  table.stats tbody th { min-width: 128px; }
  /* per-filiale table: the Filiale column stays in view while the numbers scroll sideways */
  table.stats tr > :first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
  /* report: totals in three columns; the title row is the page title again; the Filiale column stays
     in view while the numbers scroll sideways (each cell draws its own lines, right + bottom, so they move
     with it: collapsed borders stay behind in Safari) */
  .summary { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .summary > div { padding: 0 10px; }
  .summary dd { font-size: 17px; }
  .summary dd small { display: block; font-size: 12px; }
  .report-head .btn { width: 100%; justify-content: center; }
  table.report .title-row { display: none; }
  table.report { border-collapse: separate; border-spacing: 0; }
  table.report th, table.report td { border-width: 0 1px 1px 0; }
  table.report thead tr:nth-child(2) > * { border-top-width: 1px; }
  table.report thead tr:nth-child(2) > :first-child, table.report tbody tr > :first-child { border-left-width: 1px; }
  table.report .col-filiale { position: sticky; left: 0; z-index: 1; }
  table.report tbody th.col-filiale { min-width: 128px; }
  table.report tr.total th.col-filiale { background: var(--surface); }
  /* per dipendente: chart above its table; Nome column narrower */
  .e-block { grid-template-columns: minmax(0, 1fr); }
  .chart.pie { max-width: 300px; }
  .search, .search input { flex: 1 1 100%; width: 100%; }
  table.xl-list .col-name { min-width: 150px; white-space: normal; }
  .pager .inline-field { margin-left: 0; }
  table.xl-acc tr > :first-child { min-width: 170px; }
  table.xl-pivot thead tr.xl-title th { text-align: left; }
  table.xl-acc td, table.xl-acc tfoot td { min-width: 90px; }
}
/* touch screens: iPhones zoom into any field whose text is smaller than 16px */
@media (pointer: coarse) {
  input:not([type=checkbox]), select { font-size: 16px; }
}
@media print {
  .filters, .topbar-actions, .refresh, .tabs-bar, .chart-tools .seg, .head-tools, .step, #btn-xlsx, .chips, details.datatable,
  #btn-xlsx-emp, .jump, .search, .pager, #a-reset { display: none !important; }
  .e-scroll { max-height: none; }
  .sticky-head { padding-bottom: 0 !important; }
  body { background: #fff; }
}
