/* Setter Tracker — stile Apple "liquid glass" */
:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --bg: #f2f2f7;
  --label: #000;
  --label2: rgba(60, 60, 67, .62);
  --label3: rgba(60, 60, 67, .32);
  --sep: rgba(60, 60, 67, .16);
  --fill: rgba(120, 120, 128, .14);
  --fill2: rgba(120, 120, 128, .08);
  --glass: rgba(255, 255, 255, .58);
  --glass-strong: rgba(255, 255, 255, .80);
  --glass-border: rgba(255, 255, 255, .75);
  --glass-hi: rgba(255, 255, 255, .9);
  --shadow: 0 10px 40px rgba(16, 24, 64, .10), 0 1px 3px rgba(16, 24, 64, .06);
  --shadow-lg: 0 24px 80px rgba(16, 24, 64, .22), 0 2px 8px rgba(16, 24, 64, .08);
  --scrim: rgba(0, 0, 0, .22);
  --accent: #007aff;
  --accent-tint: rgba(0, 122, 255, .12);
  --green: #34c759; --red: #ff3b30; --orange: #ff9500; --yellow: #ffcc00; --teal: #30b0c7;
  --indigo: #5856d6; --purple: #af52de; --pink: #ff2d55; --cyan: #32ade6; --brown: #a2845e;
  --gray: #8e8e93; --mint: #00c7be;
  --r-lg: 26px; --r-md: 18px; --r-sm: 12px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --label: #fff;
    --label2: rgba(235, 235, 245, .62);
    --label3: rgba(235, 235, 245, .30);
    --sep: rgba(84, 84, 88, .55);
    --fill: rgba(120, 120, 128, .32);
    --fill2: rgba(120, 120, 128, .18);
    --glass: rgba(36, 36, 40, .55);
    --glass-strong: rgba(44, 44, 48, .78);
    --glass-border: rgba(255, 255, 255, .12);
    --glass-hi: rgba(255, 255, 255, .16);
    --shadow: 0 10px 40px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .3);
    --shadow-lg: 0 24px 80px rgba(0, 0, 0, .65);
    --scrim: rgba(0, 0, 0, .5);
    --accent: #0a84ff;
    --accent-tint: rgba(10, 132, 255, .2);
    --green: #30d158; --red: #ff453a; --orange: #ff9f0a; --yellow: #ffd60a; --teal: #40c8e0;
    --indigo: #5e5ce6; --purple: #bf5af2; --pink: #ff375f; --cyan: #64d2ff; --brown: #ac8e68;
    --gray: #98989d; --mint: #63e6e2;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; font: 15px/1.45 var(--font); color: var(--label); background: var(--bg);
  -webkit-font-smoothing: antialiased; letter-spacing: -.01em;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); text-decoration: none; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--label2); }
.hidden { display: none !important; }

