/* SupportDesk 1.4.3 · static/css/app.css */
/* SupportDesk – interfaccia
   Carattere: Atkinson Hyperlegible (Braille Institute, licenza OFL), scelto per la leggibilità
   di chi legge ticket tutto il giorno. Elemento distintivo: il misuratore SLA (.sla). */

@font-face { font-family: "Atkinson"; src: url("../fonts/AtkinsonHyperlegible-Regular.d3663984591b.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("../fonts/AtkinsonHyperlegible-Bold.b3cb9b97c232.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("../fonts/AtkinsonHyperlegible-Italic.bea10bef0e9a.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  color-scheme: light;
  --ink: #17262f;
  --ink-2: #44545e;
  --ink-3: #66757e;
  --paper: #edf1f2;
  --surface: #ffffff;
  --surface-2: #f6f8f9;
  --line: #d5dde0;
  --line-strong: #b9c5ca;
  --signal: #0b6e86;
  --signal-hover: #085a6e;
  --signal-soft: #dcecf0;
  --on-signal: #ffffff;
  --side: #17262f;
  --side-ink: #c9d5da;
  --side-ink-strong: #ffffff;
  --side-hover: #22353f;
  --side-active: #0b6e86;

  --st-new: #2a62b8;     --st-new-bg: #e1eaf7;
  --st-open: #0b6e86;    --st-open-bg: #dcecf0;
  --st-pending: #9a6514; --st-pending-bg: #f6ead2;
  --st-resolved: #2f7d46;--st-resolved-bg: #ddeee2;
  --st-closed: #5f6b73;  --st-closed-bg: #e6eaec;
  --danger: #c2362f;     --danger-bg: #f8e1df;
  --warn: #b7791f;       --warn-bg: #f7ebd3;

  /* serie del grafico (palette validata, slot 1 e 2) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e3e9eb;

  --radius: 6px;
  --radius-s: 4px;
  --shadow: 0 1px 0 rgba(23, 38, 47, .06);
  --font: "Atkinson", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --side-w: 236px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --ink: #e6edf0; --ink-2: #b4c2c8; --ink-3: #8c9ca3;
    --paper: #0f1a20; --surface: #16242c; --surface-2: #1b2b34;
    --line: #2a3d47; --line-strong: #3b5260;
    --signal: #3fb0cc; --signal-hover: #6ac4da; --signal-soft: #173a46; --on-signal: #06222b;
    --side: #0b141a; --side-ink: #a9b8bf; --side-hover: #16242c; --side-active: #1f6f84;
    --st-new: #7aa6ea; --st-new-bg: #1b2d47; --st-open: #4dbad4; --st-open-bg: #143843;
    --st-pending: #e0a94e; --st-pending-bg: #3a2d16; --st-resolved: #6cc488; --st-resolved-bg: #173523;
    --st-closed: #9aa8af; --st-closed-bg: #243239; --danger: #f07c74; --danger-bg: #42201e;
    --warn: #e0a94e; --warn-bg: #3a2d16;
    --series-1: #3987e5; --series-2: #d95926; --grid: #24353e;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e6edf0; --ink-2: #b4c2c8; --ink-3: #8c9ca3;
  --paper: #0f1a20; --surface: #16242c; --surface-2: #1b2b34;
  --line: #2a3d47; --line-strong: #3b5260;
  --signal: #3fb0cc; --signal-hover: #6ac4da; --signal-soft: #173a46; --on-signal: #06222b;
  --side: #0b141a; --side-ink: #a9b8bf; --side-hover: #16242c; --side-active: #1f6f84;
  --st-new: #7aa6ea; --st-new-bg: #1b2d47; --st-open: #4dbad4; --st-open-bg: #143843;
  --st-pending: #e0a94e; --st-pending-bg: #3a2d16; --st-resolved: #6cc488; --st-resolved-bg: #173523;
  --st-closed: #9aa8af; --st-closed-bg: #243239; --danger: #f07c74; --danger-bg: #42201e;
  --warn: #e0a94e; --warn-bg: #3a2d16;
  --series-1: #3987e5; --series-2: #d95926; --grid: #24353e;
  --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 15px/1.5 var(--font); font-variant-numeric: tabular-nums;
}
a { color: var(--signal); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--signal-hover); }
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 700; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* --- Struttura -------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-ink); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.1rem 1rem; color: var(--side-ink-strong); text-decoration: none; }
.brand:hover { color: var(--side-ink-strong); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.brand-sub { display: block; font-size: .78rem; font-weight: 400; color: var(--side-ink); }
.side-search { padding: 0 .9rem .9rem; }
.side-search input {
  width: 100%; border: 1px solid #2c4350; background: #0f1c23; color: #fff; border-radius: var(--radius-s);
  padding: .5rem .65rem; font: inherit; font-size: .9rem;
}
.side-search input::placeholder { color: #8ea1aa; }
.nav { padding: .25rem .5rem 1rem; }
.nav-group + .nav-group { margin-top: .9rem; }
.nav-title { font-size: .8rem; color: #8ea1aa; padding: .25rem .6rem; }
.nav a {
  display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border-radius: var(--radius-s);
  color: var(--side-ink); text-decoration: none; font-size: .95rem;
}
.nav a:hover { background: var(--side-hover); color: var(--side-ink-strong); }
.nav a.active { background: var(--side-active); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav .count { margin-left: auto; font-size: .78rem; background: rgba(255,255,255,.12); color: #fff; border-radius: 99px; padding: 0 .45rem; min-width: 1.5rem; text-align: center; }
.nav .count.hot { background: #c2362f; }
.side-foot { margin-top: auto; padding: .9rem 1.1rem; font-size: .8rem; color: #8ea1aa; border-top: 1px solid #22353f; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .6rem 1.5rem; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar .menu-btn { display: none; }
.topbar form.inline { display: flex; gap: .4rem; align-items: center; }
.topbar .input { width: 240px; padding: .4rem .6rem; }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: var(--signal-soft); color: var(--signal); font-weight: 700; font-size: .8rem;
}
.avatar.s { width: 24px; height: 24px; font-size: .68rem; }
.content { padding: 1.5rem; width: 100%; max-width: 1480px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head p { margin: .25rem 0 0; color: var(--ink-2); }
.crumbs { font-size: .88rem; color: var(--ink-3); margin-bottom: .35rem; }
.crumbs a { color: var(--ink-3); }

.impersonation {
  background: var(--warn-bg); color: var(--ink); border-bottom: 1px solid var(--warn);
  padding: .5rem 1.5rem; display: flex; gap: 1rem; align-items: center; justify-content: space-between;
}

/* --- Pannelli --------------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 1rem; }
.panel-body { padding: 1.1rem; }
.panel-body.flush { padding: 0; }
.panel + .panel { margin-top: 1rem; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: 1rem; align-items: start; }
.grid-2 > div > .panel + .panel { margin-top: 1rem; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.empty { padding: 2rem 1.1rem; text-align: center; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: .25rem; }

/* --- Striscia indicatori (dashboard) --------------------------------- */
.gauges {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; box-shadow: var(--shadow);
}
.gauge { padding: .9rem 1.1rem; border-left: 1px solid var(--line); text-decoration: none; color: inherit; display: block; }
.gauge:first-child { border-left: 0; }
a.gauge:hover { background: var(--surface-2); color: inherit; }
.gauge .label { font-size: .85rem; color: var(--ink-2); }
.gauge .value { font-size: 1.9rem; font-weight: 700; line-height: 1.15; margin-top: .15rem; }
.gauge .hint { font-size: .8rem; color: var(--ink-3); }
.gauge.alert .value { color: var(--danger); }
.gauge.hero .value { font-size: 3rem; }
.gauge .flag { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--danger); font-weight: 700; }

/* --- Misuratore SLA: elemento distintivo ------------------------------ */
.sla { display: grid; gap: 3px; min-width: 96px; }
.sla-track { height: 4px; border-radius: 2px; background: var(--signal-soft); overflow: hidden; }
.sla-fill { height: 100%; background: var(--signal); border-radius: 2px; }
.sla.warn .sla-track { background: var(--warn-bg); }
.sla.warn .sla-fill { background: var(--warn); }
.sla.over .sla-track { background: var(--danger-bg); }
.sla.over .sla-fill { background: var(--danger); width: 100% !important; }
.sla-text { font-size: .78rem; color: var(--ink-3); white-space: nowrap; }
.sla.over .sla-text { color: var(--danger); font-weight: 700; }
.sla.done .sla-track { background: var(--st-resolved-bg); }
.sla.done .sla-fill { background: var(--st-resolved); width: 100% !important; }

/* --- Badge ------------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 700; white-space: nowrap;
  padding: .1rem .5rem; border-radius: 99px; background: var(--st-closed-bg); color: var(--st-closed);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.st-new { background: var(--st-new-bg); color: var(--st-new); }
.st-open { background: var(--st-open-bg); color: var(--st-open); }
.st-pending { background: var(--st-pending-bg); color: var(--st-pending); }
.st-resolved { background: var(--st-resolved-bg); color: var(--st-resolved); }
.st-closed { background: var(--st-closed-bg); color: var(--st-closed); }
.prio { font-size: .82rem; font-weight: 700; display: inline-flex; align-items: center; gap: .3rem; color: var(--ink-2); white-space: nowrap; }
.prio svg { width: 14px; height: 14px; }
.prio-urgent { color: var(--danger); }
.prio-high { color: var(--warn); }
.prio-low { color: var(--ink-3); font-weight: 400; }
.tag { display: inline-block; font-size: .76rem; padding: 0 .45rem; border-radius: var(--radius-s); border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--surface-2); }
.tag-blue { border-color: #8fb2e6; } .tag-green { border-color: #8cc59c; } .tag-amber { border-color: #dfb56c; }
.tag-red { border-color: #e39a94; } .tag-violet { border-color: #b3a6e6; } .tag-teal { border-color: #84c3d2; }
.pill-count { font-size: .75rem; color: var(--ink-3); }

/* --- Pulsanti e campi ------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 700; font-size: .92rem;
  padding: .5rem .95rem; border-radius: var(--radius-s); border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn.primary { background: var(--signal); border-color: var(--signal); color: var(--on-signal); }
.btn.primary:hover { background: var(--signal-hover); border-color: var(--signal-hover); color: var(--on-signal); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.s { padding: .3rem .6rem; font-size: .85rem; }
.btn svg { width: 16px; height: 16px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--signal); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

.input, .select, textarea.input {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-s); padding: .5rem .65rem; min-height: 38px;
}
textarea.input { resize: vertical; line-height: 1.5; }
.input:focus, .select:focus { outline: 2px solid var(--signal); outline-offset: -1px; border-color: var(--signal); }
.select[multiple] { min-height: 8rem; }
.file { font: inherit; font-size: .9rem; color: var(--ink-2); max-width: 100%; }
.checkbox { width: 16px; height: 16px; accent-color: var(--signal); }
.field { margin-bottom: 1rem; }
.field > label, .field-label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: .3rem; }
.field.check { display: flex; gap: .5rem; align-items: flex-start; }
.field.check label { font-weight: 400; margin: 0; }
.help { font-size: .82rem; color: var(--ink-3); margin-top: .25rem; }
.errorlist { list-style: none; margin: .3rem 0 0; padding: 0; color: var(--danger); font-size: .85rem; font-weight: 700; }
.form-errors { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius-s); padding: .6rem .8rem; margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.choices { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem .9rem; }
.choices label { font-weight: 400; display: inline-flex; gap: .35rem; align-items: center; }
.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: 1.25rem; flex-wrap: wrap; }
.form-actions .spacer { flex: 1; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* --- Messaggi flash --------------------------------------------------- */
.flash { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; }
.flash li { padding: .65rem .9rem; border-radius: var(--radius-s); border-left: 4px solid var(--signal); background: var(--surface); box-shadow: var(--shadow); }
.flash .success { border-left-color: var(--st-resolved); }
.flash .warning { border-left-color: var(--warn); }
.flash .error { border-left-color: var(--danger); }

/* --- Tabelle ---------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
.data th {
  text-align: left; font-size: .82rem; font-weight: 700; color: var(--ink-2); padding: .6rem .75rem;
  border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
.data th a { color: inherit; text-decoration: none; }
.data th a:hover { color: var(--signal); }
.data td { padding: .65rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.data tr:last-child td { border-bottom: 0; }
.data tbody tr:hover { background: var(--surface-2); }
.data .num { text-align: right; }
.data td.check, .data th.check { width: 36px; padding-right: 0; }
.t-subject { font-weight: 700; color: var(--ink); text-decoration: none; display: block; overflow-wrap: anywhere; }
.t-subject:hover { color: var(--signal); }
.t-meta { font-size: .82rem; color: var(--ink-3); margin-top: .15rem; }
.t-ref { font-weight: 700; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
tr.awaiting td:first-child { box-shadow: inset 3px 0 0 var(--signal); }
tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.dot-unread { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--signal); margin-right: .35rem; vertical-align: middle; }

/* --- Lista compatta (dashboard) -------------------------------------- */
.qlist { list-style: none; margin: 0; padding: 0; }
.qlist li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem 1rem; padding: .75rem 1.1rem; border-bottom: 1px solid var(--line); }
.qlist li:last-child { border-bottom: 0; }
.qlist .who { font-size: .82rem; color: var(--ink-3); }
.events li { grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; }
.ev-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); margin-top: .1rem; }
.ev-icon svg { width: 13px; height: 13px; }
.ev-warning .ev-icon { background: var(--warn-bg); color: var(--warn); }
.ev-error .ev-icon { background: var(--danger-bg); color: var(--danger); }

