/* ==========================================================================
   Janus — achromatic ledger, chiaro e scuro
   Griglia: canvas fluido, padding 32px, 12 colonne con gap 12px.
   A 1440px con sidebar 240: area 1200 - 64 = 1136 = 12 x 83.667 + 11 x 12.
   ========================================================================== */

@font-face {
  font-family: "Gebuk";
  src: url("/fonts/Gebuk-Regular.otf") format("opentype");
  font-display: block;
}
@font-face {
  font-family: "Geist";
  src: url("/vendor/geist/geist-sans/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/vendor/geist/geist-mono/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ground: #f5f5f4;
  --surface: #ffffff;
  --raised: #efefee;
  --active: #e7e7e6;
  --border: #e3e3e2;
  --rule: #eeeeed;
  --control: #cfcfce;
  --text: #0a0a0a;
  --muted: #5f5f5f;
  --faint: #6b6b6b;
  --primary: #0a0a0a;
  --on-primary: #ffffff;
  --positive: #247b50;
  --negative: #c4242a;
  --pill-positive-bg: #dcfae5; --pill-positive-ink: #04250e;
  --pill-negative-bg: #ffedea; --pill-negative-ink: #831c1e;
  --hatch: repeating-linear-gradient(135deg, var(--text) 0 1px, transparent 1px 4px);
  --map-filter: grayscale(1) contrast(1.06) brightness(1.03);
  --shadow-float: 0 12px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);

  --font: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --logo: "Gebuk", var(--font);

  --sidebar: 240px;
  --pad: 32px;
  --gap: 12px;
  --card-pad: 20px;
  --radius-card: 8px;
  --radius-control: 6px;
  --control-height: 36px;
  --row: 48px;

  --fs-title: 24px;
  --fs-section: 15px;
  --fs-kpi: 28px;
  --fs-body: 14px;
  --fs-small: 12px;

  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --t-fast: 140ms;
  --t-mid: 280ms;
  --t-slow: 520ms;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #000000;
  --surface: #0b0b0b;
  --raised: #171717;
  --active: #1d1d1d;
  --border: #1f1f1f;
  --rule: #161616;
  --control: #3a3a3a;
  --text: #f4f4f4;
  --muted: #b4b4b4;
  --faint: #949494;
  --primary: #f4f4f4;
  --on-primary: #000000;
  --positive: #3fc07a;
  --negative: #e5566f;
  --pill-positive-bg: #172a1d; --pill-positive-ink: #3fc07a;
  --pill-negative-bg: #2c1a20; --pill-negative-ink: #e5566f;
  --map-filter: grayscale(1) invert(1) brightness(0.88) contrast(0.92);
  --shadow-float: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px #262626;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 400 var(--fs-body)/20px var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--text); color: var(--ground); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 4px; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.icon {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
[hidden] { display: none !important; }
.star { width: 0.78em; height: 0.78em; margin-left: 1px; vertical-align: -0.04em; fill: currentColor; stroke: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* --------------------------------------------------------------------------
   Intro: il nome si apre dal centro, come le due facce di Giano
   -------------------------------------------------------------------------- */

.intro {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-content: center; justify-items: center; gap: 18px;
  background: var(--ground);
  pointer-events: none;
}
/* "Janus" scritto a penna: per ogni lettera la punta traccia il contorno (il tratto si allunga lungo il
   percorso), poi l'inchiostro la riempie; le lettere si accavallano come in una firma */
.intro-word { display: block; width: clamp(240px, 46vw, 540px); height: auto; overflow: visible; color: var(--text); }
.intro-word path {
  fill: currentColor; fill-opacity: 0;
  /* Estremità piatte: con quelle tonde un tratto ancora lungo zero si vede come un puntino */
  stroke: currentColor; stroke-width: 2.4; stroke-linecap: butt; stroke-linejoin: round;
  stroke-dasharray: 1 1.02; stroke-dashoffset: 1.01; stroke-opacity: 0;
}
.intro-line { color: var(--muted); font-size: 15px; opacity: 0; transform: translateY(8px); }
.intro.play .intro-word path {
  animation:
    pen-draw 0.7s calc(var(--i) * 0.19s) cubic-bezier(0.55, 0.05, 0.3, 1) both,
    ink-fill 0.45s calc(var(--i) * 0.19s + 0.5s) var(--ease-out) forwards;
}
.intro.play .intro-line { animation: intro-rise 0.6s 1.35s var(--ease-out) forwards; }
.intro.leave { animation: intro-leave 0.55s var(--ease-drawer) forwards; }
/* Il tratto resta invisibile finché la penna non parte: niente puntini sparsi prima */
@keyframes pen-draw { from { stroke-opacity: 0; } 2% { stroke-opacity: 1; } to { stroke-dashoffset: 0; stroke-opacity: 1; } }
/* L'inchiostro riempie la lettera e il contorno della penna sparisce: resta la forma esatta del font */
@keyframes ink-fill { to { fill-opacity: 1; stroke-opacity: 0; } }
@keyframes intro-leave { to { clip-path: inset(0 0 100% 0); } }
@keyframes intro-rise { to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}
.topbar { display: none; }

.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  padding: 28px 12px 16px;
  border-right: 1px solid var(--border);
}
.brand { display: inline-flex; padding: 0 12px; width: max-content; }
.logo {
  font: 400 34px/1 var(--logo);
  letter-spacing: 0.01em;
  position: relative;
  display: inline-block;
  transition: letter-spacing var(--t-mid) var(--ease-out);
}
.brand:hover .logo { letter-spacing: 0.06em; }
.scope { padding: 10px 12px 0; color: var(--muted); font-size: var(--fs-small); line-height: 16px; }

.nav { display: grid; gap: 2px; margin-top: 32px; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 12px;
  border-radius: var(--radius-control);
  color: var(--muted);
  transition: color var(--t-fast), background-color var(--t-fast);
}
.nav a:hover { color: var(--text); background: var(--raised); }
.nav a[aria-current="page"] { color: var(--text); background: var(--active); font-weight: 500; }
.nav a:active { transform: scale(0.985); }
.nav-count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center;
  border-radius: 999px; background: var(--primary); color: var(--on-primary);
  font: 500 11px/1 var(--mono);
}

