/* Illumina CRM — design system "glassy"
   Base: palette illuminalucegas.it (navy / arancio / crema), Outfit + Manrope */

@font-face { font-family: 'Outfit'; src: url('../fonts/outfit-latin.woff2') format('woff2'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Manrope'; src: url('../fonts/manrope-latin.woff2') format('woff2'); font-weight: 400 800; font-display: swap; }

/* ───────── Token ───────── */
:root {
  --navy-950: #0c151d;
  --navy-900: #14202b;
  --navy-800: #1b2a37;
  --navy-700: #24384a;
  --orange: #f5862a;
  --orange-600: #e07318;
  --orange-soft: rgba(245, 134, 42, .14);
  --cream: #f7f2ea;
  --muted-d: #a9b0b6;

  --ok: #3ccf91;  --ok-soft: rgba(60, 207, 145, .14);
  --warn: #f2c14e; --warn-soft: rgba(242, 193, 78, .16);
  --err: #ff6b6b; --err-soft: rgba(255, 107, 107, .14);
  --info: #6ab7ff; --info-soft: rgba(106, 183, 255, .14);

  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 11px;
  --pill: 999px;
  --blur: 18px;
  --sidebar-w: 264px;
  --topbar-h: 64px;
  --font-ui: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Outfit', 'Manrope', system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* tema scuro (default) */
  --bg: var(--navy-900);
  --bg-deep: var(--navy-950);
  --text: var(--cream);
  --text-2: var(--muted-d);
  --text-3: rgba(169, 176, 182, .7);
  --glass: rgba(255, 255, 255, .045);
  --glass-strong: rgba(255, 255, 255, .075);
  --glass-solid: rgba(27, 42, 55, .96);
  --glass-border: rgba(247, 242, 234, .10);
  --glass-border-strong: rgba(247, 242, 234, .18);
  --glass-highlight: rgba(255, 255, 255, .06);
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, .55);
  --input-bg: rgba(255, 255, 255, .05);
  --hover: rgba(255, 255, 255, .06);
  --glow-1: rgba(245, 134, 42, .22);
  --glow-2: rgba(80, 140, 200, .16);
  --on-orange: var(--navy-900);
  color-scheme: dark;
}

/* tema chiaro: esplicito ([data-theme=light]) o automatico (nessun data-theme + sistema chiaro) */
:root[data-theme="light"] {
  --bg: #f4efe7;
  --bg-deep: #ebe4d8;
  --text: #14202b;
  --text-2: #4c5a66;
  --text-3: #6f7b85;
  --glass: rgba(255, 255, 255, .58);
  --glass-strong: rgba(255, 255, 255, .78);
  --glass-solid: rgba(255, 255, 255, .97);
  --glass-border: rgba(20, 32, 43, .09);
  --glass-border-strong: rgba(20, 32, 43, .16);
  --glass-highlight: rgba(255, 255, 255, .9);
  --shadow: 0 10px 34px -14px rgba(20, 32, 43, .22);
  --input-bg: rgba(255, 255, 255, .75);
  --hover: rgba(20, 32, 43, .05);
  --glow-1: rgba(245, 134, 42, .20);
  --glow-2: rgba(80, 140, 200, .14);
  --orange-soft: rgba(245, 134, 42, .15);
  --ok: #138a5b; --warn: #a06a00; --err: #c43c3c; --info: #2a6fb5;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f4efe7;
    --bg-deep: #ebe4d8;
    --text: #14202b;
    --text-2: #4c5a66;
    --text-3: #6f7b85;
    --glass: rgba(255, 255, 255, .58);
    --glass-strong: rgba(255, 255, 255, .78);
    --glass-solid: rgba(255, 255, 255, .97);
    --glass-border: rgba(20, 32, 43, .09);
    --glass-border-strong: rgba(20, 32, 43, .16);
    --glass-highlight: rgba(255, 255, 255, .9);
    --shadow: 0 10px 34px -14px rgba(20, 32, 43, .22);
    --input-bg: rgba(255, 255, 255, .75);
    --hover: rgba(20, 32, 43, .05);
    --glow-1: rgba(245, 134, 42, .20);
    --glow-2: rgba(80, 140, 200, .14);
    --ok: #138a5b; --warn: #a06a00; --err: #c43c3c; --info: #2a6fb5;
    color-scheme: light;
  }
}

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* luci di sfondo: danno profondità al vetro */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vmax 50vmax at 12% -10%, var(--glow-1), transparent 60%),
    radial-gradient(50vmax 45vmax at 105% 20%, var(--glow-2), transparent 60%),
    radial-gradient(45vmax 40vmax at 40% 120%, var(--glow-1), transparent 65%),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; letter-spacing: -.01em; margin: 0; line-height: 1.2; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 .75rem; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.eyebrow { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-2); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.num { font-variant-numeric: tabular-nums; }

