/* RadarPA — unico foglio di stile (gestionale). Palette: primario ciano #0088b0, neutri grigio-caldo. */

@font-face{font-family:"Titillium Web";font-style:normal;font-weight:400;font-display:swap;src:url("../fonts/TitilliumWeb-400-latin-ext.e08208d06e69.woff2") format("woff2");unicode-range:U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;}
@font-face{font-family:"Titillium Web";font-style:normal;font-weight:400;font-display:swap;src:url("../fonts/TitilliumWeb-400-latin.ecc0a99f1958.woff2") format("woff2");unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}
@font-face{font-family:"Titillium Web";font-style:normal;font-weight:600;font-display:swap;src:url("../fonts/TitilliumWeb-600-latin-ext.a24a5da127d5.woff2") format("woff2");unicode-range:U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;}
@font-face{font-family:"Titillium Web";font-style:normal;font-weight:600;font-display:swap;src:url("../fonts/TitilliumWeb-600-latin.ebf116db5193.woff2") format("woff2");unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}
@font-face{font-family:"Titillium Web";font-style:normal;font-weight:700;font-display:swap;src:url("../fonts/TitilliumWeb-700-latin-ext.8c2f35a6e803.woff2") format("woff2");unicode-range:U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;}
@font-face{font-family:"Titillium Web";font-style:normal;font-weight:700;font-display:swap;src:url("../fonts/TitilliumWeb-700-latin.8bdf6f4d57ea.woff2") format("woff2");unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;}

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --text: #1f2328;
  --text-2: #5c6470;
  --text-3: #8a919c;
  --line: #e4e7eb;
  --line-2: #eef0f3;
  --primary: #14a44a;
  --primary-hover: #118a3e;
  --primary-active: #0e7034;
  --primary-50: #e9f8ee;
  --primary-100: #c9eed6;
  --primary-700: #0f6e3b;
  --primary-800: #0b5230;
  --danger: #d6006c;
  --danger-50: #fff1f4;
  --danger-100: #ffdee6;
  --danger-700: #aa0b56;
  --success: #14a44a;
  --success-50: #e9f8ee;
  --success-700: #0f6e3b;
  --warn: #d68b00;
  --warn-50: #fff6e3;
  --warn-700: #8a5a00;
  --font: "Titillium Web", "Segoe UI", system-ui, sans-serif;
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(31, 35, 40, .06);
  --shadow-md: 0 4px 16px rgba(31, 35, 40, .08);
  --sidebar-w: 240px;
  --topbar-h: 60px;
}