.sidebar-foot { margin-top: auto; display: grid; gap: 8px; }
.job-mini { display: grid; gap: 6px; padding: 10px 12px; border-radius: var(--radius-control); background: var(--raised); }
.job-mini-label { font-size: var(--fs-small); }
.job-mini-track { height: 2px; background: var(--border); overflow: hidden; }
.job-mini-fill { display: block; height: 100%; width: 0; background: var(--text); transition: width var(--t-mid) var(--ease-out); }
.theme-toggle {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 12px;
  border: 0; border-radius: var(--radius-control); background: none; color: var(--muted); text-align: left;
}
.theme-toggle:hover { color: var(--text); background: var(--raised); }
.theme-toggle .icon { transition: transform var(--t-slow) var(--ease-drawer); }
:root[data-theme="dark"] .theme-toggle .icon { transform: rotate(180deg); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 14px; border-radius: 0 0 var(--radius-control) var(--radius-control); transition: background-color var(--t-fast); }
.me:hover { background: var(--raised); }
.me-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: var(--primary); color: var(--on-primary);
  font: 500 12px/1 var(--font);
}
.me-text { display: grid; min-width: 0; }
.me-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-sub { color: var(--muted); font-size: var(--fs-small); line-height: 16px; }

.canvas { padding: 32px var(--pad) 64px; min-width: 0; outline: none; }

/* --------------------------------------------------------------------------
   Titoli, pulsanti, controlli
   -------------------------------------------------------------------------- */

.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.title-row h1 { font-size: var(--fs-title); line-height: 30px; font-weight: 600; letter-spacing: -0.02em; }
.title-row .lede { margin-top: 6px; color: var(--muted); font-size: 15px; line-height: 22px; max-width: 72ch; }
.title-row .lede strong { color: var(--text); font-weight: 500; }
.actions { display: flex; align-items: center; gap: 8px; flex: none; }

.button {
  --bg: var(--surface); --fg: var(--text); --bd: var(--control);
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--control-height); padding: 0 14px;
  border: 1px solid var(--bd); border-radius: var(--radius-control);
  background: var(--bg); color: var(--fg);
  font-weight: 500; white-space: nowrap;
  transition: transform var(--t-fast) var(--ease-out), background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.button:hover { --bd: var(--text); }
.button:active { transform: scale(0.97); }
.button[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }
.button.primary { --bg: var(--primary); --fg: var(--on-primary); --bd: var(--primary); }
.button.primary:hover { --bg: var(--text); }
.button.ghost { --bg: transparent; --bd: transparent; }
.button.ghost:hover { --bg: var(--raised); }
.button.small { height: 30px; padding: 0 10px; font-size: 13px; }
.button.danger { --fg: var(--negative); }
/* L'onda al clic: un cerchio che si allarga dal punto premuto */
.button .ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: currentColor; opacity: 0.16; transform: scale(0);
  animation: ripple 520ms var(--ease-out) forwards;
}
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

.icon-button {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: var(--radius-control); background: none; color: var(--text);
}
.icon-button:hover { background: var(--raised); }

.field { display: grid; gap: 8px; }
.field > span { font-weight: 500; }
.field small { color: var(--muted); font-size: var(--fs-small); line-height: 16px; }
.input, .select, .textarea {
  width: 100%; height: var(--control-height); padding: 0 12px;
  border: 1px solid var(--control); border-radius: var(--radius-control);
  background: var(--surface); color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.textarea { height: auto; min-height: 220px; padding: 12px; line-height: 21px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px var(--active); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 8px; background: var(--raised); }
.seg button {
  height: 30px; padding: 0 12px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-weight: 500;
  transition: background-color var(--t-fast), color var(--t-fast);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }

.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; position: relative; }
.tabs button {
  position: relative; height: 40px; padding: 0; border: 0; background: none; color: var(--muted);
  white-space: nowrap; font-weight: 500;
}
.tabs button .num { margin-left: 6px; color: var(--faint); font-size: 12px; }
.tabs button[aria-selected="true"] { color: var(--text); }
.tabs button[aria-selected="true"] .num { color: var(--text); }
.tabs-ink { position: absolute; bottom: -1px; left: 0; height: 2px; background: var(--text); transition: transform var(--t-mid) var(--ease-drawer), width var(--t-mid) var(--ease-drawer); }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--text); margin: 0; }