/* --- Filtri ----------------------------------------------------------- */
.filters { padding: .9rem 1.1rem; display: grid; gap: .75rem; }
.filters-main { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(140px, 1fr)) auto; gap: .6rem; align-items: end; }
.filters-more { display: grid; grid-template-columns: repeat(5, minmax(140px, 1fr)); gap: .6rem; align-items: end; }
.filters label { font-size: .8rem; color: var(--ink-2); font-weight: 700; display: block; margin-bottom: .2rem; }
.quick { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.toggle-chip { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line-strong); border-radius: 99px; padding: .25rem .75rem; font-size: .88rem; cursor: pointer; background: var(--surface); }
.toggle-chip:has(input:checked) { border-color: var(--signal); background: var(--signal-soft); color: var(--ink); font-weight: 700; }
.toggle-chip input { accent-color: var(--signal); margin: 0; }
details.more > summary { cursor: pointer; color: var(--signal); font-size: .9rem; list-style: none; display: inline-flex; align-items: center; gap: .3rem; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary { margin-bottom: .6rem; }
.bulkbar { display: none; padding: .6rem 1.1rem; background: var(--signal-soft); border-bottom: 1px solid var(--line); gap: .6rem; align-items: center; flex-wrap: wrap; }
.bulkbar.show { display: flex; }
.bulkbar .select { width: auto; min-height: 32px; padding: .25rem .5rem; }

.pagination { display: flex; gap: .4rem; align-items: center; justify-content: space-between; padding: .75rem 1.1rem; border-top: 1px solid var(--line); font-size: .9rem; color: var(--ink-2); }

/* --- Dettaglio ticket ------------------------------------------------- */
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.ticket-title { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.ticket-title .ref { color: var(--ink-3); font-weight: 400; }
.thread { display: grid; gap: .9rem; }
.msg { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.msg-head { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.msg-head .who { font-weight: 700; }
.msg-head .when { margin-left: auto; font-size: .85rem; color: var(--ink-3); }
.msg-body { padding: 1rem; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 78ch; }
.msg.staff { border-left: 3px solid var(--signal); }
.msg.customer { border-left: 3px solid var(--line-strong); }
.msg.internal { background: var(--warn-bg); border-color: var(--warn); border-left: 3px solid var(--warn); }
.msg.internal .msg-head { border-bottom-color: rgba(183,121,31,.35); }
.msg.system { background: var(--surface-2); border-style: dashed; }
.msg-quote { padding: 0 1rem 1rem; }
.msg-quote summary { cursor: pointer; font-size: .85rem; color: var(--ink-3); }
.msg-quote .pre { color: var(--ink-3); font-size: .9rem; border-left: 2px solid var(--line-strong); padding-left: .75rem; margin-top: .5rem; }
.attachments { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0 1rem 1rem; }
.att { display: inline-flex; align-items: center; gap: .45rem; border: 1px solid var(--line); border-radius: var(--radius-s); padding: .35rem .6rem; font-size: .88rem; background: var(--surface-2); }
.att a { text-decoration: none; }
.att svg { width: 15px; height: 15px; color: var(--ink-3); }
.att form { display: inline; }
.att .link-btn { font-size: .78rem; color: var(--ink-3); }
.reply-box { margin-top: 1rem; }
.reply-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); }
.reply-tabs label { padding: .65rem 1rem; cursor: pointer; font-weight: 700; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; gap: .4rem; align-items: center; }
.reply-tabs input { position: absolute; opacity: 0; pointer-events: none; }
.reply-tabs label:has(input:checked) { color: var(--ink); border-bottom-color: var(--signal); }
.reply-box.internal .reply-tabs label:has(input:checked) { border-bottom-color: var(--warn); }
.reply-box.internal textarea { background: var(--warn-bg); }
.props dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .45rem .9rem; font-size: .92rem; }
.props dt { color: var(--ink-3); }
.props dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.timeline li { padding: .4rem 0; border-bottom: 1px dashed var(--line); color: var(--ink-2); }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--ink-3); display: block; font-size: .78rem; }

