/* ============================================================
   Spotless - design system
   Un solo file, token in :root. Font: Bricolage Grotesque (titoli), Hanken Grotesk (testo).
   Palette: carta calda + teal profondo + un tocco di ambra. Nessuna libreria CSS.
   ============================================================ */

@import url('fonts.css');

:root {
  /* colori */
  --bg:            #F6F5F1;
  --bg-2:          #EFEDE7;
  --surface:       #FFFFFF;
  --surface-2:     #FAF9F6;
  --border:        #E3E0D8;
  --border-strong: #CBC7BC;
  --text:          #17191D;
  --text-2:        #4B4F58;
  --text-3:        #7B808B;
  --text-inverse:  #FFFFFF;

  --primary:       #0E6B69;
  --primary-hover: #0B5654;
  --primary-soft:  #E1F0EF;
  --primary-ring:  rgba(14, 107, 105, .28);

  --amber:         #B8862B;
  --amber-soft:    #FBF1DC;
  --success:       #1F7A4D;
  --success-soft:  #E3F3EA;
  --warning:       #9A5B00;
  --warning-soft:  #FBEEDA;
  --danger:        #B3261E;
  --danger-soft:   #FBE7E5;
  --info:          #2B5FA8;
  --info-soft:     #E6EDF9;

  /* tipografia */
  --font-display: 'Bricolage Grotesque', 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body:    'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --fs-xs: .78rem; --fs-sm: .875rem; --fs-md: 1rem; --fs-lg: 1.125rem;
  --fs-xl: 1.375rem; --fs-2xl: 1.75rem; --fs-3xl: 2.25rem; --fs-4xl: 3rem;

  /* spaziatura e forme */
  --s-1: .25rem; --s-2: .5rem; --s-3: .75rem; --s-4: 1rem; --s-5: 1.5rem; --s-6: 2rem; --s-7: 3rem; --s-8: 4rem;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 16px; --radius-xl: 22px; --radius-full: 999px;
  --shadow-sm: 0 1px 2px rgba(23, 25, 29, .05);
  --shadow:    0 2px 8px rgba(23, 25, 29, .06), 0 1px 2px rgba(23, 25, 29, .04);
  --shadow-lg: 0 12px 32px rgba(23, 25, 29, .12), 0 2px 6px rgba(23, 25, 29, .06);
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --content-max: 1180px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: var(--fs-md); line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 650; letter-spacing: -.015em; line-height: 1.15; margin: 0 0 var(--s-3); color: var(--text); }
h1 { font-size: var(--fs-2xl); } h2 { font-size: var(--fs-xl); } h3 { font-size: var(--fs-lg); } h4 { font-size: var(--fs-md); }
@media (min-width: 640px) { h1 { font-size: var(--fs-3xl); } h2 { font-size: var(--fs-2xl); } h3 { font-size: var(--fs-xl); } h4 { font-size: var(--fs-lg); } }
p { margin: 0 0 var(--s-4); }
small, .text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.mono { font-family: var(--font-mono); font-size: .92em; }
.display { font-family: var(--font-display); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-5) 0; }
:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 2px; border-radius: var(--radius-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.container { width: 100%; max-width: var(--content-max); margin: 0 auto; padding-inline: var(--s-4); }
@media (min-width: 640px) { .container { padding-inline: var(--s-5); } }
.stack > * + * { margin-top: var(--s-4); }
.stack-sm > * + * { margin-top: var(--s-2); }
.row { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grid { display: grid; gap: var(--s-4); }
.grid-2, .grid-3, .grid-4, .grid-main { grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2, .grid-3, .grid-4, .grid-main { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 960px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }
.mt-0 { margin-top: 0 } .mt-2 { margin-top: var(--s-2) } .mt-4 { margin-top: var(--s-4) } .mt-6 { margin-top: var(--s-6) }
.mb-0 { margin-bottom: 0 } .mb-2 { margin-bottom: var(--s-2) } .mb-4 { margin-bottom: var(--s-4) } .mb-6 { margin-bottom: var(--s-6) }
.flex-1 { flex: 1 1 auto; min-width: 0; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }

/* ---------- app shell (mobile first: drawer + tabbar; sidebar fissa da 900px) ---------- */
.app { display: block; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(84vw, 300px); height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border);
  padding: calc(var(--s-4) + env(safe-area-inset-top)) var(--s-3) calc(var(--s-4) + env(safe-area-inset-bottom));
  transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); overflow-y: auto;
}
.sidebar.is-open { transform: none; }
.backdrop { position: fixed; inset: 0; background: rgba(23, 25, 29, .4); z-index: 39; }
.brand { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-2) var(--s-4); color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; letter-spacing: -.02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: var(--s-3); min-height: 44px; padding: .6rem .75rem; border-radius: var(--radius);
  color: var(--text-2); font-weight: 500; text-decoration: none; transition: background .15s var(--ease), color .15s var(--ease);
}
.nav a svg { width: 20px; height: 20px; stroke-width: 1.8; flex: none; }
.nav a:hover { background: var(--bg-2); color: var(--text); text-decoration: none; }
.nav a.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav a.btn { color: var(--text-inverse); background: var(--primary); justify-content: center; }
.nav a.btn:hover { background: var(--primary-hover); color: var(--text-inverse); }
.nav .nav-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: var(--s-4) .75rem var(--s-1); font-weight: 600; }
.sidebar-footer { margin-top: auto; padding-top: var(--s-4); border-top: 1px solid var(--border); }
.storage { font-size: var(--fs-xs); color: var(--text-3); }
.user-chip { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2); border-radius: var(--radius); margin-top: var(--s-2); }
.user-chip:hover { background: var(--bg-2); }
.avatar { width: 32px; height: 32px; border-radius: var(--radius-full); background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: var(--fs-sm); flex: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; min-height: var(--topbar-h); display: flex; align-items: center; gap: var(--s-2);
  padding: env(safe-area-inset-top) var(--s-4) 0; background: rgba(246, 245, 241, .88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: var(--fs-lg); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.content { padding: var(--s-4) var(--s-4) calc(var(--s-8) + 12px + env(safe-area-inset-bottom)); max-width: var(--content-max); width: 100%; }
.page-head { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); }
.page-head p { margin: 0; color: var(--text-2); }
.page-head .actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.menu-btn { display: inline-flex; }
.tabbar {
  display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 48px; font-size: .68rem; color: var(--text-3); text-decoration: none; }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.is-active { color: var(--primary); }
.tabbar a:hover { text-decoration: none; }
.hide-mobile { display: none !important; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; width: auto; height: 100vh; transform: none; box-shadow: none; padding: var(--s-4) var(--s-3); z-index: 1; }
  .backdrop { display: none !important; }
  .topbar { height: var(--topbar-h); padding: 0 var(--s-5); gap: var(--s-3); }
  .topbar h1 { font-size: var(--fs-xl); }
  .content { padding: var(--s-5); }
  .page-head { flex-direction: row; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5); }
  .menu-btn, .btn-icon.menu-btn { display: none; }
  .tabbar { display: none; }
  .hide-mobile { display: revert !important; }
  .hide-desktop { display: none !important; }
}