/* --------------------------------------------------------------------------
   Pannelli e griglia
   -------------------------------------------------------------------------- */

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: 1 / -1; }
.stretch { align-self: stretch; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 18px var(--card-pad) 0; }
.panel-head h2 { font-size: var(--fs-section); line-height: 22px; font-weight: 600; letter-spacing: -0.01em; }
.panel-head .meta { color: var(--muted); font-size: var(--fs-small); white-space: nowrap; }
.panel-head a.meta:hover { color: var(--text); }
.panel-body { padding: 14px var(--card-pad) var(--card-pad); }
.panel-foot { padding: 0 var(--card-pad) 16px; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: var(--fs-small); white-space: nowrap; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; border-radius: 2px; }
.sw-ink { background: var(--text); }
.sw-hatch { background: var(--hatch); box-shadow: inset 0 0 0 1px var(--text); }
.sw-grey { background: var(--control); }

/* KPI: un contenitore diviso da filetti */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: var(--gap); }
.kpi { padding: 18px var(--card-pad); min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--border); }
.kpi-label { color: var(--muted); }
.kpi-value { display: block; margin-top: 8px; font: 400 var(--fs-kpi)/34px var(--mono); letter-spacing: -0.03em; }
.kpi-value small { font-size: 15px; color: var(--muted); letter-spacing: 0; }
.kpi-sub { margin-top: 4px; color: var(--muted); font-size: var(--fs-small); line-height: 16px; }
.kpi-lead .kpi-value { font-weight: 500; }
.meter { margin-top: 10px; height: 4px; border-radius: 2px; background: var(--raised); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--text); transform-origin: left; transform: scaleX(0); transition: transform 900ms var(--ease-drawer); }
.meter.warn > span { background: var(--negative); }

/* --------------------------------------------------------------------------
   Il doppio volto: reputazione a sinistra, presenza web a destra
   -------------------------------------------------------------------------- */

.janus-bar { display: grid; grid-template-columns: 1fr 1px 1fr; align-items: center; gap: 0; width: 120px; height: 14px; flex: none; }
.janus-bar .axis { height: 14px; background: var(--text); }
.janus-bar .rep, .janus-bar .web { height: 6px; transition: transform 700ms var(--ease-drawer); }
.janus-bar .rep { justify-self: end; background: var(--text); transform-origin: right; border-radius: 2px 0 0 2px; }
.janus-bar .web { justify-self: start; background: var(--hatch); box-shadow: inset 0 0 0 1px var(--text); transform-origin: left; border-radius: 0 2px 2px 0; }
.janus-bar.pre .rep, .janus-bar.pre .web { transform: scaleX(0); }