/* --- Grafico ---------------------------------------------------------- */
.chart { position: relative; }
.chart-legend { display: flex; gap: 1rem; font-size: .85rem; color: var(--ink-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.key { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.key.s1 { background: var(--series-1); } .key.s2 { background: var(--series-2); }
.columns { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); align-items: end; height: 150px; gap: 4px; border-bottom: 1px solid var(--line-strong); background-image: linear-gradient(var(--grid) 1px, transparent 1px); background-size: 100% 50%; }
.col { display: flex; justify-content: center; align-items: flex-end; gap: 2px; height: 100%; position: relative; cursor: default; }
.col:hover { background: var(--surface-2); }
.col i { display: block; width: min(10px, 40%); border-radius: 4px 4px 0 0; min-height: 0; }
.col i.s1 { background: var(--series-1); } .col i.s2 { background: var(--series-2); }
.col-labels { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; font-size: .72rem; color: var(--ink-3); text-align: center; margin-top: .3rem; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--paper); font-size: .8rem; padding: .4rem .55rem;
  border-radius: var(--radius-s); white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity .12s; z-index: 5;
}
.chart-tip.show { opacity: 1; }
.chart-tip .key { margin-right: .3rem; }
.bars-h { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.bars-h li { display: grid; grid-template-columns: 9rem minmax(0, 1fr) 2rem; gap: .6rem; align-items: center; font-size: .88rem; }
.bars-h .bar { height: 10px; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.bars-h .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Pagine di accesso ------------------------------------------------ */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 480px); }
.auth-side { background: var(--side); color: var(--side-ink); padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { color: #fff; font-size: 2.3rem; max-width: 16ch; line-height: 1.1; }
.auth-side p { max-width: 42ch; font-size: 1.05rem; }
.auth-side .trace { width: 100%; max-width: 520px; height: auto; margin: 2rem 0; }
.auth-main { background: var(--surface); padding: 3rem 2.5rem; display: flex; flex-direction: column; justify-content: center; }
.auth-main h2 { font-size: 1.4rem; margin-bottom: .35rem; }
.auth-main .sub { color: var(--ink-2); margin-bottom: 1.5rem; }
.auth-links { margin-top: 1.25rem; font-size: .92rem; display: grid; gap: .35rem; }
.remote-tools { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .88rem; color: var(--ink-2); }

/* --- Portale clienti -------------------------------------------------- */
.portal-top { background: var(--side); color: var(--side-ink); }
.portal-top .inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.5rem; flex-wrap: wrap; }
.portal-top nav { display: flex; gap: .25rem; }
.portal-top nav a { color: var(--side-ink); text-decoration: none; padding: .4rem .7rem; border-radius: var(--radius-s); }
.portal-top nav a:hover, .portal-top nav a.active { background: var(--side-hover); color: #fff; }
.portal-top .user-menu a, .portal-top .user-menu .link-btn { color: var(--side-ink); }
.portal-main { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1.5rem; }
.status-strip { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.status-strip a { text-decoration: none; padding: .45rem .9rem; border-radius: 99px; border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--surface); font-size: .92rem; }
.status-strip a.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.stars { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: .3rem; }
.stars input { position: absolute; opacity: 0; }
.stars label { font-size: 2rem; line-height: 1; cursor: pointer; color: var(--line-strong); }
.stars input:checked ~ label, .stars label:hover, .stars label:hover ~ label { color: #d99b00; }
.stars input:focus-visible + label { outline: 2px solid var(--signal); }
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; align-items: center; gap: .9rem; padding: .75rem 1.1rem; border-bottom: 1px solid var(--line); }
.doc-list li:last-child { border-bottom: 0; }
.ext { width: 42px; height: 48px; border-radius: 4px; border: 1px solid var(--line-strong); display: grid; place-items: end center; font-size: .7rem; font-weight: 700; padding-bottom: 5px; color: var(--ink-2); background: linear-gradient(225deg, var(--paper) 10px, var(--surface) 10px); flex: none; }

/* --- Responsive ------------------------------------------------------- */
@media (max-width: 1280px) {
  .gauges { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gauge:nth-child(4) { border-left: 0; }
  .gauge:nth-child(n+4) { border-top: 1px solid var(--line); }
  .filters-main { grid-template-columns: minmax(200px, 1fr) repeat(2, minmax(140px, 1fr)); }
  .filters-more { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
}
@media (max-width: 1080px) {
  .grid-2, .ticket-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: var(--side-w); transform: translateX(-100%); transition: transform .2s; z-index: 50; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { padding: .6rem 1rem; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar .hide-m { display: none; }
  .content { padding: 1rem; }
  .gauges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gauge { border-left: 0; border-top: 1px solid var(--line); }
  .gauge:nth-child(-n+2) { border-top: 0; }
  .gauge:nth-child(even) { border-left: 1px solid var(--line); }
  .gauge.hero .value { font-size: 2.3rem; }
  .filters-main, .filters-more, .form-grid, .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { display: none; }
  .auth-main { padding: 2rem 1.25rem; }
  .data .hide-m { display: none; }
  .bars-h li { grid-template-columns: 6rem minmax(0, 1fr) 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  .side, .topbar, .reply-box, .no-print { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
}

/* --- Correzioni dopo la revisione visiva ----------------------------- */
/* Dimensione predefinita delle icone a tratto (specificità zero: le regole dei componenti vincono). */
:where(svg[viewBox="0 0 24 24"]) { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.gauge .flag svg { width: 14px; height: 14px; }
.reply-tabs label { white-space: nowrap; }
.reply-tabs svg { width: 16px; height: 16px; }
.data td a:not(.btn) { text-decoration: none; }
.data td a:not(.btn):hover { text-decoration: underline; }
@media (max-width: 860px) {
  .topbar .hide-m, .topbar form.inline.hide-m { display: none; }
  .ticket-title { font-size: 1.35rem; }
}

.app-version { display: block; margin-top: .5rem; opacity: .7; font-size: .8em; }

/* Coda email in uscita */
.notice { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; margin: 0 0 1rem; border-radius: var(--radius-s);
  border-left: 4px solid var(--warn); background: var(--warn-bg); }
.notice.danger { border-left-color: var(--danger); background: var(--danger-bg); }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: .15rem; }
.ob { display: inline-block; font-size: .78rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.ob-queued, .ob-sending { background: var(--warn-bg); color: var(--warn); }
.ob-sent { background: transparent; color: var(--st-resolved); padding-left: 0; }
.ob-failed { background: var(--danger-bg); color: var(--danger); }
.ob-cancelled { color: var(--ink-3); }
table.outbox td { vertical-align: top; }
.delivery { font-size: .8rem; margin-left: auto; }
.delivery a { color: inherit; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .75rem; }
details.more.danger-zone > summary { color: var(--danger); cursor: pointer; }