/* ───────── Vetro ───────── */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-highlight);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
  backdrop-filter: blur(var(--blur)) saturate(140%);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--glass-solid); }
}

/* ───────── Shell ───────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px 14px;
  border-radius: 0; border-width: 0 1px 0 0;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand svg { flex: none; }
.brand-name { font-family: var(--font-display); font-size: 1.45rem; font-weight: 500; line-height: 1; letter-spacing: -.02em; }
.brand-sub { display: block; font-size: .68rem; color: var(--orange); letter-spacing: .18em; font-weight: 600; margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
.nav-group { margin: 14px 10px 6px; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); font-weight: 700; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 600; font-size: .92rem;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] {
  background: var(--orange-soft); color: var(--text);
  box-shadow: inset 2px 0 0 var(--orange);
}
.nav a[aria-current="page"] svg { color: var(--orange); }
.nav .soon { margin-left: auto; font-size: .62rem; font-weight: 700; letter-spacing: .06em; padding: 2px 7px; border-radius: var(--pill); border: 1px solid var(--glass-border-strong); color: var(--text-3); }

.side-foot { border-top: 1px solid var(--glass-border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px;
  border-radius: 0; border-width: 0 0 1px 0;
}
.topbar .title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 500; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title .crumb { color: var(--text-2); font-weight: 400; }
.menu-btn { display: none; }
.content { padding: 28px; width: 100%; max-width: 1400px; margin: 0 auto; flex: 1; }

/* utente */
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 6px; border-radius: var(--pill); color: var(--text); cursor: pointer; border: 1px solid transparent; background: none; font: inherit; }
.user-chip:hover { background: var(--hover); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem; background: linear-gradient(135deg, var(--orange), #f7b15f); color: var(--on-orange); flex: none; }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; text-align: left; min-width: 0; }
.user-meta b { font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { font-size: .72rem; color: var(--text-2); }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px;
  padding: 6px; display: none; z-index: 60;
  background: var(--glass-solid);
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: var(--text); font: inherit; font-size: .9rem; font-weight: 600;
  background: none; border: 0; cursor: pointer; text-align: left;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--hover); text-decoration: none; }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--glass-border); margin: 6px 4px; }

/* banner impersonazione */
.imp-banner {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 16px; font-size: .85rem; font-weight: 600;
  background: repeating-linear-gradient(135deg, var(--orange), var(--orange) 12px, var(--orange-600) 12px, var(--orange-600) 24px);
  color: var(--navy-900);
  position: sticky; top: 0; z-index: 50;
}
.imp-banner form { margin: 0; }
.imp-banner .btn { background: var(--navy-900); color: var(--cream); border-color: transparent; padding: 5px 14px; min-height: 30px; }

/* ───────── Tema toggle ───────── */
.theme-switch { display: inline-flex; padding: 3px; border-radius: var(--pill); border: 1px solid var(--glass-border); background: var(--input-bg); }
.theme-switch button { border: 0; background: none; color: var(--text-2); width: 34px; height: 30px; border-radius: var(--pill); display: grid; place-items: center; cursor: pointer; }
.theme-switch button[aria-pressed="true"] { background: var(--orange); color: var(--on-orange); }