.mirror { display: grid; gap: 4px; }
.mirror-row { display: grid; grid-template-columns: 112px 1fr 1px 1fr; align-items: center; height: 30px; gap: 0; }
.mirror-row .label { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.mirror-row .axis { height: 30px; background: var(--border); }
.mirror-row .side { position: relative; height: 12px; display: flex; align-items: center; }
.mirror-row .side.left { justify-content: flex-end; }
.mirror-row .bar { height: 12px; transition: transform 800ms var(--ease-drawer); }
.mirror-row .left .bar { background: var(--text); transform-origin: right; border-radius: 2px 0 0 2px; }
.mirror-row .right .bar { background: var(--hatch); box-shadow: inset 0 0 0 1px var(--text); transform-origin: left; border-radius: 0 2px 2px 0; }
.mirror-row .val { font: 400 12px/1 var(--mono); color: var(--muted); padding: 0 6px; white-space: nowrap; }
.mirror.pre .bar { transform: scaleX(0); }
.mirror-axis-labels { display: grid; grid-template-columns: 112px 1fr 1fr; color: var(--muted); font-size: var(--fs-small); margin-top: 8px; }
.mirror-axis-labels span:nth-child(2) { text-align: right; padding-right: 10px; }
.mirror-axis-labels span:nth-child(3) { padding-left: 10px; }

/* --------------------------------------------------------------------------
   Liste e tabelle
   -------------------------------------------------------------------------- */

.rows { display: grid; }
.row-item {
  display: grid; grid-template-columns: minmax(0, 1fr) 120px 128px 116px; align-items: center; gap: 16px;
  min-height: 60px; padding: 8px var(--card-pad); margin: 0 1px;
  border-top: 1px solid var(--rule); cursor: pointer;
  transition: background-color var(--t-fast);
}
.row-item:first-child { border-top: 0; }
.row-item:hover { background: var(--raised); }
.row-item:active { background: var(--active); }
.ident { min-width: 0; }
.ident b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ident > span:not(.pill) { display: block; color: var(--muted); font-size: 13px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rating { font: 400 13px/18px var(--mono); white-space: nowrap; }
.rating .muted { font-size: 12px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  height: 38px; padding: 0 12px; text-align: left; font-weight: 400; font-size: var(--fs-small); color: var(--muted); white-space: nowrap;
  position: sticky; top: 0; background: var(--ground); z-index: 1;
}
.panel .table th { background: var(--surface); }
.table th button { border: 0; background: none; padding: 0; color: inherit; font: inherit; display: inline-flex; gap: 4px; align-items: center; }
.table th button:hover, .table th[aria-sort] button { color: var(--text); }
.table td { height: var(--row); padding: 6px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background-color var(--t-fast); }
.table tbody tr:hover { background: var(--surface); }
.table .num, .table th.num { text-align: right; }
.table td.ident-cell { max-width: 0; width: 34%; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--raised); color: var(--text);
}
.pill.solid { background: var(--primary); color: var(--on-primary); }
.pill.outline { background: transparent; box-shadow: inset 0 0 0 1px var(--control); }
.pill.hatch { background: var(--surface); box-shadow: inset 0 0 0 1px var(--text); }
.pill.positive { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill.negative { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 20px 0 12px; }
.toolbar .input { width: 280px; }
.toolbar .select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }
.count-line { color: var(--muted); }

.empty {
  grid-column: 1 / -1;
  display: grid; place-items: center; gap: 6px; min-height: 120px; padding: 24px;
  border: 1px dashed var(--control); border-radius: var(--radius-card); color: var(--muted); text-align: center;
}
.more { display: flex; justify-content: center; padding: 16px 0 0; }

/* --------------------------------------------------------------------------
   Pipeline e funnel
   -------------------------------------------------------------------------- */

.flow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.flow-step { position: relative; padding: 4px 16px 0 0; }
.flow-step + .flow-step { padding-left: 16px; border-left: 1px solid var(--border); }
.flow-step .kpi-label { font-size: 13px; }
.flow-step .kpi-value { font-size: 24px; line-height: 30px; margin-top: 4px; }
.flow-step .rate { color: var(--muted); font: 400 12px/16px var(--mono); margin-top: 2px; }
.flow-bar { margin-top: 12px; height: 4px; background: var(--raised); border-radius: 2px; overflow: hidden; }
.flow-bar span { display: block; height: 100%; background: var(--text); transform-origin: left; transition: transform 900ms var(--ease-drawer); }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: var(--gap); overflow-x: auto; padding-bottom: 8px; align-items: start; }
.lane { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); display: flex; flex-direction: column; min-height: 240px; max-height: calc(100dvh - 210px); transition: border-color var(--t-fast), background-color var(--t-fast); }
.lane.over { border-color: var(--text); background: var(--raised); }
.lane-head { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 14px 10px; }
.lane-head h2 { font-size: 14px; font-weight: 600; }
.lane-head .num { color: var(--muted); font-size: 12px; }
.lane-body { display: grid; gap: 6px; padding: 0 8px 8px; overflow-y: auto; align-content: start; }
.card {
  display: grid; gap: 6px; padding: 10px 12px; border-radius: 6px; background: var(--ground);
  border: 1px solid var(--border); cursor: grab; user-select: none; touch-action: manipulation;
  transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast), opacity var(--t-fast);
}
.card:hover { border-color: var(--control); }
.card b { font-weight: 500; line-height: 18px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.card-meta span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.card.dragging { opacity: 0.35; }
.card-ghost { position: fixed; z-index: 90; pointer-events: none; box-shadow: var(--shadow-float); transform: rotate(-1.5deg) scale(1.03); background: var(--surface); width: 240px; }
.lane-more { padding: 8px; text-align: center; color: var(--muted); font-size: 12px; }

/* --------------------------------------------------------------------------
   Ricerca dal vivo
   -------------------------------------------------------------------------- */

.form { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; min-height: var(--control-height); border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); }
.chips:focus-within { border-color: var(--text); box-shadow: 0 0 0 3px var(--active); }
.chips input { flex: 1; min-width: 120px; border: 0; outline: none; background: none; height: 26px; padding: 0 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 10px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-size: 13px; animation: chip-in 220ms var(--ease-out); }
.chip button { display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 50%; background: none; color: inherit; }
.chip button:hover { background: rgba(127, 127, 127, 0.3); }
.chip button .icon { width: 12px; height: 12px; }
@keyframes chip-in { from { transform: scale(0.8); opacity: 0; } }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.suggestions button { height: 28px; padding: 0 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; transition: all var(--t-fast); }
.suggestions button:hover { color: var(--text); border-color: var(--text); }
.suggestions button[aria-pressed="true"] { display: none; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--text); }
.range-row output { width: 56px; text-align: right; }
.estimate { padding: 12px 14px; border-radius: var(--radius-control); background: var(--raised); color: var(--muted); line-height: 20px; }
.estimate b { color: var(--text); font-weight: 500; }

