/* Gestionale — tema "regia" (stessa famiglia grafica della suite sala consiliare).
   Scuro di default, chiaro da pulsante o preferenza di sistema. Font di sistema Apple (SF) dove c'è. */
:root {
  --bg: #0f1217; --panel: #171b22; --panel2: #1e232c; --line: #2a303b; --line2: #363d4a;
  --fg: #e6e8ec; --muted: #9aa3b2; --dim: #6b7383;
  --accent: #4f8cff; --accent2: #7b5cff; --accent-fg: #fff; --accent-soft: rgba(79,140,255,.14);
  --ok: #2fbf71; --warn: #f5a524; --err: #ff5d5d; --info: #4f8cff;
  --radius: 12px; --radius-sm: 9px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI Variable Text", "Segoe UI",
          Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --fs: 15.5px; --fs-sm: 13.5px; --fs-xs: 12.5px;
  /* 0.111: menu laterale — gruppo aperto (sfondo, bordo, linea delle sottovoci) e voce selezionata */
  --nav-group-bg: color-mix(in srgb, var(--fg) 4.5%, transparent); --nav-group-border: color-mix(in srgb, var(--fg) 7%, transparent);
  --nav-group-line: color-mix(in srgb, var(--accent) 40%, transparent);
  --nav-active-bg: var(--accent-soft); --nav-active-fg: var(--fg);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f4f6; --panel: #ffffff; --panel2: #f6f7f9; --line: #dde1e7; --line2: #cdd3db;
    --fg: #14181f; --muted: #4b5565; --dim: #7b8494; --accent: #2f6fe0; --accent-soft: rgba(47,111,224,.10);
    --ok: #1f9d5a; --warn: #c27c0e; --err: #d93f3f; --info: #2f6fe0; color-scheme: light;
    --nav-group-bg: color-mix(in srgb, var(--accent) 4%, var(--bg)); --nav-group-border: color-mix(in srgb, var(--fg) 8%, transparent);
  }
}
:root[data-theme="light"] {
  --bg: #f3f4f6; --panel: #ffffff; --panel2: #f6f7f9; --line: #dde1e7; --line2: #cdd3db;
  --fg: #14181f; --muted: #4b5565; --dim: #7b8494; --accent: #2f6fe0; --accent-soft: rgba(47,111,224,.10);
  --ok: #1f9d5a; --warn: #c27c0e; --err: #d93f3f; --info: #2f6fe0; color-scheme: light;
  --nav-group-bg: color-mix(in srgb, var(--accent) 4%, var(--bg)); --nav-group-border: color-mix(in srgb, var(--fg) 8%, transparent);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--fg); font: var(--fs)/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