/* ───────── Bottoni ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 20px;
  border-radius: var(--pill);
  border: 1px solid var(--glass-border-strong);
  background: transparent; color: var(--text);
  font: 700 .78rem/1 var(--font-ui); letter-spacing: .1em; text-transform: uppercase;
  cursor: pointer; white-space: nowrap;
  transition: transform .12s var(--ease), background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--hover); text-decoration: none; border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--orange); border-color: var(--orange); color: var(--on-orange); box-shadow: 0 8px 24px -10px rgba(245, 134, 42, .7); }
.btn-primary:hover { background: var(--orange-600); border-color: var(--orange-600); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 14px; font-size: .7rem; }
.btn-icon { width: 42px; padding: 0; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ───────── Form ───────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: .8rem; font-weight: 700; color: var(--text-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border-strong);
  background: var(--input-bg); color: var(--text);
  font: 500 16px/1.3 var(--font-ui); /* 16px: evita lo zoom automatico su iOS */
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 4px var(--orange-soft); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 48px; }
.input-wrap .reveal { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--text-2); width: 40px; height: 38px; display: grid; place-items: center; cursor: pointer; border-radius: 8px; }
.input-wrap .reveal:hover { color: var(--text); }
.check { display: flex; align-items: center; gap: 10px; font-size: .88rem; color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--orange); }

/* ───────── Alert / badge ───────── */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 600; margin-bottom: 16px; border: 1px solid transparent; }
.alert svg { flex: none; margin-top: 1px; }
.alert-error { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--pill); font-size: .72rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-caricato { background: var(--info-soft); color: var(--info); }
.b-in_gestione { background: var(--warn-soft); color: var(--warn); }
.b-attivato { background: var(--ok-soft); color: var(--ok); }
.b-stornato { background: var(--err-soft); color: var(--err); }
.b-neutral { background: var(--hover); color: var(--text-2); }
.b-orange { background: var(--orange-soft); color: var(--orange); }

/* ───────── Pagina / card ───────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin: 6px 0 0; color: var(--text-2); }
.card { padding: 22px; }
.card + .card { margin-top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.grid { display: grid; gap: 20px; }
.grid-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: 1.6fr 1fr; }

.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi .label { display: flex; align-items: center; gap: 8px; font-size: .8rem; font-weight: 700; color: var(--text-2); }
.kpi .ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--orange-soft); color: var(--orange); }
.kpi .value { font-family: var(--font-display); font-size: 2rem; font-weight: 500; margin-top: 12px; letter-spacing: -.02em; }
.kpi .delta { font-size: .78rem; font-weight: 700; color: var(--text-2); margin-top: 2px; }

.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty svg { color: var(--text-3); margin-bottom: 10px; }

/* ───────── Tabelle (diventano card su mobile) ───────── */
.table-wrap { overflow-x: auto; margin: 0 -22px -22px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); font-weight: 700; padding: 10px 22px; border-bottom: 1px solid var(--glass-border); white-space: nowrap; }
.table td { padding: 13px 22px; border-bottom: 1px solid var(--glass-border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--hover); }
.table .r { text-align: right; }

/* ───────── Login ───────── */
.auth { min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { padding: 48px clamp(32px, 5vw, 72px); display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth-hero h1 { font-size: clamp(2rem, 1.4rem + 2.4vw, 3.3rem); font-weight: 400; max-width: 14ch; }
.auth-hero h1 em { font-style: normal; color: var(--orange); }
.auth-hero .lead { color: var(--text-2); max-width: 42ch; font-size: 1.02rem; margin-top: 16px; }
.flow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; max-width: 520px; }
.flow span { padding: 6px 12px; border-radius: var(--pill); border: 1px solid var(--glass-border-strong); font-size: .75rem; font-weight: 600; color: var(--text-2); background: var(--glass); }
.flow span.on { border-color: var(--orange); color: var(--orange); }
.auth-panel { display: grid; place-items: center; padding: 32px 24px; }
.auth-card { width: 100%; max-width: 420px; padding: 34px 30px; }
.auth-card h2 { font-size: 1.6rem; font-weight: 500; }
.auth-card .sub { color: var(--text-2); margin: 6px 0 24px; }
.auth-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: .78rem; color: var(--text-3); }