/* Sfondo: colore morbido che la "vetro" rifrange */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg); }
.bg::before, .bg::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(90px); opacity: .55;
}
.bg::before { width: 60vmax; height: 60vmax; left: -15vmax; top: -20vmax;
  background: radial-gradient(circle at 30% 30%, #7cc4ff, #8f8cff 55%, transparent 70%); }
.bg::after { width: 55vmax; height: 55vmax; right: -18vmax; bottom: -22vmax;
  background: radial-gradient(circle at 60% 60%, #ffb3d1, #b49bff 50%, transparent 70%); }
@media (prefers-color-scheme: dark) { .bg::before, .bg::after { opacity: .28; } }

/* Materiale vetro */
.glass {
  position: relative; background: var(--glass);
  -webkit-backdrop-filter: blur(28px) saturate(180%); backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--glass-border); box-shadow: var(--shadow), inset 0 1px 0 var(--glass-hi);
}
.glass::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(160deg, rgba(255, 255, 255, .35), rgba(255, 255, 255, 0) 38%);
  mix-blend-mode: soft-light;
}
.glass-strong { background: var(--glass-strong); }

/* ---------- Accesso ---------- */
body.auth { display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(400px, 100%); border-radius: 32px; padding: 36px 28px 28px; text-align: center; }
.auth-card h1 { font-size: 28px; letter-spacing: -.025em; margin: 14px 0 6px; }
.auth-card .muted { margin: 0 0 22px; font-size: 15px; }
.auth-logo { width: 72px; height: 72px; margin: 0 auto; border-radius: 17px;
  background: url(icon.svg) center/cover; box-shadow: 0 8px 24px rgba(61, 123, 244, .35); }
.field-group { border-radius: var(--r-sm); overflow: hidden; background: var(--glass-strong); border: 1px solid var(--sep); text-align: left; }
.field-group input { display: block; width: 100%; border: 0; border-bottom: 1px solid var(--sep); background: transparent;
  padding: 14px 16px; font-size: 17px; outline: none; }
.field-group input:last-child { border-bottom: 0; }
.auth-error { color: var(--red); font-size: 14px; margin: 14px 0 0; }
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; margin-top: 18px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 17px; border-radius: 14px; padding: 14px 18px;
  transition: transform .12s var(--ease), filter .12s;
}
.btn-primary:active { transform: scale(.97); filter: brightness(.92); }

/* ---------- Struttura app ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 16px; margin: 16px 0 16px 16px; height: calc(100dvh - 32px);
  border-radius: var(--r-lg); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.brand-icon { width: 30px; height: 30px; border-radius: 8px; background: url(icon.svg) center/cover; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; font-weight: 500;
  color: var(--label); transition: background .15s;
}
.nav-item:hover { background: var(--fill2); }
.nav-item[aria-current="page"] { background: var(--accent-tint); color: var(--accent); }
.nav-item .count { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--label2); font-variant-numeric: tabular-nums; }
.nav-item[aria-current="page"] .count { color: var(--accent); }
.sidebar .spacer { flex: 1; }
.sidebar .user { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 13px; color: var(--label2); }

.main { min-width: 0; padding: 28px 40px 120px; max-width: 1280px; width: 100%; }
.navbar {
  position: sticky; top: 0; z-index: 20; margin: -28px -40px 0; padding: 12px 40px; display: flex; align-items: center; gap: 10px;
  min-height: 56px; transition: background .2s, box-shadow .2s;
}
.navbar.scrolled {
  background: var(--glass); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 1px 0 var(--sep);
}
.navbar .small-title { font-weight: 600; font-size: 17px; opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s; }
.navbar.scrolled .small-title { opacity: 1; transform: none; }
.navbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.large-title { font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -.026em; margin: 6px 0 4px; }
.subtitle { color: var(--label2); margin: 0 0 22px; font-size: 15px; }

/* Tab bar (iPhone) */
.tabbar { display: none; }
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .main { padding: 8px 16px calc(110px + var(--safe-b)); }
  .navbar { margin: -8px -16px 0; padding: calc(8px + var(--safe-t)) 16px 8px; }
  .large-title { font-size: 32px; }
  .tabbar {
    display: flex; position: fixed; z-index: 40; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b));
    border-radius: 30px; padding: 6px; justify-content: space-around;
  }
  .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 5px; border-radius: 24px;
    font-size: 10px; font-weight: 600; color: var(--label2); transition: color .15s, background .2s;
  }
  .tab svg.i { width: 24px; height: 24px; }
  .tab[aria-current="page"] { color: var(--accent); background: var(--accent-tint); }
  .tab:active { transform: scale(.94); }
}

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 14px;
  background: var(--fill); color: var(--label); transition: transform .12s var(--ease), background .15s; white-space: nowrap;
}
.btn:active, .icon-btn:active, .chip-btn:active { transform: scale(.95); }
.btn.tinted { background: var(--accent-tint); color: var(--accent); }
.btn.filled { background: var(--accent); color: #fff; }
.btn.danger { background: rgba(255, 59, 48, .12); color: var(--red); }
.btn svg.i { width: 17px; height: 17px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--label);
  background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border); box-shadow: var(--shadow); transition: transform .12s var(--ease);
}
.icon-btn.accent { background: var(--accent); color: #fff; border-color: transparent; }

/* Segmented control */
.seg {
  position: relative; display: inline-flex; padding: 2px; border-radius: 10px; background: var(--fill); isolation: isolate;
}
.seg button { position: relative; z-index: 1; padding: 6px 14px; font-size: 13px; font-weight: 600; border-radius: 8px; color: var(--label); white-space: nowrap; }
.seg .thumb {
  position: absolute; z-index: 0; top: 2px; bottom: 2px; left: 0; border-radius: 8px; background: var(--glass-strong);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04);
  transition: transform .32s var(--ease), width .32s var(--ease);
}
@media (prefers-color-scheme: dark) { .seg .thumb { background: #636366; } }

/* Ricerca */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search {
  flex: 1 1 260px; display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px; border-radius: 12px; background: var(--fill);
  color: var(--label2);
}
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 16px; color: var(--label); }
.search svg.i { width: 18px; height: 18px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; margin-bottom: 14px; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--fill2); color: var(--label); white-space: nowrap; transition: background .15s, transform .12s;
}
.chip-btn[aria-pressed="true"] { background: var(--label); color: var(--bg); }
.chip-btn .n { opacity: .55; font-variant-numeric: tabular-nums; }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--fill2); color: var(--label2); white-space: nowrap;
}
.badge.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--gray)); }
.badge.tint { background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); }
.badge svg.i { width: 13px; height: 13px; stroke-width: 2.2; }