.live { display: grid; gap: 18px; }
.live-top { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: start; }
.area-grid { position: relative; display: grid; gap: 3px; width: 168px; aspect-ratio: 1; overflow: hidden; }
.area-cell {
  position: relative; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 3px; background: var(--surface);
  font: 400 11px/1 var(--mono); color: var(--faint);
  transition: background-color 500ms var(--ease-out), color 500ms, border-color 300ms;
}
.area-cell.active { border-color: var(--text); color: var(--text); animation: cell-pulse 1s ease-in-out infinite; }
.area-cell.done { background: var(--text); color: var(--ground); border-color: var(--text); }
.area-cell.done.light { background: var(--control); color: var(--text); border-color: var(--control); }
@keyframes cell-pulse { 50% { box-shadow: inset 0 0 0 3px var(--active); } }
.area-grid.scanning::after {
  content: ""; position: absolute; left: 0; right: 0; height: 1px; top: 0;
  background: var(--text); opacity: 0.5; animation: scan 1.6s linear infinite;
}
@keyframes scan { from { transform: translateY(0); } to { transform: translateY(168px); } }
.phases { display: grid; gap: 10px; }
.phase { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 10px; color: var(--faint); }
.phase .mark { width: 10px; height: 10px; border-radius: 50%; border: 1px solid currentColor; justify-self: center; transition: all var(--t-mid); }
.phase.active { color: var(--text); }
.phase.active .mark { background: var(--text); animation: blink 1s ease-in-out infinite; }
.phase.done { color: var(--text); }
.phase.done .mark { background: var(--text); border-color: var(--text); }
@keyframes blink { 50% { opacity: 0.3; } }
.phase .num { font-size: 12px; color: var(--muted); }
.live-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.live-stats .kpi { padding: 14px 0 0; }
.live-stats .kpi + .kpi { padding-left: 16px; }
.feed { display: grid; gap: 0; max-height: 300px; overflow: hidden; mask-image: linear-gradient(to bottom, #000 70%, transparent); }
.feed-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; height: 30px; align-items: center; border-top: 1px solid var(--rule); animation: feed-in 300ms var(--ease-out); }
.feed-line span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes feed-in { from { opacity: 0; transform: translateY(-8px); } }
.idle-note { color: var(--muted); }

/* --------------------------------------------------------------------------
   Mappa
   -------------------------------------------------------------------------- */

.map-wrap { position: relative; height: calc(100dvh - 250px); min-height: 420px; border-radius: var(--radius-card); overflow: hidden; border: 1px solid var(--border); }
.map { position: absolute; inset: 0; background: var(--raised); }
.map .leaflet-tile-pane { filter: var(--map-filter); }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; background: var(--surface) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--text) !important; }
.leaflet-bar a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
.map-tip { font: 500 12px/16px var(--font); }
.leaflet-tooltip { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-float); border-radius: 6px; }
.leaflet-tooltip::before { display: none; }
.map-legend { position: absolute; z-index: 500; left: 12px; bottom: 12px; display: flex; gap: 12px; padding: 8px 12px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.map-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* --------------------------------------------------------------------------
   Scheda del lead (pannello laterale)
   -------------------------------------------------------------------------- */

.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.32); opacity: 0; transition: opacity var(--t-mid); }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; z-index: 61; top: 8px; right: 8px; bottom: 8px; width: min(600px, calc(100vw - 16px));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-float);
  transform: translateX(calc(100% + 24px)); transition: transform 460ms var(--ease-drawer);
  overflow: hidden;
}
.sheet.open { transform: none; }
.sheet-head { padding: 20px 24px 0; }
.sheet-crumbs { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.sheet-head h2 { margin-top: 10px; font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: -0.02em; }
.sheet-sub { margin-top: 4px; color: var(--muted); }
.sheet-tools { display: inline-flex; gap: 4px; }
.fav-toggle .icon { transition: transform var(--t-mid) var(--ease-out), fill var(--t-mid); }
.fav-toggle[aria-pressed="true"] { color: var(--text); }
.fav-toggle[aria-pressed="true"] .icon { fill: currentColor; }
.fav-toggle:active .icon { transform: scale(0.85); }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.quick-actions:empty { display: none; }
.table th.fav-cell, .table td.fav-cell { width: 1%; text-align: center; white-space: nowrap; }
.table td.fav-cell .icon-button { margin: -4px 0; }
.table th.fav-cell { padding-left: 4px; padding-right: 8px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 20px 24px 28px; display: grid; gap: 24px; align-content: start; }
.sheet-section h3 { font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 10px; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-card); }
.fact { padding: 14px 16px; min-width: 0; }
.fact + .fact { border-left: 1px solid var(--border); }
.fact .kpi-value { font-size: 22px; line-height: 28px; margin-top: 4px; }
.fact .kpi-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px 16px; line-height: 20px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv a { text-decoration: underline; text-decoration-color: var(--control); text-underline-offset: 3px; }
.kv a:hover { text-decoration-color: var(--text); }
.issues { display: grid; gap: 0; }
.issue { display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--rule); line-height: 20px; }
.issue:first-child { border-top: 0; }
.issue .sev { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; border: 1px solid var(--text); }
.issue .sev.critical { background: var(--text); }
.issue .sev.major { background: var(--hatch); }
.pipeline-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.pipeline-picker button { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 500; transition: all var(--t-fast); }
.pipeline-picker button:hover { border-color: var(--text); color: var(--text); }
.pipeline-picker button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.composer { display: grid; gap: 10px; }
.composer-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.composer-foot .spacer { flex: 1; }
.composer-foot .count { color: var(--muted); font-size: 12px; }
.edited-mark { color: var(--muted); font-size: 12px; }

