/* ============================================
   CRM - Foglio di stile
   Palette: inchiostro petrolio + ambra operativa
   ============================================ */

:root {
  --ink: #16262e;         /* petrolio scuro (sidebar) */
  --ink-2: #1f3540;
  --paper: #f4f5f4;       /* fondo pagina */
  --card: #ffffff;
  --line: #dfe3e2;
  --text: #24313a;
  --muted: #75828a;
  --accent: #0e7c6b;      /* verde petrolio azioni */
  --accent-dark: #0a5f52;
  --amber: #b97a13;
  --blue: #2563a8;
  --green: #2e7d4f;
  --red: #b3423a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--paper);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; letter-spacing: -0.01em; }
h2 {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); margin: 0 0 0.9rem; font-weight: 600;
}
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }
.muted { color: var(--muted); font-size: 0.88em; }

/* ---- Layout ---- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 215px; flex-shrink: 0; background: var(--ink); color: #cfd8dc;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand {
  padding: 1.3rem 1.25rem; font-weight: 700; font-size: 1.15rem; color: #fff;
  letter-spacing: 0.14em; text-transform: uppercase; border-bottom: 1px solid var(--ink-2);
}
.sidebar nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0.4rem 0; }
.sidebar nav::-webkit-scrollbar { width: 8px; }
.sidebar nav::-webkit-scrollbar-thumb { background: var(--ink-2); border-radius: 4px; }
.sidebar nav { scrollbar-width: thin; scrollbar-color: var(--ink-2) transparent; }
.nav-sec {
  margin: 0; padding: 0.85rem 1.25rem 0.3rem; font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.09em; color: #6d818b;
}
.sidebar nav a {
  display: block; padding: 0.5rem 1.25rem; color: #b9c6cc; font-size: 0.92rem;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { color: #fff; text-decoration: none; background: var(--ink-2); }
.sidebar nav a.active { color: #fff; border-left-color: var(--accent); background: var(--ink-2); }
.sidebar-foot { flex-shrink: 0; padding: 0.9rem 1.25rem; border-top: 1px solid var(--ink-2); font-size: 0.85rem; }
.sidebar-foot .who { color: #fff; }
.sidebar-foot .who span { display: block; color: #8fa0a8; font-size: 0.78rem; }
.sidebar-foot .logout {
  display: inline-block; margin-top: 0.6rem; padding: 0.4rem 0.95rem;
  border: 1px solid var(--ink-2); border-radius: 6px; color: #cfd8dc;
}
.sidebar-foot .logout:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.content { flex: 1; padding: 1.6rem 2rem; max-width: 1250px; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }

/* ---- Pannelli e tabelle ---- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1.1rem 1.25rem; margin-bottom: 1.2rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); padding: 0.45rem 0.6rem; border-bottom: 2px solid var(--line); }
td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.t-right { text-align: right; }

/* ---- Statistiche ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.9rem; margin-bottom: 1.4rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1rem; color: inherit; border-top: 3px solid var(--accent); }
.stat:hover { text-decoration: none; border-color: var(--accent); }
.stat.s-amber { border-top-color: var(--amber); }
.stat.s-blue { border-top-color: var(--blue); }
.stat-n { display: block; font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-l { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }

/* ---- Form ---- */
label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.15rem; }
input, select, textarea {
  width: 100%; padding: 0.5rem 0.6rem; margin-top: 0.2rem;
  border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.form-grid .span2 { grid-column: span 2; }
.inline-form { display: flex; gap: 0.6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 180px; margin: 0; }
.inline-form select { width: auto; margin: 0; }
.searchbar { display: flex; gap: 0.6rem; margin-bottom: 1.2rem; }
.searchbar input { max-width: 380px; margin: 0; }
.actions-row { display: flex; gap: 0.6rem; }

/* ---- Bottoni ---- */
.btn {
  display: inline-block; padding: 0.5rem 0.95rem; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; color: var(--text); font: inherit;
  font-size: 0.88rem; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #256842; color: #fff; }
.btn-danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 0.28rem 0.6rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* ---- Badge di stato ---- */
.badge {
  display: inline-block; padding: 0.12rem 0.55rem; border-radius: 99px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.03em; white-space: nowrap;
}
.b-richiesta       { background: #f6ead2; color: #8a5a0c; }
.b-presa_in_carico { background: #dbe8f6; color: #1d4f87; }
.b-eseguita        { background: #dcefe3; color: #226340; }
.b-nuovo           { background: #e8e4f4; color: #4c3d8f; }
.b-contattato      { background: #dbe8f6; color: #1d4f87; }
.b-in_trattativa   { background: #f6ead2; color: #8a5a0c; }
.b-convertito      { background: #dcefe3; color: #226340; }
.b-perso           { background: #f4dcda; color: #8f322b; }
.b-aperta          { background: #dbe8f6; color: #1d4f87; }
.b-chiusa          { background: #e7e9e8; color: #5a6570; }
.b-bassa           { background: #e7e9e8; color: #5a6570; }
.b-media           { background: #f6ead2; color: #8a5a0c; }
.b-alta            { background: #f4dcda; color: #8f322b; }

/* ---- Filtri ---- */
.filterbar { display: flex; gap: 0.45rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.chip {
  padding: 0.3rem 0.8rem; border: 1px solid var(--line); border-radius: 99px;
  background: #fff; color: var(--text); font-size: 0.83rem;
}
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---- Kanban ---- */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start; }
.kcol { background: #edefee; border-radius: 8px; padding: 0.7rem; border-top: 4px solid var(--line); }
.k-richiesta       { border-top-color: var(--amber); }
.k-presa_in_carico { border-top-color: var(--blue); }
.k-eseguita        { border-top-color: var(--green); }
.kcol-head { display: flex; justify-content: space-between; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); padding: 0.2rem 0.3rem 0.7rem; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 0.7rem 0.8rem; margin-bottom: 0.6rem; }
.kcard-title { font-weight: 600; color: var(--text); display: block; }
.kcard-meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.kcard-act { margin-top: 0.55rem; }
.kempty { text-align: center; padding: 1rem 0; }

/* ---- Flash, timeline, varie ---- */
.flash { padding: 0.65rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash-ok  { background: #dcefe3; color: #226340; border: 1px solid #b9dcc6; }
.flash-err { background: #f4dcda; color: #8f322b; border: 1px solid #e5bcb8; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 0.5rem 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.timeline li:last-child { border-bottom: 0; }
.collapsible { display: none; }
.collapsible.open { display: block; }

/* ---- Login ---- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--ink); }
.login-card { background: #fff; border-radius: 10px; padding: 2.2rem 2.4rem; width: 100%; max-width: 380px; }
.login-brand { font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.4rem; }
.login-card h1 { margin-bottom: 1.2rem; }
.login-card label { margin-bottom: 0.8rem; }
.login-card .btn { margin-top: 0.4rem; }

/* ---- Mobile ---- */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { display: flex; flex-wrap: wrap; padding: 0.3rem; overflow: visible; min-height: 0; }
  .sidebar nav a { border-left: 0; border-bottom: 3px solid transparent; padding: 0.5rem 0.8rem; }
  .sidebar nav a.active { border-bottom-color: var(--accent); }
  .nav-sec { display: none; }
  .sidebar-foot { display: flex; justify-content: space-between; align-items: center; }
  .sidebar-foot .logout { margin: 0; }
  .content { padding: 1rem; }
  .two-col, .kanban, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  table { display: block; overflow-x: auto; }
}

/* ---- Assegnazione richieste ---- */
.filter-sep { width: 1px; background: var(--line); margin: 0 0.3rem; }
.assign-panel form { align-items: center; }
.assign-current { align-self: center; margin-right: 0.4rem; }

/* ---- Impostazioni / branding ---- */
.brand img { max-height: 42px; max-width: 165px; display: block; }
.login-logo { max-height: 60px; max-width: 220px; display: block; margin: 0 auto 0.8rem; }
.color-input { height: 42px; padding: 0.2rem; cursor: pointer; }
.logo-preview { background: var(--ink); border-radius: 8px; padding: 1rem; display: inline-block; }
.logo-preview img { max-height: 60px; max-width: 240px; display: block; }

/* ---- Multi-azienda ---- */
.company-switch { padding: 0.75rem 1.1rem; border-bottom: 1px solid var(--ink-2); }
.company-switch select {
  width: 100%; margin: 0; background: var(--ink-2); color: #fff;
  border: 1px solid var(--ink-2); font-size: 0.85rem;
}
.check-row { display: flex; gap: 0.7rem; flex-wrap: wrap; align-items: center; }
.check-item { display: inline-flex; align-items: center; gap: 0.3rem; margin: 0; color: var(--text); font-size: 0.86rem; white-space: nowrap; }
.check-item input { width: auto; margin: 0; }
.lab-inline { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.35rem; }

/* ---- v5: card lavorazioni e modifica in linea ---- */
.kcard-client { font-weight: 700; font-size: 0.95rem; color: var(--text); margin-bottom: 0.1rem; }
.kcard-title { font-weight: 500; color: var(--accent); }
.edit-row td { background: #f2f6f5; border-left: 3px solid var(--accent); }
.done-by { display: block; font-size: 0.78rem; color: var(--muted); }

/* ---- v6: notifiche ---- */
.nbadge {
  display: inline-block; min-width: 18px; text-align: center;
  background: #c0392b; color: #fff; border-radius: 99px;
  font-size: 0.7rem; font-weight: 700; padding: 0.05rem 0.35rem; margin-left: 0.3rem;
}
.notif-unread { background: #f2f6f5; border-left: 3px solid var(--accent); padding-left: 0.6rem !important; }
.notif-unread a { font-weight: 600; }

/* ---- v7: permessi ed eliminazioni ---- */
.t-center { text-align: center; }
.t-center input { width: auto; }
.kcard-desc { font-size: 0.84rem; color: var(--text); margin: 0.15rem 0 0.1rem; }

/* Casella di spunta in linea nei filtri (registro attività) */
.chk-inline { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; font-size: 0.92rem; }
.chk-inline input { margin: 0; }

/* Navigazione fra le pagine degli elenchi */
.pager { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-top: 1rem; }
.pager .chip { text-decoration: none; }
.list-info { color: #6b7a80; font-size: 0.88rem; margin: 0 0 0.6rem; }

/* Avviso di possibile duplicato in fase di creazione */
.panel-warn { border-left: 4px solid #d98324; background: #fff9f2; }
.dup-list { margin: 0.4rem 0 0.9rem; padding-left: 1.1rem; }
.dup-list li { margin-bottom: 0.25rem; }

/* Il nome utente nel menu porta al profilo personale */
a.who { text-decoration: none; display: block; }
a.who:hover { opacity: 0.85; }

/* Campo data promemoria nella riga dei form lavorazione */
.inline-date { display: inline-flex; flex-direction: column; font-size: 0.8rem; color: #6b7a80; gap: 0.15rem; }
.inline-date input { font-size: 0.95rem; }
.appt-tag { display: inline-block; margin-top: 0.2rem; font-size: 0.82rem; color: #b06a00; background: #fff4e0; padding: 0.05rem 0.4rem; border-radius: 4px; }

/* Numero di versione sotto il tasto Esci */
.app-version { margin-top: 0.6rem; padding-top: 0.5rem; border-top: 1px solid var(--ink-2); font-size: 0.78rem; color: #9fb0b8; text-align: center; letter-spacing: 0.03em; }

/* ---- Preventivi, listino, segnalatori (v11) ---- */
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.panel-accent { border-left: 4px solid var(--accent); background: #f0f7f5; }
.nowrap { white-space: nowrap; }
.row-off { opacity: 0.55; }

/* Etichette tipo prodotto e stato preventivo */
.tag { display: inline-block; padding: 0.08rem 0.5rem; border-radius: 99px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
.tag-one { background: #e8e4f4; color: #4c3d8f; }
.tag-rec { background: #d7ece6; color: #145c4c; }
.tag-bozza     { background: #e7ebee; color: #4a5a66; }
.tag-inviato   { background: #dbe8f6; color: #1d4f87; }
.tag-accettato { background: #dcefe3; color: #226340; }
.tag-rifiutato { background: #f4dcda; color: #8f322b; }

/* Righe preventivo e aggiunta */
.quote-lines th, .quote-lines td { vertical-align: top; }
.line-add { display: flex; gap: 0.5rem; align-items: center; margin: 0.3rem 0 1rem; flex-wrap: wrap; }
.line-add select { flex: 1; min-width: 160px; margin: 0; }
.line-add input { margin: 0; }
.line-add input.qty { width: 90px; flex: none; }

/* Riepilogo totali del preventivo */
.totals { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 0.8rem; }
.totrow { display: flex; justify-content: space-between; padding: 0.25rem 0; }
.totrow.comm { color: var(--amber); }
.totrow strong { font-size: 1.05rem; }

/* Riepilogo intestazione preventivo in sola lettura (portale segnalatore) */
.readonly-head { gap: 0.8rem 1rem; }
.readonly-head .span2 { padding: 0.2rem 0; }

/* Riga totale nei report */
.row-total td { border-top: 2px solid var(--line); background: #f6f8f9; }
.head-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ============================================
   v16 — CALENDARIO
   ============================================ */

/* Intestazione e navigazione */
.cal-nav { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.cal-title { font-size: 1.35rem; margin-left: 0.5rem; text-transform: capitalize; }
.cal-arrow { font-size: 1.05rem; line-height: 1; padding: 0.32rem 0.62rem; }
.page-head .actions-row { flex-wrap: wrap; align-items: center; }

/* Filtri per tipo di evento */
.cal-filters { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.cal-filter {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.28rem 0.75rem;
  border: 1px solid var(--line); border-radius: 99px; background: #fff;
  color: var(--muted); font-size: 0.83rem;
}
.cal-filter:hover { text-decoration: none; border-color: var(--c); color: var(--text); }
.cal-filter.on { border-color: var(--c); color: var(--text); background: #fff; font-weight: 600; }
.cal-filter .cal-dot { background: var(--c); opacity: 0.28; }
.cal-filter.on .cal-dot { opacity: 1; }
.cal-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; display: inline-block; }
.cal-count { color: var(--muted); font-size: 0.83rem; margin-left: auto; }

/* ---- Vista mese ---- */
.cal-month { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.cal-week-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: #f7f9f9; border-bottom: 1px solid var(--line); }
.cal-week-head div {
  padding: 0.45rem 0.6rem; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted); font-weight: 600; text-align: center;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-day {
  min-height: 116px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 0.25rem 0.3rem 0.4rem; display: flex; flex-direction: column; gap: 0.15rem;
}
.cal-grid > .cal-day:nth-child(7n) { border-right: 0; }
.cal-day.cal-out { background: #fafbfb; }
.cal-day.cal-out .cal-daynum { color: #a9b4b9; }
.cal-day-head { display: flex; align-items: center; justify-content: space-between; min-height: 22px; }
.cal-daynum {
  display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px;
  border-radius: 50%; font-size: 0.85rem; font-weight: 600; color: var(--text);
}
.cal-daynum:hover { background: #eaefef; text-decoration: none; }
.cal-today .cal-daynum { background: var(--accent); color: #fff; }
.cal-add {
  border: 0; background: none; color: var(--muted); font-size: 1.05rem; line-height: 1;
  cursor: pointer; padding: 0 0.25rem; opacity: 0; border-radius: 4px;
}
.cal-day:hover .cal-add { opacity: 1; }
.cal-add:hover { color: var(--accent); background: #eef4f3; }
.cal-day-list { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* Pillola evento */
.cal-chip {
  display: flex; align-items: center; gap: 0.32rem; width: 100%; text-align: left;
  border: 0; background: none; padding: 0.11rem 0.25rem; border-radius: 4px;
  font: inherit; font-size: 0.79rem; color: var(--text); cursor: pointer;
  white-space: nowrap; overflow: hidden;
}
.cal-chip:hover { background: #eef2f2; }
.cal-chip .cal-dot { width: 8px; height: 8px; }
.cal-chip-h { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.cal-chip-t { overflow: hidden; text-overflow: ellipsis; }
.cal-chip.cal-done { opacity: 0.55; }
.cal-chip.cal-done .cal-chip-t { text-decoration: line-through; }
.cal-more { font-size: 0.76rem; color: var(--muted); padding-left: 0.3rem; }

/* ---- Viste settimana e giorno ---- */
.cal-time { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.cal-time-head, .cal-allday { display: grid; grid-template-columns: 58px repeat(var(--cols, 7), 1fr); }
.cal-cols-1 { --cols: 1; }
.cal-cols-7 { --cols: 7; }
.cal-time-head { border-bottom: 1px solid var(--line); background: #f7f9f9; }
.cal-dayhead { padding: 0.4rem; text-align: center; border-left: 1px solid var(--line); }
.cal-dayname { display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.cal-allday { border-bottom: 1px solid var(--line); min-height: 34px; }
.cal-allday-col { border-left: 1px solid var(--line); padding: 3px; display: flex; flex-direction: column; gap: 2px; }
.cal-gutter-cell { font-size: 0.66rem; color: var(--muted); padding: 0.4rem 0.3rem; text-align: right; }
.cal-time-body {
  display: grid; grid-template-columns: 58px repeat(var(--cols, 7), 1fr);
  max-height: 62vh; overflow-y: auto; position: relative;
}
.cal-gutter-h { height: 46px; text-align: right; padding-right: 0.4rem; position: relative; }
.cal-gutter-h span { font-size: 0.68rem; color: var(--muted); position: relative; top: -0.45em; }
.cal-col { position: relative; border-left: 1px solid var(--line); }
.cal-slot { height: 46px; border-bottom: 1px solid #eef1f1; cursor: pointer; }
.cal-slot:hover { background: #f4f8f7; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: #d0453c; z-index: 3; }
.cal-now::before { content: ''; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: #d0453c; }
.cal-ev {
  position: absolute; z-index: 2; overflow: hidden; text-align: left; cursor: pointer;
  border: 0; border-left: 3px solid var(--c); border-radius: 4px;
  background: var(--cbg, #eef2f2); color: var(--text);
  font: inherit; font-size: 0.78rem; padding: 0.15rem 0.35rem; margin-left: 2px;
}
.cal-ev:hover { background: var(--cbg2, #e4eaea); }
.cal-ev-h { display: block; font-size: 0.7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-ev-t { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev.cal-done { opacity: 0.6; }
.cal-ev.cal-done .cal-ev-t { text-decoration: line-through; }

/* ---- Popup ---- */
.cal-modal {
  position: fixed; inset: 0; background: rgba(22, 38, 46, 0.45); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.cal-modal[hidden] { display: none; }
.cal-modal-box {
  background: #fff; border-radius: 10px; padding: 1.3rem 1.5rem; width: 100%; max-width: 430px;
  max-height: 86vh; overflow-y: auto; position: relative; box-shadow: 0 18px 48px rgba(0,0,0,0.24);
}
.cal-modal-wide { max-width: 640px; }
.cal-close {
  position: absolute; top: 0.5rem; right: 0.6rem; border: 0; background: none;
  font-size: 1.4rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0.15rem 0.35rem;
}
.cal-close:hover { color: var(--text); }
body.cal-locked { overflow: hidden; }
.cal-detail h3 { margin: 0.15rem 0 0.35rem; font-size: 1.15rem; }
.cal-detail p { margin: 0.28rem 0; font-size: 0.92rem; }
.cal-detail-kind { display: flex; align-items: center; gap: 0.4rem; font-size: 0.76rem !important;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.cal-detail-when { color: var(--text); font-weight: 600; }
.cal-detail-desc { white-space: pre-line; background: #f6f8f8; border-radius: 6px; padding: 0.5rem 0.65rem; }
.cal-detail-act { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; align-items: center; }

/* ---- Elenco eventi (eventi.php) ---- */
.ev-when { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ev-kind { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--muted); }
.ev-row-past { opacity: 0.62; }
.ev-title { border: 0; background: none; padding: 0; font: inherit; font-weight: 600;
  color: var(--accent); cursor: pointer; text-align: left; }
.ev-title:hover { text-decoration: underline; }
.ev-daysep td { background: #f5f8f8; font-weight: 600; font-size: 0.82rem; color: var(--text);
  text-transform: capitalize; }

/* ---- Mobile ---- */
@media (max-width: 900px) {
  /* Su schermo stretto il mese resta leggibile scorrendolo in orizzontale */
  .cal-month { overflow-x: auto; }
  .cal-week-head, .cal-grid { min-width: 640px; }
  .cal-day { min-height: 84px; }
  .cal-add { opacity: 1; }
  .cal-chip-t { font-size: 0.74rem; }
  .cal-time-head, .cal-allday, .cal-time-body { grid-template-columns: 44px repeat(var(--cols, 7), minmax(96px, 1fr)); }
  .cal-time-body { max-height: 70vh; }
  .cal-count { margin-left: 0; }
}