/* ---------- Liste (inset grouped) ---------- */
.section-title {
  display: flex; align-items: baseline; gap: 8px; margin: 26px 4px 8px; font-size: 20px; font-weight: 700; letter-spacing: -.02em;
}
.section-title .n { font-size: 15px; color: var(--label2); font-weight: 600; }
.section-title .more { margin-left: auto; font-size: 15px; font-weight: 500; }
.list { border-radius: var(--r-md); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 11px 16px; width: 100%; text-align: left; position: relative;
  transition: background .12s;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 64px; right: 0; height: .5px; background: var(--sep); }
button.row:hover { background: var(--fill2); }
button.row:active { background: var(--fill); }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--label2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .acc { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.row .chev { color: var(--label3); width: 16px; height: 16px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
  background: linear-gradient(140deg, var(--a1, #7cc4ff), var(--a2, #5e5ce6)); letter-spacing: 0;
}
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }
.empty { padding: 34px 20px; text-align: center; color: var(--label2); }
.empty .big { font-size: 34px; margin-bottom: 6px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { border-radius: var(--r-md); padding: 14px 16px 16px; text-align: left; transition: transform .15s var(--ease); }
button.kpi:active { transform: scale(.98); }
.kpi .k-top { display: flex; align-items: center; justify-content: space-between; }
.kpi .k-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--c, var(--accent)); }
.kpi .k-ico svg.i { width: 17px; height: 17px; stroke-width: 2.1; }
.kpi .k-val { font-size: 30px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi .k-lab { color: var(--label2); font-weight: 600; font-size: 14px; margin-top: 8px; }

/* ---------- Pipeline (kanban) ---------- */
.board {
  display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 18px; margin: 0 -40px; padding-left: 40px; padding-right: 40px;
  scroll-snap-type: x proximity; scroll-padding: 0 40px; overscroll-behavior-x: contain;
}
.col {
  flex: 0 0 290px; scroll-snap-align: start; border-radius: var(--r-lg); padding: 10px; background: var(--fill2);
  display: flex; flex-direction: column; min-height: 220px; max-height: calc(100dvh - 210px); transition: background .15s, box-shadow .15s;
}
.col.drop { background: color-mix(in srgb, var(--c) 14%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 55%, transparent); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-weight: 700; font-size: 15px; }
.col-head .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.col-head .n { margin-left: auto; color: var(--label2); font-weight: 600; font-size: 13px; }
.col-body { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 60px; padding: 2px; margin: -2px; }
.card {
  border-radius: 16px; padding: 11px 12px; text-align: left; width: 100%; cursor: grab; touch-action: pan-x pan-y;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  background: var(--glass-strong); border: 1px solid var(--glass-border); box-shadow: 0 2px 10px rgba(16, 24, 64, .06);
  transition: transform .15s var(--ease), opacity .15s;
}
.card:active { transform: scale(.985); }
.card .c-top { display: flex; align-items: center; gap: 8px; }
.card .c-user { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .c-sub { color: var(--label2); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .c-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.card.ghost { opacity: .28; }
.drag-clone {
  position: fixed; z-index: 100; pointer-events: none; margin: 0; cursor: grabbing;
  box-shadow: var(--shadow-lg); will-change: transform;
}
.temp { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.temp.freddo { background: var(--cyan); } .temp.tiepido { background: var(--orange); } .temp.caldo { background: var(--red); }
.qdots { display: inline-flex; gap: 3px; }
.qdots i { width: 6px; height: 6px; border-radius: 50%; background: var(--fill); }
.qdots i.on { background: var(--green); }
@media (max-width: 900px) {
  .board { margin: 0 -16px; padding-left: 16px; padding-right: 16px; scroll-padding: 0 16px; scroll-snap-type: x mandatory; }
  .col { flex-basis: 84vw; max-height: calc(100dvh - 250px); }
}

/* ---------- Statistiche ---------- */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.panel { border-radius: var(--r-md); padding: 16px 18px; }
.panel h3 { margin: 0 0 12px; font-size: 17px; letter-spacing: -.015em; }
.funnel-row { display: grid; grid-template-columns: 130px 1fr 44px; gap: 10px; align-items: center; margin: 7px 0; font-size: 14px; }
.funnel-row .bar { height: 10px; border-radius: 999px; background: var(--fill2); overflow: hidden; }
.funnel-row .bar span { display: block; height: 100%; border-radius: inherit; background: var(--c); transform-origin: left; animation: grow .7s var(--ease) both; }
.funnel-row .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--label2); font-weight: 600; }
@keyframes grow { from { transform: scaleX(0); } }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; color: var(--label2); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; padding: 6px 4px; }
table.t td { padding: 8px 4px; border-top: .5px solid var(--sep); font-variant-numeric: tabular-nums; }
table.t td.num, table.t th.num { text-align: right; }
.chart { width: 100%; height: 170px; display: block; }
.chart .b { fill: var(--accent); }
.chart text { fill: var(--label2); font-size: 11px; font-family: var(--font); }

/* ---------- Impostazioni ---------- */
.settings { max-width: 680px; }
.setting-row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; position: relative; }
.setting-row + .setting-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: .5px; background: var(--sep); }
.setting-row .lab { flex: 1; }
.setting-row .lab small { display: block; color: var(--label2); font-size: 13px; }
.footnote { color: var(--label2); font-size: 13px; margin: 8px 16px 0; }
.token-box { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; padding: 10px 12px;
  border-radius: 10px; background: var(--fill2); user-select: all; margin-top: 8px; }