.ico { flex: none; vertical-align: middle; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.012em; }
h1 { font-size: 25px; } h2 { font-size: 19px; } h3 { font-size: 16.5px; }
small, .muted { color: var(--muted); }
.dim { color: var(--dim); }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
code { background: var(--panel2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font: 13.5px var(--mono); word-break: break-all; }
button, input, select, textarea { font-family: inherit; }

/* ---------- struttura */
.shell { display: flex; min-height: 100vh; }
.side { width: 264px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 16px 12px; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; font-weight: 700; font-size: 17px; min-width: 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand::before { content: ""; width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: conic-gradient(from 210deg, var(--accent), var(--accent2), var(--accent)); }
.brand:has(img)::before { display: none; }
/* 0.109: senza logo, coi temi che lo chiedono (theme.json «brand_mark»): quadrato con l'iniziale */
.brand-mark { width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-fg); font-weight: 800; font-size: 16px; }
.brand:has(.brand-mark)::before { display: none; }
.brand img { max-height: 34px; max-width: 150px; flex: none; }
.brand img.icon { height: 32px; width: 32px; max-width: none; object-fit: contain; border-radius: 7px; }   /* 0.86: icona quadrata */
.brand img.full:not(.alone) { max-width: 120px; max-height: 30px; }                  /* con il testo accanto: resta spazio per il nome */
.brand img.full.alone { max-height: 40px; max-width: 200px; }                    /* logo completo senza testo accanto: più spazio */
.brand img.onwhite { background: #fff; padding: 3px 6px; border-radius: 7px; }   /* loghi con scritta scura, nel tema scuro */
.brand img.icon.onwhite { padding: 3px; }
.side-label { padding: 14px 22px 6px; color: var(--dim); font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; font-weight: 600; }
.nav { flex: 1; overflow-y: auto; padding: 0 10px 12px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: var(--muted);
  text-decoration: none; font-weight: 550; cursor: pointer; list-style: none; user-select: none; transition: background .12s, color .12s; }
.nav-item:hover { background: var(--panel2); color: var(--fg); }
.nav-item.active { background: var(--accent-soft); color: var(--fg); }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item.active .ico { color: var(--accent); }
.nav-item.sub { padding-left: 22px; font-weight: 500; font-size: 14.5px; }
.nav-item span { flex: 1; }
.nav summary::-webkit-details-marker { display: none; }
.nav details[open] > summary { color: var(--fg); }
/* 0.111: il gruppo aperto (titolo e sottovoci) si distingue dagli altri gruppi e dalla voce selezionata */
.nav details { border-radius: 10px; margin: 2px 0; }
.nav details[open] { background: var(--nav-group-bg); box-shadow: inset 0 0 0 1px var(--nav-group-border); padding-bottom: 4px; }
.nav details[open] > summary { font-weight: 650; }
.nav details[open] > .nav-item.sub { padding-left: 26px; }          /* rientro fisso: la linea non tocca le icone */
.nav details[open] > .nav-item.sub::after { content: ""; position: absolute; left: 11px; top: 2px; bottom: 2px; width: 2px;
  border-radius: 2px; background: var(--nav-group-line); }
.nav details[open] > .nav-item.sub.active::after { background: var(--accent); }
.nav .nav-item.active { background: var(--nav-active-bg); color: var(--nav-active-fg); font-weight: 650; }
.nav details[open] > summary .chev { transform: rotate(180deg); }
.chev { transition: transform .15s; color: var(--dim); }
/* utente e uscita in fondo al menu (al posto della barra piena) */
.side-foot { margin: 0; padding: 10px 12px 14px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.side-user { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 9px;
  text-decoration: none; color: var(--fg); font-size: 14px; font-weight: 550; }
.side-user:hover { background: var(--panel2); }
.side-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout { flex: none; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  border: 1px solid var(--line2); background: transparent; color: var(--muted); border-radius: 9px; }
.logout:hover { color: var(--err); border-color: color-mix(in srgb, var(--err) 50%, var(--line2)); background: color-mix(in srgb, var(--err) 10%, transparent); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 10; height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 24px;
  background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); }
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 550; white-space: nowrap; overflow: hidden; }
.crumbs > * { overflow: hidden; text-overflow: ellipsis; }
.crumbs a { text-decoration: none; } .crumbs a:hover { color: var(--fg); }
.crumbs .sep { color: var(--dim); flex: none; }
.clock-pill { padding: 5px 11px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); font-size: 13px;
  color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.content { padding: 28px clamp(16px, 4vw, 52px); max-width: 1520px; width: 100%; margin: 0 auto; flex: 1; }
.foot { padding: 10px 24px; color: var(--dim); font-size: 12px; text-align: right; }
.foot a { color: inherit; text-decoration: none; } .foot a:hover { color: var(--fg); text-decoration: underline; }   /* 0.117 */
.only-mobile { display: none !important; }
.scrim { display: none; }

@media (max-width: 900px) {
  :root { --fs: 16px; }
  .only-mobile { display: inline-flex !important; }
  .side { position: fixed; left: 0; top: 0; z-index: 30; width: min(300px, 86vw); transform: translateX(-100%); transition: transform .2s;
    box-shadow: 0 0 40px rgba(0,0,0,.4); }
  body.nav-open { overflow: hidden; }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(5,8,12,.55); z-index: 20; }
  .top { padding: 0 12px; height: 54px; }
  .clock-pill { display: none; }
  .content { padding: 18px 14px 40px; }
  h1 { font-size: 22px; }
  .nav-item { padding: 11px 12px; }
}

/* ---------- componenti */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; min-width: 0; }
.card + .card { margin-top: 20px; }
.grid > .card + .card { margin-top: 0; }
.card > h2, .card-head h2, .card.f > h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650;
  display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid { display: grid; gap: 20px; }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(290px, 1fr); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g-main, .g3 { grid-template-columns: minmax(0, 1fr); } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .g2, .g4 { grid-template-columns: minmax(0, 1fr); }
  .li { flex-wrap: wrap; } .li .li-side { text-align: left; flex-basis: 100%; }
  .card { padding: 16px 15px; border-radius: 11px; }
  .kv { flex-direction: column; gap: 2px; } .kv > span { min-width: 0; font-size: var(--fs-sm); }
  .page-head { gap: 8px; } .page-head h1 { flex: 0 0 100% !important; order: -1; }
  .valbar > span:first-child { flex-basis: 100%; }
}
.stack > * + * { margin-top: var(--gap, 20px); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { flex: 1; min-width: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--accent); background: var(--accent);
  color: var(--accent-fg); font: 600 15px var(--font); padding: 9px 16px; border-radius: 9px; cursor: pointer; text-decoration: none;
  white-space: nowrap; min-height: 40px; transition: filter .12s, background .12s; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: var(--panel2); color: var(--fg); border-color: var(--line2); }
