/* Igloo CRM — design system basato sul manuale di identità Igloo (2024)
   Palette: Cool Gray #E5E1E6 · Black #212721 · Lime 809C #E7F908 */

:root {
  --ig-dark: #212721;
  --ig-dark-2: #2c332c;
  --ig-dark-3: #3a423a;
  --ig-gray: #e5e1e6;
  --ig-gray-2: #f3f1f4;
  --ig-lime: #e7f908;
  --ig-lime-soft: #f6fdb0;
  --ig-lime-ink: #4a5200;
  --ig-muted: #6b6f6b;
  --ig-radius: 14px;
  --ig-radius-sm: 10px;
  --ig-shadow: 0 1px 2px rgba(33, 39, 33, .04), 0 8px 24px -12px rgba(33, 39, 33, .12);
  --ig-sidebar-w: 248px;

  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-bg: var(--ig-gray-2);
  --bs-body-color: var(--ig-dark);
  --bs-border-color: #e3e0e5;
  --bs-primary: var(--ig-dark);
  --bs-primary-rgb: 33, 39, 33;
  --bs-link-color: var(--ig-dark);
  --bs-link-color-rgb: 33, 39, 33;
  --bs-link-hover-color: #000;
  --bs-secondary-color: var(--ig-muted);
  --ig-card-bg: #fff;
  --ig-hover: #f7f6f8;
  --ig-link-line: #d2e400;  /* sottolineatura dei link: lime un filo più scuro, visibile sul bianco */
}

[data-bs-theme="dark"] {
  --bs-body-bg: #151915;
  --bs-body-color: #e9ebe6;
  --bs-border-color: #2b322b;
  --bs-link-color: #e9ebe6;
  --bs-link-color-rgb: 233, 235, 230;
  --bs-link-hover-color: var(--ig-lime);
  --bs-secondary-color: #9aa29a;
  --ig-card-bg: #1c211c;
  --ig-hover: #232923;
  --bs-primary-rgb: 231, 249, 8;
  --ig-link-line: var(--ig-lime);
}