[data-theme="dark"] {
  --bg: #15181c;
  --surface: #1d2126;
  --surface-2: #242930;
  --text: #e9ebee;
  --text-2: #aab1ba;
  --text-3: #7f8791;
  --line: #2f353d;
  --line-2: #292f36;
  --primary: #22b85a;
  --primary-hover: #2ccb67;
  --primary-active: #1ea04f;
  --primary-50: #17301f;
  --primary-100: #1e4a2d;
  --primary-700: #6fdc97;
  --primary-800: #9be8b8;
  --danger-50: #3a1526;
  --danger-100: #531b37;
  --danger-700: #ff86b8;
  --success-50: #17301f;
  --success-700: #6fdc97;
  --warn-50: #3a2b0c;
  --warn-700: #f2c05a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .5);
}
[data-theme="dark"] .table tbody tr:hover { background: var(--surface-2); }
[data-theme="dark"] .btn:hover { border-color: #3d444d; }

/* ── Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body:not(.ready) { visibility: hidden; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 26px; } h2 { font-size: 18px; } h3 { font-size: 16px; } h4 { font-size: 14px; }
p { margin: 0 0 12px; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }
img, svg { display: block; }
ul, ol { margin: 0; padding: 0; }
button { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary-100); }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── App shell (base.html) ────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px; text-decoration: none; color: var(--text); }
.logo:hover { text-decoration: none; color: var(--text); }
.logo-mark { width: 36px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center; overflow: hidden; }
.logo-mark img { width: 36px; height: 36px; }
.logo-mark .icon { width: 22px; height: 22px; stroke-width: 1.8; }
.logo-name { font-size: 20px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.logo-name span { color: var(--primary); }
.logo-sub { display: block; font-size: 11px; color: var(--text-3); margin-top: 3px; }
.logo-text { display: flex; flex-direction: column; }
.sidebar-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 0 12px; margin: 26px 0 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r-md); color: var(--text-2); font-weight: 600; font-size: 14px; text-decoration: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--primary-50); color: var(--primary-700); }
.nav a[aria-current="page"] .icon { color: var(--primary); }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; background: var(--danger-50); color: var(--danger-700); }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 8px; }
.sidebar-tools { display: flex; align-items: center; gap: 6px; padding: 0 4px; }
.sidebar-tools .btn-icon { width: 34px; height: 34px; }
.theme-switch { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.theme-switch button { width: 30px; height: 28px; border: 0; background: transparent; border-radius: 999px; display: grid; place-items: center; color: var(--text-3); cursor: pointer; }
.theme-switch button .icon { width: 15px; height: 15px; }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.user { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: var(--r-md); width: 100%; border: 0; background: transparent; cursor: pointer; text-align: left; }
.user:hover, .user[aria-expanded="true"] { background: var(--surface-2); }
.user-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-caret { color: var(--text-3); rotate: 180deg; }
.user-menu { position: relative; }
.menu { display: none; position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-md); padding: 6px; z-index: 20; }
.user-menu[data-open] .menu { display: block; }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; font-size: 13.5px; font-weight: 600; color: var(--text-2); border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: transparent; border-radius: var(--r-md); color: var(--text); font-weight: 600; font-size: 13.5px; text-decoration: none; cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.menu-item .icon { color: var(--text-3); width: 16px; height: 16px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-100); color: var(--primary-800); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.user-name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.user-role { font-size: 12px; color: var(--text-3); }
.user { text-decoration: none; color: inherit; }
.user:hover { text-decoration: none; color: inherit; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 16px; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-ente { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-2); }
.topbar-ente .icon { color: var(--text-3); }
.topbar-search { flex: 1; max-width: 460px; margin-left: auto; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar-date { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.content { padding: 28px; display: flex; flex-direction: column; gap: 20px; }

/* ── Intestazione pagina ──────────────────────────────── */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; min-height: 40px; }
.page-head p { margin: 4px 0 0; color: var(--text-2); max-width: 70ch; }
.crumbs { display: flex; gap: 6px; font-size: 13px; color: var(--text-3); margin-bottom: 4px; }
.crumbs a { color: var(--text-3); }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; white-space: nowrap; margin-bottom: -1px; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; text-decoration: none; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--primary-700); border-color: var(--primary); }
.tabs .count { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); }

/* ── Griglie ──────────────────────────────────────────── */
.grid { display: grid; gap: 20px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack-sm { gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1; }
.between { justify-content: space-between; }
@media (max-width: 1100px) { .grid-main, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 800px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; }
  .content { padding: 16px; }
}