.btn.ghost:hover { border-color: var(--dim); filter: none; }
.btn.danger { background: color-mix(in srgb, var(--err) 10%, transparent); color: var(--err); border-color: color-mix(in srgb, var(--err) 50%, var(--line2)); }
.btn.danger:hover { background: color-mix(in srgb, var(--err) 18%, transparent); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.sm { padding: 5px 11px; font-size: 13.5px; min-height: 32px; border-radius: 8px; }
.btn.lg { padding: 13px 24px; font-size: 16.5px; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid var(--line2);
  border-radius: 9px; background: var(--panel2); color: var(--fg); cursor: pointer; text-decoration: none; flex: none; }
.iconbtn:hover { border-color: var(--dim); }

.flash { padding: 11px 15px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.flash.err { background: color-mix(in srgb, var(--err) 12%, transparent); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
.flash.info { background: color-mix(in srgb, var(--info) 11%, transparent); border-color: color-mix(in srgb, var(--info) 38%, transparent); }
.flash a { color: var(--accent); }

/* form */
form.f { display: grid; gap: 16px; }
.fgrid { display: grid; gap: 14px 18px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld.wide { grid-column: 1 / -1; }
.fld > span { font-size: var(--fs-sm); color: var(--muted); font-weight: 550; }
.fld small { color: var(--dim); font-size: var(--fs-xs); }
.req { color: var(--err); font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], input[type=month],
input[type=url], input[type=search], input[type=datetime-local], input[type=tel], select, textarea {
  width: 100%; background: var(--panel2); color: var(--fg); border: 1px solid var(--line2); border-radius: 9px;
  padding: 9px 12px; font: 15px var(--font); min-height: 40px; }
@media (max-width: 900px) {   /* 16px: iOS non fa zoom entrando nel campo */
  input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], input[type=month],
  input[type=url], input[type=search], input[type=datetime-local], input[type=tel], select, textarea { font-size: 16px; min-height: 44px; }
  .btn { min-height: 44px; } .btn.sm { min-height: 36px; }
}
select[multiple] { min-height: 0; }
input[type=file] { color: var(--muted); font-size: 14px; max-width: 100%; }
input[type=file]::file-selector-button { font: 600 13.5px var(--font); color: var(--fg); background: var(--panel2); border: 1px solid var(--line2);
  border-radius: 8px; padding: 6px 11px; margin-right: 10px; cursor: pointer; }
input[type=color] { width: 46px; height: 40px; padding: 2px; background: var(--panel2); border: 1px solid var(--line2); border-radius: 9px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; }
input[type=checkbox] { accent-color: var(--accent); }
.chk { display: grid; grid-template-columns: 18px minmax(0, 1fr); column-gap: 10px; align-items: start; cursor: pointer; padding: 4px 0; }
.chk input { margin: 3px 0 0; width: 18px; height: 18px; }
.chk small { grid-column: 2; color: var(--dim); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px 18px; margin: 0; }
legend { padding: 0 6px; color: var(--muted); font-weight: 650; font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters .fld { min-width: 160px; }
@media (max-width: 700px) { .filters .fld { min-width: 0; flex: 1 1 140px; } }

/* tabelle */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--panel2); white-space: nowrap; font-weight: 650; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--panel2) 70%, transparent); }
.tbl tbody tr[data-href] { cursor: pointer; }
.tbl a.rowlink { text-decoration: none; font-weight: 600; }
.tbl a.rowlink:hover { color: var(--accent); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tfoot td { background: var(--panel2); }
.empty { padding: 34px; text-align: center; color: var(--muted); }
/* su telefono le tabelle con etichette (data-l) diventano schede impilate */
@media (max-width: 700px) {
  .tbl-wrap:has(td[data-l]) { border: 0; background: none; overflow: visible; }
  .tbl:has(td[data-l]) thead { display: none; }
  .tbl:has(td[data-l]) tr { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 8px 12px; margin-bottom: 10px; }
  .tbl:has(td[data-l]) td { display: flex; gap: 12px; justify-content: space-between; border: 0; padding: 5px 0; text-align: right; }
  .tbl:has(td[data-l]) td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: var(--fs-sm); text-align: left; flex: none; }
  .tbl:has(td[data-l]) td.num { white-space: normal; }
  .tbl:has(td[data-l]) td:empty { display: none; }
  .tbl:has(td[data-l]) tfoot tr { background: var(--panel2); }
}

.badge { --b: var(--dim); display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: color-mix(in srgb, var(--b) 16%, transparent); color: color-mix(in srgb, var(--b) 70%, var(--fg));
  border: 1px solid color-mix(in srgb, var(--b) 40%, transparent); white-space: nowrap; }
.badge.ok { --b: var(--ok); } .badge.err { --b: var(--err); } .badge.warn { --b: var(--warn); } .badge.info { --b: var(--info); } .badge.acc { --b: var(--accent); }
.tag { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; padding: 0 5px; border-radius: 4px;
  border: 1px solid currentColor; opacity: .85; vertical-align: 1px; }
.tag.mod { color: var(--warn); opacity: 1; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist > li { position: relative; padding: 0 0 12px 18px; border-left: 2px solid var(--line); margin-left: 5px; }
.hist > li:last-child { border-left-color: transparent; }
.hist > li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--b, var(--accent)); }
.hist .diff { font-size: 13px; margin-top: 4px; }
.hist .diff del { color: var(--err); text-decoration: line-through; opacity: .85; }
.hist .diff ins { color: var(--ok); text-decoration: none; font-weight: 600; }

.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; flex: none;
  background: conic-gradient(from 210deg, var(--accent), var(--accent2), var(--accent)); color: #fff; font-weight: 700; }

.kv { display: flex; gap: 10px; padding: 6px 0; align-items: baseline; }
.kv > span { color: var(--muted); min-width: 140px; display: inline-flex; gap: 8px; align-items: center; }
.kv > b { font-weight: 550; word-break: break-word; }
.kvs { margin-top: 6px; }