html, body { height: 100%; }
body { font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, .display-font { font-family: "Inter Tight", "Inter", sans-serif; letter-spacing: -.02em; font-weight: 700; }
a { text-decoration: none; }
::selection { background: var(--ig-lime); color: var(--ig-dark); }

/* ---------- layout ---------- */
.ig-shell { display: flex; min-height: 100vh; }
.ig-sidebar {
  width: var(--ig-sidebar-w); flex-shrink: 0; background: var(--ig-dark); color: #cfd3cf;
  position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 1040;
  transition: transform .25s ease;
}
.ig-sidebar .brand { padding: 22px 22px 14px; display: flex; align-items: center; gap: 10px; }
.ig-sidebar .brand img { height: 30px; }
.ig-sidebar .brand .tag { font-size: .65rem; font-weight: 700; letter-spacing: .14em; color: var(--ig-dark); background: var(--ig-lime); padding: 2px 6px; border-radius: 4px; }
/* menu scorrevole (rotella, trackpad, tocco) ma senza barra di scorrimento visibile */
.ig-nav { overflow-y: auto; padding: 6px 12px 24px; flex: 1; scrollbar-width: none; }
.ig-nav::-webkit-scrollbar { display: none; }
.ig-nav .section { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #7f877f; margin: 18px 10px 6px; font-weight: 600; }
/* sezioni collassabili: titolo-pulsante con la freccia, chiusura animata (grid 1fr -> 0fr) */
.ig-nav button.section { display: flex; align-items: center; gap: 6px; width: calc(100% - 20px); background: none; border: 0; padding: 4px 0; text-align: left;
  border-radius: 6px; transition: color .15s; }
.ig-nav button.section:hover { color: #cfd3cf; }
.ig-nav button.section:focus-visible { outline: 2px solid var(--ig-lime); outline-offset: 2px; }
.ig-nav button.section .bi-chevron-down { margin-left: auto; font-size: .7rem; transition: transform .2s ease; }
.ig-nav-dot { display: none; width: 6px; height: 6px; border-radius: 50%; background: var(--ig-lime); }
.ig-nav-items { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .2s ease; }
.ig-nav-items > div { overflow: hidden; min-height: 0; }
.ig-nav-group.collapsed .ig-nav-items { grid-template-rows: 0fr; }
.ig-nav-group.collapsed .bi-chevron-down { transform: rotate(-90deg); }
.ig-nav-group.collapsed:has(.count) .ig-nav-dot { display: inline-block; }  /* sezione chiusa con conteggi: un puntino */
.ig-nav.no-anim .ig-nav-items, .ig-nav.no-anim .bi-chevron-down { transition: none; }
.ig-nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: #cfd3cf;
  font-size: .9rem; font-weight: 500; position: relative; transition: background .15s, color .15s;
}
.ig-nav a i { font-size: 1.05rem; opacity: .85; width: 18px; text-align: center; }
.ig-nav a:hover { background: var(--ig-dark-2); color: #fff; }
.ig-nav a.active { background: var(--ig-lime); color: var(--ig-dark); font-weight: 600; }
.ig-nav a.active i { opacity: 1; }
.ig-nav .count { margin-left: auto; font-size: .7rem; background: var(--ig-dark-3); color: #fff; border-radius: 20px; padding: 1px 8px; }
.ig-nav a.active .count { background: var(--ig-dark); color: var(--ig-lime); }
.ig-sidebar .footer { padding: 14px 18px; border-top: 1px solid var(--ig-dark-3); font-size: .78rem; color: #8b938b; }

.ig-main { flex: 1; margin-left: var(--ig-sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.ig-topbar {
  position: sticky; top: 0; z-index: 1030; height: 64px; display: flex; align-items: center; gap: 14px; padding: 0 28px;
  background: color-mix(in srgb, var(--bs-body-bg) 82%, transparent); backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--bs-border-color);
}
.ig-content { padding: 26px 28px 60px; width: 100%; }  /* larghezza fluida: segue la finestra */
.ig-search { position: relative; flex: 1; max-width: 560px; }
.ig-search input { padding-left: 40px; border-radius: 12px; background: var(--ig-card-bg); height: 42px; }
.ig-search > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ig-muted); }
.ig-search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: var(--ig-gray); color: var(--ig-muted); font-size: .7rem; }
.ig-search-results { position: absolute; top: 48px; left: 0; right: 0; z-index: 1050; }

@media (max-width: 991.98px) {
  .ig-sidebar { transform: translateX(-100%); }
  .ig-sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .ig-main { margin-left: 0; }
  .ig-content { padding: 18px 16px 60px; }
  .ig-topbar { padding: 0 16px; }
}

/* ---------- components ---------- */
.card { --bs-card-bg: var(--ig-card-bg); border-radius: var(--ig-radius); border: 1px solid var(--bs-border-color); box-shadow: var(--ig-shadow); }
.card-header { background: transparent; border-bottom-color: var(--bs-border-color); padding: 14px 18px; font-weight: 600; }
.card-body { padding: 18px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 1.65rem; margin: 0; }
.page-head .eyebrow { font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ig-muted); font-weight: 600; margin-bottom: 4px; }

.btn { border-radius: 10px; font-weight: 600; font-size: .88rem; padding: .48rem .95rem; }
.btn-sm { border-radius: 8px; font-size: .8rem; }
.btn-primary { --bs-btn-bg: var(--ig-dark); --bs-btn-border-color: var(--ig-dark); --bs-btn-hover-bg: #000; --bs-btn-hover-border-color: #000;
  --bs-btn-active-bg: #000; --bs-btn-color: #fff; --bs-btn-hover-color: var(--ig-lime); --bs-btn-disabled-bg: var(--ig-dark-3); }
.btn-lime { background: var(--ig-lime); color: var(--ig-dark); border: 1px solid #d3e400; }
.btn-lime:hover { background: #d9ec00; color: var(--ig-dark); }
.btn-light { --bs-btn-bg: var(--ig-card-bg); --bs-btn-border-color: var(--bs-border-color); --bs-btn-hover-bg: var(--ig-hover); --bs-btn-hover-border-color: #cfcbd2; }
[data-bs-theme="dark"] .btn-primary { --bs-btn-bg: var(--ig-lime); --bs-btn-color: var(--ig-dark); --bs-btn-border-color: var(--ig-lime); --bs-btn-hover-bg: #f2ff4d; --bs-btn-hover-color: var(--ig-dark); }
[data-bs-theme="dark"] .btn-light { --bs-btn-color: #e9ebe6; }

.form-control, .form-select { border-radius: 10px; border-color: var(--bs-border-color); background-color: var(--ig-card-bg); font-size: .9rem; }
.form-control:focus, .form-select:focus { border-color: var(--ig-dark); box-shadow: 0 0 0 .2rem rgba(231, 249, 8, .55); }
.form-label { font-size: .8rem; font-weight: 600; color: var(--ig-muted); margin-bottom: .3rem; }
.form-check-input:checked { background-color: var(--ig-dark); border-color: var(--ig-dark); }

.table { --bs-table-bg: transparent; --bs-table-hover-bg: var(--ig-hover); font-size: .875rem; margin: 0; }
.table > thead th { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ig-muted); font-weight: 600; border-bottom-width: 1px; white-space: nowrap; padding: 10px 14px; background: var(--ig-card-bg); position: sticky; top: 0; z-index: 1; }
.table > tbody td { padding: 11px 14px; vertical-align: middle; border-color: var(--bs-border-color); }
/* un solo stile per i link nel testo (clienti e fornitori, documenti, riferimenti nelle schede):
   grassetto con la sottolineatura gialla fluo, sempre visibile */
.ig-link, .ig-party-link, .table a.row-link, .table td a:not([class]), .dl-grid dd a:not([class]) {
  color: inherit; font-weight: 600; text-decoration: underline; text-decoration-color: var(--ig-link-line);
  text-decoration-thickness: 2px; text-underline-offset: 3px; }
.ig-link:hover, .ig-party-link:hover, .table a.row-link:hover, .table td a:not([class]):hover, .dl-grid dd a:not([class]):hover {
  color: inherit; text-decoration-color: var(--ig-lime); text-decoration-thickness: 3px; }
/* elenchi dei documenti: tipo + numero, intestatario con link alla scheda, righe secondarie in piccolo */
.ig-doc-ref { display: inline-flex; align-items: baseline; gap: .4em; }
.ig-doc-type { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ig-muted); }
.ig-cell-sub { font-size: .75rem; color: var(--ig-muted); line-height: 1.3; margin-top: 2px; }
.ig-party-cell { min-width: 200px; max-width: 300px; }
.ig-row-actions { display: inline-flex; gap: 4px; }
/* link dentro una riga interamente cliccabile (stretched-link): resta cliccabile sopra */
.ig-above-stretch { position: relative; z-index: 2; }
.ig-row-actions .btn { padding: .15rem .45rem; }
.table-card { overflow-x: auto; border-radius: var(--ig-radius); }  /* nessuna altezza massima: scorre la pagina */
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge { font-weight: 600; border-radius: 6px; padding: .35em .6em; font-size: .72rem; letter-spacing: .01em; }
.badge-lime { background: var(--ig-lime); color: var(--ig-dark); }
.badge-dark { background: var(--ig-dark); color: #fff; }
.badge-soft { background: var(--ig-gray); color: var(--ig-dark); }
.badge-ok { background: #dff5e1; color: #1d6b2a; }
.badge-warn { background: #fff1cc; color: #8a5a00; }
.badge-danger { background: #fde1df; color: #a1261b; }
.badge-info { background: #e2ecfb; color: #1f4f99; }
[data-bs-theme="dark"] .badge-soft { background: #2b322b; color: #e9ebe6; }
[data-bs-theme="dark"] .badge-ok { background: #173c1d; color: #8fe39b; }
[data-bs-theme="dark"] .badge-warn { background: #3d3112; color: #ffd36b; }
[data-bs-theme="dark"] .badge-danger { background: #43201d; color: #ff9d93; }
[data-bs-theme="dark"] .badge-info { background: #1a2a43; color: #9cc0ff; }
.badge-source-danea { background: transparent; border: 1px solid currentColor; color: var(--ig-muted); }

/* KPI */
.kpi { position: relative; overflow: hidden; height: 100%; }
.kpi .label { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ig-muted); font-weight: 600; }
.kpi .value { font-family: "Inter Tight", sans-serif; font-size: 1.85rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; margin-top: 6px; }
.kpi .sub { font-size: .8rem; color: var(--ig-muted); margin-top: 4px; }
.kpi .icon { position: absolute; right: 16px; top: 16px; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--ig-gray-2); font-size: 1.1rem; }
.kpi.accent { background: var(--ig-dark); color: #fff; border-color: var(--ig-dark); }
.kpi.accent .label, .kpi.accent .sub { color: #b9c0b9; }
.kpi.accent .icon { background: var(--ig-lime); color: var(--ig-dark); }
.kpi.lime { background: var(--ig-lime); border-color: #d3e400; }
.kpi.lime .label, .kpi.lime .sub { color: var(--ig-lime-ink); }
.kpi.lime .icon { background: var(--ig-dark); color: var(--ig-lime); }
[data-bs-theme="dark"] .kpi .icon { background: #2b322b; }
/* riquadro interamente cliccabile (stretched-link verso l'elenco che lo dettaglia) */
.kpi-link:hover { background: var(--ig-hover); }
.kpi-link a:hover { text-decoration: underline; }
[data-bs-theme="dark"] .kpi.lime { color: var(--ig-dark); }

.progress { height: 8px; border-radius: 10px; background: var(--ig-gray); }
.progress-bar { background: var(--ig-dark); border-radius: 10px; }
.progress-bar.lime { background: var(--ig-lime); }
[data-bs-theme="dark"] .progress { background: #2b322b; }
[data-bs-theme="dark"] .progress-bar { background: var(--ig-lime); }

.nav-pills-ig { gap: 4px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.nav-pills-ig .nav-link { color: var(--ig-muted); font-weight: 600; font-size: .85rem; border-radius: 9px; padding: .45rem .85rem; white-space: nowrap; }
.nav-pills-ig .nav-link.active, .nav-pills-ig .nav-link:hover { background: var(--ig-dark); color: #fff; }
[data-bs-theme="dark"] .nav-pills-ig .nav-link.active { background: var(--ig-lime); color: var(--ig-dark); }
.nav-pills-ig .nav-link .count { font-size: .7rem; opacity: .7; margin-left: 4px; }

.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 22px; margin: 0; }
.dl-grid dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ig-muted); font-weight: 600; }
.dl-grid dd { margin: 2px 0 0; font-weight: 500; word-break: break-word; }
.dl-grid .modified dd::after { content: "modificato nel CRM"; margin-left: 6px; font-size: .65rem; background: var(--ig-lime); color: var(--ig-dark); padding: 1px 5px; border-radius: 4px; font-weight: 700; vertical-align: middle; }

.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 4px; bottom: 4px; width: 2px; background: var(--bs-border-color); }
.timeline li { position: relative; padding: 0 0 16px 44px; }
.timeline .dot { position: absolute; left: 4px; top: 0; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; background: var(--ig-card-bg); border: 2px solid var(--bs-border-color); }
.timeline .dot.lime { background: var(--ig-lime); border-color: var(--ig-lime); }
.timeline .dot.dark { background: var(--ig-dark); border-color: var(--ig-dark); color: #fff; }

.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: .78rem; background: var(--ig-lime); color: var(--ig-dark); flex-shrink: 0; }
.avatar.sm { width: 24px; height: 24px; font-size: .66rem; }
.avatar.dark { background: var(--ig-dark); color: var(--ig-lime); }
.avatar.soft { background: var(--ig-gray); color: var(--ig-dark); }
[data-bs-theme="dark"] .avatar.soft { background: #2b322b; color: #e9ebe6; }

.empty { text-align: center; padding: 48px 16px; color: var(--ig-muted); }
.empty i { font-size: 2.2rem; display: block; margin-bottom: 8px; opacity: .5; }

.list-group-item { background: transparent; border-color: var(--bs-border-color); }
.list-group-item-action:hover { background: var(--ig-hover); }

/* B / C / D comparison */
.bcd { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.bcd .cell { border: 1px solid var(--bs-border-color); border-radius: 10px; padding: 10px 12px; min-height: 64px; background: var(--ig-card-bg); }
.bcd .cell .tag { font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--ig-muted); }
.bcd .cell .val { font-weight: 600; margin-top: 4px; word-break: break-word; font-size: .88rem; }
.bcd .cell.crm { border-color: var(--ig-dark); }
.bcd .cell.new { border-color: #c9d900; background: color-mix(in srgb, var(--ig-lime) 18%, var(--ig-card-bg)); }
@media (max-width: 767.98px) { .bcd { grid-template-columns: 1fr; } }

/* Kanban (React) */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; }
.kanban-col { background: color-mix(in srgb, var(--ig-gray) 55%, transparent); border-radius: var(--ig-radius); padding: 12px; min-height: 60vh; display: flex; flex-direction: column; transition: background .15s, outline .15s; }
[data-bs-theme="dark"] .kanban-col { background: #1a1f1a; }
.kanban-col.drop { outline: 2px dashed var(--ig-dark); background: var(--ig-lime-soft); }
.kanban-col h6 { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin: 2px 4px 10px; }
.kanban-card { background: var(--ig-card-bg); border: 1px solid var(--bs-border-color); border-radius: 12px; padding: 12px; margin-bottom: 10px; cursor: grab; box-shadow: var(--ig-shadow); transition: transform .12s, box-shadow .12s; }
.kanban-card:hover { transform: translateY(-2px); }
.kanban-card.dragging { opacity: .4; }
.kanban-card .title { font-weight: 600; font-size: .9rem; line-height: 1.3; }
.kanban-card .meta { font-size: .78rem; color: var(--ig-muted); }
.kanban-card .value { font-weight: 700; font-variant-numeric: tabular-nums; }
.kanban-card.attention { border-left: 4px solid #e8590c; }

/* htmx */
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-swapping { opacity: .5; transition: opacity .15s; }
.ig-loading-bar { position: fixed; top: 0; left: 0; height: 3px; width: 100%; background: linear-gradient(90deg, var(--ig-lime), var(--ig-dark), var(--ig-lime)); background-size: 200% 100%; animation: igbar 1s linear infinite; z-index: 2000; display: none; }
.htmx-request.ig-loading-bar, body.htmx-request .ig-loading-bar { display: block; }
@keyframes igbar { from { background-position: 0 0; } to { background-position: -200% 0; } }

.toast-container { z-index: 2100; }
.toast { border-radius: 12px; border: 0; box-shadow: 0 10px 30px rgba(0,0,0,.18); }

/* login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: var(--ig-dark); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
[data-bs-theme="dark"] .login-logo { filter: invert(1) brightness(1.15); }
.login-art h2 { font-size: clamp(2rem, 3vw, 2.6rem); max-width: 460px; position: relative; }
.login-form { display: grid; place-items: center; padding: 32px; }
.login-art-logo { position: relative; height: 64px; width: auto; align-self: flex-start; }
.login-logo-mobile { display: none !important; }
@media (max-width: 899.98px) { .login-wrap { grid-template-columns: 1fr; } .login-art { display: none; } .login-logo-mobile { display: block !important; } }

.text-muted-ig { color: var(--ig-muted) !important; }
.fw-600 { font-weight: 600; }
.small-caps { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 600; color: var(--ig-muted); }
.cursor-pointer { cursor: pointer; }
.sticky-actions { position: sticky; bottom: 0; background: var(--ig-card-bg); border-top: 1px solid var(--bs-border-color); padding: 12px 18px; border-radius: 0 0 var(--ig-radius) var(--ig-radius); }
.chart-box { position: relative; height: 260px; }
/* barre mese per mese in testa agli elenchi delle fatture */
.kpi.compact .value { font-size: 1.45rem; white-space: nowrap; }
.kpi.compact .label { padding-right: 34px; }
.kpi.compact .icon { width: 30px; height: 30px; right: 12px; top: 12px; border-radius: 9px; font-size: .95rem; }
.ig-bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; height: 150px; }
.ig-bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; min-width: 0; }
.ig-bar .track { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; }
.ig-bar .fill { display: block; min-height: 2px; border-radius: 6px 6px 2px 2px; background: var(--ig-dark); }
.ig-bar .amount { font-size: .66rem; color: var(--ig-muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: clip; margin-bottom: 3px; }
.ig-bar .month { font-size: .7rem; color: var(--ig-muted); text-align: center; margin-top: 6px; text-transform: capitalize; }
.ig-bar.future .fill { background: var(--ig-gray); }
.ig-bar.current .fill, .ig-bar:hover .fill { background: var(--ig-lime); }
[data-bs-theme="dark"] .ig-bar .fill { background: #9aa29a; }
[data-bs-theme="dark"] .ig-bar.future .fill { background: #2b322b; }
[data-bs-theme="dark"] .ig-bar.current .fill, [data-bs-theme="dark"] .ig-bar:hover .fill { background: var(--ig-lime); }
@media (max-width: 767.98px) { .ig-bar .amount { display: none; } .ig-bars { height: 110px; gap: 4px; } }
/* flusso previsto dello Scadenzario: incassi sopra la linea, pagamenti sotto */
.ig-flow { display: grid; gap: 6px; }
.ig-flow-col { display: flex; flex-direction: column; min-width: 0; padding: 2px 3px; border-radius: 8px; }
.ig-flow-col:hover { background: var(--ig-hover); }
/* l'importo sta accanto alla barra: il riquadro gli lascia spazio fuori dall'altezza della barra piena */
.ig-flow-col .up, .ig-flow-col .down { box-sizing: content-box; height: 72px; display: flex; flex-direction: column; }
.ig-flow-col .up { justify-content: flex-end; padding: 1.1em 0 2px; }
.ig-flow-col .down { justify-content: flex-start; border-top: 1px solid var(--bs-border-color); padding: 2px 0 1.1em; }
.ig-flow-col .fill { flex: none; }
.ig-flow-col .fill { display: block; border-radius: 4px 4px 1px 1px; background: var(--ig-dark); }
.ig-flow-col .down .fill { border-radius: 1px 1px 4px 4px; background: #b3adb7; }
.ig-flow-col .amount { font-size: .66rem; color: var(--ig-muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: clip; min-height: 1.1em; }
.ig-flow-col .month { font-size: .7rem; color: var(--ig-muted); text-align: center; margin-top: 4px; text-transform: capitalize; white-space: nowrap; overflow: hidden; }
.ig-flow-col.current .month { color: var(--bs-body-color); font-weight: 600; }
.ig-flow-col.overdue .up .fill { background: #c4323f; }
.ig-flow-col.overdue .down .fill { background: #eba4ab; }
.ig-flow-col.overdue .month { color: #c4323f; font-weight: 600; }
.ig-legend { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: normal; color: var(--ig-muted); }
.ig-legend::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--ig-dark); }
.ig-legend.out::before { background: #b3adb7; }
[data-bs-theme="dark"] .ig-legend::before { background: #b9c0b9; }
[data-bs-theme="dark"] .ig-legend.out::before { background: #545c54; }
.kpi.accent .text-danger { color: #ff9a9a !important; }
[data-bs-theme="dark"] .ig-flow-col .fill { background: #b9c0b9; }
[data-bs-theme="dark"] .ig-flow-col .down .fill { background: #545c54; }
[data-bs-theme="dark"] .ig-flow-col.overdue .up .fill { background: #ef6a75; }
[data-bs-theme="dark"] .ig-flow-col.overdue .down .fill { background: #7a3138; }
[data-bs-theme="dark"] .ig-flow-col.overdue .month { color: #ef6a75; }
@media (max-width: 767.98px) { .ig-flow-col .amount { display: none; } .ig-flow-col .up, .ig-flow-col .down { height: 48px; } .ig-flow { gap: 2px; } }
.modal-content { border-radius: 18px; border: 0; background: var(--ig-card-bg); }
.offcanvas { background: var(--ig-card-bg); }

@media (max-width: 575.98px) {
  .kpi .value { font-size: 1.35rem; }
  .page-head h1 { font-size: 1.35rem; }
  .kpi .icon { display: none; }
}

/* ---------- notifiche ---------- */
.ig-bell-badge {
  position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--ig-lime); color: var(--ig-dark); font-size: .66rem; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--bs-body-bg);
}
.ig-bell-menu { width: 380px; max-width: calc(100vw - 24px); padding: 0; border-radius: var(--ig-radius); overflow: hidden; background: var(--ig-card-bg); }
.ig-bell-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--bs-border-color); }
.ig-bell-list { max-height: min(60vh, 460px); overflow-y: auto; }
.ig-bell-foot { display: flex; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--bs-border-color); font-size: .85rem; }
.ig-bell-foot a { text-decoration: none; font-weight: 600; }
.ig-notification { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--bs-border-color); }
.ig-notification:last-child { border-bottom: 0; }
.ig-notification:hover { background: var(--ig-hover); color: inherit; }
.ig-notification .icon { flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--ig-gray-2); color: var(--ig-muted); }
[data-bs-theme="dark"] .ig-notification .icon { background: var(--ig-dark-2); }
.ig-notification.unread .icon { background: var(--ig-lime); color: var(--ig-dark); }
.ig-notification .title { display: block; font-weight: 500; line-height: 1.3; }
.ig-notification.unread .title { font-weight: 700; }
.ig-notification .body { display: block; font-size: .84rem; color: var(--bs-secondary-color); margin-top: 2px; }
.ig-notification .meta { display: block; font-size: .74rem; color: var(--bs-secondary-color); margin-top: 4px; }
.ig-notification .dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--ig-dark); margin-top: 8px; }
[data-bs-theme="dark"] .ig-notification .dot { background: var(--ig-lime); }
.min-w-0 { min-width: 0; }
.ig-pref-row { display: flex; gap: 14px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--bs-border-color); }
.ig-pref-row:last-child { border-bottom: 0; }
.ig-pref-row .icon { flex-shrink: 0; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--ig-lime); color: var(--ig-dark); font-size: 1.1rem; }
.ig-pref-row.is-off .icon { background: var(--ig-gray-2); color: var(--ig-muted); }
.ig-pref-row.is-off .fw-600 { color: var(--bs-secondary-color); }
.ig-pref-switches { display: flex; gap: 18px; flex-shrink: 0; }
.ig-pref-switches .form-check-input { cursor: pointer; }
@media (max-width: 575.98px) {
  .ig-pref-row { display: grid; grid-template-columns: 38px 1fr; column-gap: 14px; row-gap: 10px; align-items: start; }
  .ig-pref-switches { grid-column: 2; }
}

/* ---------- app installata (PWA) ---------- */
@media (display-mode: standalone) {
  .ig-topbar { padding-top: env(safe-area-inset-top); height: calc(64px + env(safe-area-inset-top)); }
  .ig-sidebar { padding-top: env(safe-area-inset-top); }
  .ig-content { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
}

/* ---------- finestre modali ---------- */
.modal-backdrop { background: #151915; }
.modal-backdrop.show { opacity: .6; }
.modal-content { border-radius: 20px; overflow: hidden; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45), 0 0 0 1px rgba(33, 39, 33, .06); }
.modal.fade .modal-dialog { transform: translateY(14px) scale(.98); transition: transform .22s cubic-bezier(.2, .8, .2, 1); }
.modal.show .modal-dialog { transform: none; }
/* il form racchiude header/body/footer: solo il corpo scorre, intestazione e pulsanti restano visibili */
.modal-content > form { display: flex; flex-direction: column; min-height: 0; max-height: 100%; }
.modal-dialog-scrollable .modal-content > form { overflow: hidden; }
.modal-dialog-scrollable .modal-content > form > .modal-body { overflow-y: auto; }
.modal-header { padding: 18px 24px; }
.modal-body { padding: 22px 24px; }
.modal-footer { padding: 14px 24px; gap: 8px; background: var(--ig-gray-2); border-top: 1px solid var(--bs-border-color) !important; }
.modal-footer > * { margin: 0; }
[data-bs-theme="dark"] .modal-footer { background: #181d18; }
.ig-modal-head {
  position: relative; gap: 14px; align-items: center; border-bottom: 1px solid var(--bs-border-color) !important; padding-top: 22px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--ig-lime) 16%, var(--ig-card-bg)) 0%, var(--ig-card-bg) 100%);
}
.ig-modal-head::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--ig-lime); }
[data-bs-theme="dark"] .ig-modal-head { background: linear-gradient(180deg, color-mix(in srgb, var(--ig-lime) 7%, var(--ig-card-bg)) 0%, var(--ig-card-bg) 100%); }
.ig-modal-head .btn-close { align-self: flex-start; margin: 2px 0 0 auto; }
.ig-modal-icon {
  flex-shrink: 0; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 1.3rem;
  background: var(--ig-dark); color: var(--ig-lime); box-shadow: 0 6px 16px -8px rgba(33, 39, 33, .6);
}
[data-bs-theme="dark"] .ig-modal-icon { background: var(--ig-lime); color: var(--ig-dark); }
.ig-modal-eyebrow { font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--bs-secondary-color); margin-bottom: 2px; }
.ig-modal-title { font-family: "Inter Tight", "Inter", sans-serif; font-weight: 700; letter-spacing: -.02em; font-size: 1.3rem; line-height: 1.2; margin: 0; }
.ig-modal-subtitle { font-size: .85rem; color: var(--bs-secondary-color); margin-top: 2px; }
.ig-modal-hint { font-size: .78rem; color: var(--bs-secondary-color); }
.req { color: #d03b3b; margin-left: 3px; font-weight: 700; }
.ig-confirm { text-align: center; padding: 36px 32px 28px; position: relative; }
.ig-confirm-icon { width: 64px; height: 64px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 1.6rem; margin-bottom: 16px; }
.ig-confirm-icon.danger { background: #fde8e8; color: #c62f2f; box-shadow: 0 0 0 8px #fef4f4; }
[data-bs-theme="dark"] .ig-confirm-icon.danger { background: #4a1f1f; color: #ff8a8a; box-shadow: 0 0 0 8px #2c1717; }
.ig-confirm-icon.ok { background: var(--ig-lime); color: var(--ig-dark); box-shadow: 0 0 0 8px var(--ig-lime-soft); }

/* ---------- form ---------- */
.ig-form-section + .ig-form-section { margin-top: 26px; }
.ig-form-section-title {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--bs-body-color);
}
.ig-form-section-title i { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: .85rem; background: var(--ig-lime); color: var(--ig-dark); }
.ig-form-section-title::after { content: ""; flex: 1; height: 1px; background: var(--bs-border-color); }
.ig-form .form-label { color: var(--bs-body-color); font-size: .8rem; margin-bottom: 6px; }
.ig-form .form-control, .ig-form .form-select { min-height: 44px; padding: .55rem .85rem; border-color: #d9d5db; transition: border-color .15s, box-shadow .15s, background-color .15s; }
.ig-form .form-select { padding-right: 2.4rem; }
.ig-form textarea.form-control { min-height: 88px; resize: vertical; line-height: 1.5; }
.ig-form .form-control:hover, .ig-form .form-select:hover { border-color: #b4b0b6; }
.ig-form .form-control:focus, .ig-form .form-select:focus { border-color: var(--ig-dark); box-shadow: 0 0 0 4px rgba(231, 249, 8, .5); }
.ig-form .form-control::placeholder { color: #a7a3a9; }
.ig-form .input-group-text {
  min-width: 44px; justify-content: center; border-color: #d9d5db; border-radius: 10px;
  background: var(--ig-gray-2); color: var(--ig-muted); font-size: .9rem; font-weight: 600; transition: color .15s, background-color .15s;
}
.ig-form .input-group { border-radius: 10px; transition: box-shadow .15s; }
.ig-form .input-group:focus-within { box-shadow: 0 0 0 4px rgba(231, 249, 8, .5); }
.ig-form .input-group:focus-within .form-control { box-shadow: none; }
.ig-form .input-group:focus-within .input-group-text { color: var(--ig-dark); background: var(--ig-lime-soft); border-color: var(--ig-dark); }
.ig-form .form-text { font-size: .76rem; margin-top: 5px; }
.ig-form .has-error .form-control, .ig-form .has-error .form-select, .ig-form .has-error .input-group-text, .ig-form .has-error .ts-control { border-color: #d03b3b; }
.ig-form .has-error .form-label { color: #c62f2f; }
.ig-form .ts-wrapper .ts-control { min-height: 44px; border-radius: 10px; border-color: #d9d5db; padding: .55rem .85rem; }
.ig-form .ts-wrapper.focus .ts-control { border-color: var(--ig-dark); box-shadow: 0 0 0 4px rgba(231, 249, 8, .5); }
[data-bs-theme="dark"] .ig-form .form-control, [data-bs-theme="dark"] .ig-form .form-select,
[data-bs-theme="dark"] .ig-form .input-group-text, [data-bs-theme="dark"] .ig-form .ts-wrapper .ts-control { border-color: #343c34; }
[data-bs-theme="dark"] .ig-form .input-group-text { background: #222822; color: #9aa29a; }
[data-bs-theme="dark"] .ig-form .form-control:focus, [data-bs-theme="dark"] .ig-form .form-select:focus,
[data-bs-theme="dark"] .ig-form .ts-wrapper.focus .ts-control { border-color: var(--ig-lime); box-shadow: 0 0 0 4px rgba(231, 249, 8, .18); }
[data-bs-theme="dark"] .ig-form .input-group:focus-within { box-shadow: 0 0 0 4px rgba(231, 249, 8, .18); }
[data-bs-theme="dark"] .ig-form .input-group:focus-within .input-group-text { background: rgba(231, 249, 8, .12); color: var(--ig-lime); border-color: var(--ig-lime); }
.ig-switch-tile {
  display: flex; align-items: center; gap: 12px; min-height: 44px; height: 100%; padding: 10px 14px; margin: 0;
  border: 1px solid #d9d5db; border-radius: 12px; cursor: pointer; transition: border-color .15s, background-color .15s;
}
.ig-switch-tile:hover { border-color: #b4b0b6; }
.ig-switch-tile:has(input:checked) { border-color: var(--ig-dark); background: color-mix(in srgb, var(--ig-lime) 22%, var(--ig-card-bg)); }
[data-bs-theme="dark"] .ig-switch-tile { border-color: #343c34; }
[data-bs-theme="dark"] .ig-switch-tile:has(input:checked) { border-color: var(--ig-lime); background: rgba(231, 249, 8, .08); }
.ig-switch-tile .form-check-input { width: 2.4em; height: 1.3em; margin: 0; cursor: pointer; }
.form-switch .form-check-input:checked { background-color: var(--ig-dark); border-color: var(--ig-dark); }
[data-bs-theme="dark"] .form-switch .form-check-input:checked {
  background-color: var(--ig-lime); border-color: var(--ig-lime);
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%27-4 -4 8 8%27%3e%3ccircle r=%273%27 fill=%27%23212721%27/%3e%3c/svg%3e");
}
.ig-form-card .card-body { padding: 24px; }
@media (max-width: 575.98px) {
  .modal-header, .modal-body, .modal-footer { padding-left: 18px; padding-right: 18px; }
  .ig-modal-hint { display: none; }
  .modal-footer .btn { flex: 1; }
}
.ig-note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 12px; background: var(--ig-gray-2); color: var(--bs-secondary-color); font-size: .82rem; }
.ig-note i { color: var(--bs-body-color); margin-top: 1px; }
[data-bs-theme="dark"] .ig-note { background: #222822; }
.ig-switch-tile .form-switch { padding-left: 0; min-height: 0; display: flex; }
.ig-switch-tile { font-size: .9rem; }

/* ---------- pagine di dettaglio ---------- */
.page-head.ig-hero {
  position: relative; align-items: center; gap: 16px 20px; padding: 24px 26px 22px; margin-bottom: 20px; overflow: hidden;
  border: 1px solid var(--bs-border-color); border-radius: var(--ig-radius); box-shadow: var(--ig-shadow);
  background: linear-gradient(115deg, color-mix(in srgb, var(--ig-lime) 20%, var(--ig-card-bg)) 0%, var(--ig-card-bg) 58%);
}
.ig-hero::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--ig-lime); }
[data-bs-theme="dark"] .page-head.ig-hero { background: linear-gradient(115deg, color-mix(in srgb, var(--ig-lime) 8%, var(--ig-card-bg)) 0%, var(--ig-card-bg) 58%); }
.ig-hero-icon {
  flex-shrink: 0; width: 58px; height: 58px; border-radius: 16px; display: grid; place-items: center; font-size: 1.6rem;
  background: var(--ig-dark); color: var(--ig-lime); box-shadow: 0 10px 22px -12px rgba(33, 39, 33, .7);
}
[data-bs-theme="dark"] .ig-hero-icon { background: var(--ig-lime); color: var(--ig-dark); }
.ig-hero > .ig-hero-icon + div { flex: 1 1 320px; min-width: 0; }
.ig-hero h1 { font-size: 1.8rem; line-height: 1.15; }
.ig-hero .btn-light { background: var(--ig-card-bg); }
.ig-hero .badge { font-size: .74rem; padding: .4em .7em; }
.ig-ch-icon {
  display: inline-grid; place-items: center; flex-shrink: 0; width: 28px; height: 28px; margin-right: 10px; vertical-align: middle;
  border-radius: 8px; background: var(--ig-lime); color: var(--ig-dark); font-size: .85rem;
}
.card-header:has(> .ig-ch-icon) { display: flex; align-items: center; }
.card-header > span:has(> .ig-ch-icon) { display: inline-flex; align-items: center; }
.card-header { font-size: .95rem; }
.dl-grid { gap: 10px; }
.dl-grid > div { min-width: 0; padding: 10px 14px; border-radius: 12px; background: var(--ig-gray-2); }
[data-bs-theme="dark"] .dl-grid > div { background: #222822; }
.dl-grid dt { font-size: .66rem; }
.dl-grid dd { margin-top: 3px; font-weight: 600; }
.ig-prose { margin-top: 16px; padding: 14px 16px; border-radius: 12px; border-left: 4px solid var(--ig-lime); background: var(--ig-gray-2); }
[data-bs-theme="dark"] .ig-prose { background: #222822; }
.ig-prose-label { font-size: .66rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--bs-secondary-color); margin-bottom: 4px; }
.ig-prose-text { white-space: pre-wrap; line-height: 1.55; }
@media (max-width: 575.98px) {
  .page-head.ig-hero { padding: 18px 16px; }
  .ig-hero-icon { width: 46px; height: 46px; font-size: 1.3rem; border-radius: 14px; }
  .ig-hero h1 { font-size: 1.35rem; }
  .ig-hero > .ig-hero-icon + div { flex-basis: calc(100% - 66px); }
}
.kpi.accent .dl-grid > div { background: rgba(255, 255, 255, .08); }
.kpi.lime .dl-grid > div { background: rgba(33, 39, 33, .08); }
#library-panel .card-header .badge { margin-left: 6px; }
.form-control::file-selector-button { background: var(--ig-dark); color: #fff; border: 0; font-weight: 600; margin-right: 10px; }
.form-control:hover:not(:disabled)::file-selector-button { background: #000; color: var(--ig-lime); }
[data-bs-theme="dark"] .form-control::file-selector-button { background: var(--ig-lime); color: var(--ig-dark); }
@media (max-width: 575.98px) { .dl-grid { grid-template-columns: 1fr 1fr; gap: 8px; } .dl-grid > div { padding: 9px 12px; } }

/* ---------- assistente AI ---------- */
.ig-assistant-head {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--bs-border-color); position: relative;
  background: linear-gradient(180deg, color-mix(in srgb, var(--ig-lime) 14%, var(--ig-card-bg)) 0%, var(--ig-card-bg) 100%);
}
.ig-assistant-head::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--ig-lime); }
[data-bs-theme="dark"] .ig-assistant-head { background: linear-gradient(180deg, color-mix(in srgb, var(--ig-lime) 6%, var(--ig-card-bg)) 0%, var(--ig-card-bg) 100%); }
.ig-assistant-head .ig-ch-icon { margin-right: 4px; }
.ig-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ig-chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 12px; }
.ig-chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px 14px; border-top: 1px solid var(--bs-border-color); background: var(--ig-gray-2); }
[data-bs-theme="dark"] .ig-chat-form { background: #181d18; }
.ig-chat-form textarea { resize: none; min-height: 44px; max-height: 160px; border-radius: 12px; padding: .6rem .85rem; line-height: 1.45; }
.ig-chat-form textarea:focus { border-color: var(--ig-dark); box-shadow: 0 0 0 4px rgba(231, 249, 8, .5); }
.ig-chat-form .btn { height: 44px; width: 44px; border-radius: 12px; flex-shrink: 0; }
/* allegati della chat: anteprime prima dell'invio e nei messaggi */
.ig-chat-input { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ig-chat-files { display: flex; flex-wrap: wrap; gap: 6px; }
.ig-file-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 230px; padding: 3px 6px 3px 3px; border-radius: 10px; font-size: .78rem; font-weight: 600;
  background: var(--ig-card-bg); border: 1px solid var(--bs-border-color); color: inherit; text-decoration: none; }
.ig-file-chip img { width: 34px; height: 34px; object-fit: cover; border-radius: 7px; flex-shrink: 0; }
.ig-file-chip > .bi { font-size: 1.25rem; width: 34px; text-align: center; flex-shrink: 0; color: var(--bs-secondary-color); }
.ig-file-chip > .bi-file-earmark-pdf { color: #c62f2f; }
.ig-file-chip > .bi-file-earmark-word { color: #2b5fb4; }
.ig-file-chip > .bi-file-earmark-excel, .ig-file-chip > .bi-filetype-csv { color: #1d7a45; }
.ig-msg.user .ig-file-chip > .bi { color: inherit; }
.ig-file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ig-file-chip button { border: 0; background: none; padding: 0 2px; color: var(--bs-secondary-color); line-height: 1; }
.ig-file-chip button:hover { color: var(--bs-body-color); }
.ig-msg-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.ig-msg-files:last-child { margin-bottom: 0; }
.ig-msg-thumb img { display: block; max-width: min(220px, 100%); max-height: 220px; border-radius: 10px; object-fit: cover; }
.ig-msg.user .ig-file-chip { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .22); }
[data-bs-theme="dark"] .ig-msg.user .ig-file-chip { background: rgba(0, 0, 0, .08); border-color: rgba(0, 0, 0, .15); }
.ig-dropzone { outline: 2px dashed var(--ig-dark); outline-offset: -6px; }
[data-bs-theme="dark"] .ig-dropzone { outline-color: var(--ig-lime); }
.ig-clip { color: var(--bs-secondary-color); text-decoration: none; margin-left: 2px; }
.ig-clip:hover { color: var(--bs-body-color); }
.ig-msg { display: flex; gap: 8px; max-width: 100%; }
.ig-msg .bubble { padding: 10px 14px; border-radius: 16px; line-height: 1.5; font-size: .92rem; overflow-wrap: anywhere; min-width: 0; }
.ig-msg.user { justify-content: flex-end; }
.ig-msg.user .bubble { background: var(--ig-dark); color: #fff; border-bottom-right-radius: 4px; max-width: 85%; }
[data-bs-theme="dark"] .ig-msg.user .bubble { background: var(--ig-lime); color: var(--ig-dark); }
.ig-msg.assistant .bubble { background: var(--ig-gray-2); border-bottom-left-radius: 4px; max-width: calc(100% - 40px); }
[data-bs-theme="dark"] .ig-msg.assistant .bubble { background: #222822; }
.ig-msg.error .bubble { background: #fde8e8; color: #8f2020; }
[data-bs-theme="dark"] .ig-msg.error .bubble { background: #3a1c1c; color: #ffb3b3; }
.ig-msg-avatar { flex-shrink: 0; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--ig-lime); color: var(--ig-dark); font-size: .9rem; }
.ig-msg.error .ig-msg-avatar { background: #fde8e8; color: #c62f2f; }
.ig-msg.tool { flex-direction: column; gap: 8px; padding-left: 38px; }
.ig-skill-chip { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 600; color: var(--bs-secondary-color);
  border: 1px dashed var(--bs-border-color); border-radius: 20px; padding: 2px 10px; }
.ig-md p { margin: 0 0 .5rem; }
.ig-md p:last-child, .ig-md ul:last-child, .ig-md ol:last-child { margin-bottom: 0; }
.ig-md ul, .ig-md ol { padding-left: 1.2rem; margin-bottom: .5rem; }
.ig-md a { font-weight: 600; text-decoration-color: var(--ig-lime); text-decoration-thickness: 2px; text-underline-offset: 2px; }
.ig-md table { width: 100%; font-size: .84rem; margin: .4rem 0; border-collapse: collapse; }
.ig-md th, .ig-md td { padding: 4px 6px; border-bottom: 1px solid var(--bs-border-color); }
.ig-md code { background: rgba(33, 39, 33, .08); padding: 1px 4px; border-radius: 4px; color: inherit; }
.ig-md h3, .ig-md h4, .ig-md h5 { font-size: .95rem; margin: .6rem 0 .3rem; }
.ig-chat-block { border: 1px solid var(--bs-border-color); border-radius: 12px; overflow: hidden; background: var(--ig-card-bg); }
.ig-chat-block-title { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--bs-secondary-color); padding: 8px 12px; border-bottom: 1px solid var(--bs-border-color); }
.ig-chat-block .table { font-size: .82rem; }
.ig-chat-block .table th { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bs-secondary-color); white-space: nowrap; }
.ig-chat-block .table td { white-space: nowrap; }
.ig-chat-chart { position: relative; height: 220px; padding: 10px; }
.ig-chat-link { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; text-decoration: none; padding: 4px 10px; border-radius: 20px;
  background: var(--ig-lime-soft); color: var(--ig-dark); }
[data-bs-theme="dark"] .ig-chat-link { background: rgba(231, 249, 8, .12); color: var(--ig-lime); }
.ig-action-card { border: 1px solid var(--ig-dark); border-radius: 14px; padding: 12px 14px; background: var(--ig-card-bg); box-shadow: 0 0 0 4px rgba(231, 249, 8, .45); }
.ig-action-card.done, .ig-action-card.cancelled, .ig-action-card.failed { box-shadow: none; border-color: var(--bs-border-color); }
[data-bs-theme="dark"] .ig-action-card { border-color: var(--ig-lime); box-shadow: 0 0 0 4px rgba(231, 249, 8, .12); }
.ig-action-head { display: flex; align-items: center; margin-bottom: 8px; }
.ig-action-lines { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 10px; font-size: .85rem; }
.ig-action-lines dt { color: var(--bs-secondary-color); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; padding-top: 2px; }
.ig-action-lines dd { margin: 0; font-weight: 500; }
.ig-chat-welcome { margin: auto 0; text-align: center; padding: 10px 6px; }
.ig-chat-welcome .ig-hero-icon { margin: 0 auto; }
.ig-chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ig-suggestion { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--bs-border-color); background: var(--ig-card-bg); color: inherit;
  border-radius: 20px; padding: 6px 12px; font-size: .82rem; font-weight: 500; transition: border-color .15s, background-color .15s; }
.ig-suggestion:hover { border-color: var(--ig-dark); background: var(--ig-lime-soft); }
[data-bs-theme="dark"] .ig-suggestion:hover { border-color: var(--ig-lime); background: rgba(231, 249, 8, .08); }
.ig-typing .bubble { display: inline-flex; gap: 4px; align-items: center; }
.ig-typing .bubble span { width: 7px; height: 7px; border-radius: 50%; background: var(--bs-secondary-color); animation: ig-dot 1.2s infinite ease-in-out; }
.ig-typing .bubble span:nth-child(2) { animation-delay: .15s; }
.ig-typing .bubble span:nth-child(3) { animation-delay: .3s; }
@keyframes ig-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ig-assistant-page { display: grid; grid-template-columns: 300px 1fr; gap: 16px; height: calc(100vh - 64px - 86px); min-height: 520px; }
.ig-assistant-history, .ig-assistant-main { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.ig-assistant-list { overflow-y: auto; flex: 1; }
.ig-assistant-list .list-group-item.active { background: var(--ig-dark); border-color: var(--ig-dark); }
[data-bs-theme="dark"] .ig-assistant-list .list-group-item.active { background: var(--ig-lime); border-color: var(--ig-lime); color: var(--ig-dark); }
.ig-assistant-main .ig-chat-messages { padding: 22px clamp(16px, 4vw, 48px) 8px; }
/* telefono e tablet: la chat riempie lo schermo visibile (barra di invio sempre in vista), le conversazioni si aprono dall'intestazione */
@media (max-width: 991.98px) {
  .ig-content:has(> .ig-assistant-page) { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .ig-assistant-page { display: flex; flex-direction: column; gap: 12px; min-height: 360px;
    height: calc(100vh - 64px - 30px); height: calc(100dvh - 64px - env(safe-area-inset-top) - 30px - env(safe-area-inset-bottom)); }
  .ig-assistant-history { display: none; flex-shrink: 0; max-height: 45%; }
  .ig-assistant-page.history-open .ig-assistant-history { display: flex; }
  .ig-assistant-main { flex: 1; }
  .ig-assistant-head { padding: 10px 12px; }
  .ig-assistant-head .inuit { width: 34px; height: 34px; }
  .ig-assistant-head .ig-modal-eyebrow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ig-assistant-head .btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; flex-shrink: 0; }
  .ig-assistant-main .ig-chat-messages { padding: 14px 12px 8px; }
  .ig-chat-form { padding: 10px; }
}

/* ---------- Inuit: icona, widget e chat ---------- */
.inuit { display: block; flex-shrink: 0; }
.inuit .inuit-bg { fill: var(--ig-dark); }
.inuit .inuit-ring { fill: #fff; }
.inuit .inuit-eyes, .inuit .inuit-block { fill: var(--ig-lime); }
.inuit .inuit-eyes { transform-box: view-box; transform-origin: 32px 32.5px; }
.inuit-blink .inuit-eyes { animation: inuit-blink 6s infinite; }
.inuit-thinking .inuit-eyes { animation: inuit-look 1.6s infinite ease-in-out; }
@keyframes inuit-blink { 0%, 93%, 100% { transform: scaleY(1); } 95.5% { transform: scaleY(.12); } }
@keyframes inuit-look { 0%, 100% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }
@media (prefers-reduced-motion: reduce) { .inuit-blink .inuit-eyes, .inuit-thinking .inuit-eyes { animation: none; } }
/* icona monocromatica per menu e pulsanti (stesso uso delle bootstrap icons) */
.bi-inuit::before {
  content: ""; display: inline-block; width: 1em; height: 1em; vertical-align: -.125em; background: currentColor;
  -webkit-mask: url("../img/inuit-mono.svg") center / contain no-repeat; mask: url("../img/inuit-mono.svg") center / contain no-repeat;
}
.ig-msg-avatar.inuit { width: 32px; height: 32px; border-radius: 10px; }

.inuit-widget { position: fixed; right: 22px; bottom: 22px; z-index: 1045; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
@media (display-mode: standalone) { .inuit-widget { bottom: calc(22px + env(safe-area-inset-bottom)); } }
.inuit-fab {
  display: inline-flex; align-items: center; gap: 10px; height: 56px; padding: 0 20px 0 7px; border: 0; border-radius: 28px;
  background: var(--ig-dark); color: var(--ig-lime); font-weight: 700; font-size: .95rem;
  box-shadow: 0 16px 34px -12px rgba(21, 25, 21, .75), 0 0 0 1px rgba(255, 255, 255, .06); transition: transform .15s, box-shadow .15s;
}
.inuit-fab .inuit { width: 42px; height: 42px; }
.inuit-fab:hover { transform: translateY(-2px); box-shadow: 0 20px 40px -14px rgba(21, 25, 21, .85), 0 0 0 1px rgba(255, 255, 255, .06); }
.inuit-widget.open .inuit-fab { box-shadow: 0 0 0 4px rgba(231, 249, 8, .55), 0 16px 34px -12px rgba(21, 25, 21, .75); }
.inuit-card {
  width: min(380px, calc(100vw - 32px)); background: var(--ig-card-bg); border-radius: 20px; overflow: hidden;
  border: 1px solid var(--bs-border-color); box-shadow: 0 30px 70px -20px rgba(21, 25, 21, .5);
  transform-origin: bottom right; animation: inuit-pop .18s cubic-bezier(.2, .8, .2, 1);
}
@keyframes inuit-pop { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
.inuit-card[hidden] { display: none; }
.inuit-card-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px; position: relative;
  background: linear-gradient(180deg, color-mix(in srgb, var(--ig-lime) 16%, var(--ig-card-bg)) 0%, var(--ig-card-bg) 100%);
}
.inuit-card-head::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--ig-lime); }
[data-bs-theme="dark"] .inuit-card-head { background: linear-gradient(180deg, color-mix(in srgb, var(--ig-lime) 7%, var(--ig-card-bg)) 0%, var(--ig-card-bg) 100%); }
.inuit-card-head .inuit { border-radius: 12px; }
.inuit-card-head .btn-close { align-self: flex-start; }
.fw-700 { font-weight: 700; }
.inuit-card-body { padding: 4px 16px 12px; }
.inuit-card-body textarea { resize: none; min-height: 64px; max-height: 160px; border-radius: 12px; font-size: .92rem; }
.inuit-card-body textarea:focus { border-color: var(--ig-dark); box-shadow: 0 0 0 4px rgba(231, 249, 8, .5); }
.inuit-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.inuit-chips button { border: 1px solid var(--bs-border-color); background: var(--ig-card-bg); color: inherit; border-radius: 20px; padding: 4px 10px; font-size: .78rem; font-weight: 500; }
.inuit-chips button:hover { border-color: var(--ig-dark); background: var(--ig-lime-soft); }
[data-bs-theme="dark"] .inuit-chips button:hover { border-color: var(--ig-lime); background: rgba(231, 249, 8, .08); }
.inuit-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 10px 16px; border-top: 1px solid var(--bs-border-color); background: var(--ig-gray-2); }
[data-bs-theme="dark"] .inuit-card-foot { background: #181d18; }
.inuit-card-foot a { text-decoration: none; font-weight: 600; }
.inuit-card.sending .inuit-eyes { animation: inuit-look 1.6s infinite ease-in-out; }
.inuit-card.sending .btn-primary::after { content: ""; display: inline-block; width: .8em; height: .8em; margin-left: 6px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spinner-border .7s linear infinite; vertical-align: -.1em; }
@media (max-width: 575.98px) {
  .inuit-widget { right: 14px; bottom: 14px; }
  .inuit-fab { padding: 0 7px; width: 56px; justify-content: center; }
  .inuit-fab-label { display: none; }
}
.ig-chat-welcome .inuit { margin: 0 auto; border-radius: 20px; box-shadow: 0 14px 30px -14px rgba(21, 25, 21, .6); }
.ig-assistant-head .inuit { border-radius: 12px; }
.ig-msg-avatar.inuit { background: none; display: block; }
.inuit-widget ~ #ig-toasts { padding-bottom: 92px !important; }
/* la finestra del widget non supera lo schermo: scorre il contenuto, intestazione e pulsanti restano visibili */
.inuit-card { display: flex; flex-direction: column; max-height: calc(100vh - 110px); max-height: calc(100dvh - 110px); }
.inuit-card-body { overflow-y: auto; min-height: 0; }
/* telefono e tablet: il pulsante di Inuit non copre i comandi della pagina */
@media (max-width: 991.98px) {
  body:has(#inuit-widget) .ig-content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  body:has(.sticky-actions) .inuit-widget { bottom: calc(84px + env(safe-area-inset-bottom)); }
  body:has(.ig-sidebar.open) .inuit-widget,
  body:has(.ig-main :is(input, textarea, select, [contenteditable]):focus) .inuit-widget { display: none; }
}
/* schermi touch: testo dei campi a 16px (iOS altrimenti ingrandisce la pagina e i pulsanti escono dallo schermo), bersagli più grandi */
@media (pointer: coarse) {
  .form-control, .form-select, .ts-control, .ts-control input, .inuit-card-body textarea { font-size: 16px; }
  .inuit-chips button, .ig-suggestion { min-height: 36px; }
  .ig-chat-link { min-height: 32px; }
  .ig-file-chip button { padding: 6px; }
  .ig-action-card .btn-sm { min-height: 38px; padding-left: 14px; padding-right: 14px; }
}

/* ---------- finestra di conferma (sostituisce alert/confirm/prompt del browser) ---------- */
.ig-dialog { z-index: 1070; }
.modal-backdrop.ig-dialog-backdrop { z-index: 1065; }
.ig-dialog .modal-dialog { max-width: 460px; }
.ig-dialog .ig-confirm { padding-top: 32px; }
.ig-dialog .modal-footer .btn { min-width: 120px; }
/* menu delle select con ricerca agganciato alla pagina: sopra modali e finestre */
body > .ts-dropdown { z-index: 1080; }