/* ---------- Sheet (dettaglio lead) ---------- */
.scrim { position: fixed; inset: 0; z-index: 60; background: var(--scrim); opacity: 0; transition: opacity .3s var(--ease); }
.scrim.on { opacity: 1; }
.sheet {
  position: fixed; z-index: 61; display: flex; flex-direction: column; overflow: hidden;
  background: var(--glass-strong); -webkit-backdrop-filter: blur(40px) saturate(180%); backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--glass-border); box-shadow: var(--shadow-lg);
  top: 14px; right: 14px; bottom: 14px; width: min(540px, calc(100vw - 28px)); border-radius: 30px; will-change: transform;
}
@media (max-width: 900px) {
  .sheet { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: calc(100dvh - 44px - var(--safe-t)); border-radius: 30px 30px 0 0; }
}
.grabber { display: none; }
@media (max-width: 900px) {
  .grabber { display: block; padding: 8px 0 0; touch-action: none; cursor: grab; }
  .grabber::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--label3); margin: 0 auto; }
}
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 12px; touch-action: none; }
.sheet-head .who { flex: 1; min-width: 0; }
.sheet-head .who .h { font-size: 20px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-head .who .s { color: var(--label2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-scroll { flex: 1; overflow-y: auto; padding: 0 16px calc(24px + var(--safe-b)); overscroll-behavior: contain; }
.status-strip { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 14px; }
.stage-select {
  appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; padding: 7px 30px 7px 14px; font-weight: 700; font-size: 14px;
  background: color-mix(in srgb, var(--c) 16%, transparent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 9px center/15px;
  color: var(--c); cursor: pointer; outline: none;
}
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.quick button {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 11px 4px 9px; border-radius: 16px; font-size: 12px; font-weight: 600;
  background: var(--fill2); color: var(--label); transition: transform .12s var(--ease), background .15s;
}
.quick button:active { transform: scale(.95); background: var(--fill); }
.quick button svg.i { color: var(--accent); width: 22px; height: 22px; }
.composer { border-radius: var(--r-md); padding: 12px; margin-bottom: 14px; background: var(--fill2); }
.composer textarea { width: 100%; min-height: 84px; border: 0; background: transparent; outline: none; resize: vertical; font-size: 16px; }
.composer .c-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.composer .c-foot input { border: 0; background: var(--fill); border-radius: 8px; padding: 6px 8px; font-size: 14px; }
.composer .c-foot .grow { flex: 1; }

.form-section { margin-bottom: 18px; }
.form-section > .fs-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--label2); margin: 0 14px 6px; }
.form { border-radius: var(--r-md); background: var(--glass); border: 1px solid var(--glass-border); overflow: hidden; }
.f-row { display: flex; align-items: center; gap: 12px; padding: 0 14px; min-height: 46px; position: relative; }
.f-row + .f-row::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: .5px; background: var(--sep); }
.f-row > label { flex: 0 0 132px; color: var(--label); font-size: 15px; }
.f-row input, .f-row select {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none; text-align: right; font-size: 16px; padding: 12px 0; color: var(--label2);
}
.f-row input:focus, .f-row select:focus, .f-row textarea:focus { color: var(--label); }
.f-row select { appearance: none; -webkit-appearance: none; direction: rtl; cursor: pointer; }
.f-row.stack { flex-direction: column; align-items: stretch; gap: 2px; padding: 10px 14px; }
.f-row.stack > label { flex: none; font-size: 13px; color: var(--label2); font-weight: 600; }
.f-row textarea { border: 0; background: transparent; outline: none; resize: vertical; font-size: 16px; min-height: 44px; padding: 4px 0; field-sizing: content; }
.f-row.switch-row > label { flex: 1; }
.f-row .hint { font-size: 12px; color: var(--label2); display: block; }

/* Switch iOS */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--fill); transition: background .25s var(--ease); }
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16); transition: transform .28s var(--ease);
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }

/* Timeline */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; border-radius: 2px; background: var(--sep); }
.ev { position: relative; padding: 0 0 14px; }
.ev .ico { position: absolute; left: -26px; top: 0; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--c, var(--gray)); box-shadow: 0 0 0 3px var(--bg); }
.ev .ico svg.i { width: 12px; height: 12px; stroke-width: 2.4; }
.ev .meta { font-size: 12px; color: var(--label2); display: flex; gap: 8px; align-items: center; }
.ev .meta button { color: var(--label3); font-size: 12px; }
.ev .txt { white-space: pre-wrap; word-wrap: break-word; font-size: 15px; }
.ev.lead .txt { background: var(--fill2); border-radius: 4px 14px 14px 14px; padding: 7px 11px; display: inline-block; max-width: 100%; }
.ev.noi .txt { background: var(--accent-tint); border-radius: 14px 4px 14px 14px; padding: 7px 11px; display: inline-block; max-width: 100%; }

/* Toast e alert */
.toast {
  position: fixed; z-index: 200; left: 50%; top: calc(14px + var(--safe-t)); transform: translate(-50%, -140%); border-radius: 999px;
  padding: 10px 18px; font-weight: 600; font-size: 14px; display: flex; gap: 8px; align-items: center;
  transition: transform .45s var(--ease);
}
.toast.on { transform: translate(-50%, 0); }
.toast svg.i { width: 18px; height: 18px; color: var(--green); stroke-width: 2.4; }
.toast.err svg.i { color: var(--red); }
.alert-wrap { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; background: var(--scrim); opacity: 0; transition: opacity .2s; padding: 20px; }
.alert-wrap.on { opacity: 1; }
.alert { width: min(290px, 100%); border-radius: 22px; overflow: hidden; text-align: center; transform: scale(1.12); transition: transform .32s var(--ease); background: var(--glass-strong); }
.alert-wrap.on .alert { transform: none; }
.alert .a-body { padding: 20px 18px 16px; }
.alert .a-title { font-weight: 700; font-size: 17px; margin-bottom: 4px; }
.alert .a-msg { font-size: 14px; color: var(--label2); }
.alert .a-btns { display: grid; grid-template-columns: 1fr 1fr; border-top: .5px solid var(--sep); }
.alert .a-btns button { padding: 13px; font-size: 17px; color: var(--accent); }
.alert .a-btns button + button { border-left: .5px solid var(--sep); font-weight: 600; }
.alert .a-btns button.destructive { color: var(--red); }