/* ───────── Bottom nav mobile ───────── */
.bottom-nav { display: none; }
.scrim { display: none; }

/* ───────── Responsive ───────── */
@media (max-width: 1100px) {
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --blur: 12px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(86vw, 300px);
    transform: translateX(-105%); transition: transform .25s var(--ease);
    background: var(--glass-solid); border-width: 0 1px 0 0;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 12px 0 8px; gap: 6px; }
  .topbar .user-meta, .topbar .theme-switch { display: none; }
  .content { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
    padding: 6px; border-radius: 20px;
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px;
    color: var(--text-2); font: 700 .66rem/1 var(--font-ui); border-radius: 14px; background: none; border: 0; cursor: pointer;
  }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav [aria-current="page"] { color: var(--orange); background: var(--orange-soft); }
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 28px 20px 0; gap: 12px; }
  .auth-hero .flow, .auth-hero .hero-foot { display: none; }
  .auth-hero h1 { font-size: 1.9rem; }
  .auth-hero .lead { font-size: .95rem; margin-top: 10px; }
  .auth-panel { place-items: start center; padding: 24px 16px 32px; }
  .auth-card { padding: 26px 20px; }

  /* tabella → card */
  .table-wrap { margin: 0; overflow: visible; }
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { padding: 12px 0; border-bottom: 1px solid var(--glass-border); }
  .table.stack tr:hover { background: none; }
  .table.stack td { padding: 3px 0; border: 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table.stack td::before { content: attr(data-label); color: var(--text-3); font-size: .78rem; font-weight: 700; text-align: left; }
  .table.stack td.primary { font-weight: 700; font-size: 1rem; text-align: left; }
  .table.stack td.primary::before { display: none; }
}
@media (max-width: 520px) {
  .grid-kpi { gap: 12px; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 1.55rem; }
  .card { padding: 18px 16px; }
  .page-head { margin-bottom: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ───────── Step list ───────── */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; display: flex; flex-direction: column; gap: 4px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; column-gap: 12px; padding: 8px 0; position: relative; }
.steps li::before { content: counter(s); grid-row: span 2; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 800; color: var(--orange); background: var(--orange-soft); border: 1px solid color-mix(in srgb, var(--orange) 35%, transparent); }
.steps li:not(:last-child)::after { content: ''; position: absolute; left: 14.5px; top: 40px; bottom: -6px; width: 1px; background: var(--glass-border-strong); }
.steps b { font-size: .92rem; }
.steps span { font-size: .82rem; color: var(--text-2); }

/* tema: in alto su desktop, nel menu su mobile */
@media (min-width: 901px) { .side-foot .theme-switch { display: none; } }
@media (max-width: 900px) { .theme-switch-top { display: none; } }

/* ───────── Filtri / persona ───────── */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters .grow { flex: 1 1 260px; }
.filters select.input { flex: 0 1 220px; }
.who { display: flex; align-items: center; gap: 12px; text-align: left; }
.who > span:last-child { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.avatar.sm { width: 32px; height: 32px; font-size: .72rem; }
@media (max-width: 900px) {
  .filters select.input { flex: 1 1 100%; }
  .table.stack td[data-label=""] { justify-content: flex-end; }
  .table.stack td[data-label=""]::before { display: none; }
}

/* fix specificità */
.topbar .menu-btn { display: none; }
@media (max-width: 900px) { .topbar .menu-btn { display: inline-flex; border-color: transparent; } }
.grid > .card + .card { margin-top: 0; }
.nav a > span:not(.soon) { flex: 1; min-width: 0; }
.auth-hero h1 { max-width: 17ch; }
.imp-banner { position: relative; }
/* testo arancio leggibile anche su fondo chiaro (AA) */
:root { --accent-text: var(--orange); }
:root[data-theme="light"] { --accent-text: #b4560a; }
@media (prefers-color-scheme: light) { :root:not([data-theme]) { --accent-text: #b4560a; } }
a, .brand-sub, .nav a[aria-current="page"] svg, .kpi .ico, .b-orange, .steps li::before { color: var(--accent-text); }
.btn-primary, .btn-primary:hover { color: var(--on-orange); }
.btn { text-decoration: none; }
.imp-banner { z-index: 25; }
@media (max-width: 900px) {
  .imp-banner { justify-content: space-between; flex-wrap: nowrap; padding: 6px 8px 6px 12px; font-size: .78rem; gap: 8px; }
  .imp-banner .imp-long { display: none; }
  .imp-banner .btn { padding: 4px 12px; min-height: 28px; font-size: .64rem; }
}
@media (min-width: 901px) { .imp-banner .imp-short { display: none; } }

/* ───────── Logo ufficiale ───────── */
.logo { display: inline-flex; align-items: center; gap: 10px; }
.logo .mark { color: var(--text); flex: none; }
.logo-wm { display: flex; flex-direction: column; }
.logo .wm { display: block; width: auto; }
.logo .wm-ink { display: none; }
:root[data-theme="light"] .logo .wm-light { display: none; }
:root[data-theme="light"] .logo .wm-ink { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .logo .wm-light { display: none; }
  :root:not([data-theme]) .logo .wm-ink { display: block; }
}
.logo-sub { font-size: .62rem; letter-spacing: .2em; text-transform: uppercase; font-weight: 700; color: var(--text-2); margin-top: 2px; }
.brand { padding: 4px 8px 18px; }

/* ───────── Componenti catalogo / form ───────── */
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 700; color: var(--text-2); margin-bottom: 14px; }
.back:hover { color: var(--text); text-decoration: none; }
svg.flip { transform: scaleX(-1); }
.card-flat { padding: 12px; border-radius: var(--radius); margin-bottom: 20px; }
.card-flat.filters { margin-bottom: 20px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; scrollbar-width: none; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--pill); color: var(--text-2); font-weight: 700; font-size: .85rem; white-space: nowrap; border: 1px solid transparent; }
.tabs a:hover { background: var(--hover); text-decoration: none; color: var(--text); }
.tabs a[aria-current="page"] { background: var(--glass-strong); border-color: var(--glass-border-strong); color: var(--text); }
.tabs .count { font-size: .72rem; padding: 1px 7px; border-radius: var(--pill); background: var(--hover); }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.product-card { display: flex; flex-direction: column; padding: 20px; color: var(--text); transition: transform .18s var(--ease), border-color .18s; min-height: 210px; }
.product-card:hover { text-decoration: none; transform: translateY(-2px); border-color: color-mix(in srgb, var(--orange) 45%, transparent); }
.product-card.is-off { opacity: .62; }
.pc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; }
.pc-cat { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 800; color: var(--accent-text); }
.product-card h3 { font-size: 1.15rem; }
.pc-sup { color: var(--text-2); font-size: .85rem; margin: 4px 0 10px; }
.pc-desc { color: var(--text-2); font-size: .85rem; flex: 1; }
.pc-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: .78rem; font-weight: 700; color: var(--text-2); margin-top: auto; padding-top: 12px; border-top: 1px solid var(--glass-border); }
.pc-meta span { display: inline-flex; align-items: center; gap: 5px; }
.pc-money { margin-left: auto; color: var(--text); font-size: .9rem; }

.prose { color: var(--text-2); line-height: 1.65; margin-top: 10px; }
.req-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.req-list { list-style: none; padding: 0; margin: 8px 0 0; }
.req-list li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--glass-border); font-size: .9rem; font-weight: 600; }
.req-list li:last-child { border-bottom: 0; }
.req { color: var(--accent-text); }
.facts { margin: 10px 0 0; }
.facts div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--glass-border); }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--text-2); font-size: .85rem; font-weight: 600; }
.facts dd { margin: 0; font-weight: 700; text-align: right; }