/* ---------- pagine pubbliche ---------- */
.site-header { position: sticky; top: 0; z-index: 20; background: rgba(246, 245, 241, .88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: var(--s-3); }
.site-nav { display: flex; align-items: center; gap: var(--s-3); }
.site-nav a { color: var(--text-2); font-weight: 500; min-height: 44px; display: inline-flex; align-items: center; padding-inline: var(--s-1); }
.site-nav a.btn { color: var(--text-inverse); min-height: 40px; padding-inline: 1rem; } /* .site-nav a ha specificita' maggiore di .btn: ripristina il testo bianco */
.site-footer { border-top: 1px solid var(--border); padding: var(--s-6) 0; margin-top: var(--s-8); color: var(--text-3); font-size: var(--fs-sm); }
.site-footer .container { display: flex; flex-direction: column; gap: var(--s-2); }
@media (min-width: 640px) { .site-footer .container { flex-direction: row; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; } }
.hero { padding: var(--s-6) 0 var(--s-5); }
@media (min-width: 640px) { .hero { padding: var(--s-8) 0 var(--s-7); } }
.hero h1 { font-size: clamp(1.9rem, 6vw, 3.6rem); max-width: 16ch; }
.hero p.lead { font-size: var(--fs-lg); color: var(--text-2); max-width: 52ch; }
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: start center; padding: calc(var(--s-5) + env(safe-area-inset-top)) var(--s-4) var(--s-6); }
@media (min-width: 640px) { .auth-page { place-items: center; } }
.auth-card { width: 100%; max-width: 440px; }
.auth-card .brand { justify-content: center; padding-bottom: var(--s-5); }