/* righe "scheda" */
.list { display: grid; gap: 10px; }
.li { display: flex; gap: 14px; align-items: center; padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel2); text-decoration: none; transition: border-color .12s; }
a.li:hover { border-color: var(--dim); }
.li .li-main { flex: 1; min-width: 0; }
.li .li-title { font-weight: 600; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .li-sub { color: var(--muted); font-size: var(--fs-sm); }
.li .li-side { text-align: right; color: var(--muted); font-size: var(--fs-sm); }
.li .li-side b { color: var(--fg); }

/* profilo */
.profile { display: flex; gap: 22px; align-items: flex-start; }
.profile .avatar { width: 96px; height: 96px; font-size: 34px; }
.profile-name { font-size: 21px; font-weight: 650; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.profile-name small { font-weight: 500; font-size: 15px; }
@media (max-width: 600px) { .profile { flex-direction: column; } }

/* timbratura e statistiche */
.punch { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 10px 0; }
.punch .clock { font-size: 44px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.stat { padding: 15px 17px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel2); }
.stat b { display: block; font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { color: var(--muted); font-size: var(--fs-sm); }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 16px; color: var(--muted); }
/* schede a pillola (come le sotto-schede della regia) */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 6px 14px; text-decoration: none; color: var(--muted); border: 1px solid var(--line2); border-radius: 999px;
  background: var(--panel); font-weight: 550; font-size: 14px; }
.tabs a.on { color: #fff; background: var(--accent); border-color: var(--accent); }
.tabs a:hover:not(.on) { color: var(--fg); border-color: var(--dim); }
.tabs a { display: inline-flex; align-items: center; gap: 6px; }
.tabs .tcount { font-size: 12px; font-weight: 600; padding: 0 6px; border-radius: 999px; background: var(--line2); color: var(--fg); }
.tabs a.on .tcount { background: rgba(255,255,255,.25); color: #fff; }
.tabs .tdot { width: 8px; height: 8px; border-radius: 50%; background: var(--err, #ff5d5d); }
[data-pane] + [data-pane] { margin-top: 20px; }
.js-tabs [data-pane][hidden] { display: none !important; }
.js-tabs [data-pane] + [data-pane] { margin-top: 0; }

/* accesso */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent),
              radial-gradient(700px 400px at 110% 110%, color-mix(in srgb, var(--accent2) 14%, transparent), transparent); }
.auth .card { width: min(420px, 100%); border-radius: 16px; padding: 28px; }
.auth h1 { margin-bottom: 4px; }
.ms-btn { width: 100%; justify-content: center; background: var(--panel2); color: var(--fg); border-color: var(--line2); padding: 11px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 12px; margin: 6px 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

.perm-mod { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 16px; background: var(--panel2); }
.perm-mod h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.perm-access { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 8px 10px; margin-bottom: 10px; border-radius: 8px;
  background: var(--accent-soft); }
.perm-access .chk.mod span { font-weight: 650; }
.perm-mod.off .perm-access ~ .perm-grid, .perm-mod.off .perm-access .chk:not(.mod) { opacity: .4; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 2px 18px; }
.mono { font-family: var(--mono); font-size: 13px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; }
.inline { display: inline; margin: 0; }
details.box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 14px; background: var(--panel2); }
details.box > summary { cursor: pointer; font-weight: 600; }
[hidden] { display: none !important; }
.list > *, .stack > *, .grid > * { min-width: 0; }
.bell { position: relative; }
.dotn { position: absolute; top: -5px; right: -6px; background: var(--err); color: #fff; font-size: 10.5px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; }
.notif { display: flex; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel2); }
.notif.unread { border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: var(--accent-soft); }
.notif .when { color: var(--dim); font-size: 12px; white-space: nowrap; }
.secret-ok { color: var(--ok); font-weight: 600; } .secret-no { color: var(--dim); }
.token-box { font-family: var(--mono); padding: 12px; border: 1px dashed var(--accent); border-radius: var(--radius-sm); word-break: break-all; background: var(--accent-soft); user-select: all; }
.att { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel2); }
.att a { text-decoration: none; font-weight: 550; } .att .muted { font-size: var(--fs-xs); }
.balance-neg { color: var(--err); font-weight: 700; }

/* planning settimanale */
.week { table-layout: fixed; min-width: 960px; }
.week td { vertical-align: top; height: 68px; padding: 6px; }
.week th:first-child, .week td:first-child { width: 150px; position: sticky; left: 0; background: var(--panel); z-index: 1; }
.week thead th:first-child { background: var(--panel2); }
.pl { display: block; border-left: 3px solid var(--b, var(--accent)); background: color-mix(in srgb, var(--b, var(--accent)) 15%, transparent);
  border-radius: 6px; padding: 4px 7px; margin-bottom: 4px; font-size: 13px; text-decoration: none; line-height: 1.3; min-width: 0; flex: 1; }
.pl b { display: block; font-weight: 600; overflow-wrap: break-word; hyphens: auto; } .pl:hover { filter: brightness(1.12); }
.pl .pl-desc { display: block; overflow-wrap: break-word; hyphens: auto; }
.pl .pl-time { display: block; opacity: .85; font-variant-numeric: tabular-nums; }
.pl.pending { border-left-style: dashed; outline: 1px dashed color-mix(in srgb, var(--b, var(--accent)) 60%, transparent); outline-offset: -1px; }
.pl-row { position: relative; }
.pl-row input { position: absolute; top: 5px; right: 5px; width: 17px; height: 17px; margin: 0; z-index: 1; }
.pl-row input + .pl { padding-right: 26px; }
.week td.off { background: color-mix(in srgb, var(--dim) 7%, transparent); }
.week .today { box-shadow: inset 0 0 0 2px var(--accent); }
.valbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px; border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--ok) 45%, var(--line)); background: color-mix(in srgb, var(--ok) 9%, var(--panel)); }
.selbar .selacts { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.selbar:not(.has-sel) .selacts { opacity: .55; }

.agenda { display: none; }
@media (max-width: 700px) {
  .week-wrap { display: none; }
  .agenda { display: grid; gap: 10px; }
  .agenda-day { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
  .agenda-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
  .agenda-day.off { background: color-mix(in srgb, var(--dim) 7%, var(--panel)); }
  .agenda-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
  .agenda .pl { font-size: 14.5px; padding: 7px 10px; }
  .agenda .pl-row input { width: 22px; height: 22px; top: 8px; right: 8px; }
  .agenda .pl-row input + .pl { padding-right: 38px; }
}

/* fascicolo */
.contract { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel2); }
.contract + .contract { margin-top: 10px; }
.contract.concluso { opacity: .72; }
.contract.in_corso { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }

@media print {
  .side, .top, .foot, .scrim, .form-actions, .valbar { display: none !important; }
  body { background: #fff; color: #000; } .card, .tbl-wrap { border-color: #ccc; background: #fff; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.tbl.rates input { min-width: 72px; width: 100%; text-align: right; padding: 6px 8px; min-height: 34px; }
.tbl.rates th, .tbl.rates td { padding: 8px 6px; }
.tbl.rates input[type=date] { min-width: 132px; text-align: left; }
.tbl.rates tr.newrow td { background: var(--accent-soft); }
.pl.leave { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--b) 16%, transparent) 0 8px,
  color-mix(in srgb, var(--b) 9%, transparent) 8px 16px); }