.file-list { list-style: none; padding: 0; margin: 0 0 12px; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--glass-border); }
.file-list li.is-off { opacity: .55; }
.file-list a { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: var(--text); }
.file-list a:hover { text-decoration: none; }
.file-list a:hover b { color: var(--accent-text); }
.file-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--orange-soft); color: var(--accent-text); flex: none; }
.file-meta { display: flex; flex-direction: column; min-width: 0; }
.file-meta b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9rem; }

.drop { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px; border: 1.5px dashed var(--glass-border-strong); border-radius: var(--radius); color: var(--text-2); font-weight: 700; font-size: .85rem; cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.drop:hover, .drop:focus-within { border-color: var(--orange); background: var(--orange-soft); color: var(--text); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop.tall { flex-direction: column; padding: 26px 16px; }
.drop small { font-weight: 500; color: var(--text-3); }
.drop.has-files { border-style: solid; border-color: var(--ok); }
.drop .picked { color: var(--ok); font-weight: 700; word-break: break-word; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 8px 14px; border-radius: var(--pill); border: 1px solid var(--glass-border-strong); font-size: .82rem; font-weight: 700; color: var(--text-2); }
.seg input:checked + span { background: var(--orange); border-color: var(--orange); color: var(--on-orange); }
.seg input:focus-visible + span { outline: 2px solid var(--orange); outline-offset: 2px; }

.form-grid { display: flex; flex-direction: column; gap: 20px; max-width: 920px; }
.form-grid .card + .card { margin-top: 0; }
.sec-title { margin-bottom: 16px; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.hint { font-size: .78rem; color: var(--text-3); }
.field-err { font-size: .8rem; font-weight: 700; color: var(--err); }
.input[aria-invalid="true"] { border-color: var(--err); }
textarea.input { resize: vertical; min-height: 110px; }
.repeater { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.repeater:empty { display: none; }
.rep-row { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr auto auto; gap: 10px; align-items: center; padding: 10px; border-radius: var(--radius-sm); background: var(--hover); }
.rep-row.doc { grid-template-columns: 1fr auto auto; }
.rep-row .opts[hidden] { display: none; }
.rep-row:not(:has(.opts:not([hidden]))) { grid-template-columns: 1.4fr 1fr auto auto; }
.rep-row.doc { grid-template-columns: 1fr auto auto; }
.rep-row .check { white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { border: 1px dashed var(--glass-border-strong); background: none; color: var(--text-2); font: 700 .78rem/1 var(--font-ui); padding: 8px 12px; border-radius: var(--pill); cursor: pointer; }
.chip:hover { border-color: var(--orange); color: var(--text); }
.chip.done { border-style: solid; border-color: var(--ok); color: var(--ok); }
.form-actions { position: sticky; bottom: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--radius); z-index: 5; }
.form-actions .spacer { flex: 1; }

.grid-even { grid-template-columns: 1fr 1fr; }
.add-row { display: flex; gap: 8px; margin-bottom: 14px; }
.add-row .input { min-height: 40px; }
.set-list { list-style: none; padding: 0; margin: 0; }
.set-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--glass-border); }
.set-list li.is-off .input { opacity: .55; }
.set-list .rename { display: flex; gap: 6px; flex: 1; min-width: 0; }
.set-list .rename .input { min-height: 38px; padding: 7px 12px; }
.set-list form { margin: 0; }

@media (max-width: 900px) {
  .req-cols, .cols-2, .grid-even { grid-template-columns: 1fr; }
  .rep-row, .rep-row:not(:has(.opts:not([hidden]))) { grid-template-columns: 1fr auto; }
  .rep-row .input:first-child { grid-column: 1 / -1; }
  .rep-row select.input, .rep-row .opts { grid-column: 1 / -1; }
  .rep-row.doc { grid-template-columns: 1fr auto; }
  .form-actions { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .form-actions .check { flex: 1 1 100%; }
  .form-actions .spacer { display: none; }
  .form-actions .btn { flex: 1; }
  .set-list li { flex-wrap: wrap; }
  .set-list .rename { flex: 1 1 100%; }
  .product-grid { grid-template-columns: 1fr; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
}

/* ───────── Agenzie / utenti ───────── */
.opt { font-weight: 500; color: var(--text-3); font-size: .75rem; margin-left: 4px; }
.cols-3 { display: grid; grid-template-columns: 2fr .7fr 1fr; gap: 0 18px; }
.bonus-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 12px; }
.bonus-cell { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; font-weight: 700; color: var(--text-2); }
.input-suffix { position: relative; display: inline-flex; align-items: center; width: 100%; }
.input-suffix .input { padding-right: 34px; }
.input-suffix i { position: absolute; right: 13px; font-style: normal; font-weight: 700; color: var(--text-3); pointer-events: none; }
.input-suffix.sm { max-width: 130px; }
.input-suffix.sm .input { min-height: 38px; padding-top: 7px; padding-bottom: 7px; }
.card-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.neg { color: var(--err); }
.txt { color: var(--text); }
.avatar.sq { border-radius: 10px; background: linear-gradient(135deg, var(--navy-700), var(--navy-800)); color: var(--cream); }
tr.is-off td, li.is-off { opacity: .6; }
tr.row-link { cursor: pointer; }
a.who { color: var(--text); }
a.who:hover { text-decoration: none; }
a.who:hover b { color: var(--accent-text); }

details.confirm { position: relative; }
details.confirm > summary { list-style: none; }
details.confirm > summary::-webkit-details-marker { display: none; }
.confirm-pop { position: absolute; right: 0; top: calc(100% + 8px); width: min(340px, calc(100vw - 32px)); padding: 16px; z-index: 40; background: var(--glass-solid); display: flex; flex-direction: column; gap: 10px; }
.confirm-pop.wide { width: min(460px, calc(100vw - 32px)); }
.confirm-pop p { margin: 0; }
.confirm-pop .field { margin-bottom: 4px; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--err) 85%, #000); border-color: transparent; }
.dropdown-menu button.danger { color: var(--err); }

.people { list-style: none; padding: 0; margin: 0 0 14px; }
.people li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--glass-border); }
.people-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.people-meta b { font-size: .92rem; }
.people-meta .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.row-actions .dropdown-menu { min-width: 250px; }
.row-actions .dropdown-menu.fixed { position: fixed; right: auto; }
.add-person > summary { list-style: none; display: inline-flex; }
.add-person > summary::-webkit-details-marker { display: none; }
.add-person[open] > summary { margin-bottom: 14px; }
.add-person form { align-items: end; }

.timeline { list-style: none; padding: 0; margin: 10px 0 0; border-left: 2px solid var(--glass-border-strong); }
.timeline li { position: relative; padding: 4px 0 12px 16px; display: flex; flex-direction: column; font-size: .88rem; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 3px var(--bg); }

.rates { display: flex; flex-direction: column; gap: 8px; }
.rate-row { display: grid; grid-template-columns: 1fr 110px 120px; gap: 10px; align-items: center; }
.rate-row .input { min-height: 40px; padding: 8px 12px; }
.rate-label { font-weight: 700; font-size: .9rem; display: flex; flex-direction: column; }
.rate-label small { font-weight: 500; font-size: .74rem; }
.rate-input { display: flex; flex-wrap: wrap; gap: 6px 20px; align-items: flex-end; }
.rate-input .field { width: 180px; margin-bottom: 12px; }

@media (max-width: 900px) {
  .cols-3 { grid-template-columns: 1fr 1fr; }
  .cols-3 .field:first-child { grid-column: 1 / -1; }
  .people li { flex-wrap: wrap; }
  .people-tags { order: 3; width: 100%; justify-content: flex-start; padding-left: 44px; }
  .rate-row { grid-template-columns: 1fr 90px 100px; }
  details.confirm { width: 100%; }
  details.confirm > summary { width: 100%; }
  .confirm-pop { left: 0; right: auto; }
}
.dropdown-menu.portal { display: block; z-index: 80; }