/* ---------- card ---------- */
.feature-head { display: flex; align-items: center; gap: var(--s-3); padding-bottom: var(--s-3); }
.feature-head .icon-box { width: 40px; height: 40px; border-radius: var(--radius); background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.feature-head .icon-box svg { width: 20px; height: 20px; }
.card-muted { background: var(--surface-2); }
.list-plain { padding-left: 1.1rem; margin: 0; }
.inline-link { display: inline-block; margin-top: var(--s-3); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s-5); box-shadow: var(--shadow-sm); }
.card-sm { padding: var(--s-4); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.card-head h2, .card-head h3 { margin: 0; }
.card-title { font-family: var(--font-display); font-weight: 650; font-size: var(--fs-lg); margin: 0; }
a.card, a.card:hover { color: inherit; text-decoration: none; }
.card.is-clickable { transition: box-shadow .15s var(--ease), transform .15s var(--ease); }
.card.is-clickable:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi { display: flex; flex-direction: column; gap: var(--s-1); }
.kpi .kpi-label { font-size: var(--fs-sm); color: var(--text-3); font-weight: 500; }
.kpi .kpi-value { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi .kpi-delta { font-size: var(--fs-xs); color: var(--text-3); }
.kpi .kpi-delta.up { color: var(--success); } .kpi .kpi-delta.down { color: var(--danger); }

/* ---------- bottoni ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px; padding: .6rem 1rem; border-radius: var(--radius); border: 1px solid transparent; background: var(--primary); color: var(--text-inverse);
  font-weight: 600; font-size: var(--fs-sm); line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap; -webkit-tap-highlight-color: transparent;
  transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease), transform .05s;
}
.btn svg { width: 18px; height: 18px; stroke-width: 2; }
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #8F1E17; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover { background: #F5D3D0; }
.btn-sm { min-height: 38px; padding: .4rem .7rem; font-size: var(--fs-xs); }
.btn-lg { padding: .8rem 1.3rem; font-size: var(--fs-md); }
.btn-icon { min-width: 44px; min-height: 44px; padding: .5rem; border-radius: var(--radius); background: transparent; color: var(--text-2); border: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; position: relative; -webkit-tap-highlight-color: transparent; }
.btn-icon:hover { background: var(--bg-2); color: var(--text); }
.btn-icon svg { width: 20px; height: 20px; stroke-width: 1.8; }
.btn-block { width: 100%; }
.badge-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }

/* ---------- form ---------- */
.field { display: flex; flex-direction: column; gap: var(--s-1); margin-bottom: var(--s-4); }
.field label, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: .6rem .8rem; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  font-size: 16px; transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.input.is-invalid, .select.is-invalid { border-color: var(--danger); }
.textarea { min-height: 120px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%234B4F58' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2.2rem; }
.help { font-size: var(--fs-xs); color: var(--text-3); }
.error { font-size: var(--fs-xs); color: var(--danger); }
.check { display: flex; align-items: flex-start; gap: var(--s-2); font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; }
.check { min-height: 44px; align-items: center; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .2s; }
.switch span::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s var(--ease); box-shadow: var(--shadow-sm); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--primary-ring); }
.input-group { display: flex; gap: var(--s-2); }
.input-group .input { flex: 1; }

/* ---------- tabelle ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
/* Tabella responsive: con .table-cards su mobile ogni riga diventa una card e le celle mostrano data-label */
@media (max-width: 639px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: var(--s-2) 0; border-bottom: 1px solid var(--border); }
  .table-cards td { display: flex; justify-content: space-between; gap: var(--s-3); padding: .3rem .9rem; border: 0; text-align: right; }
  .table-cards td::before { content: attr(data-label); color: var(--text-3); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; text-align: left; flex: none; }
  .table-cards td.actions { justify-content: flex-end; }
  .table-cards td.actions::before { content: none; }
}