/* planning mensile */
.month-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.month { table-layout: fixed; min-width: 900px; }
.month td { vertical-align: top; height: 118px; padding: 5px; border-right: 1px solid var(--line); }
.month td:last-child { border-right: 0; }
.month td.out { opacity: .45; }
.month td.off { background: color-mix(in srgb, var(--dim) 7%, transparent); }
.month td.today { box-shadow: inset 0 0 0 2px var(--accent); }
.month .mday { display: flex; gap: 6px; align-items: baseline; margin-bottom: 4px; font-size: 13px; }
.month .mday > a:first-child { font-weight: 700; text-decoration: none; }
/* 0.70: nel mese, con più persone, il giorno è diviso per persona come le righe della settimana */
.mperson + .mperson { margin-top: 6px; padding-top: 5px; border-top: 1px dashed var(--line); }
.mperson-name { font-size: 11.5px; color: var(--muted); margin: 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mperson-name b { color: var(--fg); font-weight: 650; }
.month .mday .madd { margin-left: auto; text-decoration: none; font-size: 16px; line-height: 1; }
.month .pl { font-size: 12px; padding: 3px 6px; margin-bottom: 3px; }
.month .pl b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 700px) { .month-wrap { display: none; } }

/* 0.29 — riquadro trascina e rilascia per i campi file */
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; padding: 12px 14px; border: 2px dashed var(--line); border-radius: 10px; text-align: center;
  color: var(--muted); font-size: 13.5px; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone:focus-within { border-color: var(--accent); }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--fg); }
.dropzone.has { border-style: solid; }
.dropzone.err { border-color: var(--err); background: color-mix(in srgb, var(--err) 8%, transparent); }
.dropzone .dz-files { font-weight: 600; color: var(--fg); word-break: break-word; }
.dropzone.err .dz-files { color: var(--err); }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

/* 0.30 — intestazioni ordinabili */
.tbl th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.tbl th.th-sort::after { content: "↕"; margin-left: 4px; opacity: .3; font-size: 11px; }
.tbl th.th-sort[aria-sort="ascending"]::after { content: "▲"; opacity: .8; }
.tbl th.th-sort[aria-sort="descending"]::after { content: "▼"; opacity: .8; }
.tbl th.th-sort:hover, .tbl th.th-sort:focus-visible { color: var(--accent); }

/* 0.37 — scelta delle persone nel planning */
.people-pick { position: relative; }
.people-pick > summary { list-style: none; cursor: pointer; }
.people-pick > summary::-webkit-details-marker { display: none; }
.people-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 300px; max-height: 60vh; overflow: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.people-list { display: flex; flex-direction: column; gap: 2px; }

/* 0.60: tabella compatta (voci della nota spese) */
.tbl.compact th, .tbl.compact td { padding: 6px 9px; font-size: 13.5px; vertical-align: top; }
.tbl.compact tfoot td { border-top: 2px solid var(--line); }