/* ── Pannelli e card ──────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.panel-head h2, .panel-head h3 { margin: 0; }
.panel-head .sub { font-size: 13px; color: var(--text-3); margin-top: 2px; font-weight: 400; }
.panel-body { padding: 20px; }
.panel-body-flush { padding: 0; }
.panel-foot { padding: 12px 20px; border-top: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--text-2); flex-wrap: wrap; }
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.kpi-label { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.kpi-label .icon { width: 16px; height: 16px; color: var(--primary); }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-value.danger { color: var(--danger-700); }
.kpi-note { font-size: 12px; color: var(--text-3); }
.kpi-note a { color: inherit; text-decoration: underline; }
.card { display: flex; flex-direction: column; gap: 10px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--primary); text-decoration: none; color: inherit; box-shadow: var(--shadow-md); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-3); }
.card-title { font-size: 16px; font-weight: 700; line-height: 1.25; }
.card-text { font-size: 13px; color: var(--text-2); margin: 0; flex: 1; }
.card-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; font-size: 13px; }
.card-facts dt { color: var(--text-3); font-size: 12px; }
.card-facts dd { margin: 0; font-weight: 600; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line-2); }

/* ── Bottoni ──────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; text-decoration: none; font-weight: 600; font-size: 14px; line-height: 1.2; color: var(--text); background: var(--surface); border: 1px solid var(--line); padding: 8px 14px; border-radius: var(--r-md); white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); border-color: #d3d7dc; }
.btn:active { background: var(--line-2); }
.btn .icon { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-primary:active { background: var(--primary-active); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary-700); }
.btn-ghost:hover { background: var(--primary-50); border-color: transparent; color: var(--primary-800); }
.btn-danger { color: var(--danger-700); border-color: var(--danger-100); background: var(--danger-50); }
.btn-danger:hover { background: var(--danger-100); border-color: var(--danger-100); color: var(--danger-700); }
.btn-icon { width: 36px; height: 36px; padding: 0; position: relative; }
.btn-icon .icon { width: 18px; height: 18px; }
.btn-sm { font-size: 13px; padding: 5px 10px; }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-block { width: 100%; }
.dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }

/* ── Badge di stato ───────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.5; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-plain::before { display: none; }
.badge-ok { background: var(--success-50); color: var(--success-700); }
.badge-wait { background: var(--warn-50); color: var(--warn-700); }
.badge-late { background: var(--danger-50); color: var(--danger-700); }
.badge-info { background: var(--primary-50); color: var(--primary-800); }
.badge-neutral { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); color: var(--text); white-space: nowrap; }
.chip-outline { background: transparent; border-style: dashed; color: var(--text-2); }
.conf { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ── Form ─────────────────────────────────────────────── */
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.input { width: 100%; min-height: 38px; padding: 7px 12px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: #c9ced4; }
.input:focus-visible { border-color: var(--primary); outline: 2px solid var(--primary-100); outline-offset: 0; }
textarea.input { min-height: 100px; resize: vertical; line-height: 1.5; }
select.input { appearance: none; padding-right: 32px; background-image: url("../img/sprite.0a0801be87ce.svg#i-chevron"); background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; }
.search { position: relative; }
.search .icon { position: absolute; left: 11px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 36px; background: var(--surface-2); }
.search .input:focus-visible { background: var(--surface); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg-opt { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; line-height: 1.4; font-size: 13px; font-weight: 600; color: var(--text-2); border-radius: var(--r-sm); cursor: pointer; white-space: nowrap; }
.seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.seg-opt:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg-opt:not(:has(input:checked)):hover { color: var(--text); }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--primary); }
.seg-opt .count { font-size: 11px; color: var(--text-3); }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; cursor: pointer; padding: 8px 0; }
.check input { accent-color: var(--primary); width: 16px; height: 16px; margin: 2px 0 0; flex: none; }
.check + .check { border-top: 1px solid var(--line-2); }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 220px; }