/* ---------- badge e tag ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: .2rem .55rem; border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: 600; background: var(--bg-2); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.no-dot::before { display: none; }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success, .badge-ready, .badge-done, .badge-active, .badge-sent { background: var(--success-soft); color: var(--success); }
.badge-warning, .badge-needs_review, .badge-needs_consent, .badge-pending, .badge-queued { background: var(--warning-soft); color: var(--warning); }
.badge-danger, .badge-failed, .badge-expired, .badge-locked { background: var(--danger-soft); color: var(--danger); }
.badge-info, .badge-processing, .badge-running { background: var(--info-soft); color: var(--info); }
.badge-muted, .badge-archive_only, .badge-dismissed { background: var(--bg-2); color: var(--text-3); }
.tag { display: inline-flex; align-items: center; padding: .15rem .5rem; border-radius: var(--radius-sm); background: var(--bg-2); color: var(--text-2); font-size: var(--fs-xs); font-weight: 500; }
.tag-amber { background: var(--amber-soft); color: var(--amber); }

/* ---------- alert, toast, empty ---------- */
.alert { display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-sm); margin-bottom: var(--s-4); }
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert-success { background: var(--success-soft); border-color: #BFE3CF; color: #14522F; }
.alert-warning { background: var(--warning-soft); border-color: #F1D7A6; color: #6B3F00; }
.alert-danger { background: var(--danger-soft); border-color: #F1C2BE; color: #7A1A14; }
.alert-info { background: var(--info-soft); border-color: #C3D4EF; color: #1E4076; }
.toasts { position: fixed; left: var(--s-4); right: var(--s-4); bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 100; display: flex; flex-direction: column; gap: var(--s-2); }
@media (min-width: 900px) { .toasts { left: auto; bottom: var(--s-4); max-width: 380px; } }
.toast { background: var(--text); color: #fff; padding: .75rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); display: flex; gap: var(--s-3); align-items: center; animation: toast-in .25s var(--ease); }
.toast-success { background: var(--success); } .toast-danger { background: var(--danger); } .toast-warning { background: var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.empty { text-align: center; padding: var(--s-7) var(--s-4); color: var(--text-3); }
.empty svg { width: 44px; height: 44px; margin: 0 auto var(--s-3); stroke-width: 1.4; color: var(--border-strong); }
.empty h3 { color: var(--text-2); font-size: var(--fs-lg); }
.empty p { max-width: 40ch; margin-inline: auto; }

/* ---------- modale ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; padding: 0; background: rgba(23, 25, 29, .45); }
.modal-box { background: var(--surface); border-radius: var(--radius-xl) var(--radius-xl) 0 0; width: 100%; max-height: 92vh; max-height: 92dvh; overflow: auto; box-shadow: var(--shadow-lg); padding: var(--s-4) var(--s-4) calc(var(--s-5) + env(safe-area-inset-bottom)); animation: sheet-in .25s var(--ease); }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  .modal { align-items: center; padding: var(--s-4); }
  .modal-box { border-radius: var(--radius-xl); max-width: 520px; max-height: 90vh; padding: var(--s-5); animation: toast-in .2s var(--ease); }
  .modal-box.is-wide { max-width: 760px; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-4); }
.modal-head h3 { margin: 0; }
.modal-foot { display: flex; flex-direction: column-reverse; gap: var(--s-2); margin-top: var(--s-5); }
.modal-foot .btn { width: 100%; }
@media (min-width: 640px) { .modal-foot { flex-direction: row; justify-content: flex-end; } .modal-foot .btn { width: auto; } }

/* ---------- liste e voci ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: var(--s-3); min-height: 56px; padding: var(--s-3) 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .icon-box { width: 40px; height: 40px; border-radius: var(--radius); background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.list-item .icon-box svg { width: 20px; height: 20px; }
.list-item .title { font-weight: 600; }
.list-item .sub { font-size: var(--fs-xs); color: var(--text-3); }
.list-item .meta { margin-left: auto; text-align: right; font-size: var(--fs-sm); white-space: nowrap; }
a.list-item { color: inherit; text-decoration: none; }
a.list-item:hover { background: var(--surface-2); margin-inline: calc(-1 * var(--s-3)); padding-inline: var(--s-3); border-radius: var(--radius); }

/* ---------- upload ---------- */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); padding: var(--s-5) var(--s-4); text-align: center; background: var(--surface); transition: border-color .15s, background .15s; cursor: pointer; }
.dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone svg { width: 40px; height: 40px; margin: 0 auto var(--s-3); color: var(--primary); stroke-width: 1.5; }
.progress { height: 8px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s var(--ease); }
.progress.is-warning > span { background: var(--warning); } .progress.is-danger > span { background: var(--danger); }

/* ---------- calendario ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-4); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); text-align: center; padding: var(--s-1) 0; font-weight: 600; }
.cal-day { min-height: 52px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; font-size: var(--fs-xs); display: flex; flex-direction: column; gap: 3px; }
@media (min-width: 640px) { .cal-day { min-height: 88px; padding: 6px; border-radius: var(--radius); } }
.cal-day .d { font-weight: 600; color: var(--text-2); }
.cal-day.is-other { opacity: .45; }
.cal-day.is-today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-day.is-today .d { color: var(--primary); }
.cal-ev { display: block; height: 6px; padding: 0; border-radius: 3px; background: var(--primary-soft); color: var(--primary); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; font-size: 0; }
@media (min-width: 640px) { .cal-ev { height: auto; padding: 2px 6px; border-radius: 4px; font-size: var(--fs-xs); } }
.cal-ev.is-warning { background: var(--warning-soft); color: var(--warning); }
.cal-ev.is-danger { background: var(--danger-soft); color: var(--danger); }
.cal-ev.is-done { background: var(--bg-2); color: var(--text-3); text-decoration: line-through; }
.deadline-days { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); min-width: 3.2rem; text-align: center; }
.deadline-days.is-soon { color: var(--warning); } .deadline-days.is-late { color: var(--danger); } .deadline-days.is-ok { color: var(--success); }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; height: calc(100dvh - var(--topbar-h) - var(--s-4) * 2 - 60px - env(safe-area-inset-bottom)); min-height: 360px; }
@media (min-width: 900px) { .chat { height: calc(100vh - var(--topbar-h) - var(--s-5) * 2); min-height: 480px; } }
.chat-log { flex: 1; overflow-y: auto; padding: var(--s-2) var(--s-1); display: flex; flex-direction: column; gap: var(--s-3); }
.msg { max-width: 92%; padding: .75rem 1rem; border-radius: var(--radius-lg); line-height: 1.5; font-size: var(--fs-md); }
.msg-user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 6px; }
@media (min-width: 640px) { .msg { max-width: min(78ch, 88%); } }
.msg-assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.msg-assistant p:last-child { margin-bottom: 0; }
.msg-assistant ul, .msg-assistant ol { padding-left: 1.2rem; margin: .4rem 0; }
.msg .cites { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--s-2); }
.msg .cites a { font-size: var(--fs-xs); background: var(--primary-soft); color: var(--primary); padding: 2px 8px; border-radius: 999px; }
.msg-status { font-size: var(--fs-xs); color: var(--text-3); align-self: flex-start; }
.chat-input { display: flex; gap: var(--s-2); align-items: flex-end; padding-top: var(--s-3); border-top: 1px solid var(--border); }
.chat-input .textarea { min-height: 48px; max-height: 160px; }
.chips { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); min-height: 36px; padding: .35rem .8rem; border-radius: 999px; font-size: var(--fs-sm); cursor: pointer; color: var(--text-2); display: inline-flex; align-items: center; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.typing { display: inline-flex; gap: 4px; padding: .5rem .8rem; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s } .typing i:nth-child(3) { animation-delay: .4s }
@keyframes blink { 0%, 80%, 100% { opacity: .25 } 40% { opacity: 1 } }

/* ---------- varie ---------- */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-2) var(--s-4); font-size: var(--fs-sm); }
.dl dt { color: var(--text-3); font-weight: 500; }
.dl dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.pill-nav { display: inline-flex; background: var(--bg-2); padding: 3px; border-radius: var(--radius); gap: 2px; }
.pill-nav a, .pill-nav button { min-height: 38px; display: inline-flex; align-items: center; padding: .35rem .8rem; border-radius: 8px; font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); border: 0; background: transparent; cursor: pointer; text-decoration: none; }
.pill-nav .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.skeleton { background: linear-gradient(90deg, var(--bg-2) 25%, #F4F2EC 50%, var(--bg-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius-sm); min-height: 1em; }
@keyframes shimmer { to { background-position: -200% 0; } }
.preview-frame { width: 100%; height: min(60vh, 720px); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-2); }
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: var(--s-1); z-index: 50; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: var(--s-2); width: 100%; padding: .5rem .7rem; border-radius: var(--radius-sm); color: var(--text-2); background: none; border: 0; text-align: left; font-size: var(--fs-sm); cursor: pointer; text-decoration: none; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--bg-2); color: var(--text); }
.dropdown-menu svg { width: 16px; height: 16px; }
.notif-panel { position: fixed; left: var(--s-2); right: var(--s-2); top: calc(var(--topbar-h) + env(safe-area-inset-top)); width: auto; max-height: 70vh; overflow: auto; }
@media (min-width: 640px) { .notif-panel { position: absolute; left: auto; right: 0; top: calc(100% + 6px); width: 360px; } }
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: .3rem .3rem .3rem .7rem; }
.notif-head .btn { width: auto; display: inline-flex; min-height: 40px; color: var(--primary); } /* non deve prendere lo stile a tutta larghezza delle voci del dropdown */
.notif { display: flex; gap: var(--s-2); padding: .6rem .7rem; border-radius: var(--radius-sm); font-size: var(--fs-sm); color: var(--text-2); }
.notif + .notif { margin-top: 2px; }
.notif.is-unread { background: var(--primary-soft); }
.notif .t { font-weight: 600; color: var(--text); }
.notif .when { font-size: var(--fs-xs); color: var(--text-3); }
.prose { max-width: 72ch; }
.prose h2 { margin-top: var(--s-6); }
.prose li { margin-bottom: var(--s-1); }
.step { display: flex; gap: var(--s-3); }
.step-n { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: var(--fs-sm); flex: none; }
.offer { border: 1px solid #F1D7A6; background: var(--amber-soft); border-radius: var(--radius); padding: var(--s-3) var(--s-4); font-size: var(--fs-sm); }
.offer .why { font-size: var(--fs-xs); color: var(--text-3); }
.chart-box { position: relative; height: 260px; }
/* Touch / mobile: anche i bottoni piccoli, le pill e i chip arrivano a 44px (regola mobile first). In fondo al file: deve vincere sulle regole dei componenti */
@media (pointer: coarse), (max-width: 899px) { .btn-sm, .chip, .pill-nav a, .pill-nav button { min-height: 44px; } }
@media print { .sidebar, .topbar, .tabbar, .btn { display: none !important; } .app { display: block; } }