/* 0.70 — elenchi con ricerca (select[data-search]); 0.107: tutte le tendine (stesso aspetto ovunque) */
.combo { position: relative; width: 100%; min-width: 0; }
.combo-input { width: 100%; padding-right: 34px !important; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b91a0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: right 11px center !important; background-size: 15px !important; }
.combo-pick .combo-input { cursor: pointer; caret-color: transparent; }
.combo.open .combo-input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b91a0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m18 15-6-6-6 6'/%3E%3C/svg%3E") !important; }
.combo.dis .combo-input { opacity: .55; cursor: not-allowed; }
.combo-native { position: absolute !important; left: 0; bottom: 0; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; opacity: 0; pointer-events: none; }
.combo-list { position: fixed; z-index: 200; max-height: 300px; overflow: auto; margin: 0; padding: 4px;
  list-style: none; background: var(--panel); border: 1px solid var(--line2); border-radius: var(--radius-sm); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.combo-list li { padding: 7px 9px; border-radius: 6px; cursor: pointer; font-size: var(--fs-sm); line-height: 1.3; color: var(--fg); }
.combo-list li small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.combo-list li.on, .combo-list li:hover { background: var(--accent-soft); }
.combo-list li.sel { font-weight: 650; }
.combo-list li.combo-empty { color: var(--dim); cursor: default; background: none; font-style: italic; }
.combo-list li.combo-group { cursor: default; background: none; font-weight: 700; font-size: var(--fs-xs); color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; padding: 9px 9px 4px; }
.combo-list li.in-group { padding-left: 16px; }

/* 0.92: planning, vista Elenco */
.plist { padding: 0; overflow: hidden; }
.plist-day + .plist-day { border-top: 1px solid var(--line); }
.plist-day.off { background: color-mix(in srgb, var(--panel2, var(--panel)) 60%, transparent); }
.plist-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px 6px; font-size: 14.5px; }
.plist-day.today .plist-head b { color: var(--accent); }
.plist-row { display: grid; grid-template-columns: 26px 104px minmax(0, 1fr) auto auto auto; gap: 10px; align-items: center;
  padding: 8px 16px 8px 12px; margin: 0 8px 4px; border-radius: var(--radius-sm); border-left: 4px solid var(--b, var(--line2));
  background: color-mix(in srgb, var(--b, var(--line2)) 9%, transparent); }
