/* Tempo Progetti — stile dell'app.
   I colori sono tutti nelle variabili qui sotto (:root): tema chiaro, poi tema scuro.
   Rosso Digitale: --accent #B9102A. */
/* Layout: menu laterale fisso con logo e sezioni, barra superiore con il timer sempre visibile, contenuto a card fino a 1040px; sul telefono menu in basso. */
:root {
  --bg: #f6f5f2; --surface: #ffffff; --surface2: #f0eee9; --text: #1d1c1a; --muted: #6b6862;
  --border: #e2dfd8; --accent: #B9102A; --accent-ink: #B9102A; --accent-text: #fff; --info: #2f6fde; --danger: #c23b30; --ok: #1f8a4c; --warn: #b8700f;
  --shadow: rgba(0, 0, 0, .15); --backdrop: rgba(0, 0, 0, .4); --on-solid: #fff;
  --radius: 12px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161615; --surface: #201f1d; --surface2: #2a2926; --text: #eceae5; --muted: #a19d95;
    --border: #363430; --accent: #B9102A; --accent-ink: #E5566B; --info: #5b8ff0; --danger: #e5675c; --ok: #4cc27e; --warn: #e3a33b;
    --shadow: rgba(0, 0, 0, .5); --backdrop: rgba(0, 0, 0, .6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161615; --surface: #201f1d; --surface2: #2a2926; --text: #eceae5; --muted: #a19d95;
  --border: #363430; --accent: #B9102A; --accent-ink: #E5566B; --info: #5b8ff0; --danger: #e5675c; --ok: #4cc27e; --warn: #e3a33b;
  --shadow: rgba(0, 0, 0, .5); --backdrop: rgba(0, 0, 0, .6); color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15.5px/1.45 "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
/* icone */
.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.btn .ic { margin-right: 6px; }
.btn.icon-only .ic, .btn.small.icon-only .ic { margin: 0; }
.btn.small .ic { width: 16px; height: 16px; margin-right: 4px; vertical-align: -3px; }
.btn.ghost.small.icon-only { padding: 6px; line-height: 0; }
/* struttura */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 22px 14px 16px;
  padding-left: max(14px, env(safe-area-inset-left, 0px)); background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; min-width: 0; }
.brand .logo { width: 38px; height: 38px; border-radius: 9px; flex: none; display: block; }
.brand .names { display: flex; flex-direction: column; line-height: 1.12; min-width: 0; }
.brand .company { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-ink); }
.brand .app-name { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav button, .side-link { display: flex; align-items: center; gap: 11px; width: 100%; border: 0; background: none; color: var(--muted);
  padding: 9px 10px; border-radius: 9px; font: inherit; font-weight: 500; cursor: pointer; text-align: left; transition: background .15s, color .15s; }
.side-nav button:hover, .side-link:hover { background: var(--surface2); color: var(--text); }
.side-nav button.active { background: color-mix(in srgb, var(--accent) 14%, var(--surface2)); color: var(--text); font-weight: 600; }
.side-nav button.active .ic { color: var(--accent-ink); }
.side-label { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 0 10px; margin-bottom: 4px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.side-link kbd { margin-left: auto; }
.side-status { display: flex; flex-direction: column; gap: 10px; padding: 12px 10px 0; border-top: 1px solid var(--border); margin-top: 8px; }
kbd { font: 600 11px/1 "Barlow", sans-serif; color: var(--muted); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 3px 6px; background: var(--bg); }
.seg { display: flex; background: var(--surface2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px; border: 0; background: none; color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 500; padding: 6px 4px; border-radius: 7px; cursor: pointer; }
.seg button .ic { width: 15px; height: 15px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px var(--shadow); }
.sync { font-size: 12.5px; font-weight: 500; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.sync:empty { display: none; }
.sync.warn::before { background: var(--warn); }
.sync.error { color: var(--danger); } .sync.error::before { background: var(--danger); }
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; align-items: center; gap: 14px;
  padding-block: 12px; padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); min-height: 64px; }
.topbar h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0; margin-right: auto; text-wrap: balance; }
.topbar .m-logo { display: none; width: 30px; height: 30px; border-radius: 7px; }
.icon-btn { display: none; border: 0; background: none; color: var(--text); padding: 8px; border-radius: 8px; cursor: pointer; line-height: 0; }
.icon-btn:hover { background: var(--surface2); }
.icon-btn .ic { width: 20px; height: 20px; }
.tb { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 5px 5px 5px 12px; min-width: 0; }
.tb select { border: 0; background: transparent; padding: 6px 4px; max-width: 220px; font-weight: 500; }
.tb.run { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.tb-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; animation: pulse 1.4s infinite; }
.tb-info { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; max-width: 240px; }
.tb-info b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-info span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-clock { font: 600 19px/1 "Barlow", sans-serif; font-variant-numeric: tabular-nums; letter-spacing: .02em; padding: 4px 6px; border: 0; border-radius: 8px; background: none; color: inherit; cursor: pointer; }
.tb-clock:hover { background: var(--surface2); }
@keyframes pulse { 50% { opacity: .3; } }
@keyframes fadeIn { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
main { width: 100%; max-width: 1040px; margin: 0 auto; padding-block: 24px 72px; padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px)); }
main.fade { animation: fadeIn .2s ease; }
.bottom-nav { display: none; }
@media (prefers-reduced-motion: reduce) { .tb-dot { animation: none; } main.fade, dialog[open], .toast { animation: none !important; } }
h2 { font-size: 16px; margin: 0 0 12px; text-wrap: balance; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; min-width: 0;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--shadow) 35%, transparent); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 200px; }
.spread { justify-content: space-between; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 1px; }
label, .field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field > .row { flex-wrap: nowrap; gap: 6px; }
.field > .row > select { flex: 1; }
.btn { font: inherit; font-weight: 500; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn:hover { background: var(--surface2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.stop { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface2); }
.btn.danger { color: var(--danger); }
.btn.solid-danger { background: var(--danger); border-color: var(--danger); color: var(--on-solid); font-weight: 600; }
.clock { font: 600 34px/1 "Barlow", sans-serif; font-variant-numeric: tabular-nums; letter-spacing: .02em; min-width: 150px; text-align: center; }
.clock-box { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .dur { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.item .actions { display: flex; gap: 2px; }
.day { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--muted);
  margin: 18px 0 4px; text-transform: capitalize; }
.day:first-child { margin-top: 0; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }
.hint { font-size: 13px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px;
  border-radius: 999px; background: var(--surface2); color: var(--muted); white-space: nowrap; }
.pill.over { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, var(--surface)); }
.pill.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.pill .ic { width: 12px; height: 12px; margin-right: 1px; vertical-align: -1px; }
.check-row { flex-direction: row; align-items: center; gap: 7px; font-size: 13.5px; color: var(--text); margin-top: -4px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.btn.ghost.on { color: var(--accent-ink); }
/* registro: elenco o settimana */
.log-seg { display: inline-flex; margin-bottom: 16px; }
.log-seg button { padding: 7px 14px; font-size: 14px; }
.wk-label { font-size: 15px; min-width: 170px; text-align: center; font-variant-numeric: tabular-nums; }
.wk-table { min-width: 720px; }
.wk-table th, .wk-table td { padding: 6px 4px; text-align: center; vertical-align: middle; }
.wk-table .wk-proj { text-align: left; min-width: 180px; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.wk-table tbody .wk-proj { border-top: 1px solid var(--border); }
.wk-table tbody .wk-proj > * { vertical-align: middle; }
.wk-name { display: inline-flex; flex-direction: column; line-height: 1.2; min-width: 0; margin-left: 6px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); font-weight: 400; }
.wk-name .hint { font-size: 12px; }
.wk-day { font-size: 12px; line-height: 1.15; }
.wk-day span { display: block; font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: 0; }
.wk-day.today span { color: var(--accent-ink); }
.wk-table .we { background: color-mix(in srgb, var(--surface2) 55%, transparent); }
.wk-cell { width: 64px; text-align: center; padding: 7px 4px; font-variant-numeric: tabular-nums; font-weight: 600; background: var(--surface); }
.wk-tot { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 64px; }
.wk-table tfoot td, .wk-table tfoot th { font-weight: 700; font-variant-numeric: tabular-nums; }
/* orario di contratto */
.wk-table tfoot .wk-contract th, .wk-table tfoot .wk-contract td { font-weight: 500; color: var(--muted); }
.wk-table td.neg, b.neg { color: var(--danger); }
.wk-table td.pos, b.pos { color: var(--ok); }
.wh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.wh-head { margin: 12px 0 8px; font-size: 15px; color: var(--muted); }
.wh-head b { font-size: 26px; color: var(--text); font-variant-numeric: tabular-nums; }
.wh-days { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 12px; }
.wh-day { flex: 1; min-width: 70px; display: flex; flex-direction: column; align-items: flex-start; border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px;
  font: inherit; font-variant-numeric: tabular-nums; color: var(--text); background: var(--surface); text-align: left; cursor: pointer; }
.wh-day:hover { background: var(--surface2); }
.wh-day.off { background: var(--surface2); border-style: dashed; }
.wh-day.off b { color: var(--muted); font-weight: 600; }
.wk-abs-btn { font: inherit; font-size: 12px; font-weight: 500; color: var(--muted); background: none; border: 1px dashed transparent; border-radius: 6px;
  padding: 3px 6px; cursor: pointer; white-space: nowrap; }
.wk-abs-btn:hover { border-color: var(--border); color: var(--text); }
.wk-abs-btn.on { color: var(--info); font-weight: 600; background: color-mix(in srgb, var(--info) 12%, var(--surface)); }
/* luogo di lavoro */
.wk-abs-btn.ufficio, .wh-day em.ufficio { color: var(--warn); font-weight: 600; background: color-mix(in srgb, var(--warn) 14%, var(--surface)); }
.wk-abs-btn.smart, .wh-day em.smart { color: var(--ok); font-weight: 600; background: color-mix(in srgb, var(--ok) 13%, var(--surface)); }
.wk-place-sum { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.wh-day em { font-style: normal; font-size: 11px; border-radius: 5px; padding: 0 5px; margin: 2px 0 1px; }
.wh-day span { font-size: 12px; color: var(--muted); }
.wh-day small { font-size: 12px; color: var(--muted); }
.wh-day.ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); }
.wh-day.ok b { color: var(--ok); }
.wh-day.neg { border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.wh-day.neg b { color: var(--danger); }
.wh-day.today { border-color: var(--accent); }
.wh-day.future { opacity: .55; }
/* clienti */
.client-card { cursor: pointer; display: flex; flex-direction: column; gap: 14px; transition: border-color .15s; margin-bottom: 0; }
.client-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.client-card:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.client-card .name { font-weight: 700; font-size: 16px; }
.client-card .nums { display: flex; gap: 18px; font-size: 13px; color: var(--muted); }
.client-card .nums b { display: block; font-size: 17px; color: var(--text); font-variant-numeric: tabular-nums; }
.cc-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cc-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-head.big { margin-bottom: 16px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 15px;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent-ink); }
.cc-head.big .avatar { width: 52px; height: 52px; font-size: 19px; }
.info { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; overflow-wrap: anywhere; }
.info a { color: var(--accent-ink); }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-stats div { background: var(--surface2); border-radius: 9px; padding: 10px 12px; }
.mini-stats span { display: block; font-size: 12px; color: var(--muted); }
.mini-stats b { font-size: 19px; font-variant-numeric: tabular-nums; }
textarea { resize: vertical; font: inherit; }
/* promemoria */
.nav-badge { margin-left: auto; min-width: 20px; text-align: center; font-size: 11.5px; font-weight: 700; line-height: 1; padding: 4px 6px;
  border-radius: 999px; background: var(--accent); color: var(--accent-text); }
.rem-add { display: flex; gap: 8px; flex-wrap: wrap; }
.rem-add #rem-text { flex: 1 1 280px; }
.rem-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.rem-h { display: flex; align-items: center; gap: 8px; }
.rem-h.over { color: var(--danger); }
.rem-h.today { color: var(--warn); }
.alert .main .ic { width: 16px; height: 16px; vertical-align: -3px; }
/* credenziali */
.side-group { display: flex; flex-direction: column; gap: 2px; padding-top: 14px; border-top: 1px solid var(--border); }
.vault-gate { max-width: 520px; margin: 32px auto; display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; }
.vault-ico { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent-ink); }
.vault-ico .ic { width: 26px; height: 26px; }
.vault-form { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 360px; }
.vault-warn { font-size: 13px; color: var(--warn); margin: 0; }
.vault-warn .ic { width: 15px; height: 15px; vertical-align: -3px; }
.vault-search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 0 10px; flex: 1 1 280px; max-width: 460px; }
.vault-search .ic { color: var(--muted); }
.vault-search input { border: 0; background: none; flex: 1; padding: 9px 0; outline: none; }
.vault-item { padding: 14px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.vault-item:first-child { border-top: 0; padding-top: 0; }
.vault-head { display: flex; align-items: center; gap: 12px; }
.vault-head .title { font-weight: 700; }
.vault-av { width: 36px; height: 36px; font-size: 13px; border-radius: 9px; }
.vault-sub { display: flex; gap: 10px; flex-wrap: wrap; }
.vault-sub a { color: var(--accent-ink); }
.vault-fields { display: flex; flex-direction: column; gap: 4px; padding-left: 48px; }
.vault-field { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.vault-field span { width: 72px; flex: none; color: var(--muted); font-size: 13px; }
.vault-field code { font: 500 14px/1.3 ui-monospace, "SF Mono", Menlo, monospace; background: var(--surface2); border-radius: 6px; padding: 3px 8px; overflow-wrap: anywhere; }
.vault-field code.masked { letter-spacing: .12em; color: var(--muted); }
.vault-notes { padding-left: 48px; white-space: pre-line; }
@media (max-width: 640px) { .vault-fields, .vault-notes { padding-left: 0; } }
.log-more { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 18px; margin-top: 8px; border-top: 1px solid var(--border); }
.pill.info { color: var(--info); background: color-mix(in srgb, var(--info) 14%, var(--surface)); }
/* stato del progetto: etichetta che si apre come menu */
select.pill.status-sel { appearance: none; -webkit-appearance: none; border: 0; font-family: inherit; cursor: pointer; width: auto; min-height: 0;
  padding: 2px 22px 2px 9px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; }
select.pill.status-sel:hover { filter: brightness(.96); }
select.pill.status-sel:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media print { select.pill.status-sel { background-image: none; padding-right: 9px; } }
.pgroup { margin-bottom: 26px; }
.pgroup-h { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 12px; }
.pgroup-n { font-size: 12px; font-weight: 600; letter-spacing: 0; background: var(--surface2); color: var(--muted); border-radius: 999px; padding: 1px 8px; }
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.projects > .card { margin-bottom: 0; }
.proj { border-left: 5px solid; display: flex; flex-direction: column; gap: 8px; }
.proj.archived { opacity: .55; }
.proj .name { font-weight: 700; font-size: 16px; }
.proj .client { color: var(--muted); font-size: 13px; }
.proj .nums { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.proj .nums b { display: block; font-size: 17px; color: var(--text); font-variant-numeric: tabular-nums; }
.proj .actions-row { margin-top: auto; padding-top: 4px; flex-wrap: nowrap; }
.proj .proj-more { margin-left: auto; }
/* scheda compatta: stato accanto al nome, niente riga "Usate" (ripete il totale), attività più strette */
.proj-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.proj-title { min-width: 0; }
.proj-pills { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.proj-pills select.pill.status-sel { field-sizing: content; }   /* largo quanto lo stato scelto, non quanto il più lungo */
.proj .budget-used { display: none; }
.proj .budget { gap: 4px; }
.task-line { display: flex; align-items: center; gap: 8px; font-size: 13px; min-height: 26px; }
.task-count { display: inline-flex; align-items: center; gap: 5px; border: 0; border-radius: 999px; padding: 2px 9px; cursor: pointer;
  background: var(--surface2); color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.task-count:hover { color: var(--text); }
.task-count .ic { width: 13px; height: 13px; }
.task-next { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-line .btn { padding: 2px 6px; min-height: 0; }
.task-line .btn .ic { width: 12px; height: 12px; }
.proj .proj-more > .btn { font-size: 18px; line-height: 1; }
.proj .menu-pop { min-width: 170px; }
.proj .menu-pop button { justify-content: flex-start; }
/* progetti consegnati: sezione in fondo che si apre con un clic */
.pgroup-toggle { background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; }
.pgroup-toggle:hover { color: var(--text); }
.pgroup-toggle .chev { width: 10px; }
.delivered .proj { opacity: .85; }
/* Progetti: barra con vista, raggruppamento e filtri; vista a elenco */
.proj-count { margin-bottom: 8px; }
.proj-bar { margin-bottom: 20px; gap: 8px; }
.proj-bar .proj-new { margin-left: auto; }
.proj-bar select { width: auto; }
.proj-table + .pgroup, .pgroup:has(> .proj-table) { margin-top: 0; }
.proj-table { margin-bottom: 26px; }
.pl-group td { padding: 18px 6px 6px; border-top: 0; }
.pl-group:first-child td { padding-top: 10px; }
.pl-group .pgroup-h { margin: 0; }
.proj-bar .seg button { padding: 6px 12px; }
.proj-table { padding: 4px 14px; }
.proj-table table { table-layout: fixed; }
.proj-table th { padding-top: 10px; }
.proj-table th:nth-last-child(1) { width: 84px; }
.proj-table th.n { width: 104px; }
.proj-table th.pl-last { width: 120px; }
.proj-table .pl-last { padding-left: 18px; }
.proj-table th:first-child { width: 32%; }
.proj-table td { vertical-align: middle; }
.proj-table td.n { white-space: nowrap; }
.proj-table tr.archived td { opacity: .55; }
.proj-table tr.running td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.th-sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.th-sort:hover, .th-sort.on { color: var(--text); }
.pl-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.pl-title { min-width: 0; }
.pl-title b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-tasks { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; }
.pl-tasks:hover { color: var(--text); text-decoration: underline; }
.pl-client, .pl-cat { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.pl-pills select.pill.status-sel { field-sizing: content; }
.pl-act .row { gap: 4px; flex-wrap: nowrap; justify-content: flex-end; }
.pl-act .proj-more { margin-left: 0; }
.pl-act .menu-pop { min-width: 170px; }
.pl-act .menu-pop button { justify-content: flex-start; }
.proj-more > .btn { font-size: 18px; line-height: 1; }
@media (max-width: 900px) { .proj-table .pl-cat, .proj-table .pl-total { display: none; } .proj-table table { table-layout: auto; } .pl-title b { white-space: normal; } }
@media (max-width: 640px) {
  .proj-table { padding: 2px 8px; }
  .proj-table .pl-client, .proj-table .pl-last, .pl-pills .pill:not(select) { display: none; }
  .proj-table th:first-child { width: auto; }
  .proj-table th.n { width: 76px; }
  .proj-table th:nth-last-child(1) { width: 66px; }
  .proj-table th.pl-status { width: 104px; }
  .proj-table th, .proj-table td { padding-left: 4px; padding-right: 4px; }
  .pl-tasks { display: none; }
  .pl-act .btn.icon-only { padding: 5px; }
}
.colors { display: flex; gap: 6px; flex-wrap: wrap; }
.colors input { position: absolute; opacity: 0; pointer-events: none; }
.colors span { display: block; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.colors input:checked + span { border-color: var(--text); }
.colors input:focus-visible + span { outline: 2px solid var(--accent-ink); outline-offset: 1px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 6px; border-top: 1px solid var(--border); }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; border-top: 0; }
td.n, th.n { text-align: right; }
.meter { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; min-width: 60px; }
.meter i { display: block; height: 100%; border-radius: 4px; }
tfoot td { font-weight: 700; }
.budget { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.timer .budget { margin-top: 14px; }
.ts { position: relative; display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 0 10px; margin-bottom: 12px; }
.ts:focus-within { border-color: var(--accent-ink); }
.ts > .ic { color: var(--muted); flex: none; }
.ts input { border: 0; background: none; flex: 1; min-width: 0; padding: 10px 0; outline: none; }
.ts input::-webkit-search-cancel-button { cursor: pointer; }
.ts-key { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 6px; }
.ts:focus-within .ts-key { display: none; }
.ts-res { position: absolute; left: -1px; right: -1px; top: calc(100% + 4px); z-index: 6; background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 4px; max-height: 340px; overflow-y: auto; }
.ts:not(:focus-within) .ts-res { display: none; }
.ts-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 7px; background: none;
  color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.ts-item .recent-txt { flex: 1; }
.ts-item .recent-txt span { font-size: 12px; }
.ts-item.on, .ts-item:hover { background: var(--surface2); }
.ts-item .ic { width: 14px; height: 14px; color: var(--muted); flex: none; }
.ts-item.on .ic { color: var(--accent-ink); }
.ts-kind { font-size: 11px; color: var(--muted); }
.ts-empty { padding: 10px; }
.recent { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.recent-k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-right: 4px; }
.recent-chip { display: inline-flex; align-items: center; gap: 7px; max-width: 240px; padding: 5px 8px 5px 10px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.recent-chip:hover { background: var(--surface2); border-color: var(--accent); }
.recent-chip .ic { width: 13px; height: 13px; color: var(--muted); flex: none; }
.recent-chip:hover .ic { color: var(--accent-ink); }
.recent-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.recent-txt b, .recent-txt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-txt span { font-size: 11px; color: var(--muted); }
.budget-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; color: var(--muted); }
.budget b.ok { color: var(--ok); } .budget b.warn { color: var(--warn); } .budget b.over { color: var(--danger); }
.meter i.ok { background: var(--ok); } .meter i.warn { background: var(--warn); } .meter i.over { background: var(--danger); }
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 20px; width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog::backdrop { background: var(--backdrop); }
dialog > form, .panel-body { display: flex; flex-direction: column; gap: 12px; }
.form-err { color: var(--danger); font-size: 13px; min-height: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px; display: none; flex-direction: column; min-width: 220px; box-shadow: 0 8px 24px var(--shadow); z-index: 6; }
.menu-pop.open { display: flex; }
.menu-pop button { text-align: left; border: 0; }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }
/* attività e categorie */
.task { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.task:first-child { border-top: 0; }
.task .t-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.task input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.task .t-time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-row { display: flex; align-items: center; gap: 8px; }
.cat-row input[type=text] { flex: 1; }
.cat-row input[type=color] { width: 36px; height: 34px; padding: 2px; flex: none; }
details summary { cursor: pointer; font-size: 13px; color: var(--muted); padding: 6px 0; }
/* avviso timer dimenticato */
#banner { padding-left: max(28px, var(--gutter-l)); padding-right: max(28px, var(--gutter-r)); }
.banner-in { max-width: 984px; margin: 14px auto 0; padding: 12px 16px; border: 1px solid var(--warn); border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 16%, var(--surface)); display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
/* barra del file dati */
#fileBar { padding-left: max(28px, var(--gutter-l)); padding-right: max(28px, var(--gutter-r)); }
@media (max-width: 900px) { #banner, #fileBar { padding-left: var(--gutter-l); padding-right: var(--gutter-r); } }
.file-in { max-width: 984px; margin: 14px auto 0; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.file-in.conflict { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.file-in .main { flex: 1 1 260px; min-width: 0; font-size: 14px; }
.file-menu { display: flex; flex-direction: column; }
.file-menu[hidden] { display: none; }
.gate { max-width: 520px; margin: 40px auto; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
/* panoramica */
.alert { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; background: var(--surface2);
  border-left: 4px solid var(--muted); margin-bottom: 8px; flex-wrap: wrap; }
.alert:last-child { margin-bottom: 0; }
.alert.over { border-left-color: var(--danger); } .alert.warn { border-left-color: var(--warn); } .alert.info { border-left-color: var(--info); }
.alert .main { flex: 1 1 220px; min-width: 0; }
.allgood { color: var(--ok); font-weight: 600; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.cols > .card { margin-bottom: 0; }
.bitem { padding: 10px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.bitem:first-of-type { border-top: 0; padding-top: 0; }
.week { display: flex; gap: 8px; align-items: stretch; height: 160px; }
.wcol { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.wbar { flex: 1; width: 100%; max-width: 40px; background: var(--surface2); border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden; }
.wbar i { display: block; width: 100%; background: var(--accent); border-radius: 6px 6px 0 0; }
.wv { font-size: 12px; font-weight: 600; height: 16px; font-variant-numeric: tabular-nums; }
.wl { font-size: 12px; color: var(--muted); white-space: nowrap; }
.wcol.today .wl { color: var(--text); font-weight: 700; }
.cat-bars { display: flex; flex-direction: column; gap: 10px; }
.cat-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 14px; }
.cat-bar .meter { grid-column: 1 / -1; }
.cat-bar .v { font-variant-numeric: tabular-nums; color: var(--muted); }
/* report cliente */
.doc-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid var(--text); padding-bottom: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.doc-brand { display: flex; align-items: center; gap: 16px; }
.doc-logo { height: 72px; width: auto; border-radius: 6px; display: block; }
.doc-title { font-size: 22px; font-weight: 700; }
.doc-sub { color: var(--muted); font-size: 16px; }
.doc-meta { text-align: right; font-size: 13px; color: var(--muted); }
.doc-meta b { color: var(--text); font-size: 15px; }
.doc-proj { margin-bottom: 26px; }
.doc-proj h3 { margin: 0 0 10px; font-size: 17px; }
.doc-sum { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.doc-sum div { flex: 1; min-width: 120px; background: var(--surface2); border-radius: 8px; padding: 8px 12px; }
.doc-sum span { display: block; font-size: 12px; color: var(--muted); }
.doc-sum b { font-size: 17px; font-variant-numeric: tabular-nums; }
.doc-sum .over b { color: var(--danger); }
.doc-total { display: flex; justify-content: space-between; border-top: 2px solid var(--text); padding-top: 10px; font-size: 16px; }
/* report riepilogativo in PDF: sempre chiaro, anche con il tema scuro; la larghezza la decide la pagina A4 */
.pdf-doc { --bg: #fff; --surface: #fff; --surface2: #f2f2f2; --text: #000; --muted: #555; --border: #ccc; --danger: #b00;
  color-scheme: light; background: #fff; color: #000; font-size: 13px; }
.pdf-doc .doc-sum div { border: 1px solid #ccc; }
.doc-sec { margin-bottom: 24px; }
.doc-sec h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.doc-chart { display: block; width: 100%; height: auto; }
.doc-split { display: flex; align-items: center; gap: 28px; }
.doc-split table { flex: 1; }
.doc-donut { width: 160px; height: 160px; flex: none; }
tr.doc-group td { font-weight: 700; background: var(--surface2); }
tr.doc-item td:first-child { padding-left: 26px; }
.toast { position: fixed; left: var(--gutter-l); right: var(--gutter-r); bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  margin: 0 auto; max-width: 480px; background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 10px;
  box-shadow: 0 8px 24px var(--shadow); z-index: 20; font-size: 14px; display: flex; align-items: center; gap: 14px; animation: pop .2s ease; }
.toast[hidden] { display: none; }
.toast span { flex: 1; }
.toast button { border: 0; background: none; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; }
dialog[open] { animation: pop .16s ease; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 28px 12px; color: var(--muted); }
.empty-state .ic { width: 34px; height: 34px; stroke-width: 1.5; color: var(--border); }
.empty-state b { color: var(--text); font-size: 15px; }
/* ricerca rapida */
#palette { padding: 0; width: min(560px, calc(100vw - 32px)); margin-top: 12vh; }
.pal-in { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.pal-in input { flex: 1; border: 0; background: none; padding: 4px 0; font-size: 16px; outline: none; }
.pal-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.pal-group { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 10px 10px 4px; }
.pal-item { display: flex; align-items: center; gap: 11px; width: 100%; border: 0; background: none; color: var(--text); font: inherit; text-align: left;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.pal-item.on { background: color-mix(in srgb, var(--accent) 11%, var(--surface)); }
.pal-item .ic { color: var(--muted); }
.pal-item .sub { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; align-items: center; font-size: 14px; }
@media print {
  /* anche con il tema scuro la stampa è sempre chiara */
  :root, :root:not([data-theme="light"]), :root[data-theme="dark"] {
    --bg: #fff; --surface: #fff; --surface2: #f2f2f2; --text: #000; --muted: #555; --border: #ccc; --danger: #b00; color-scheme: light; }
  .side, .topbar, .bottom-nav, #banner, #fileBar, .no-print, .toast { display: none !important; }
  .app { display: block; }
  main.fade, dialog[open], .toast { animation: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .doc { border: 0; padding: 0; }
  .doc-sum div { border: 1px solid #ccc; }
  .doc-proj { break-inside: avoid; }
}
@media (max-width: 720px) {
  .cols { grid-template-columns: 1fr; }
  .tgrid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .topbar { padding-left: var(--gutter-l); padding-right: var(--gutter-r); gap: 8px; min-height: 58px; }
  .topbar h1 { font-size: 19px; }
  .topbar .m-logo, .icon-btn { display: block; }
  main { padding-left: var(--gutter-l); padding-right: var(--gutter-r); padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); }
  .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none; color: var(--muted);
    font: inherit; font-size: 11px; font-weight: 500; padding: 6px 2px; border-radius: 8px; cursor: pointer; }
  .bottom-nav button .ic { width: 21px; height: 21px; }
  .bottom-nav button.active { color: var(--accent-ink); font-weight: 600; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  .tb-info { max-width: 120px; }
  .tb select { max-width: 130px; }
}
@media (max-width: 640px) {
  .tb .hide-s, .topbar h1, .topbar .icon-btn[data-act=palette] { display: none; }
  .tb { margin-right: auto; gap: 6px; padding-left: 10px; }
  .tb-info { max-width: 96px; }
  .tb-info span { display: none; }
  .tb-clock { font-size: 16px; padding: 0 2px; }
  .tb .btn.small { padding: 6px 8px; }
  .tb .btn.small .ic { margin: 0; }
  .stats { gap: 8px; }
  .stat .v { font-size: 17px; }
  .clock { font-size: 26px; flex: 1; text-align: left; min-width: 0; }
  .clock-box { flex: 1; align-items: flex-start; min-width: 0; }
  .timer .row > input, .timer .row > .grow { flex: 1 1 calc(100% - 24px); }
  .hide-m { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}