/* ── Tabelle ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; line-height: 1.4; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfc; }
.table tr[hidden] { display: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .nowrap { white-space: nowrap; }
.table .obj { font-weight: 600; color: var(--text); display: block; min-width: 260px; }
.table .sub { display: block; font-size: 12px; color: var(--text-3); margin-top: 1px; }
.table a.obj:hover { color: var(--primary-700); text-decoration: none; }
.table .prot { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--primary-700); }
.table .late { color: var(--danger-700); font-weight: 600; }
.table .row-actions { display: flex; gap: 4px; justify-content: flex-end; }
tr.is-late td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.check-cell { width: 36px; }
.check-cell input { accent-color: var(--primary); width: 15px; height: 15px; margin: 0; display: block; }

/* ── Alert ────────────────────────────────────────────── */
.alert { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-radius: var(--r-md); border: 1px solid; font-size: 13.5px; }
.alert .icon { margin-top: 2px; }
.alert p { margin: 0; flex: 1; }
.alert strong { font-weight: 700; }
.alert-danger { background: var(--danger-50); border-color: var(--danger-100); color: var(--danger-700); }
.alert-info { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary-800); }
.alert-ok { background: var(--success-50); border-color: #c9ecd7; color: var(--success-700); }
.alert .btn { flex: none; align-self: center; }

/* ── Liste ────────────────────────────────────────────── */
.list { list-style: none; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.list li:last-child { border-bottom: 0; }
.list .lbl { display: flex; align-items: center; gap: 10px; min-width: 0; }
.list .lbl .icon { color: var(--text-3); width: 16px; height: 16px; }
.list .lbl a { color: var(--text); font-weight: 600; }
.list .lbl a:hover { color: var(--primary-700); }
.list .meta { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.list .n { font-weight: 700; font-variant-numeric: tabular-nums; }
.list .sub { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; }
.bars { list-style: none; display: grid; gap: 12px; }
.bars li { display: grid; grid-template-columns: 110px 1fr 36px; gap: 10px; align-items: center; font-size: 13px; }
.bars .track { height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.bars .fill { display: block; height: 100%; background: var(--primary); border-radius: 4px; width: var(--w, 0%); }
.bars .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.fact { padding: 14px 16px; background: var(--surface-2); border-radius: var(--r-md); margin-bottom: 12px; }
.fact-label { font-size: 12px; color: var(--text-3); font-weight: 600; margin-bottom: 4px; }
.fact-value { font-size: 20px; font-weight: 700; line-height: 1.15; }
.fact-value small { display: block; font-size: 12px; font-weight: 400; color: var(--text-3); margin-top: 2px; }
.reqs { list-style: none; display: grid; gap: 10px; }
.panel-body h4 { margin-bottom: 10px; }
.reqs li { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; font-size: 13.5px; }
.reqs .icon { width: 18px; height: 18px; margin-top: 1px; color: var(--success); }
.reqs li.no .icon { color: var(--danger); }
.reqs li.neutral .icon { color: var(--text-3); }
.defs { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; font-size: 13.5px; margin: 0; }
.defs dt { color: var(--text-3); }
.defs dd { margin: 0; }
.doc { font-size: 14px; line-height: 1.6; max-width: 72ch; }

/* ── Timeline ─────────────────────────────────────────── */
.timeline { list-style: none; position: relative; padding-left: 24px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding-bottom: 16px; font-size: 13.5px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--text-3); }
.timeline li.done::before { background: var(--primary); border-color: var(--primary); }
.timeline li.alert-step::before { background: var(--danger); border-color: var(--danger); }
.timeline li.pending::before { border-style: dashed; }
.timeline time { display: block; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.timeline .who { color: var(--text-3); }

/* ── Chat ─────────────────────────────────────────────── */
.chat-panel { display: flex; flex-direction: column; }
.chat-home { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 40px 0; min-height: calc(100vh - var(--topbar-h) - 56px); }
.chat-home-title { display: flex; align-items: center; gap: 14px; font-size: 34px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.chat-home-title .icon { width: 36px; height: 36px; color: var(--primary); stroke-width: 1.6; }
.chat-home .composer { width: min(820px, 100%); padding: 0; border: 0; background: transparent; }
.chat-home .composer-box { padding: 14px 16px; border-radius: 16px; box-shadow: var(--shadow-sm); }
.chat-home .composer textarea { font-size: 17px; min-height: 56px; }
.chat-home .chat-thread { width: min(820px, 100%); padding: 0; }
.chat-home .chat-thread:empty { display: none; }
.chat-home.has-thread { justify-content: flex-start; }
.chat-home.has-thread .chat-home-title, .chat-home.has-thread .suggestions { display: none; }
.chat-home.has-thread .chat-thread { flex: 1; }
.suggestions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: min(820px, 100%); }
.suggestion { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; }
.suggestion:hover { border-color: var(--primary); color: var(--text); }
.suggestion .icon { width: 14px; height: 14px; color: var(--primary); }
.composer-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.chat-page { display: flex; flex-direction: column; gap: 20px; min-height: calc(100vh - var(--topbar-h) - 56px); }
.chat-page .chat-thread { flex: 1; padding: 0; }
.chat-page .composer { padding: 0; border: 0; background: transparent; width: 100%; }
.chat-thread { flex: 1; padding: 24px; display: flex; flex-direction: column; gap: 22px; }
.msg { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; }
.msg-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); }
.msg-ai .msg-avatar { background: var(--primary); border-color: var(--primary); color: #fff; }
.msg-ai .msg-avatar .icon { width: 17px; height: 17px; }
.msg-who { font-size: 12px; color: var(--text-3); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.msg-who strong { color: var(--text); font-weight: 600; }
.msg-body { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 0 var(--r-lg) var(--r-lg) var(--r-lg); padding: 12px 16px; font-size: 14px; }
.msg-user .msg-body { background: var(--primary-50); border-color: var(--primary-100); }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body ul, .msg-body ol { padding-left: 1.3em; margin: 0 0 10px; }
.msg-body li { margin-bottom: 4px; }
.refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ref { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.ref:hover { border-color: var(--primary); color: var(--primary-700); text-decoration: none; }
.ref .icon { width: 14px; height: 14px; color: var(--primary); }
.ref .path { color: var(--text-3); font-weight: 400; }
.msg-actions { display: flex; gap: 4px; margin-top: 8px; }
.composer { padding: 16px 24px 20px; border-top: 1px solid var(--line-2); background: var(--surface); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.composer-box { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); padding: 10px 12px; display: grid; gap: 8px; }
.composer-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.composer-box .seg { padding: 2px; }
.composer textarea { width: 100%; border: 0; background: transparent; font: inherit; font-size: 15px; color: inherit; resize: none; min-height: 48px; padding: 4px; }
.composer textarea::placeholder { color: var(--text-3); }
.composer-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.composer-bar .seg { margin-right: auto; }
.composer-hint { font-size: 12px; color: var(--text-3); margin: 8px 0 0; }
.prompts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.prompt { display: grid; gap: 6px; padding: 14px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); cursor: pointer; }
.prompt:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.prompt-k { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--primary-700); }
.prompt-k .icon { width: 14px; height: 14px; }
.prompt-t { font-size: 13.5px; color: var(--text); line-height: 1.4; }
.hello h1 { font-size: 26px; }
.hello p { color: var(--text-2); margin: 4px 0 0; }
.draft textarea.input { min-height: 240px; font-size: 14px; line-height: 1.6; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.status code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: var(--surface-2); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--text); }
.news { list-style: none; }
.news li { padding: 12px 20px; border-bottom: 1px solid var(--line-2); display: grid; gap: 3px; }
.news li:last-child { border-bottom: 0; }
.news .src { font-size: 12px; color: var(--text-3); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.news a { color: var(--text); font-weight: 600; font-size: 14px; line-height: 1.3; }
.news a:hover { color: var(--primary-700); text-decoration: none; }
.news p { margin: 0; font-size: 12.5px; color: var(--text-2); }
.types { list-style: none; }
.types li { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 10px 20px; border-bottom: 1px solid var(--line-2); }
.types li:last-child { border-bottom: 0; }
.types .ico { width: 34px; height: 34px; border-radius: var(--r-md); background: var(--primary-50); color: var(--primary-700); display: grid; place-items: center; }
.types .ico .icon { width: 17px; height: 17px; }
.types a { color: var(--text); font-weight: 600; }
.types a:hover { color: var(--primary-700); text-decoration: none; }
.types .sub { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; }
.types .n { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.quote { margin: 0; padding: 12px 16px; border-left: 3px solid var(--primary); background: var(--surface-2); font-size: 13.5px; color: var(--text-2); font-style: italic; border-radius: 0 var(--r-md) var(--r-md) 0; }
.source { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); }
.source .icon { width: 13px; height: 13px; }
.empty { padding: 32px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ── Modale ───────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(15, 18, 22, .55); display: none; align-items: center; justify-content: center; padding: 24px; }
.modal-backdrop[data-open] { display: flex; }
.modal { width: min(880px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-md); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px 0; }
.modal-head h2 { font-size: 20px; }
.modal .tabs { padding: 0 24px; margin-top: 10px; }
.modal .tabs button:first-child { margin-left: -14px; }
.modal-body { padding: 24px; overflow: auto; }
.modal-foot { padding: 14px 24px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; }
[data-panel] { display: none; }
[data-panel][data-active] { display: block; }
.tabs button { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; margin-bottom: -1px; color: var(--text-2); font-weight: 600; border: 0; border-bottom: 2px solid transparent; background: transparent; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--primary-700); border-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-section { display: grid; gap: 14px; }
.form-section + .form-section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line-2); }
.form-section h4 { margin-bottom: 2px; }
.form-section .hint { font-size: 12.5px; color: var(--text-3); margin: 0; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; font-size: 13.5px; }
.toggle + .toggle { border-top: 1px solid var(--line-2); }
.toggle .sub { display: block; font-size: 12px; color: var(--text-3); }
.toggle input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; flex: none; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); transition: left .15s; }
.toggle input:checked { background: var(--primary); }
.toggle input:checked::after { left: 19px; }
.inline-table .table th:first-child, .inline-table .table td:first-child { padding-left: 0; }
.inline-table .table th:last-child, .inline-table .table td:last-child { padding-right: 0; }
.inline-table .table th { background: transparent; }
.new-user { margin: 16px 0 20px; padding: 18px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); display: grid; gap: 14px; }
.new-user h4 { margin: 0; }
.new-user .toggle { padding: 12px 0 0; border-top: 1px solid var(--line); }
.perms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.perms .check + .check { border-top: 0; }
@media (max-width: 720px) { .form-grid, .perms { grid-template-columns: minmax(0, 1fr); } }

