/* =====================================================================
   Ermes Digital — Sistema Ticket
   Stile brand: rosso #c4191c, sfondo #f4f4f4, font Poppins/Sora
   ===================================================================== */

:root {
  --rosso: #c4191c;
  --rosso-hover: #7a1f1f;
  --lime: #c9f31d;
  --nero: #1a1a1a;
  --testo: #333;
  --testo-soft: #777;
  --sfondo: #f4f4f4;
  --bianco: #fff;
  --bordo: #e6e6e6;
  --ombra: 0 2px 10px rgba(0, 0, 0, .07);
  --raggio: 12px;
  --font-body: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-head: 'Sora', 'Poppins', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
/* niente guardie overflow su html/body: hidden rompe position:sticky della
   sidebar e clip blocca perfino lo scroll verticale (per spec, clip su un
   asse forza clip anche sull'altro se è visible). L'overflow orizzontale è
   prevenuto alla fonte: word-break sui testi lunghi, min-width:0 sui figli
   di grid e tabelle che scorrono nel proprio .table-wrap. */
html, body { max-width: 100%; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--testo);
  background: var(--sfondo);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--nero); line-height: 1.25; overflow-wrap: anywhere; }
/* testi con email, URL e codici lunghi non devono mai sfondare i contenitori */
.card, .side-box, .bubble, td, .sub, .meta, .mono, .tcard .info, label { overflow-wrap: break-word; word-break: break-word; }
a { color: var(--rosso); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ---- Header pubblico ------------------------------------------------- */
.topbar {
  background: var(--nero);
  color: #fff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; color: #fff; font-family: var(--font-head); font-weight: 600; }
.topbar .brand img { height: 36px; display: block; }
.topbar .brand span { font-size: 14px; opacity: .85; }
.topbar nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.topbar nav a {
  color: #ddd; padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 500;
}
.topbar nav a:hover, .topbar nav a.active { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.topbar nav a.cta { background: var(--rosso); color: #fff; }
.topbar nav a.cta:hover { background: var(--rosso-hover); }
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; justify-content: center; }
  .topbar .brand span { display: none; }
  /* su mobile la navigazione passa alla barra in basso */
  .topbar nav { display: none; }

  /* spaziature compatte e piena larghezza sugli schermi piccoli */
  .container { padding: 16px 12px 50px; }
  .card { padding: 18px 14px; border-radius: 10px; }
  .hero { padding: 22px 10px 16px; }
  .admin-head { gap: 8px; }
  .admin-head h1 { font-size: 19px; }
  .toolbar input[type=text] { max-width: none; flex: 1 1 160px; }
  .toolbar { gap: 8px; }
  .form-row { gap: 0 12px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat b { font-size: 22px; }
  .msg { gap: 8px; }
  .msg .avatar { width: 30px; height: 30px; font-size: 11.5px; }
  .msg .bubble { padding: 11px 12px; }
  .msg .meta { gap: 6px; }
  .thread { gap: 10px; }
  .side-box { padding: 14px; }
  .atts { gap: 6px; }
  .att { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .quick-filters { display: flex; width: 100%; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .quick-filters .pill { white-space: nowrap; }
  .pagination a, .pagination span { padding: 6px 10px; font-size: 12.5px; }
  .modal { padding: 20px 16px; }
}

/* ---- App bar mobile (PWA) ---------------------------------------------- */
.appbar { display: none; }
@media (max-width: 640px) {
  .appbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    display: flex; justify-content: space-around; align-items: stretch;
    background: var(--nero);
    border-top: 1px solid rgba(255, 255, 255, .1);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .appbar a {
    flex: 1; max-width: 120px;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: #aaa; font-size: 11px; font-weight: 500;
    padding: 5px 4px; border-radius: 10px; text-decoration: none;
  }
  .appbar a svg { width: 22px; height: 22px; }
  .appbar a.active { color: #fff; }
  .appbar a.active svg { color: var(--lime); }
  .appbar a:active { background: rgba(255, 255, 255, .08); }
  body.has-appbar { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
}

/* ---- Banner installazione PWA ------------------------------------------- */
#pwa-banner { display: none; }
@media (max-width: 820px) {
  #pwa-banner {
    position: fixed; left: 10px; right: 10px; z-index: 99;
    bottom: calc(80px + env(safe-area-inset-bottom));
    display: flex; align-items: center; gap: 12px;
    background: var(--nero); color: #fff;
    border-radius: 14px; padding: 12px 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
  }
  #pwa-banner[hidden] { display: none; }
  #pwa-banner img { width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0; }
  #pwa-banner .txt { flex: 1; min-width: 0; }
  #pwa-banner .txt b { display: block; font-size: 14px; }
  #pwa-banner .txt span { font-size: 12px; color: #bbb; line-height: 1.35; display: block; }
  #pwa-banner .close {
    background: none; border: none; color: #888; font-size: 18px;
    padding: 4px 6px; cursor: pointer; flex-shrink: 0;
  }
}

/* ---- Contenitori ------------------------------------------------------ */
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; flex: 1; }
.container.narrow { max-width: 680px; }

.card {
  background: var(--bianco);
  border-radius: var(--raggio);
  box-shadow: var(--ombra);
  padding: 26px;
  margin-bottom: 20px;
}
.card h2 { margin-bottom: 6px; font-size: 20px; }
.card .sub { color: var(--testo-soft); font-size: 13.5px; margin-bottom: 18px; }

/* ---- Hero pubblico ------------------------------------------------------ */
.hero { text-align: center; padding: 34px 16px 26px; }
.hero h1 { font-size: clamp(26px, 4.5vw, 38px); margin-bottom: 10px; }
.hero h1 em { color: var(--rosso); font-style: normal; }
.hero p { color: var(--testo-soft); max-width: 560px; margin: 0 auto; }

/* ---- Form -------------------------------------------------------------- */
label { display: block; font-weight: 500; font-size: 13.5px; margin: 14px 0 5px; color: var(--nero); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #ccc;
  border-radius: 9px;
  font: inherit;
  color: var(--testo);
  background: #fff;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--rosso); }
textarea { min-height: 130px; resize: vertical; }
::placeholder { color: #999; }
.hint { font-size: 12.5px; color: var(--testo-soft); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.honeypot { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }

.btn {
  display: inline-block;
  background: var(--rosso);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 12px 26px;
  font: 600 14.5px var(--font-body);
  cursor: pointer;
  transition: background .15s, transform .1s;
  text-decoration: none;
}
.btn:hover { background: var(--rosso-hover); color: #fff; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.secondary { background: #fff; color: var(--nero); border: 1.5px solid #ccc; }
.btn.secondary:hover { border-color: var(--nero); background: #fafafa; }
.btn.small { padding: 7px 14px; font-size: 13px; border-radius: 7px; }
.btn.ghost { background: transparent; color: var(--rosso); border: 1.5px solid var(--rosso); }
.btn.ghost:hover { background: var(--rosso); color: #fff; }
.btn.dark { background: var(--nero); }
.btn.dark:hover { background: #000; }
.btn:disabled { opacity: .55; cursor: wait; }

/* ---- Flash ---------------------------------------------------------------- */
.flash { padding: 13px 18px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; font-weight: 500; }
.flash.success { background: #e7f6e7; color: #1d6b2f; border: 1px solid #bfe5c4; }
.flash.error { background: #fdeaea; color: #a11417; border: 1px solid #f3c2c3; }

/* ---- Badge stati ------------------------------------------------------------ */
.badge {
  display: inline-block; padding: 3px 11px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge.nuovo { background: #fdeaea; color: var(--rosso); }
.badge.aperto { background: #e8f0fd; color: #1d4fb8; }
.badge.in_lavorazione { background: #fff3e0; color: #b26a00; }
.badge.in_attesa { background: #f3e8fd; color: #7b2fb8; }
.badge.risolto { background: #e7f6e7; color: #1d6b2f; }
.badge.chiuso { background: #ececec; color: #666; }
.badge.priority-alta { background: #fff3e0; color: #b26a00; }
.badge.priority-urgente { background: #fdeaea; color: var(--rosso); }
.badge.gray { background: #ececec; color: #666; }
.badge.lime { background: var(--lime); color: var(--nero); }

/* ---- Tabelle ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--testo-soft); padding: 10px 12px; border-bottom: 2px solid var(--bordo); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--bordo); vertical-align: middle; }
tr:hover td { background: #fafafa; }
tr.filter-row td { padding: 6px 8px; background: #fafafa; }
tr.filter-row input, tr.filter-row select { padding: 7px 10px; font-size: 13px; border-radius: 7px; min-width: 90px; width: 100%; }
tr.filter-row:hover td { background: #fafafa; }
th a:hover { color: var(--rosso) !important; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--rosso); }
th.sortable[data-dir=asc]::after { content: ' ▲'; font-size: 9px; }
th.sortable[data-dir=desc]::after { content: ' ▼'; font-size: 9px; }
td .sub { color: var(--testo-soft); font-size: 12.5px; }

/* ---- Layout admin ---------------------------------------------------------------- */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; background: var(--nero); color: #ccc; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand img { height: 32px; }
.sidebar .brand small { display: block; color: #888; font-size: 11px; margin-top: 6px; letter-spacing: .06em; text-transform: uppercase; }
.sidebar nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.sidebar nav .sez { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #777; padding: 14px 10px 5px; }
.sidebar nav a {
  display: flex; align-items: center; justify-content: space-between;
  color: #ccc; padding: 9px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 2px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--rosso); color: #fff; }
.sidebar .foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; color: #999; }
.sidebar .foot a { color: #ccc; }
.admin-main { flex: 1; min-width: 0; padding: 26px 28px 60px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-head h1 { font-size: 23px; }
.count-pill { background: var(--rosso); color: #fff; font-size: 11px; border-radius: 99px; padding: 1px 8px; font-weight: 600; }

/* ---- Admin mobile: header + drawer + bottom bar --------------------------- */
.admin-topbar, .admin-backdrop, .admin-appbar { display: none; }
@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }

  .admin-topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 90;
    background: var(--nero); padding: 10px 14px;
  }
  .admin-topbar img { height: 26px; display: block; }
  .admin-topbar .burger {
    background: none; border: none; color: #fff; cursor: pointer; padding: 6px;
    display: flex; flex-direction: column; gap: 4px;
  }
  .admin-topbar .burger span { display: block; width: 22px; height: 2px; background: #fff; border-radius: 2px; }

  /* la sidebar diventa un drawer off-canvas */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 272px; height: 100dvh;
    z-index: 120; overflow-y: auto;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 4px 0 30px rgba(0, 0, 0, .4);
  }
  .admin-shell.menu-open .sidebar { transform: none; }
  .admin-backdrop {
    position: fixed; inset: 0; z-index: 110;
    background: rgba(0, 0, 0, .55);
  }
  .admin-shell.menu-open .admin-backdrop { display: block; }
  .sidebar nav a { padding: 12px 12px; font-size: 15px; }

  .admin-main { padding: 16px 12px calc(84px + env(safe-area-inset-bottom)); }

  /* bottom bar admin */
  .admin-appbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    display: flex; justify-content: space-around; align-items: stretch;
    background: var(--nero);
    border-top: 1px solid rgba(255, 255, 255, .1);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .admin-appbar a, .admin-appbar button {
    flex: 1; max-width: 110px;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: #aaa; font-size: 11px; font-weight: 500;
    padding: 5px 4px; border-radius: 10px; text-decoration: none;
    background: none; border: none; font-family: inherit; cursor: pointer;
    position: relative;
  }
  .admin-appbar svg { width: 22px; height: 22px; }
  .admin-appbar a.active { color: #fff; }
  .admin-appbar a.active svg { color: var(--lime); }
  .admin-appbar .dot {
    position: absolute; top: 2px; right: 22px;
    background: var(--rosso); color: #fff; font-size: 10px; font-weight: 700;
    border-radius: 99px; padding: 0 5px; line-height: 15px; min-width: 15px;
  }
}

/* ---- Dashboard stats --------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: #fff; border-radius: var(--raggio); box-shadow: var(--ombra); padding: 18px;
  border-top: 3px solid var(--bordo);
}
.stat b { display: block; font-size: 28px; font-family: var(--font-head); color: var(--nero); }
.stat span { font-size: 12.5px; color: var(--testo-soft); }
.stat.rosso { border-top-color: var(--rosso); }
.stat.blu { border-top-color: #1d4fb8; }
.stat.arancio { border-top-color: #b26a00; }
.stat.verde { border-top-color: #1d6b2f; }
.stat.lime { border-top-color: var(--lime); }

/* ---- Thread messaggi ------------------------------------------------------------------ */
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 12px; }
.msg .avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff; background: var(--testo-soft);
}
.msg.client .avatar { background: #1d4fb8; }
.msg.operator .avatar { background: var(--rosso); }
.msg.ai .avatar { background: var(--nero); }
.msg.system .avatar { background: #bbb; }
.msg .bubble {
  background: #fff; border-radius: 12px; box-shadow: var(--ombra);
  padding: 14px 17px; flex: 1; min-width: 0;
}
.msg.internal .bubble { background: #fffbe8; border: 1px dashed #e5c94a; }
.msg .meta { font-size: 12px; color: var(--testo-soft); margin-bottom: 6px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.msg .meta b { color: var(--nero); }
.msg .body { white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; }
.msg.system .bubble { background: transparent; box-shadow: none; padding: 4px 0; }
.msg.system .body { font-size: 13px; color: var(--testo-soft); font-style: italic; white-space: normal; }
.atts { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.att {
  display: inline-flex; align-items: center; gap: 7px;
  background: #f6f6f6; border: 1px solid var(--bordo); border-radius: 8px;
  padding: 6px 12px; font-size: 12.5px; color: var(--nero);
}
.att:hover { border-color: var(--rosso); text-decoration: none; }
.att small { color: var(--testo-soft); }

/* ---- Ticket detail layout -------------------------------------------------------------- */
.detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.detail-grid > div { min-width: 0; } /* i figli di grid non devono allargare la pagina */
@media (max-width: 980px) { .detail-grid { grid-template-columns: 1fr; } }
.side-box { background: #fff; border-radius: var(--raggio); box-shadow: var(--ombra); padding: 18px; margin-bottom: 16px; }
.side-box h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--testo-soft); margin-bottom: 12px; }
.side-box .riga { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 5px 0; }
.side-box .riga span:first-child { color: var(--testo-soft); }

/* ---- Tabs ------------------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--bordo); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a {
  padding: 9px 18px; font-size: 14px; font-weight: 500; color: var(--testo-soft);
  border-bottom: 2.5px solid transparent; margin-bottom: -2px;
}
.tabs a.active { color: var(--rosso); border-bottom-color: var(--rosso); }
.tabs a:hover { text-decoration: none; color: var(--nero); }

/* ---- Pending mail card -------------------------------------------------------------------- */
.pending-mail { border-left: 4px solid var(--rosso); }
.pending-mail .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.mail-body-preview {
  background: #fafafa; border: 1px solid var(--bordo); border-radius: 8px;
  padding: 12px 14px; font-size: 13.5px; white-space: pre-wrap; max-height: 180px; overflow-y: auto; margin-top: 10px;
}

/* ---- Ticket list cards (portale) ------------------------------------------------------------ */
.tlist { display: flex; flex-direction: column; gap: 12px; }
.tcard {
  background: #fff; border-radius: var(--raggio); box-shadow: var(--ombra);
  padding: 18px 20px; display: flex; justify-content: space-between; gap: 14px; align-items: center;
  color: inherit;
}
.tcard:hover { text-decoration: none; box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.tcard .info { min-width: 0; }
.tcard .code { font-size: 12px; color: var(--testo-soft); font-weight: 600; letter-spacing: .03em; }
.tcard .subj { font-weight: 600; color: var(--nero); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard .when { font-size: 12.5px; color: var(--testo-soft); }

/* ---- Login box ---------------------------------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--nero); padding: 20px; }
.auth-box { background: #fff; border-radius: 16px; padding: 36px; width: 100%; max-width: 400px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.auth-box .logo {
  text-align: center;
  margin: -36px -36px 20px;
  padding: 26px 20px;
  background: var(--nero);
  border-radius: 16px 16px 0 0;
}
.auth-box .logo img { height: 44px; }
.auth-box h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.auth-box .sub { text-align: center; color: var(--testo-soft); font-size: 13.5px; margin-bottom: 14px; }
.auth-box .btn { width: 100%; margin-top: 18px; }

/* ---- Footer ---------------------------------------------------------------------------------------- */
.footer { text-align: center; padding: 26px 16px; color: var(--testo-soft); font-size: 12.5px; }
.footer a { color: var(--testo-soft); text-decoration: underline; }

/* ---- Misc -------------------------------------------------------------------------------------------- */
.muted { color: var(--testo-soft); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.pre-box {
  background: #1e1e1e; color: #e8e8e8; border-radius: 10px; padding: 16px;
  font-family: ui-monospace, Menlo, monospace; font-size: 12.5px;
  white-space: pre-wrap; word-wrap: break-word; max-height: 480px; overflow-y: auto;
}
.pagination { display: flex; gap: 6px; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 7px 13px; border-radius: 7px; background: #fff; box-shadow: var(--ombra); font-size: 13.5px;
}
.pagination .current { background: var(--rosso); color: #fff; font-weight: 600; }
.inline-form { display: inline; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input[type=text] { max-width: 260px; }
.toolbar select { width: auto; }
details.editor { margin-top: 8px; }
details.editor summary { cursor: pointer; font-size: 13px; color: var(--rosso); font-weight: 500; }
details.editor .inner { padding-top: 10px; }
.file-label {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 10px;
  font-size: 13.5px; color: var(--testo-soft); cursor: pointer;
}
.ai-draft-box { background: #f2f7ff; border: 1px solid #c6dbff; border-radius: 10px; padding: 14px; margin-top: 12px; font-size: 14px; white-space: pre-wrap; display: none; }
/* ---- Filtri rapidi stato (segmented control) -------------------------------- */
.quick-filters {
  display: inline-flex; flex-wrap: wrap; gap: 2px;
  background: #e8e8e8; border-radius: 11px; padding: 3px;
  margin-bottom: 16px;
}
.quick-filters .pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--testo-soft);
  transition: background .12s, color .12s;
}
.quick-filters .pill:hover { color: var(--nero); background: rgba(255, 255, 255, .6); text-decoration: none; }
.quick-filters .pill.active {
  background: #fff; color: var(--nero); font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .14);
}
.quick-filters .pill span { font-size: 11px; font-weight: 700; color: #9a9a9a; }
.quick-filters .pill.active span { color: var(--rosso); }
.quick-filters .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.quick-filters .st-nuovo .dot { background: var(--rosso); }
.quick-filters .st-aperto .dot { background: #1d4fb8; }
.quick-filters .st-in_lavorazione .dot { background: #b26a00; }
.quick-filters .st-in_attesa .dot { background: #7b2fb8; }
.quick-filters .st-risolto .dot { background: #1d6b2f; }
.quick-filters .st-chiuso .dot { background: #999; }

/* ---- Barra di caricamento PJAX --------------------------------------------- */
#pjax-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--rosso); z-index: 400; opacity: 0;
  transition: width .25s ease, opacity .3s ease;
}
#pjax-progress.on {
  opacity: 1; width: 75%;
  transition: width 6s cubic-bezier(.08, .74, .11, 1), opacity .1s;
}

/* ---- Modale di conferma HTML ---------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0, 0, 0, .55);
  display: none; align-items: center; justify-content: center; padding: 18px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px; padding: 26px;
  width: 100%; max-width: 440px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .35);
  animation: modal-in .18s ease;
}
@keyframes modal-in { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 18px; margin-bottom: 10px; }
.modal .msg { font-size: 14px; white-space: pre-line; color: var(--testo); margin-bottom: 6px; }
.modal .word-check { margin-top: 14px; }
.modal .word-check label { font-size: 13px; }
.modal .word-check input { text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.modal .btn.danger { background: #7a1f1f; }
.modal .btn.danger:hover { background: #5d1414; }

.spin { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
.btn.secondary .spin, .btn.ghost .spin { border-color: rgba(0,0,0,.2); border-top-color: var(--nero); }
@keyframes spin { to { transform: rotate(360deg); } }