/* Messaggio scritto dall'AI nella scheda */
.ai-working { display: grid; gap: 12px; padding: 14px 16px; border-radius: var(--radius-control); background: var(--raised); }
.ai-working p { line-height: 21px; color: var(--muted); }
.ai-working b { color: var(--text); font-weight: 600; }
.ai-bar { position: relative; display: block; height: 2px; overflow: hidden; background: var(--border); border-radius: 1px; }
.ai-bar::after { content: ""; position: absolute; inset: 0; width: 35%; background: var(--text); animation: ai-scan 1.4s var(--ease-drawer) infinite; }
@keyframes ai-scan { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
.ai-result { display: grid; gap: 12px; }
.ai-analysis { line-height: 22px; }
.ai-ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; counter-reset: step; }
.ai-ladder li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; align-items: start; padding: 10px 0; border-top: 1px solid var(--rule); animation: rise-photo 360ms var(--ease-out) backwards; }
.ai-ladder li:nth-child(2) { animation-delay: 60ms; } .ai-ladder li:nth-child(3) { animation-delay: 120ms; }
.ai-ladder li:nth-child(4) { animation-delay: 180ms; } .ai-ladder li:nth-child(5) { animation-delay: 240ms; }
.ai-ladder .pill { justify-self: start; margin-top: 1px; }
.ai-ladder b { font-weight: 500; }
.ai-ladder p { margin-top: 2px; color: var(--muted); line-height: 20px; }
.ai-meta { color: var(--muted); font-size: 12px; line-height: 18px; }
.ai-meta b { color: var(--text); font-weight: 500; }
.ai-meta code, .settings-label code { font-family: var(--mono); font-size: 0.95em; padding: 1px 5px; border-radius: 4px; background: var(--raised); color: var(--text); }