/* ── Esplora archivio ─────────────────────────────────── */
.explorer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: start; }
.explorer > .chat-side { width: 360px; }
.explorer > [hidden] { display: none; }
.chat-home .chat-home-title + .chat-thread { margin-top: -8px; }
[data-panel] .chat-home { min-height: calc(100vh - var(--topbar-h) - 56px - 110px); }
@media (max-width: 1100px) { .explorer { grid-template-columns: minmax(0, 1fr); } .explorer > .chat-side { width: auto; position: static; max-height: none; } }
@media (max-width: 800px) { .explorer { grid-template-columns: minmax(0, 1fr); } }
.tree { list-style: none; padding: 8px; }
.tree li a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-md); color: var(--text-2); font-weight: 600; font-size: 13.5px; }
.tree li a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.tree li a[aria-current="true"] { background: var(--primary-50); color: var(--primary-700); }
.tree li a .icon { width: 16px; height: 16px; color: var(--text-3); }
.tree li a[aria-current="true"] .icon { color: var(--primary); }
.tree .n { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tree .sub { padding-left: 18px; list-style: none; }
.tree .sub a { font-weight: 400; padding: 6px 10px; }
.tree-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 10px 10px 4px; }
.file { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file .ico { width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center; flex: none; font-size: 9px; font-weight: 700; letter-spacing: .02em; }
.file .ico-pdf { background: var(--danger-50); color: var(--danger-700); }
.file .ico-doc { background: var(--primary-50); color: var(--primary-800); }
.file .ico-xls { background: var(--success-50); color: var(--success-700); }
.file .ico-dir { background: var(--surface-2); color: var(--text-2); }
.file .ico-dir .icon { width: 16px; height: 16px; }
.file a { color: var(--text); font-weight: 600; }
.file .sub { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; }
.file a:hover { color: var(--primary-700); text-decoration: none; }
.chat-side { display: flex; flex-direction: column; position: sticky; top: calc(var(--topbar-h) + 20px); max-height: calc(100vh - var(--topbar-h) - 40px); }
.chat-side .chat-thread { overflow: auto; }
.chat-side .chat-thread { padding: 16px 20px; gap: 16px; }
.chat-side .composer { padding: 12px 16px 16px; }
.chat-side .msg { grid-template-columns: 28px minmax(0, 1fr); gap: 10px; }
.chat-side .msg-avatar { width: 28px; height: 28px; }
.chat-side .msg-body { font-size: 13.5px; padding: 10px 12px; }
.chat-side .composer textarea { font-size: 14px; min-height: 40px; }
.chat-side .composer-box { padding: 8px 10px; }
.chat-side .composer-bar .seg { display: inline-flex; }
.chat-side .composer-bar { gap: 6px; }
.chat-side .composer-tools { margin-left: auto; }
.chat-side .chat-thread:empty::before { content: "Fai una domanda sull'archivio: la risposta cita i file da cui è tratta."; display: block; font-size: 13px; color: var(--text-3); text-align: center; padding: 20px 10px; }

/* ── Cartelle (griglia) ───────────────────────────────── */
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; padding: 20px; }
.folder { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 12px; border: 1px solid transparent; border-radius: var(--r-lg); background: transparent; cursor: pointer; text-align: center; color: inherit; text-decoration: none; }
.folder:hover { background: var(--surface-2); border-color: var(--line); text-decoration: none; color: inherit; }
.folder .icon { width: 84px; height: 68px; stroke: none; }
.folder-name { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.folder-meta { font-size: 12px; color: var(--text-3); }
.folder-c1 { color: #0e7034; } .folder-c2 { color: #14a44a; } .folder-c3 { color: #2bb862; }
.folder-c4 { color: #45c579; } .folder-c5 { color: #63d091; } .folder-c6 { color: #1a8f52; }
.folder-c7 { color: #37a86d; } .folder-c8 { color: #7fd9a6; }
[data-view] { display: none; }
[data-view][data-active] { display: block; }
.back-btn { display: inline-flex; align-items: center; gap: 6px; }

/* ── Toast ────────────────────────────────────────────── */
.toasts { position: fixed; right: 24px; bottom: 24px; z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--text); color: var(--bg); border-radius: var(--r-md); box-shadow: var(--shadow-md); font-size: 13.5px; font-weight: 600; animation: toast-in .18s ease-out; }
.toast .icon { width: 16px; height: 16px; color: var(--primary); }
@keyframes toast-in { from { opacity: 0; translate: 0 8px; } }
.modal-sm .modal { width: min(560px, 100%); }
.route-list { list-style: none; display: grid; gap: 10px; }
.route-list li { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.route-list li:last-child { border-bottom: 0; }
.route-list .obj { font-weight: 600; display: block; }
.route-list .sub { font-size: 12px; color: var(--text-3); }
.drop { border: 2px dashed var(--line); border-radius: var(--r-lg); padding: 36px 20px; text-align: center; display: grid; gap: 8px; justify-items: center; background: var(--surface-2); }
.drop .icon { width: 30px; height: 30px; color: var(--primary); }
.drop-title { font-weight: 700; }
.drop-sub { font-size: 12.5px; color: var(--text-3); }
.upload-list { list-style: none; display: grid; gap: 8px; margin-top: 16px; }
.upload-list li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.progress { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.progress .fill { display: block; height: 100%; background: var(--primary); width: var(--w, 0%); }
.upload-list .obj { display: block; font-weight: 600; margin-bottom: 4px; }