.plist-row:last-child { margin-bottom: 10px; }
.plist-row.pending { border-left-style: dashed; }
.plist-chk input { width: 17px; height: 17px; margin: 0; display: block; }
.plist-time { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.plist-main { text-decoration: none; color: inherit; min-width: 0; display: block; }
.plist-main b, .plist-main span { overflow-wrap: anywhere; }
.plist-main small { display: block; color: var(--dim); font-size: 12.5px; margin-top: 1px; }
.plist-icons { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.pico { display: inline-flex; gap: 4px; align-items: center; font-size: 12.5px; color: var(--dim); }
.pico.car-co { color: var(--accent); font-weight: 600; }
.pico.none { opacity: .5; }
.plist-act { display: flex; gap: 4px; align-items: center; justify-content: flex-end; min-width: 68px; }
.plist-empty { padding: 2px 16px 12px; font-size: 14px; }
@media (max-width: 760px) {
  .plist-row { grid-template-columns: 24px minmax(0, 1fr) auto; row-gap: 4px; }
  .plist-time { grid-column: 2; }
  .plist-main { grid-column: 2 / 4; }
  .plist-icons { grid-column: 2; flex-wrap: wrap; }
  .plist-state { grid-column: 3; grid-row: 1; justify-self: end; }
  .plist-act { grid-column: 3; justify-self: end; }
}

/* 0.100 — icona del tipo di risorsa (Risorse IT) */
.aico { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 8px;
  color: var(--c, var(--muted)); background: color-mix(in srgb, var(--c, var(--muted)) 14%, transparent); }
.aico.lg { width: 44px; height: 44px; border-radius: 12px; }

/* 0.102 — targa dei mezzi */
.plate { display: inline-flex; align-items: stretch; vertical-align: middle; background: #fff; color: #111;
  border: 1px solid #c3c9d2; border-radius: 6px; overflow: hidden; line-height: 1; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; font-size: 14px;
  letter-spacing: .12em; box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.plate-eu { width: 9px; flex: none; background: #1f4fd6; }
.plate-n { padding: 6px 9px 6px 8px; }
.plate.sm { font-size: 12px; border-radius: 4px; }
.plate.sm .plate-eu { width: 6px; }
.plate.sm .plate-n { padding: 3px 6px 3px 5px; }
.vcell { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.flash-target { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 0.106: loghi per il tema scuro (facoltativi). Scuro è il tema di partenza; chiaro con data-theme o preferenza di sistema */
img.lg-d { display: none; }
:root:not([data-theme="light"]) img.lg-l.has-d { display: none; }
:root:not([data-theme="light"]) img.lg-d { display: inline-block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) img.lg-l.has-d { display: inline-block; }
  :root:not([data-theme="dark"]) img.lg-d { display: none; }
}

/* 0.109 — menu a comparsa (es. scelta del tema): <details class="pop"><summary>…</summary><div class="pop-menu">…</div></details> */
.pop { position: relative; }
.pop > summary { list-style: none; cursor: pointer; }
.pop > summary::-webkit-details-marker { display: none; }
.pop-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 230px; padding: 6px; margin: 0;
  background: var(--panel); border: 1px solid var(--line2); border-radius: var(--radius-sm); box-shadow: 0 10px 30px rgba(0,0,0,.25);
  display: flex; flex-direction: column; gap: 2px; }
.pop-title { padding: 6px 10px 4px; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent;
  color: var(--fg); font: inherit; font-size: var(--fs-sm); text-align: left; cursor: pointer; text-decoration: none; }
.pop-item:hover { background: var(--panel2); }
.pop-item.on { background: var(--accent-soft); font-weight: 650; }
.pop-item small { color: var(--muted); margin-left: auto; }
.pop-item .sw { width: 22px; height: 22px; border-radius: 6px; flex: none; border: 1px solid var(--line2);
  background: conic-gradient(var(--bg) 0 50%, var(--accent) 0); }
.pop-foot { display: block; padding: 8px 10px 4px; margin-top: 4px; border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--muted); }

/* 0.109 — documentazione UI (/ui/docs): testo da Markdown */
.uidoc-wrap { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.uidoc-toc { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 2px; padding: 10px; font-size: var(--fs-sm); }
.uidoc-toc a { text-decoration: none; padding: 5px 8px; border-radius: 6px; color: var(--muted); }
.uidoc-toc a:hover { background: var(--panel2); color: var(--fg); }
.uidoc { line-height: 1.65; max-width: 980px; }
.uidoc h1 { margin: 0 0 12px; } .uidoc h2 { margin: 28px 0 10px; padding-top: 8px; border-top: 1px solid var(--line); } .uidoc h3 { margin: 20px 0 8px; }
.uidoc table { border-collapse: collapse; width: 100%; margin: 10px 0 16px; font-size: var(--fs-sm); }
.uidoc th, .uidoc td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.uidoc th { color: var(--muted); font-weight: 600; }
.uidoc pre { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto; }
.uidoc pre code { background: none; border: 0; padding: 0; word-break: normal; white-space: pre; }
.uidoc blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
@media (max-width: 900px) { .uidoc-wrap { grid-template-columns: minmax(0, 1fr); } .uidoc-toc { position: static; } }

/* 0.110 — mappe: modulo Mappa, riquadro «Mostra su mappa» (dialog.mapdlg + iframe /mappa/punto), pulsante .mapbtn */
/* 0.114: Leaflet dà ai suoi strati z-index 400–1000: senza un contesto proprio la mappa copriva i menu a comparsa dei
   filtri (persone, gruppi, clienti, commesse), la barra in alto e il menu laterale. La mappa resta nel suo strato,
   i filtri stanno sopra la card della mappa (anche durante l'animazione di entrata delle card). */
.leaflet-container { position: relative; z-index: 0; isolation: isolate; }
.map-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; position: relative; z-index: 5; }
.map-group { display: contents; }
.map-group[hidden] { display: none; }
.map-filters .fld { min-width: 150px; }
.map-pop { left: 0; right: auto; width: 320px; }
.map-pop input[type=search] { margin-bottom: 8px; }
.map-card { padding: 0; overflow: hidden; }
.map-box { height: 62vh; min-height: 360px; width: 100%; }
.map-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i, .map-day .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.map-legend i.cli { background: #9ca3af; border: 2px solid #111827; }
.map-legend i.cli-op { background: #111827; border: 2px solid #fff; box-shadow: 0 0 0 1px #111827; }
.map-legend i.com { background: #d97706; border: 2px solid #fff; box-shadow: 0 0 0 1px #d97706; }
.map-day summary { display: flex; align-items: center; gap: 8px; }
.map-steps { margin: 8px 0 0; padding-left: 22px; font-size: var(--fs-sm); }
.map-steps li { padding: 2px 0; }
.mapbtn { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; padding: 1px 8px; font: 600 var(--fs-xs) var(--font);
  color: var(--accent); background: var(--accent-soft); border: 1px solid transparent; border-radius: 999px; cursor: pointer; vertical-align: middle; white-space: nowrap; }
.mapbtn:hover { border-color: var(--accent); }
dialog.mapdlg { width: min(860px, 94vw); height: min(620px, 86vh); padding: 0; border: 1px solid var(--line2); border-radius: var(--radius);
  background: var(--panel); color: var(--fg); box-shadow: 0 30px 80px rgba(0,0,0,.45); overflow: hidden; }
dialog.mapdlg[open] { display: flex; flex-direction: column; }
dialog.mapdlg::backdrop { background: rgba(0,0,0,.5); }
.mapdlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.mapdlg iframe { flex: 1; width: 100%; border: 0; background: var(--bg); }
body.map-solo { display: flex; flex-direction: column; height: 100vh; }
body.map-solo .map-box { flex: 1; height: auto; min-height: 0; }
.map-links { display: flex; gap: 14px; align-items: center; padding: 8px 14px; font-size: var(--fs-sm); border-top: 1px solid var(--line); }
.map-links span.muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }

/* 0.111 — animazioni di BASE dei componenti (valgono con ogni tema; un tema le sostituisce con regole sue sotto
   [data-style="…"][data-motion="on"], o le spegne con animation: none). Mai con «riduci movimento» del sistema. */
@keyframes ui-fade-up { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes ui-pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes ui-drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  [data-motion="on"] .content > .page-head, [data-motion="on"] .content > .card, [data-motion="on"] .content > .grid > * {
    animation: ui-fade-up .25s ease-out backwards; animation-delay: calc(var(--i, 0) * 30ms); }
  [data-motion="on"] .flash { animation: ui-drop .25s ease-out backwards; }
  [data-motion="on"] .pop[open] > .pop-menu, [data-motion="on"] .people-pick[open] > .people-pop,
  [data-motion="on"] .combo-list:not([hidden]) { animation: ui-pop .14s ease-out; transform-origin: top; }
  [data-motion="on"] .js-tabs [data-pane]:not([hidden]) { animation: ui-fade-up .22s ease-out; }
  [data-motion="on"] details.box[open] > :not(summary), [data-motion="on"] .nav details[open] > .nav-item.sub {
    animation: ui-fade-up .18s ease-out backwards; }
  [data-motion="on"] .btn, [data-motion="on"] .iconbtn { transition: transform .12s ease, filter .12s, background-color .15s; }
  [data-motion="on"] .btn:active:not(:disabled), [data-motion="on"] .iconbtn:active { transform: scale(.97); }
  [data-motion="on"] .nav details { transition: background-color .2s, box-shadow .2s; }
}

/* 0.111 — galleria dei componenti (/ui/componenti e pagina esportata) */
.ui-toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; position: sticky; top: 64px; z-index: 9; margin-bottom: 16px; }
.ui-toolbar .fld { min-width: 180px; }
.ui-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 16px; align-items: start; }
.ui-index { position: sticky; top: 170px; display: flex; flex-direction: column; gap: 1px; padding: 10px; font-size: var(--fs-sm); max-height: 70vh; overflow: auto; }
.ui-index a { text-decoration: none; padding: 4px 8px; border-radius: 6px; color: var(--muted); }
.ui-index a:hover { background: var(--panel2); color: var(--fg); }
.ui-index-g { font-size: var(--fs-xs); font-weight: 650; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; padding: 8px 8px 2px; }
.ui-list > .ui-comp + .ui-comp { margin-top: 16px; }
.ui-desc { margin: 4px 0 10px; }
.ui-meta { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); margin-bottom: 8px; }
.ui-meta > div > span { display: inline-block; min-width: 92px; color: var(--muted); }
.ui-ex { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.ui-ex-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.ui-demo { padding: 14px; border: 1px dashed var(--line2); border-radius: var(--radius-sm); background: var(--bg); }
.ui-demo > .card:first-child, .ui-demo > .flash:last-child { margin-bottom: 0; }
.ui-code { margin-top: 8px; }
.ui-code pre { margin: 4px 0 8px; padding: 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; overflow: auto; font: 12.5px/1.5 var(--mono); }
.ui-code pre code { background: none; border: 0; padding: 0; word-break: normal; white-space: pre-wrap; }
.ui-code-l { font-size: var(--fs-xs); color: var(--dim); }
@media (max-width: 900px) { .ui-layout { grid-template-columns: minmax(0, 1fr); } .ui-index { position: static; max-height: none; } .ui-toolbar { position: static; } }
/* 0.112 — mappa: icone di abitazione e sede, legenda dei punti, tratte del percorso stradale */
.map-ico span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 2px solid; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.map-legend i.gps { background: #2563eb; border: 2px solid #fff; box-shadow: 0 0 0 1px #2563eb; }
.map-legend i.pln { background: #fff; border: 3px solid #2563eb; }
.map-legend .ico { color: var(--muted); }
.map-road { margin: 8px 0 4px; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); }
.map-leg { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.regbtn { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; padding: 1px 8px; font: 600 var(--fs-xs) var(--font);
  color: var(--accent); background: var(--accent-soft); border: 1px solid transparent; border-radius: 999px; text-decoration: none; white-space: nowrap; vertical-align: middle; }
.regbtn:hover { border-color: var(--accent); }
.regbtn.copied { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }

/* 0.114 — interruttori a pillola (componente togglechips): caselle di spunta vere, disegnate come pillole */
.tchips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tchips > span { font-size: var(--fs-sm); color: var(--muted); margin-right: 2px; }
.tchip { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer; font-size: var(--fs-sm); color: var(--muted); background: var(--panel); user-select: none; }
.tchip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.tchip:hover { border-color: var(--accent); }
.tchip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--fg); font-weight: 600; }
.tchip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.map-filters > .tchips { flex-basis: 100%; }
@media (prefers-reduced-motion: no-preference) {
  [data-motion="on"] .tchip { transition: background-color .15s, border-color .15s, color .15s; }
}

/* 0.115 — barra «Installa l'app» (componente installbar, gestita da /static/js/pwa.js) */
.installbar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 25;
  display: flex; align-items: center; gap: 12px; max-width: 560px; margin: 0 auto; padding: 10px 10px 10px 12px;
  background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.installbar[hidden] { display: none; }
.installbar.preview { position: static; margin: 0; box-shadow: none; }
.installbar-icon { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.installbar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: var(--fs-sm); line-height: 1.35; }
.installbar-text > b { font-size: 14.5px; }
.installbar-text span { color: var(--muted); }
.installbar-text svg { vertical-align: -2px; }
body.has-installbar .content { padding-bottom: 96px; }
@media (prefers-reduced-motion: no-preference) {
  [data-motion="on"] .installbar:not(.preview) { animation: ui-fade-up .3s ease-out backwards; }
}

/* 0.116 — telefono: i menu a comparsa con le caselle (persone, gruppi, clienti, commesse) diventano un pannello in basso
   largo quanto lo schermo: ancorati al pulsante uscivano dallo schermo (a sinistra nel planning, a destra nella mappa). */
@media (max-width: 700px) {
  .people-pick > .people-pop { position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    width: auto; max-height: 70vh; z-index: 60; box-shadow: 0 -8px 40px rgba(0,0,0,.35); }
  .people-pick[open] > summary::after { content: ""; position: fixed; inset: 0; z-index: 55; background: rgba(5,8,12,.45); }
  /* intestazione: solo l'ultima voce del percorso (il titolo della pagina), le altre non ci stavano */
  .crumbs > :not(:last-child) { display: none; }
}
