/* =============================================================================
   Agendy — Anteprima del gestionale (componente condiviso)
   Usato da: index.html (dashboard in home + anteprima preset) e configuratore.html
   ("Guarda un esempio"). Tutto è confinato sotto .ag-preview per non entrare in
   conflitto con gli stili delle singole pagine. Richiede le variabili colore
   (--surface-2, --border-soft, --gradient, …) definite dalla pagina.
   ============================================================================= */

/* Colori dei collaboratori (chiavi in js/util.js → COLORI): valgono in tutte le pagine */
.ag-col-rosso{ --col:#F87171; } .ag-col-blu{ --col:#60A5FA; } .ag-col-verde{ --col:#4ADE80; } .ag-col-giallo{ --col:#FACC15; }
.ag-col-viola{ --col:#C084FC; } .ag-col-arancione{ --col:#FB923C; } .ag-col-rosa{ --col:#F472B6; } .ag-col-azzurro{ --col:#22D3EE; }

.ag-preview{
  max-width:1080px;
  margin:0 auto;
  border:1px solid var(--border);
  border-radius:20px;
  background:linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  padding:14px;
  display:grid;
  grid-template-columns:200px 1fr;
  gap:14px;
  min-height:520px;
}
@media (max-width:720px){
  .ag-preview{ grid-template-columns:1fr; }
}

.ag-preview .dash-sidebar{
  background:var(--surface-2);
  border:1px solid var(--border-soft);
  border-radius:14px;
  padding:20px 16px;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.ag-preview .dash-sidebar .brand{
  font-weight:800;
  font-size:15px;
  margin-bottom:18px;
  padding-left:6px;
}
.ag-preview .dash-nav-item{
  padding:10px 12px;
  border-radius:8px;
  font-size:14px;
  color:var(--gray);
  display:flex;
  align-items:center;
  gap:10px;
}
.ag-preview .dash-nav-item.active{
  color:var(--white);
  background:rgba(255,255,255,0.06);
}
.ag-preview .dash-nav-item .dot{
  width:6px;height:6px;border-radius:50%;
  background:var(--gray-dim);
  flex-shrink:0;
}
.ag-preview .dash-nav-item.active .dot{ background:var(--accent-1); }
.ag-preview .dash-nav-gruppo{
  margin:14px 0 2px; padding:12px 6px 0; border-top:1px solid var(--border-soft);
  font-size:10.5px; font-weight:700; letter-spacing:0.1em; text-transform:uppercase; color:var(--gray-dim);
}
@media (max-width:720px){ .ag-preview .dash-nav-gruppo{ display:none; } }

.ag-preview .dash-main{ display:flex; flex-direction:column; gap:14px; }

.ag-preview .dash-kpis{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
}
@media (max-width:480px){ .ag-preview .dash-kpis{ grid-template-columns:1fr; } }

.ag-preview .kpi-card{
  background:var(--surface-2);
  border:1px solid var(--border-soft);
  border-radius:14px;
  padding:18px 20px;
}
.ag-preview .kpi-label{ font-size:12.5px; color:var(--gray); text-transform:uppercase; letter-spacing:0.08em; }
.ag-preview .kpi-value{ font-size:26px; font-weight:700; margin-top:6px; font-variant-numeric:tabular-nums; }
.ag-preview .kpi-value.grad{ background:var(--gradient); -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent; }

.ag-preview .dash-row{
  display:grid;
  grid-template-columns:1.3fr 1fr;
  gap:14px;
  flex:1;
}
@media (max-width:720px){ .ag-preview .dash-row{ grid-template-columns:1fr; } }

.ag-preview .panel{
  background:var(--surface-2);
  border:1px solid var(--border-soft);
  border-radius:14px;
  padding:20px;
  display:flex;
  flex-direction:column;
  gap:14px;
}
.ag-preview .panel-title{ font-size:14px; font-weight:700; }
.ag-preview .cal-heading{ display:flex; flex-direction:column; gap:2px; }
.ag-preview .panel-subtitle{ font-size:12px; color:var(--gray); }

.ag-preview .panel.hero-panel{
  border:1px solid rgba(255,106,0,0.45);
  box-shadow:0 0 0 1px rgba(230,33,107,0.12), 0 0 60px -10px rgba(255,106,0,0.35);
}

.ag-preview .task-row{
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 0;
  border-bottom:1px solid var(--border-soft);
  font-size:13.5px;
}
.ag-preview .task-row:last-child{ border-bottom:none; }
.ag-preview .task-check{
  width:16px;height:16px;
  border-radius:5px;
  border:1.5px solid var(--gray-dim);
  flex-shrink:0;
}
.ag-preview .task-check.done{
  background:var(--gradient);
  border-color:transparent;
}
.ag-preview .task-name{ flex:1; }
.ag-preview .task-tag{ font-size:11px; color:var(--gray); border:1px solid var(--border); padding:3px 8px; border-radius:999px; }

.ag-preview .cal-grid{
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:6px;
  text-align:center;
}
.ag-preview .cal-dow{
  font-size:10.5px;
  color:var(--gray-dim);
  font-weight:700;
  text-transform:uppercase;
}
.ag-preview .cal-day{
  font-size:12.5px;
  color:var(--gray);
  padding-block:4px;
  border-radius:6px;
  font-variant-numeric:tabular-nums;
}
.ag-preview .cal-day.cal-deadline{
  color:var(--white);
  position:relative;
}
.ag-preview .cal-day.cal-deadline::after{
  content:"";
  display:block;
  width:4px;height:4px;
  border-radius:50%;
  background:var(--gradient);
  margin:2px auto 0;
}
.ag-preview .cal-day.cal-today{
  color:var(--white);
  font-weight:700;
  background:var(--gradient);
}
.ag-preview button.dash-nav-item{
  width:100%;
  border:0;
  background:transparent;
  font:inherit;
  font-size:14px;
  text-align:left;
  cursor:pointer;
  transition:color .2s ease, background .2s ease;
}
.ag-preview button.dash-nav-item:hover{ color:var(--white); background:rgba(255,255,255,0.03); }
.ag-preview button.dash-nav-item.active{ background:rgba(255,255,255,0.06); }
.ag-preview button.dash-nav-item:focus-visible{ outline:2px solid var(--white); outline-offset:2px; }
.ag-preview .preset-view{ min-height:540px; }
/* le colonne grid non devono allargarsi oltre il pannello (es. settimana scorrevole su mobile) */
.ag-preview > *, .ag-preview .dash-row > *, .ag-preview .split-2 > *{ min-width:0; }

.ag-preview .panel-head{ display:flex; align-items:flex-start; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.ag-preview .split-2{ display:grid; grid-template-columns:1fr 1.35fr; gap:14px; }
@media (max-width:720px){ .ag-preview .split-2{ grid-template-columns:1fr; } }

.ag-preview .cat-list{ display:flex; flex-direction:column; gap:6px; }
.ag-preview .cat-item{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:9px 12px; border-radius:9px; border:1px solid var(--border-soft);
  font-size:13px; color:var(--gray);
}
.ag-preview .cat-item.active{ color:var(--white); border-color:rgba(255,106,0,0.45); background:rgba(255,106,0,0.06); }
.ag-preview .cat-item .task-tag{ white-space:nowrap; }

.ag-preview .progress{ height:4px; border-radius:999px; background:rgba(255,255,255,0.08); overflow:hidden; }
.ag-preview .progress span{ display:block; height:100%; background:var(--gradient); border-radius:999px; }
.ag-preview .task-row.sub{ padding-left:28px; font-size:12.5px; color:var(--gray); }
.ag-preview .task-row.sub .task-check{ width:13px; height:13px; border-radius:4px; }

.ag-preview .week-dow.today{ color:var(--accent-1); }
.ag-preview .week-slot.today{ box-shadow:0 0 0 1px rgba(230,33,107,0.5); }
.ag-preview .week-slot .more{ display:block; margin-top:4px; font-weight:400; color:var(--gray); }
@media (max-width:560px){
  .ag-preview .week-grid{ grid-template-columns:repeat(7, minmax(64px,1fr)); overflow-x:auto; }
}

.ag-preview .kpis-3{ grid-template-columns:repeat(3,1fr); }
@media (max-width:600px){ .ag-preview .kpis-3{ grid-template-columns:1fr; } }
.ag-preview .kpis-3 .kpi-value{ font-size:22px; }

.ag-preview .money-row{
  display:grid; grid-template-columns:1fr auto auto; align-items:center; gap:12px;
  padding:10px 0; border-bottom:1px solid var(--border-soft);
}
.ag-preview .money-row:last-child{ border-bottom:none; }
.ag-preview .money-name{ font-size:13.5px; font-weight:600; }
.ag-preview .money-meta{ font-size:11.5px; color:var(--gray); margin-top:2px; }
.ag-preview .money-amount{ font-size:13.5px; font-weight:700; font-variant-numeric:tabular-nums; white-space:nowrap; }
.ag-preview .pay-badge{ font-size:10.5px; font-weight:700; padding:3px 9px; border-radius:999px; white-space:nowrap; border:1px solid; }
.ag-preview .pay-badge.pagato{ color:#4ADE9A; border-color:rgba(74,222,154,0.4); background:rgba(74,222,154,0.08); }
.ag-preview .pay-badge.da_pagare{ color:#FF5C93; border-color:rgba(230,33,107,0.45); background:rgba(230,33,107,0.08); }
.ag-preview .pay-badge.parziale{ color:#FF9A4D; border-color:rgba(255,106,0,0.45); background:rgba(255,106,0,0.08); }
@media (max-width:480px){
  .ag-preview .money-row{ grid-template-columns:1fr auto; }
  .ag-preview .money-row .pay-badge{ grid-column:2; justify-self:end; }
}

.ag-preview .bar-chart.tall{ height:150px; }
.ag-preview .bar-labels{ display:flex; gap:8px; }
.ag-preview .bar-labels span{ flex:1; text-align:center; font-size:10.5px; color:var(--gray-dim); text-transform:uppercase; }

.ag-preview .chip-row{ display:flex; gap:8px; flex-wrap:wrap; }
.ag-preview .chip{ font-size:11.5px; padding:5px 11px; border-radius:999px; border:1px solid var(--border-soft); color:var(--gray); }
.ag-preview .chip.active{ color:var(--white); border-color:rgba(255,106,0,0.5); background:rgba(255,106,0,0.08); }

.ag-preview .file-row{
  display:flex; align-items:center; gap:14px; padding:11px 0; border-bottom:1px solid var(--border-soft);
}
.ag-preview .file-icon{
  width:38px; height:44px; flex-shrink:0; border-radius:7px; display:flex; align-items:flex-end; justify-content:center;
  padding-bottom:6px; font-size:9px; font-weight:800; letter-spacing:0.04em;
  border:1px solid var(--border); background:var(--surface-2);
}
.ag-preview .file-icon.pdf{ color:#FF5C93; }
.ag-preview .file-icon.img{ color:#FF9A4D; }
.ag-preview .file-icon.doc{ color:#7FB2FF; }
.ag-preview .file-icon.xls{ color:#4ADE9A; }
.ag-preview .file-info{ flex:1; min-width:0; }
.ag-preview .file-info .money-name{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ag-preview .file-date{ font-size:12px; color:var(--gray); text-align:right; white-space:nowrap; }
.ag-preview .file-date span{ display:block; font-size:11px; color:var(--gray-dim); margin-top:2px; }
.ag-preview .drop-zone{
  margin-top:6px; padding:22px; border:1.5px dashed var(--border); border-radius:12px;
  text-align:center; font-size:13px; color:var(--gray);
}

.ag-preview .week-grid{
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:6px;
}
.ag-preview .week-dow{
  font-size:10.5px;
  color:var(--gray-dim);
  text-transform:uppercase;
  font-weight:700;
  text-align:center;
}
.ag-preview .week-slot{
  min-height:56px;
  border:1px solid var(--border-soft);
  border-radius:8px;
  padding:6px;
  font-size:10px;
  color:var(--gray);
  line-height:1.35;
}
.ag-preview .week-slot.appt{
  background:rgba(255,106,0,0.08);
  border-color:rgba(255,106,0,0.45);
  color:var(--white);
  font-weight:600;
}

.ag-preview .case-row{
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 0;
  border-bottom:1px solid var(--border-soft);
  font-size:13.5px;
}
.ag-preview .case-row:last-child{ border-bottom:none; }
.ag-preview .case-name{ flex:1; }
.ag-preview .countdown-badge{
  font-size:11px;
  font-weight:700;
  padding:3px 10px;
  border-radius:999px;
  background:var(--gradient);
  color:var(--bg);
  white-space:nowrap;
}

.ag-preview .bar-chart{ display:flex; align-items:flex-end; gap:8px; height:80px; }
.ag-preview .bar-chart .bar{
  flex:1;
  border-radius:5px 5px 0 0;
  background:var(--gradient);
  opacity:0.85;
}

.ag-preview .modules-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
}
.ag-preview .module-card{
  border:1px dashed var(--border);
  border-radius:12px;
  padding:14px 10px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:8px;
  font-size:11.5px;
  color:var(--gray);
  text-align:center;
  transition:border-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.ag-preview .module-card:hover{
  border-color:rgba(255,106,0,0.5);
  color:var(--white);
  box-shadow:0 0 30px -14px rgba(255,106,0,0.5);
}
.ag-preview .module-plus{
  width:22px;height:22px;
  border-radius:50%;
  border:1px solid var(--border);
  display:flex;align-items:center;justify-content:center;
  font-size:14px;
  color:var(--gray-dim);
}
.ag-preview .empty-placeholder{
  grid-column:1/-1;
  border:1.5px dashed var(--border);
  border-radius:16px;
  padding:44px 20px;
  text-align:center;
  color:var(--gray);
  font-size:13.5px;
  margin-top:4px;
}

/* testo sfumato (usato nell'area "trascina qui i file") */
.ag-preview .grad-text{ background:var(--gradient); -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent; }

/* schermi stretti: la sidebar diventa una fila di schede scorrevole */
@media (max-width:720px){
  .ag-preview .dash-sidebar{ flex-direction:row; overflow-x:auto; padding:8px; gap:4px; }
  .ag-preview .dash-sidebar .brand{ display:none; }
  .ag-preview .dash-nav-item{ white-space:nowrap; }
  .ag-preview button.dash-nav-item{ width:auto; }
  .ag-preview .preset-view{ min-height:0; }
}

/* pulsante "+ Nuova attività" del calendario (solo dimostrativo nell'anteprima) */
.ag-preview .add-attivita{
  display:inline-flex; align-items:center; padding:7px 14px; border-radius:999px;
  background:var(--gradient); color:var(--white); font-size:12.5px; font-weight:700; white-space:nowrap;
  box-shadow:0 10px 26px -14px rgba(230,33,107,0.8);
}

/* ---- Archivio: ricerca, filtri, cartella per cliente ---- */
.ag-preview .ag-search{
  display:flex; align-items:center; gap:8px; min-width:0; flex:1 1 220px; max-width:320px;
  padding:0 12px; border-radius:999px; border:1px solid var(--border-soft); background:var(--surface-2); color:var(--gray-dim);
}
.ag-preview .ag-search:focus-within{ border-color:rgba(255,106,0,0.55); }
.ag-preview .ag-search svg{ width:14px; height:14px; flex-shrink:0; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; }
.ag-preview .ag-search input{
  flex:1; min-width:0; padding:8px 0; border:0; background:none; color:var(--white);
  font-family:inherit; font-size:12.5px;
}
.ag-preview .ag-search input:focus{ outline:none; }
.ag-preview .ag-search input::placeholder{ color:var(--gray-dim); }
.ag-preview button.chip{ font-family:inherit; background:transparent; cursor:pointer; }
.ag-preview button.chip:hover{ color:var(--white); border-color:var(--border); }
.ag-preview button.chip:focus-visible{ outline:2px solid var(--white); outline-offset:2px; }
.ag-preview .ag-arch-list{ display:flex; flex-direction:column; gap:8px; }
.ag-preview .ag-folder{ border:1px solid var(--border-soft); border-radius:11px; overflow:hidden; }
.ag-preview .ag-folder-head{
  width:100%; display:flex; align-items:center; gap:10px; padding:11px 12px;
  border:0; background:transparent; color:var(--white); font-family:inherit; font-size:13.5px; font-weight:600;
  text-align:left; cursor:pointer;
}
.ag-preview .ag-folder-head:hover{ background:rgba(255,255,255,0.03); }
.ag-preview .ag-folder-head:focus-visible{ outline:2px solid var(--white); outline-offset:-2px; }
.ag-preview .ag-folder-head svg{ width:16px; height:16px; flex-shrink:0; fill:none; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.ag-preview .ag-chev{ stroke:var(--gray-dim); transition:transform .2s ease; }
.ag-preview .ag-folder-head[aria-expanded="true"] .ag-chev{ transform:rotate(90deg); }
.ag-preview .ag-folder-ico{ stroke:var(--accent-1); }
.ag-preview .ag-folder-nome{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ag-preview .ag-folder-n{ font-size:11.5px; color:var(--gray-dim); font-weight:500; white-space:nowrap; }
.ag-preview .ag-folder-files{ border-top:1px solid var(--border-soft); padding:0 12px 0 38px; }
.ag-preview .ag-folder-files .file-row:last-child{ border-bottom:none; }
.ag-preview mark{ background:rgba(255,106,0,0.35); color:var(--white); border-radius:3px; padding:0 1px; }
.ag-preview .ag-arch-empty{ font-size:13px; color:var(--gray-dim); padding:18px 4px; text-align:center; }

/* ---- Anteprima esplorabile: pulsanti, giorni cliccabili, modulo nuova attività ---- */
.ag-preview .ag-btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px; min-height:32px; padding:6px 12px;
  border-radius:999px; border:none; background:var(--gradient); color:var(--white);
  font-family:inherit; font-size:12.5px; font-weight:700; cursor:pointer; white-space:nowrap;
}
.ag-preview .ag-btn.ghost{ background:transparent; border:1px solid var(--border); color:var(--gray); font-weight:600; }
.ag-preview .ag-btn.ghost:hover{ color:var(--white); border-color:rgba(255,255,255,0.3); }
.ag-preview .ag-icon{
  width:30px; height:30px; flex-shrink:0; display:inline-flex; align-items:center; justify-content:center;
  border-radius:8px; border:1px solid var(--border-soft); background:transparent; color:var(--gray); cursor:pointer;
}
.ag-preview .ag-icon:hover{ color:var(--white); border-color:var(--border); }
.ag-preview .ag-icon svg{ width:15px; height:15px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.ag-preview .ag-btn:focus-visible, .ag-preview .ag-icon:focus-visible, .ag-preview .ag-link:focus-visible,
.ag-preview .week-slot:focus-visible, .ag-preview .cal-day:focus-visible, .ag-preview .cat-item:focus-visible,
.ag-preview .ag-voce:focus-visible, .ag-preview .ag-row:focus-visible, .ag-preview .ag-paga:focus-visible{ outline:2px solid var(--white); outline-offset:2px; }
.ag-preview .ag-link{ background:none; border:0; padding:0; color:var(--white); font:inherit; font-weight:600; cursor:pointer; text-decoration:underline; text-decoration-color:var(--accent-1); text-underline-offset:3px; }
.ag-preview .ag-head-actions{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.ag-preview .add-attivita{ border:none; font-family:inherit; cursor:pointer; }
.ag-preview .ag-cap{ text-transform:capitalize; }
.ag-preview .ag-vuoto{ font-size:13px; color:var(--gray-dim); padding:6px 0; }

/* giorni della settimana e del mese: pulsanti */
.ag-preview button.week-slot{ font-family:inherit; text-align:left; cursor:pointer; background:transparent; }
.ag-preview button.week-slot.appt{ background:rgba(255,106,0,0.08); }
/* chi segue l'impegno: bordo del colore del collaboratore, pallino + nome negli elenchi */
.ag-preview .week-slot.con-chi{ border-left:3px solid var(--col); }
.ag-preview .ag-chi{ display:inline-flex; align-items:center; gap:6px; font-size:11.5px; font-weight:600; color:var(--gray); white-space:nowrap; flex-shrink:0; }
.ag-preview .ag-chi-dot{ width:8px; height:8px; border-radius:50%; background:var(--col); flex-shrink:0; }
/* Entrate e spese */
.ag-preview .panel.ag-ent-testa{ display:flex; flex-direction:row; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; padding-block:12px; text-align:left; }
.ag-preview .ag-ent-testa .ag-tabs{ margin:0; }
.ag-preview .ag-periodo{ margin:0; }
.ag-preview .ag-kpi4{ grid-template-columns:repeat(4, minmax(0,1fr)); }
@media (max-width:900px){ .ag-preview .ag-kpi4{ grid-template-columns:repeat(2, minmax(0,1fr)); } }
.ag-preview .ag-delta{ display:block; margin-top:4px; font-size:11.5px; color:var(--gray); }
.ag-preview .ag-delta.su{ color:#4ADE9A; }
.ag-preview .ag-delta.giu{ color:#FF7AA8; }
.ag-preview button.ag-delta{ background:none; border:0; padding:0; font:inherit; font-size:11.5px; text-align:left; cursor:pointer; text-decoration:underline; text-decoration-color:var(--accent-1); text-underline-offset:3px; }
.ag-preview .ag-margine{ border-color:rgba(255,106,0,0.45); }
.ag-preview .ag-legenda-fin{ display:flex; gap:12px; font-size:11.5px; color:var(--gray); }
.ag-preview .ag-legenda-fin span{ display:inline-flex; align-items:center; gap:6px; }
.ag-preview .ag-q{ width:10px; height:10px; border-radius:3px; display:inline-block; }
.ag-preview .ag-q.ent, .ag-preview .ag-b.ent, .ag-preview .ag-hb-val.ent{ background:linear-gradient(180deg, var(--accent-1), var(--accent-2)); }
.ag-preview .ag-q.spe, .ag-preview .ag-b.spe, .ag-preview .ag-hb-val.spe{ background:rgba(255,255,255,0.28); }
.ag-preview .ag-barre2{ display:grid; grid-template-columns:repeat(12, minmax(0,1fr)); gap:6px; height:170px; align-items:end; margin-top:8px; }
.ag-preview .ag-mese{ display:flex; flex-direction:column; align-items:center; gap:6px; height:100%; justify-content:flex-end; opacity:0.55; }
.ag-preview .ag-mese.nel-periodo{ opacity:1; }
.ag-preview .ag-coppia{ display:flex; align-items:flex-end; gap:2px; height:100%; width:100%; justify-content:center; }
.ag-preview .ag-b{ width:42%; max-width:14px; border-radius:4px 4px 0 0; min-height:2px; }
.ag-preview .ag-mese-nome{ font-size:10.5px; color:var(--gray-dim); text-transform:uppercase; }
.ag-preview .ag-hbarre{ display:flex; flex-direction:column; gap:10px; margin-top:10px; }
.ag-preview .ag-hbarra{ display:grid; grid-template-columns:minmax(0,1.2fr) minmax(0,1.6fr) 72px; gap:10px; align-items:center; font-size:12.5px; }
.ag-preview .ag-hb-nome{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--white); }
.ag-preview .ag-hb-traccia{ height:8px; border-radius:999px; background:rgba(255,255,255,0.06); overflow:hidden; }
.ag-preview .ag-hb-val{ display:block; height:100%; border-radius:999px; }
.ag-preview .ag-hb-num{ font-variant-numeric:tabular-nums; color:var(--gray); font-size:12px; text-align:right; }
.ag-preview .ag-spese .money-row{ grid-template-columns:minmax(0,1fr) auto 92px; }
.ag-preview .ag-spese .money-row > :last-child{ justify-self:end; }
.ag-preview .money-amount{ font-variant-numeric:tabular-nums; }
.ag-preview .ag-nonpagati{ border-color:rgba(255,92,147,0.35); }
.ag-preview .ag-uscita{ color:var(--gray); }
.ag-preview .pay-badge.ag-ricorrente{ color:var(--gray); border-color:var(--border); background:transparent; }
.ag-preview .ag-check{ flex-direction:row !important; align-items:center; gap:8px; align-self:end; padding-bottom:10px; }

/* Attività: lavori da fare, scaduti, completati */
.ag-preview .ag-tabs{ display:flex; gap:6px; flex-wrap:wrap; margin-bottom:12px; }
.ag-preview .ag-tab{
  display:inline-flex; align-items:center; gap:7px; padding:7px 13px; min-height:34px; border-radius:999px;
  border:1px solid var(--border-soft); background:transparent; color:var(--gray); font:inherit; font-size:13px; font-weight:600; cursor:pointer;
}
.ag-preview .ag-tab:hover{ color:var(--white); border-color:var(--border); }
.ag-preview .ag-tab.on{ color:var(--white); background:rgba(255,255,255,0.06); border-color:rgba(255,255,255,0.3); }
.ag-preview .ag-tab-n{ min-width:20px; padding:1px 7px; border-radius:999px; background:rgba(255,255,255,0.08); font-size:11.5px; text-align:center; }
.ag-preview .ag-tab.allarme .ag-tab-n{ background:rgba(255,92,147,0.18); color:#FF7AA8; }
.ag-preview .ag-lavoro{ gap:10px; flex-wrap:wrap; }
.ag-preview .ag-lavoro .case-name{ flex:1; min-width:160px; }
.ag-preview .ag-badge-scaduto, .ag-preview .ag-badge-fatto{ font-size:11px; font-weight:700; padding:3px 9px; border-radius:999px; white-space:nowrap; }
.ag-preview .ag-badge-scaduto{ color:#FF7AA8; border:1px solid rgba(255,92,147,0.45); background:rgba(255,92,147,0.08); }
.ag-preview .ag-badge-fatto{ color:#4ADE9A; border:1px solid rgba(74,222,154,0.4); background:rgba(74,222,154,0.07); }
.ag-preview .ag-mini{ min-height:28px; padding:3px 11px; font-size:12px; }
.ag-preview .ag-mini svg{ width:14px; height:14px; }
.ag-preview .ag-lavoro-apri{
  background:none; border:0; padding:0; font:inherit; color:inherit; text-align:left; cursor:pointer;
  text-decoration:underline; text-decoration-color:transparent; text-underline-offset:3px;
}
.ag-preview .ag-lavoro-apri:hover{ text-decoration-color:var(--accent-1); }
.ag-preview .ag-lavoro-apri:focus-visible{ outline:2px solid var(--white); outline-offset:2px; border-radius:4px; }
.ag-preview .ag-scheda-titolo{ margin:6px 0 10px; font-size:17px; }
.ag-preview .ag-scheda-titolo:focus{ outline:none; }
.ag-preview .ag-scheda-dati{ display:grid; grid-template-columns:repeat(auto-fit, minmax(150px, 1fr)); gap:10px 18px; margin:0 0 14px; }
.ag-preview .ag-scheda-dati dt{ font-size:11px; font-weight:700; letter-spacing:0.06em; text-transform:uppercase; color:var(--gray-dim); }
.ag-preview .ag-scheda-dati dd{ margin:3px 0 0; font-size:13.5px; }
.ag-preview .ag-scheda-check{ border-top:1px solid var(--border-soft); padding-top:10px; }
.ag-preview .ag-legenda{ display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
.ag-preview .ag-filtro{
  display:inline-flex; align-items:center; gap:6px; padding:5px 11px; min-height:30px; border-radius:999px;
  border:1px solid var(--border-soft); background:transparent; color:var(--gray); font:inherit; font-size:12px; font-weight:600; cursor:pointer;
}
.ag-preview .ag-filtro:hover{ border-color:var(--border); color:var(--white); }
.ag-preview .ag-filtro.on{ border-color:rgba(255,255,255,0.35); background:rgba(255,255,255,0.06); color:var(--white); }
.ag-preview .ag-orari-chi{ margin:10px 0 0; font-size:12.5px; color:var(--gray); line-height:1.5; }
.ag-preview .ag-orari-chi strong{ color:var(--white); }
.ag-preview button.week-slot:hover{ border-color:var(--border); }
.ag-preview .week-slot.selected{ outline:2px solid var(--accent-1); outline-offset:-1px; }
.ag-preview button.cal-day{ border:0; background:transparent; font-family:inherit; cursor:pointer; }
.ag-preview button.cal-day:hover{ background:rgba(255,255,255,0.06); color:var(--white); }
.ag-preview button.cal-day.cal-today{ background:var(--gradient); }
.ag-preview .cal-day.selected{ box-shadow:inset 0 0 0 1.5px var(--accent-1); color:var(--white); }

/* righe cliccabili */
.ag-preview button.task-row{ width:100%; border:0; border-bottom:1px solid var(--border-soft); background:transparent; color:inherit; font-family:inherit; text-align:left; cursor:pointer; }
.ag-preview button.task-row:hover .task-name{ color:var(--white); }
.ag-preview .cat-row{ display:flex; align-items:center; gap:6px; }
.ag-preview .cat-row .cat-item{ flex:1; min-width:0; }
.ag-preview button.cat-item{ width:100%; background:transparent; font-family:inherit; text-align:left; cursor:pointer; }
.ag-preview button.cat-item:hover{ color:var(--white); border-color:var(--border); }
.ag-preview button.pay-badge{ font-family:inherit; cursor:pointer; background:transparent; }
.ag-preview button.pay-badge:hover{ filter:brightness(1.2); }

/* modulo "Nuova attività" */
.ag-preview .ag-form label{ display:flex; flex-direction:column; gap:5px; font-size:12px; font-weight:600; color:var(--gray); }
.ag-preview .ag-form input, .ag-preview .ag-form select{
  padding:9px 11px; border-radius:10px; border:1px solid var(--border); background:var(--surface-2);
  color:var(--white); font-family:inherit; font-size:13.5px; color-scheme:dark;
}
.ag-preview .ag-form input:focus, .ag-preview .ag-form select:focus{ outline:none; border-color:rgba(255,106,0,0.6); }
.ag-preview .ag-form select option{ background:#161616; }
.ag-preview .ag-form-row{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.ag-preview .ag-form-actions{ display:flex; justify-content:flex-end; gap:8px; }
.ag-preview .ag-nota{ margin:0; font-size:11.5px; color:var(--gray-dim); }

/* ‹ Oggi ›: un unico controllo compatto (settimana e mese del calendario) */
.ag-preview .ag-seg{
  display:inline-flex; align-items:stretch; flex-shrink:0; height:30px;
  border:1px solid var(--border); border-radius:999px; overflow:hidden;
}
.ag-preview .ag-seg button{
  display:inline-flex; align-items:center; justify-content:center; min-width:30px; padding:0 8px;
  border:0; background:transparent; color:var(--gray); font-family:inherit; font-size:12px; font-weight:600; cursor:pointer;
}
.ag-preview .ag-seg button + button{ border-left:1px solid var(--border-soft); }
.ag-preview .ag-seg button:hover{ color:var(--white); background:rgba(255,255,255,0.05); }
.ag-preview .ag-seg button:focus-visible{ outline:2px solid var(--white); outline-offset:-2px; }
.ag-preview .ag-seg svg{ width:14px; height:14px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.ag-preview .ag-seg-oggi{ padding:0 12px !important; }

/* ============ TELEFONO: tutta la larghezza, sezioni che scorrono, settimana da scorrere ============ */
@media (max-width:640px){
  /* via la cornice esterna (il gestionale vero ha già la sua impaginazione) */
  .ag-preview:not(.g-reale){ border:0; border-radius:0; background:none; padding:0; gap:10px; }
  .ag-preview .panel{ padding:14px; }
  /* le sezioni scorrono: la sfumatura a destra fa capire che ce ne sono altre */
  .ag-preview:not(.g-reale) .dash-sidebar{
    scrollbar-width:none;
    -webkit-mask-image:linear-gradient(90deg, #000 78%, transparent);
    mask-image:linear-gradient(90deg, #000 78%, transparent);
  }
  .ag-preview .dash-sidebar::-webkit-scrollbar{ display:none; }
  /* settimana: un giorno per scheda, larghe abbastanza da leggere, da scorrere col dito */
  .ag-preview .week-grid{ grid-template-columns:repeat(7, 124px); overflow-x:auto; scroll-snap-type:x proximity; padding-bottom:6px; scrollbar-width:thin; }
  .ag-preview .week-dow, .ag-preview .week-slot{ scroll-snap-align:start; }
  .ag-preview .week-slot{ font-size:12px; padding:8px; }
}