/* Countdown finestra 24h */
.window-ring { --p: 0; width: 18px; height: 18px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--c) calc(var(--p) * 1turn), var(--fill) 0); -webkit-mask: radial-gradient(circle, transparent 5px, #000 5.5px); mask: radial-gradient(circle, transparent 5px, #000 5.5px); }

/* Indicatore "Salvato" che non ruba spazio all'intestazione */
.sheet-head { position: relative; }
.saved-badge { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); opacity: 0; transition: opacity .3s; pointer-events: none;
  background: color-mix(in srgb, var(--green) 16%, var(--glass-strong)); color: var(--green); }
.saved-badge svg.i { width: 12px; height: 12px; }
@media (max-width: 600px) { .sheet-head .icon-btn { width: 34px; height: 34px; } .sheet-head { gap: 8px; } .saved-badge { top: -6px; } }

/* Scrollbar discrete */
.board { scrollbar-width: none; }
.board::-webkit-scrollbar { display: none; }
.sheet-scroll, .col-body { scrollbar-width: thin; scrollbar-color: var(--label3) transparent; }

/* iPhone: KPI a due colonne, badge sotto il titolo */
@media (max-width: 600px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px 14px; }
  .kpi .k-val { font-size: 26px; }
  .kpi .k-lab { font-size: 13px; line-height: 1.25; }
  .row { flex-wrap: wrap; row-gap: 6px; }
  .row .body { flex: 1 1 0; }
  .row .chev { order: 2; }
  .row .acc { order: 3; flex-basis: 100%; justify-content: flex-start; padding-left: 50px; }
  .row .acc:empty { display: none; }
  .quick { gap: 6px; }
  .quick button { font-size: 11px; padding: 10px 2px 8px; }
  .f-row > label { flex-basis: 112px; }
  .section-title { font-size: 19px; }
  .navbar .btn.filled { padding: 8px 12px; }
}

/* Accessibilità */
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; border-radius: 8px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .sheet, .navbar.scrolled, .icon-btn { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--bg); }
  .glass-strong, .card { background: var(--bg); }
}
@media (prefers-contrast: more) {
  .glass, .card, .form { border-color: var(--label3); }
}