/* Anteprima del sito nella scheda */
.demo-form { display: grid; gap: 14px; }
.demo-box { display: grid; gap: 12px; margin-bottom: 16px; padding: 14px 16px; border-radius: var(--radius-control); background: var(--raised); }
.demo-box b { font-weight: 600; }
.demo-box p { margin-top: 4px; color: var(--muted); line-height: 20px; overflow-wrap: anywhere; }
.demo-box.ready { background: var(--primary); color: var(--on-primary); }
.demo-box.ready p, .demo-box.ready .text-link { color: var(--on-primary); opacity: 0.85; }
.demo-box.ready .button { --bg: transparent; --fg: var(--on-primary); --bd: var(--on-primary); }
.demo-box.ready .button.primary { --bg: var(--on-primary); --fg: var(--primary); }
.demo-box .composer-foot { justify-content: flex-start; }
.command-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.command-row code { padding: 6px 10px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo { position: relative; margin: 0; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--raised); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; animation: rise-photo 360ms var(--ease-out); }
@keyframes rise-photo { from { opacity: 0; transform: scale(1.04); } }
.photo button {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--primary); color: var(--on-primary); opacity: 0; transition: opacity var(--t-fast);
}
.photo:hover button, .photo button:focus-visible { opacity: 1; }
@media (hover: none) { .photo button { opacity: 1; } }
.photo.doc { background: var(--raised); box-shadow: inset 0 0 0 1px var(--border); }
.photo.doc a { display: grid; place-content: center; justify-items: center; gap: 4px; height: 100%; padding: 8px; text-align: center; color: var(--text); transition: background-color var(--t-fast); }
.photo.doc a:hover { background: var(--active); }
.photo.doc .icon { width: 22px; height: 22px; }
.photo.doc span { font-size: 11px; line-height: 14px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.photo.doc small { font: 500 10px/1 var(--mono); color: var(--muted); letter-spacing: 0.04em; }
.photo.add { display: grid; place-content: center; justify-items: center; gap: 4px; border: 1px dashed var(--control); background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; transition: border-color var(--t-fast), color var(--t-fast); }
.photo.add:hover { border-color: var(--text); color: var(--text); }

/* --------------------------------------------------------------------------
   Statistiche
   -------------------------------------------------------------------------- */

.stack { display: flex; height: 28px; border-radius: 4px; overflow: hidden; gap: 2px; }
.stack span { display: block; height: 100%; transform-origin: left; transition: transform 900ms var(--ease-drawer); }
.stack .s-none { background: var(--text); }
.stack .s-social { background: var(--hatch); box-shadow: inset 0 0 0 1px var(--text); }
.stack .s-broken { background: var(--muted); }
.stack .s-outdated { background: var(--control); }
.stack .s-valid { background: var(--raised); box-shadow: inset 0 0 0 1px var(--border); }
.stack-legend { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-top: 14px; }
.stack-legend div { display: grid; gap: 2px; }
.stack-legend i { width: 10px; height: 10px; display: inline-block; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.stack-legend .num { font-size: 18px; line-height: 24px; }
.bars { display: grid; grid-template-columns: 36px 1fr; gap: 0 8px; }
.bars-plot { position: relative; height: 180px; display: flex; align-items: flex-end; gap: 6px; border-bottom: 1px solid var(--text); }
.bars-plot span { flex: 1; max-width: 40px; background: var(--text); transform-origin: bottom; transition: transform 900ms var(--ease-drawer); }
.bars-plot .grid-line { position: absolute; left: 0; right: 0; height: 1px; background: var(--rule); }
.bars-axis { position: relative; height: 180px; font: 400 11px/1 var(--mono); color: var(--muted); }
.bars-axis span { position: absolute; right: 0; transform: translateY(50%); }
.bars-x { display: flex; gap: 6px; grid-column: 2; margin-top: 6px; font-size: 11px; color: var(--muted); }
.bars-x span { flex: 1; max-width: 40px; text-align: center; white-space: nowrap; }

/* --------------------------------------------------------------------------
   Impostazioni: colonna delle etichette accanto al pannello (§8.2)
   -------------------------------------------------------------------------- */

.settings { display: grid; gap: 32px; max-width: 1120px; }
.settings-row { display: grid; grid-template-columns: minmax(220px, 320px) minmax(0, 1fr); gap: 32px; padding-top: 32px; border-top: 1px solid var(--border); }
.settings-row:first-child { border-top: 0; padding-top: 0; }
.settings-label h2 { font-size: 16px; line-height: 22px; font-weight: 600; margin-top: 6px; }
.settings-label p { margin-top: 6px; color: var(--muted); line-height: 21px; }
.settings-panel { padding: var(--card-pad); display: grid; gap: 16px; align-content: start; }
.settings-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.form-status { flex: 1; color: var(--muted); font-size: 13px; line-height: 18px; }
.form-status[data-kind="error"], [data-key-result][data-kind="error"] { color: var(--negative); }
.form-status[data-kind="ok"], [data-key-result][data-kind="ok"] { color: var(--positive); }
.field-note { color: var(--muted); font-size: 13px; }
.text-link { text-decoration: underline; text-decoration-color: var(--control); text-underline-offset: 3px; }
.text-link:hover { text-decoration-color: var(--text); }
.key-row { display: flex; gap: 8px; }
.key-row .input { flex: 1; }
.input:disabled, .select:disabled { background: var(--raised); color: var(--muted); cursor: not-allowed; }
.preview { display: grid; gap: 8px; padding: 14px 16px; border-radius: var(--radius-control); background: var(--raised); }
.preview-label { color: var(--muted); font-size: 12px; }
.preview-body { margin: 0; font: 400 14px/21px var(--font); white-space: pre-wrap; }
.ai-instant { border-top: 1px solid var(--rule); padding-top: 16px; }
.ai-instant .field-note { margin: 0 0 10px; line-height: 20px; }
.templates { border-top: 1px solid var(--rule); padding-top: 14px; }
.templates summary { cursor: pointer; font-weight: 500; list-style: none; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.templates summary::-webkit-details-marker { display: none; }
.templates summary::before { content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform var(--t-mid) var(--ease-out); }
.templates[open] summary::before { transform: rotate(45deg); }
.templates summary:hover { color: var(--text); }
.templates > .field-note { margin: 12px 0; line-height: 20px; }
.templates .form { display: grid; gap: 16px; }
.tone-seg { flex-wrap: wrap; }
.tone-seg label { position: relative; cursor: pointer; }
.tone-seg input { position: absolute; opacity: 0; pointer-events: none; }
.tone-seg span { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 6px; color: var(--muted); font-weight: 500; transition: background-color var(--t-fast), color var(--t-fast); }
.tone-seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.tone-seg input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }
.msg-preview { gap: 10px; }
.msg-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.msg-preview .preview-body { max-height: 340px; overflow-y: auto; }
.placeholder-chip { display: inline-block; margin: 2px 2px 0 0; padding: 1px 6px; border-radius: 4px; background: var(--raised); color: var(--text); font-size: 12px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 16px; border-top: 1px solid var(--rule); }
.switch-row b { font-weight: 500; }
.switch-row p { margin-top: 2px; color: var(--muted); font-size: 13px; line-height: 19px; overflow-wrap: anywhere; }
.switch {
  position: relative; flex: none; width: 36px; height: 22px; padding: 0; border: 0; border-radius: 999px;
  background: var(--control); transition: background-color var(--t-mid) var(--ease-out);
}
.switch span {
  position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface);
  transition: transform var(--t-mid) var(--ease-drawer);
}
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"] span { transform: translateX(14px); background: var(--on-primary); }
.switch:disabled { opacity: 0.5; cursor: not-allowed; }

.setup-note {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: var(--gap);
  padding: 14px var(--card-pad); border-radius: var(--radius-card); background: var(--primary); color: var(--on-primary);
}
.setup-note p { line-height: 20px; }
.setup-note .button { --bg: var(--on-primary); --fg: var(--primary); --bd: var(--on-primary); flex: none; }

/* Schermata del codice di accesso (dal telefono) */
.lock { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.lock-card { width: min(380px, 100%); display: grid; gap: 18px; justify-items: start; }
.lock-card .logo { font-size: 56px; }
.lock-title { font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: -0.02em; }
.lock-card .field { width: 100%; }
.lock { padding-top: max(24px, env(safe-area-inset-top)); }
@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top); height: calc(52px + env(safe-area-inset-top)); }
}
.lock-card p { color: var(--muted); line-height: 21px; }
.lock-card form { width: 100%; display: grid; gap: 10px; }
.lock-card .input { height: 48px; font-size: 16px; }
.lock-card .button { height: 44px; }
.lock-error { color: var(--negative); font-size: 13px; min-height: 18px; }
body.locked .shell { display: none; }

/* --------------------------------------------------------------------------
   Notifiche
   -------------------------------------------------------------------------- */

.toasts { position: fixed; z-index: 80; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 8px 8px 16px;
  background: var(--primary); color: var(--on-primary); border-radius: 10px; box-shadow: var(--shadow-float);
  pointer-events: auto; animation: toast-in 380ms var(--ease-drawer);
}
.toast.out { animation: toast-out 260ms var(--ease-out) forwards; }
.toast .button { --bg: transparent; --fg: var(--on-primary); --bd: transparent; height: 30px; }
.toast .button:hover { --bg: rgba(127, 127, 127, 0.25); }
@keyframes toast-in { from { transform: translateY(16px) scale(0.96); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(8px); opacity: 0; } }

/* --------------------------------------------------------------------------
   Entrate: i blocchi salgono in sequenza quando la vista cambia
   -------------------------------------------------------------------------- */

/* Un'animazione, non una transizione: parte appena c'è la classe, senza aspettare un frame, e il ritardo
   (--d) non tocca le altre transizioni dell'elemento (hover delle righe, focus) */
.reveal { opacity: 0; }
.reveal.in { opacity: 1; animation: rise 340ms var(--ease-out) backwards; animation-delay: var(--d, 0ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.skeleton { display: inline-block; height: 1em; width: 6ch; border-radius: 3px; background: var(--raised); vertical-align: middle; }

/* Il cambio di tema: un cerchio che si apre dal pulsante */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: theme-wipe 640ms var(--ease-drawer); }
@keyframes theme-wipe { from { clip-path: circle(0 at var(--wipe-x, 0) var(--wipe-y, 100%)); } to { clip-path: circle(var(--wipe-r, 150vmax) at var(--wipe-x, 0) var(--wipe-y, 100%)); } }

/* --------------------------------------------------------------------------
   Tablet e telefono
   -------------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: 1 / -1; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(4) { border-left: 0; }
  .kpi:nth-child(n + 4) { border-top: 1px solid var(--border); }
}

@media (max-width: 900px) {
  :root { --pad: 16px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 8px 0 16px;
    background: var(--ground); border-bottom: 1px solid var(--border);
  }
  .topbar .brand { padding: 0; }
  .topbar .logo { font-size: 26px; }
  .topbar-title { flex: 1; color: var(--muted); font-weight: 500; }
  .sidebar {
    position: fixed; z-index: 50; inset: 52px 0 0 0; height: auto;
    background: var(--ground); border: 0; padding: 16px;
    transform: translateY(-8px); opacity: 0; visibility: hidden;
    transition: opacity var(--t-mid) var(--ease-out), transform var(--t-mid) var(--ease-out), visibility 0s var(--t-mid);
  }
  .sidebar.open { transform: none; opacity: 1; visibility: visible; transition-delay: 0s; }
  .sidebar > .brand, .sidebar > .scope { display: none; }
  .nav { margin-top: 0; }
  .nav a { height: 48px; font-size: 16px; }
  .canvas { padding: 20px var(--pad) 48px; }
  .title-row { flex-direction: column; gap: 14px; }
  .title-row .actions { width: 100%; }
  .title-row .actions .button { flex: 1; }
  .board { grid-auto-columns: 82vw; scroll-snap-type: x mandatory; }
  .lane { scroll-snap-align: start; max-height: none; }
  .live-top { grid-template-columns: 1fr; }
  .settings-row { grid-template-columns: minmax(180px, 240px) minmax(0, 1fr); gap: 20px; }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 0; }
  .flow-step:nth-child(odd) { border-left: 0; padding-left: 0; }
  .flow-step:last-child { grid-column: 1 / -1; }
  .sheet { inset: 0; width: 100%; border-radius: 0; border: 0; transform: translateY(100%); }
}

@media (max-width: 640px) {
  :root { --fs-title: 22px; --fs-kpi: 24px; --card-pad: 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi + .kpi { border-left: 0; }
  .kpi:nth-child(even) { border-left: 1px solid var(--border); }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .panel-head { flex-wrap: wrap; row-gap: 6px; }
  .row-item { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .row-item .janus-bar { grid-column: 1; grid-row: 2; width: 100px; }
  .row-item .pill-cell { grid-column: 2; grid-row: 1; justify-self: end; }
  .row-item .rating { grid-column: 2; grid-row: 2; justify-self: end; }
  .toolbar .input, .toolbar .select { width: 100%; }
  .toolbar .seg { width: 100%; }
  .toolbar .seg button { flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .settings-row { grid-template-columns: 1fr; gap: 14px; }
  .key-row { flex-direction: column; }
  .key-row .input { flex: none; }
  .setup-note { flex-direction: column; align-items: flex-start; }
  .fact { padding: 12px; }
  .fact .kpi-value { font-size: 18px; line-height: 24px; }
  .fact .janus-bar { width: 72px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .stack-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .mirror-row, .mirror-axis-labels { grid-template-columns: 84px 1fr 1px 1fr; }
  .mirror-axis-labels { grid-template-columns: 84px 1fr 1fr; }
  /* Le tabelle diventano liste di righe a due livelli */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 0; border-top: 1px solid var(--border); }
  .table td { height: auto; padding: 0; border: 0; }
  .table td.ident-cell { max-width: none; width: auto; grid-column: 1; }
  .table td.hide-sm { display: none; }
  .table td.score-cell { grid-column: 2; grid-row: 1; text-align: right; }
  .table td.web-cell { grid-column: 1; }
  .table td.rating-cell { grid-column: 2; grid-row: 2; text-align: right; }
  .table td.fav-cell { grid-column: 2; grid-row: 3; width: auto; justify-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .reveal { opacity: 1; transform: none; }
  .intro { display: none; }
}
