/* Sistema Pavone — Editorial Engineering tokens */
:root {
  /* Paper & ink */
  --paper: #FAF7F2;
  --paper-2: #F4F0EA;
  --paper-3: #ECE7DD;
  --surface: #FFFFFF;
  --ink: #1B1A17;
  --ink-2: #4A4742;
  --ink-3: #6E6962;
  --ink-4: #B8B2A4;
  --rule: #E5DFD5;
  --rule-2: #D4CDC0;
  --rule-3: #BFB7A6;

  /* Signals */
  --red: #B8392E;
  --red-soft: #F5E4E1;
  --red-edge: #E8C4BD;
  --red-text: #8E2A22;     /* for text on red-soft (≥6.5:1) and small text on white */
  --amber: #B8770F;
  --amber-soft: #F5EAD3;
  --amber-edge: #E8D2A8;
  --amber-text: #8A5808;   /* for text on amber-soft (≥5:1) and small text on white */
  --green: #3A7A4A;
  --green-soft: #DDEBDF;
  --green-edge: #B8D5BD;
  --green-text: #265F32;   /* for text on green-soft (≥6:1) */
  --quiet-dot: #C4C0B6;

  /* Workspace defaults — overridden by [data-workspace] */
  --ws: #2B3870;
  --ws-soft: #E8EAF2;
  --ws-edge: #C4C9DC;

  /* Type ramp */
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 32px;
  --text-4xl: 44px;

  /* Spacing */
  --s1: 2px; --s2: 4px; --s3: 8px; --s4: 12px; --s5: 16px;
  --s6: 24px; --s7: 32px; --s8: 48px; --s9: 64px;

  /* Radii */
  --r-sm: 3px; --r-md: 4px; --r-lg: 6px;

  /* Shadows */
  --sh-1: 0 1px 0 rgba(27,26,23,0.04);
  --sh-2: 0 1px 2px rgba(27,26,23,0.06), 0 0 0 0.5px rgba(27,26,23,0.04);
  --sh-3: 0 12px 32px rgba(27,26,23,0.10), 0 2px 8px rgba(27,26,23,0.06);

  /* Type families */
  --ff-display: "Fraunces", Georgia, serif;
  --ff-ui: "Instrument Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --ff-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --t-fast: 120ms cubic-bezier(0.2,0,0,1);
  --t-mid: 200ms cubic-bezier(0.2,0,0,1);
  --t-panel: 220ms cubic-bezier(0.2,0,0,1);
}

[data-workspace="fo"]      { --ws:#2B3870; --ws-soft:#E8EAF2; --ws-edge:#C4C9DC; }
[data-workspace="tecnica"] { --ws:#1F6F6F; --ws-soft:#DCEAEA; --ws-edge:#A8C8C8; }
[data-workspace="back"]    { --ws:#4A2D7C; --ws-soft:#E8E2F0; --ws-edge:#C4B8D8; }
[data-workspace="ammin"]   { --ws:#3A4F66; --ws-soft:#E0E5EC; --ws-edge:#B8C2CD; }
[data-workspace="comp"]    { --ws:#3D2D5C; --ws-soft:#E5E0EC; --ws-edge:#C0B8CD; }
[data-workspace="dir"]     { --ws:#3F3D38; --ws-soft:#E5E2DC; --ws-edge:#C0BCB2; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ff-ui);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.mono { font-family: var(--ff-mono); font-feature-settings: "tnum"; }
.serif { font-family: var(--ff-display); }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ─── App shell ─── */
.app { display: grid; grid-template-rows: 48px 1fr; height: 100vh; min-width: 1280px; background: var(--paper); }
.topbar {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  height: 48px; padding: 0 var(--s5); gap: var(--s5);
  background: var(--paper-2); border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: var(--s3); }
.brand-mark {
  width: 22px; height: 22px; border: 1px solid var(--ink-3); border-radius: 999px;
  display: grid; place-items: center; font-family: var(--ff-display); font-weight:500; font-size: 14px;
  background: var(--paper); color: var(--ws); line-height: 1; padding-bottom: 1px;
}
.brand-name { font-family: var(--ff-display); font-weight: 500; font-size: 15px; color: var(--ink); letter-spacing: -0.005em; }
.brand-sep { width: 1px; height: 18px; background: var(--rule-2); margin: 0 var(--s4); }

.ws-pill {
  display: inline-flex; align-items: center; gap: var(--s3);
  background: var(--ws); color: white; padding: 6px 12px; border-radius: var(--r-sm);
  font-family: var(--ff-display); font-weight: 500; font-size: 14px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--ws) 80%, black);
  transition: filter var(--t-fast);
  user-select: none;
}
.ws-pill:hover { filter: brightness(1.08); }
.ws-pill .ico { width:14px; height:14px; }
.ws-pill .caret { opacity: 0.7; margin-left: 2px; }

.search-wrap { justify-self: center; width: 100%; max-width: 480px; position: relative; }
.search-input {
  width: 100%; height: 32px; padding: 0 var(--s4) 0 32px; border-radius: var(--r-sm);
  border: 1px solid var(--rule-2); background: var(--paper); color: var(--ink);
  font-size: var(--text-base);
}
.search-input::placeholder { color: var(--ink-3); }
.search-icon { position:absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; gap: 2px;
  font-family: var(--ff-mono); font-size: 10px; color: var(--ink-3);
  background: var(--paper-3); border: 1px solid var(--rule-2); padding: 2px 6px; border-radius: 3px;
}
.user-cluster { display: flex; align-items: center; gap: var(--s3); }
.user-name { font-size: var(--text-base); color: var(--ink-2); white-space: nowrap; }
.avatar {
  width: 28px; height: 28px; border-radius: 999px;
  background: var(--ws-soft); color: var(--ws);
  display: grid; place-items: center;
  font-family: var(--ff-display); font-weight: 600; font-size: 11px;
  border: 1px solid var(--ws-edge);
}

/* connectivity chip */
.conn-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-xs); color: var(--ink-3); white-space: nowrap;
}
.conn-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

/* ─── Body grid (Slice 5 redesign) ─── */
.body-grid {
  display: grid;
  grid-template-columns: 64px 1fr;
  height: calc(100vh - 48px);
  min-height: 0;
}
.body-grid.drawer-open { grid-template-columns: 64px 248px 1fr; }
.body-grid.widgets-open { grid-template-columns: 64px 1fr 280px; }
.body-grid.drawer-open.widgets-open { grid-template-columns: 64px 248px 1fr 280px; }

/* Slim icon rail */
.slim-rail {
  background: #1B1A17;
  border-right: 1px solid rgba(255,255,255,0.08);
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 0;
  gap: 4px;
}
.slim-rail::before {
  content: ''; width: 36px; height: 3px; background: var(--ws);
  border-radius: 2px; margin-bottom: 6px;
}
.rail-btn {
  width: 44px; height: 40px;
  display: grid; place-items: center;
  border: none; background: transparent;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: all var(--t-fast);
  position: relative;
}
.rail-btn:hover { background: rgba(255,255,255,0.08); color: white; }
.rail-divider { width: 32px; height: 1px; background: rgba(255,255,255,0.12); margin: 6px 0; }
.rail-spacer { flex: 1; }
.rail-ws.active {
  color: white;
  background: rgba(255,255,255,0.1);
}
.rail-ws.active::before {
  content: ''; position: absolute; left: -1px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 2px 2px 0;
  background: var(--ws);
}
.rail-ws[data-ws="fo"].active::before      { background: #6680B5; }
.rail-ws[data-ws="tecnica"].active::before { background: #5BA09F; }
.rail-ws[data-ws="back"].active::before    { background: #8060B5; }
.rail-ws[data-ws="ammin"].active::before   { background: #7088A0; }
.rail-ws[data-ws="comp"].active::before    { background: #7560A0; }
.rail-ws[data-ws="dir"].active::before     { background: #ABA89F; }
.rail-hamburger { color: rgba(255,255,255,0.85); }

/* Drawer */
.drawer-nav {
  background: var(--paper-2);
  border-right: 1px solid var(--rule);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: drawerSlide 0.18s ease-out;
}
@keyframes drawerSlide {
  from { transform: translateX(-12px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.drawer-h {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--rule);
}
.drawer-ws-label {
  font-family: var(--ff-display); font-size: 14px; font-weight: 500;
  color: var(--ink); letter-spacing: -0.005em;
}
.drawer-pin {
  width: 26px; height: 26px; border: none; background: transparent;
  display: grid; place-items: center;
  color: var(--ink-3); cursor: pointer; border-radius: var(--r-sm);
  transition: all var(--t-fast);
}
.drawer-pin:hover { background: var(--paper); color: var(--ink); }
.drawer-pin.pinned { color: var(--ws); background: var(--ws-soft); }

.drawer-tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.drawer-tab {
  height: 34px;
  border: none; background: transparent;
  font-size: 12px; font-weight: 600; color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--t-fast);
}
.drawer-tab:hover { color: var(--ink-2); }
.drawer-tab.active { color: var(--ws); border-bottom-color: var(--ws); background: var(--paper-2); }

.drawer-search {
  display: flex; align-items: center; gap: 6px;
  margin: 10px 12px;
  padding: 6px 10px;
  background: var(--paper); border: 1px solid var(--rule-2);
  border-radius: var(--r-sm);
  color: var(--ink-3);
}
.drawer-search input {
  flex: 1; background: transparent; border: none; outline: none;
  font-size: 12px; color: var(--ink);
}
.drawer-search input::placeholder { color: var(--ink-3); }

.drawer-content { flex: 1; overflow: auto; padding: 0 0 16px; }
.drawer-tree-body { padding: 4px 12px 16px; }
.drawer-section { margin-top: 14px; }
.drawer-section:first-child { margin-top: 4px; }
.drawer-section-h {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); font-weight: 600; padding: 0 8px 6px;
}
.drawer-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 7px 10px;
  border: none; background: transparent;
  border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 12.5px;
  cursor: pointer; text-align: left;
  transition: all var(--t-fast);
}
.drawer-item:hover { background: var(--paper); color: var(--ink); }
.drawer-item.active {
  background: var(--ws-soft); color: var(--ws);
  font-weight: 500;
}
.drawer-item svg { color: var(--ink-3); }
.drawer-item.active svg { color: var(--ws); }
.drawer-empty {
  padding: 24px 16px; text-align: center;
  font-size: 12px; color: var(--ink-3);
}

/* Override existing .tree-side rules within the drawer to fit narrower width */
.drawer-content .tree-side { padding: 0; background: transparent; border-right: none; }
.drawer-content .tree-side::before { display: none; }
.drawer-content .tree-section { padding: 0 12px; }
.drawer-content .tree-section + .tree-section { margin-top: 12px; padding-top: 10px; }
.drawer-content .tree-search { display: none; } /* drawer has its own search above */

/* Widgets column (right) */
.widgets-col {
  background: var(--paper-2);
  border-left: 1px solid var(--rule);
  display: flex; flex-direction: column;
  overflow: auto;
  padding: 0;
  animation: drawerSlide 0.18s ease-out;
}
.widgets-h {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--ff-display); font-size: 14px; font-weight: 500; color: var(--ink);
}
.widgets-x {
  width: 22px; height: 22px; border: none; background: transparent;
  display: grid; place-items: center;
  color: var(--ink-3); cursor: pointer; border-radius: 4px;
}
.widgets-x:hover { background: var(--paper); color: var(--ink); }

.widget {
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
}
.widget-h {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-3); font-weight: 600; margin-bottom: 10px;
}
.widget-actions { display: flex; flex-direction: column; gap: 5px; }
.widget-action {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  color: var(--ink); font-size: 12.5px; font-weight: 500;
  cursor: pointer; text-align: left;
  transition: all var(--t-fast);
}
.widget-action:hover { background: var(--paper-2); border-color: var(--ink-3); }
.widget-action svg { color: var(--ws); flex-shrink: 0; }

.widget-cron { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.widget-cron li {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 8px; align-items: center;
  padding: 7px 8px;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast);
}
.widget-cron li:hover { border-color: var(--ws); background: var(--paper-2); }
.cron-kind {
  width: 22px; height: 22px; border-radius: 999px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.cron-kind.kind-cliente { background: color-mix(in srgb, var(--ws) 14%, transparent); color: var(--ws); }
.cron-kind.kind-pratica { background: color-mix(in srgb, #4A2D7C 14%, transparent); color: #4A2D7C; }
.cron-kind.kind-lavoro  { background: color-mix(in srgb, #1F6F6F 14%, transparent); color: #1F6F6F; }
.cron-label { font-size: 12px; font-weight: 500; color: var(--ink); }
.cron-meta { font-size: 10px; color: var(--ink-3); margin-top: 1px; }
.cron-when { font-size: 10px; color: var(--ink-3); flex-shrink: 0; }

.widget-notif {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 10px;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  color: var(--ink); font-size: 12.5px; font-weight: 500;
  cursor: pointer; text-align: left;
}
.widget-notif:hover { border-color: var(--ws); }
.widget-notif > span:first-of-type { flex: 1; }

/* Static workspace chip in topbar (replaces interactive ws-pill — switching is via rail) */
/* Topbar is light (--paper-2). Use workspace color as text on a soft tinted background. */
.ws-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: var(--ws-soft);
  border: 1px solid var(--ws-edge);
  border-radius: 6px;
  color: var(--ws);
  font-size: 12px; font-weight: 600;
  letter-spacing: -0.005em;
}

/* ─── Tree sidebar ─── */
.tree-side {
  background: var(--paper-2);
  border-right: 1px solid var(--rule);
  position: relative;
  overflow: auto;
  padding: var(--s4) 0 var(--s7);
}
.tree-side::before {
  content: ""; position: absolute; top: 0; left: 0; bottom: 0; width: 3px; background: var(--ws);
}
.tree-search { padding: 0 var(--s4) var(--s4); }
.tree-search input {
  width: 100%; height: 30px; padding: 0 var(--s3) 0 28px;
  border: 1px solid var(--rule-2); background: var(--paper); border-radius: var(--r-sm);
  font-size: var(--text-base);
}
.tree-search { position: relative; }
.tree-search svg { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }

.tree-section { padding: 0 var(--s4); }
.tree-section + .tree-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--rule); }
.tree-section-h {
  font-size: 12px; font-weight: 500; color: var(--ink-3);
  padding: 0 var(--s3) var(--s2); display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.tree-section-h .h-label { display: inline-flex; align-items: center; gap: 6px; }
.tree-section-h .badge-count { font-family: var(--ff-mono); font-size: 11px; color: var(--ink-3); font-weight: 400; letter-spacing: 0; }
.badge-count.muted { color: var(--ink-4); }
.dot-grey-leaf { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-4); margin-right: 4px; flex-shrink: 0; }
.tree-row {
  display: flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 var(--s4); border-radius: var(--r-sm);
  font-size: var(--text-base); color: var(--ink-2); cursor: pointer;
  position: relative;
  user-select: none;
}
.tree-row .chev { color: var(--ink-3); width: 12px; display:inline-flex; }
.tree-row:hover { background: var(--paper-3); }
.tree-row.parent { font-weight: 500; }
.tree-row.leaf { padding-left: 28px; color: var(--ink-2); }
.tree-row.leaf.active {
  background: var(--ws-soft); color: var(--ink); font-weight: 500;
  margin: 0 calc(-1 * var(--s4)); padding-left: calc(28px + var(--s4)); padding-right: var(--s4); border-radius: 0;
  box-shadow: inset 3px 0 0 var(--ws);
  position: relative; z-index: 1;
}
.tree-row.muted { color: var(--ink-4); }
.tree-row .right { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-family: var(--ff-mono); font-size: 11px; color: var(--ink-3); }
.tree-row .dot-amber { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.tree-row .dot-red { width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.tree-row .dot-green { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.tree-row .dot-active { width: 7px; height: 7px; border-radius: 50%; background: var(--ws); box-shadow: 0 0 0 2px var(--ws-soft); }

/* ─── Tab bar ─── */
.tabbar {
  height: 40px; background: var(--paper-2); border-bottom: 1px solid var(--rule);
  display: flex; align-items: stretch; padding: 0 var(--s4); gap: var(--s2);
}
.tab {
  display: inline-flex; align-items: center; gap: var(--s3); white-space: nowrap;
  padding: 0 var(--s4); height: 100%; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-size: var(--text-base); color: var(--ink-3); font-weight: 500;
  transition: background var(--t-fast);
  position: relative;
}
.tab:hover { background: var(--paper-3); }
.tab.active { background: var(--surface); color: var(--ink); border-bottom-color: var(--ws); }
.tab .x { color: var(--ink-4); margin-left: 4px; }
.tab .x:hover { color: var(--ink-2); }
.tab.special { background: var(--amber-soft); color: var(--ink-2); border-radius: var(--r-sm) var(--r-sm) 0 0; margin: 4px 0 0 var(--s4); padding: 0 var(--s4); height: 32px; }
.tab .dotix { width:8px; height:8px; border-radius: 50%; }
.tab .dotix.green { background: var(--green); }
.tab .dotix.amber { background: var(--amber); }
.tab .dotix.red { background: var(--red); }
.tab .dotix.idle { background: transparent; border: 1.5px solid var(--ink-4); }
.tab.active .dotix.active-dot { background: var(--ws); box-shadow: 0 0 0 2px var(--ws-soft); }
.tab-plus { display: inline-flex; align-items: center; justify-content: center; width: 28px; color: var(--ink-3); cursor: pointer; margin-left: auto; }
.tab-plus:hover { background: var(--paper-3); }

/* ─── Content ─── */
.content {
  height: 100%; min-height: 0; overflow: auto; background: var(--paper);
  position: relative;
}
.scheda-wrap { padding: var(--s6) var(--s7); max-width: 1200px; margin: 0 auto; }

/* Scheda */
.scheda { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: var(--sh-2); overflow: hidden; }
.scheda-head { padding: var(--s6) var(--s7); display: grid; grid-template-columns: auto 1fr auto; gap: var(--s5); align-items: start; }
.scheda-head.field-mode { padding: var(--s6) var(--s7); }
.scheda-avatar {
  width: 64px; height: 64px; border-radius: 999px; background: var(--ink-2); color: white;
  display: grid; place-items: center; font-family: var(--ff-display); font-weight: 500; font-size: 22px;
}
.scheda-avatar.field { width: 80px; height: 80px; font-size: 28px; }
.scheda-title { font-family: var(--ff-display); font-weight: 500; font-size: var(--text-2xl); color: var(--ink); line-height: 1.15; letter-spacing: -0.01em; }
.scheda-title.field { font-size: 26px; }
.scheda-sub { font-size: var(--text-base); color: var(--ink-3); margin-top: 4px; }
.scheda-sub .mono { color: var(--ink-2); }
.scheda-addr { font-size: var(--text-base); color: var(--ink-3); margin-top: 2px; }
.scheda-actions { display: flex; gap: var(--s2); align-items: center; }
.icon-btn {
  width: 28px; height: 28px; border-radius: var(--r-sm); border: 0; background: transparent;
  display: grid; place-items: center; color: var(--ink-3); cursor: pointer;
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink-2); }

/* Strip */
.strip { border-top: 1px solid var(--rule); }
.strip-row {
  display: grid; grid-template-columns: 16px minmax(0,1fr) auto auto; gap: var(--s4); align-items: center;
  padding: 0 var(--s7); height: 44px; border-bottom: 1px solid var(--rule);
  cursor: pointer; transition: background var(--t-fast); font-size: var(--text-md);
}
.strip-row > .strip-text, .strip-row > span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: var(--s4); }
.strip-row.field { height: 52px; }
.strip-row:last-child { border-bottom: 0; }
.strip-row:hover { background: var(--paper-2); }
.strip-row.no-click { cursor: default; }
.strip-row.no-click:hover { background: transparent; }
.strip-row.red { background: var(--red-soft); }
.strip-row.red:hover { background: color-mix(in srgb, var(--red-soft) 80%, var(--red-edge)); }
.strip-row.amber-bg { background: var(--amber-soft); }
.strip-icon { color: var(--ink-3); display: grid; place-items: center; }
.strip-icon.amber { color: var(--amber-text); }
.strip-icon.red { color: var(--red-text); }
.strip-icon.ink { color: var(--ink-2); }
.strip-quiet-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--quiet-dot); justify-self: center; }
.strip-text { color: var(--ink); font-weight: 500; }
.strip-text.muted { color: var(--ink-3); font-weight: 400; }
.strip-meta { color: var(--ink-3); font-size: var(--text-sm); }
.strip-age { font-size: var(--text-sm); color: var(--ink-3); white-space: nowrap; }
.strip-age.amber { color: var(--amber-text); font-weight: 500; }
.strip-age.red { color: var(--red-text); font-weight: 500; }
.chip-peek {
  display: inline-flex; align-items: center; height: 22px; padding: 0 10px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase;
  color: #2B3870; background: #E8EAF2; border-radius: var(--r-pill);
  margin: 0 4px; white-space: nowrap; font-family: var(--ff-sans);
}
.strip-chev { color: var(--ink-4); display: inline-flex; }

/* Scheda tab bar */
.scheda-tabs { display: flex; align-items: stretch; height: 40px; background: var(--surface); border-top: 1px solid var(--rule); }
.scheda-tab {
  padding: 0 var(--s5); display: inline-flex; align-items: center;
  font-size: var(--text-base); font-weight: 500; color: var(--ink-3); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.scheda-tab.field { padding: 0 var(--s6); height: 44px; font-size: 14px; }
.scheda-tab.active { color: var(--ink); border-bottom-color: color-mix(in srgb, var(--ws) 60%, transparent); }
.scheda-tab:hover { color: var(--ink-2); }

.scheda-body { padding: var(--s6) var(--s7); border-top: 1px solid var(--rule); background: var(--surface); }

/* Note bar */
.note-bar {
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--r-md);
  padding: var(--s4) var(--s5); font-size: var(--text-md); color: var(--ink-2); margin-bottom: var(--s5); line-height: 1.55;
}
.note-bar strong { color: var(--ink); font-weight: 600; }

/* Lista / table */
.lista { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.lista th {
  text-align: left; padding: 12px 16px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); background: var(--paper-2); border-bottom: 1px solid var(--rule-2);
  border-top: 1px solid var(--rule);
}
.lista th.right { text-align: right; }
.lista td { padding: 12px 16px; border-bottom: 1px solid var(--rule); color: var(--ink-2); vertical-align: middle; }
.lista td.right { text-align: right; }
.lista tr:hover td { background: var(--paper-2); }
.lista tr.anomala td { background: var(--red-soft); color: var(--ink); }
.lista tr.anomala:hover td { background: color-mix(in srgb, var(--red-soft) 85%, var(--red-edge)); }
.lista .status-pagata { color: var(--green-text); font-weight: 500; }
.lista .status-anomala { color: var(--red-text); font-weight: 600; }

/* Linked rows — Bollette ↔ Incassi reconciliation */
.lista-link tr.clickable { cursor: pointer; }
.lista-link .row-chev {
  display: inline-flex; color: var(--ink-3);
  transition: transform var(--t-fast), color var(--t-fast);
}
.lista-link .row-chev.open { transform: rotate(90deg); color: var(--ink); }
.link-pill {
  display: inline-flex; align-items: center; height: 18px; padding: 0 8px; margin-left: 8px;
  border: 1px solid var(--rule-2); border-radius: 999px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.02em;
  color: var(--ink-2); background: var(--paper-2);
}
.lista-link tr.link-detail-row td { padding: 0; background: var(--paper-2); border-bottom: 1px solid var(--rule); }
.link-detail { padding: 16px 24px 18px; border-left: 2px solid var(--ws); margin-left: 0; }
.link-detail-h {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-3); margin-bottom: 10px;
}
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.link-list li {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 6px 0; border-bottom: 1px dashed var(--rule);
}
.link-list li:last-child { border-bottom: none; }
.link-id {
  background: transparent; border: none; padding: 0; cursor: pointer;
  font-family: var(--ff-mono); font-size: var(--text-base); font-weight: 500;
  color: var(--ws); text-decoration: underline; text-decoration-color: var(--ws-edge);
  text-underline-offset: 3px;
}
.link-id:hover { text-decoration-color: var(--ws); }
.link-meta { font-size: var(--text-sm); color: var(--ink-3); }
.link-amount { font-weight: 500; color: var(--ink); }
.link-foot {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rule);
  font-size: var(--text-sm); color: var(--ink-2);
}
.link-foot strong { color: var(--ink); font-weight: 600; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: var(--s2); height: 32px; padding: 0 var(--s4); border-radius: var(--r-sm); font-size: var(--text-base); font-weight: 500; cursor: pointer; transition: all var(--t-fast); border: 1px solid transparent; line-height: 1; white-space: nowrap; }
.btn-primary { background: var(--ws); color: white; border-color: color-mix(in srgb, var(--ws) 80%, black); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--paper); color: var(--ink); border-color: var(--rule-2); }
.btn-secondary:hover { background: var(--paper-2); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn-ghost:hover { background: var(--paper-2); }
.btn-large { height: 40px; padding: 0 var(--s5); font-size: var(--text-md); }
.btn-touch { height: 56px; padding: 0 var(--s6); font-size: var(--text-md); border-radius: var(--r-md); }
.btn-block { width: 100%; justify-content: center; }

/* Badge */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; letter-spacing: 0.02em; }
.badge.neutral { background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--rule); }
.badge.amber { background: var(--amber-soft); color: var(--amber-text); border: 1px solid var(--amber-edge); }
.badge.red { background: var(--red-soft); color: var(--red-text); border: 1px solid var(--red-edge); }
.badge.green { background: var(--green-soft); color: var(--green-text); border: 1px solid var(--green-edge); }
.badge.phase { background: transparent; color: var(--ink-3); border: 1px solid var(--rule-2); }

/* Triage panel */
.panel-overlay {
  position: fixed; top: 48px; right: 0; bottom: 0; left: 280px; pointer-events: none; z-index: 40;
}
.panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 420px;
  background: var(--surface); border-left: 1px solid var(--rule-2); box-shadow: var(--sh-3);
  display: flex; flex-direction: column; pointer-events: auto;
  animation: slideIn var(--t-panel);
}
.panel.peek { width: 380px; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.panel-head {
  height: 48px; padding: 0 var(--s5); display: flex; align-items: center; gap: var(--s3);
  border-bottom: 1px solid var(--rule);
}
.panel-title { font-size: var(--text-md); font-weight: 600; color: var(--ink); }
.panel-close { margin-left: auto; }
.chip-tiny { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 6px; border-radius: 2px; }
.chip-tiny.red { background: var(--red-soft); color: var(--red-text); }
.chip-tiny.indigo { background: var(--ws-soft); color: var(--ws); }

.panel-body { flex: 1; overflow: auto; }
.panel-section { padding: var(--s5) var(--s5); border-bottom: 1px solid var(--rule); }
.panel-section:last-child { border-bottom: 0; }
.panel-section h4 { margin: 0 0 var(--s3); font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.panel-section p { margin: 0 0 var(--s3); font-size: var(--text-md); color: var(--ink); line-height: 1.55; }
.panel-section p:last-child { margin-bottom: 0; }
.panel-section p strong { font-weight: 600; }

.dl-inline { display: grid; grid-template-columns: 1fr; gap: var(--s2); margin: var(--s3) 0 0; }
.dl-inline > div { display: grid; grid-template-columns: 140px 1fr; gap: var(--s3); align-items: baseline; }
.dl-inline dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 600; }
.dl-inline dd { margin: 0; font-size: var(--text-md); color: var(--ink); }

.panel-foot {
  padding: var(--s4) var(--s5); border-top: 1px solid var(--rule); background: var(--surface);
  display: flex; flex-direction: column; gap: var(--s3);
}
.panel-foot .btn { justify-content: center; }

.confirm-card {
  background: var(--green-soft); border: 1px solid var(--green-edge); border-radius: var(--r-md);
  padding: var(--s4) var(--s5); color: var(--ink); font-size: var(--text-md);
}
.confirm-card strong { color: var(--green-text); display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.confirm-card .sub { font-size: var(--text-base); color: var(--ink-2); margin-top: 4px; }

/* History list */
.histo { font-size: 11px; color: var(--ink-3); list-style: none; padding: 0; margin: 0; }
.histo li { padding: 4px 0; border-bottom: 1px dashed var(--rule); }
.histo li:last-child { border-bottom: 0; }

/* Workspace switcher dropdown */
.ws-dropdown {
  position: absolute; top: 44px; left: 0; width: 320px;
  background: var(--surface); border: 1px solid var(--rule-2); box-shadow: var(--sh-3);
  border-radius: var(--r-md); padding: 6px; z-index: 100;
  animation: ddIn var(--t-fast);
}
@keyframes ddIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.ws-row {
  display: grid; grid-template-columns: 12px 16px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: var(--r-sm); cursor: pointer; font-size: var(--text-md); color: var(--ink-2);
}
.ws-row:hover { background: var(--paper-2); }
.ws-row.active { background: var(--paper-2); position: relative; color: var(--ink); font-weight: 500; }
.ws-row.active::before { content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; border-radius: 2px; background: var(--row-color); }
.ws-row.disabled { color: var(--ink-3); cursor: not-allowed; }
.ws-row.disabled:hover { background: transparent; }
.ws-color { width: 10px; height: 10px; border-radius: 2px; background: var(--row-color); }
.ws-divider { height: 1px; background: var(--rule); margin: 6px 4px; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--paper); padding: var(--s8); }
.login-card { width: 100%; max-width: 420px; text-align: center; }
.login-mark { font-family: var(--ff-display); font-size: 22px; font-weight: 500; color: var(--ink); }
.login-rule { width: 64px; height: 1px; background: var(--rule-3); margin: 18px auto 32px; }
.login-hero { font-family: var(--ff-display); font-size: var(--text-4xl); font-weight: 500; line-height: 1.05; color: var(--ink); letter-spacing: -0.015em; }
.login-tag { font-size: var(--text-lg); color: var(--ink-3); margin-top: 10px; font-style: italic; }
.login-form { margin-top: 64px; max-width: 360px; margin-left: auto; margin-right: auto; text-align: left; }
.field { display: block; margin-bottom: 18px; }
.field label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.field input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--rule-2); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-size: var(--text-md); }
.field input:focus { outline: 2px solid color-mix(in srgb, var(--ink) 25%, transparent); outline-offset: 0; border-color: var(--ink); }
.btn-login { background: var(--ink); color: white; border: 0; height: 44px; width: 100%; border-radius: var(--r-sm); font-size: var(--text-md); font-weight: 500; cursor: pointer; }
.btn-login:hover { background: var(--ink-2); }
.login-link { display: block; text-align: center; font-size: var(--text-sm); color: var(--ink-3); margin-top: 14px; text-decoration: none; }
.login-link:hover { color: var(--ink-2); }
.login-foot { position: fixed; bottom: var(--s5); left: 0; right: 0; text-align: center; font-size: var(--text-xs); color: var(--ink-4); }

/* Section labels (forms etc) */
.section-label { font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; margin: var(--s5) 0 var(--s3); padding-bottom: var(--s2); border-bottom: 1px solid var(--rule); }
.section-label:first-child { margin-top: 0; }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: var(--s3); padding: 6px 0; font-size: var(--text-md); }
.kv dt { color: var(--ink-3); font-size: var(--text-base); }
.kv dd { margin: 0; color: var(--ink); }

/* Card */
.cardlet { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-md); padding: var(--s4) var(--s5); }
.cardlet h5 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 600; }

/* Two-col content */
.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: var(--s7); }

/* Presence chip */
.presence-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 4px; background: var(--amber-soft); color: var(--amber-text); font-size: 11px; font-weight: 600; border: 1px solid var(--amber-edge); margin-top: 6px; }
.presence-prompt {
  background: var(--amber-soft); border: 1px solid var(--amber-edge); border-radius: var(--r-md);
  padding: var(--s4) var(--s5); margin-bottom: var(--s4); display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap;
}
.presence-prompt .q { font-size: var(--text-md); color: var(--ink); }
.presence-prompt .q strong { font-weight: 600; }

/* Scenario bundle modal */
.modal-shade { position: fixed; top: 48px; right: 0; bottom: 0; left: 280px; background: rgba(27,26,23,0.18); display: grid; place-items: center; padding: var(--s5); overflow: auto; z-index: 40; }
.modal {
  background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--rule-2);
  box-shadow: var(--sh-3); width: 100%; max-width: 760px;
  display: flex; flex-direction: column; max-height: 92%;
}
.modal-head { padding: var(--s5) var(--s6); border-bottom: 1px solid var(--rule); display: flex; align-items: center; gap: var(--s4); }
.modal-head h3 { margin: 0; font-family: var(--ff-display); font-size: 20px; font-weight: 500; color: var(--ink); }
.modal-step { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.modal-body { padding: var(--s6); overflow: auto; }
.modal-foot { padding: var(--s4) var(--s6); border-top: 1px solid var(--rule); display: flex; justify-content: space-between; gap: var(--s3); }

.cascade-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--s2); }
.cascade-item { display: grid; grid-template-columns: 28px 1fr; gap: var(--s4); align-items: start; padding: var(--s3) 0; border-bottom: 1px dashed var(--rule); font-size: var(--text-md); color: var(--ink); }
.cascade-item:last-child { border-bottom: 0; }
.cascade-item .c-icon { display: grid; place-items: center; color: var(--ink-2); }
.cascade-item.cautela { background: var(--amber-soft); border-radius: var(--r-md); padding: var(--s4); border: 1px solid var(--amber-edge); border-bottom: 1px solid var(--amber-edge); margin: var(--s2) 0; }
.cascade-item.cautela .c-icon { color: var(--amber-text); }
.cascade-item .c-meta { font-size: var(--text-base); color: var(--ink-3); margin-top: 4px; padding-left: var(--s5); border-left: 1px dashed var(--rule-2); }
.cascade-item .c-title { font-weight: 500; }

.severity-bar { display: flex; gap: var(--s2); flex-wrap: wrap; }
.sev-chip {
  padding: 8px 16px; border-radius: var(--r-sm); border: 1px solid var(--rule-2);
  background: var(--paper); cursor: pointer; font-size: var(--text-md); color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px;
}
.sev-chip .sd { width: 8px; height: 8px; border-radius: 50%; background: var(--quiet-dot); }
.sev-chip.selected { background: var(--ws-soft); border-color: var(--ws); color: var(--ink); font-weight: 500; }
.sev-chip.selected .sd.sd-amber { background: var(--amber); }
.sev-chip .sd.sd-amber { background: var(--amber); opacity: 0.5; }

/* Reading capture */
.reading-card { max-width: 560px; margin: 0 auto; }
.reading-prev { background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--r-md); padding: var(--s5); display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin-bottom: var(--s5); }
.reading-prev .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 600; margin-bottom: 4px; }
.reading-prev .val { font-family: var(--ff-mono); font-size: var(--text-lg); color: var(--ink); font-weight: 500; }
.reading-input {
  width: 100%; height: 72px; padding: 0; text-align: center;
  font-family: var(--ff-mono); font-size: 36px; font-weight: 500; color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule-2); border-radius: var(--r-md);
  letter-spacing: 0.04em;
}
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); margin-top: var(--s4); }
.numpad button {
  height: 56px; border: 1px solid var(--rule-2); background: var(--paper); border-radius: var(--r-sm);
  font-family: var(--ff-mono); font-size: 22px; color: var(--ink); cursor: pointer;
}
.numpad button:hover { background: var(--paper-2); }
.numpad .wide { grid-column: span 1; }
.validation { padding: 10px 12px; border-radius: var(--r-sm); margin-top: var(--s4); font-size: var(--text-md); display: flex; align-items: center; gap: var(--s3); }
.validation.green { background: var(--green-soft); color: var(--green-text); border: 1px solid var(--green-edge); }
.validation.amber { background: var(--amber-soft); color: var(--amber-text); border: 1px solid var(--amber-edge); }

/* Search overlay */
.search-shade { position: fixed; inset: 0; background: rgba(27,26,23,0.18); display: grid; place-items: center; z-index: 200; padding-top: 12vh; align-items: start; }
.search-overlay-card { width: 600px; max-width: 92vw; background: var(--surface); border: 1px solid var(--rule-2); border-radius: var(--r-md); box-shadow: var(--sh-3); display: flex; flex-direction: column; max-height: 480px; }
.search-overlay-input { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--rule); }
.search-overlay-input input { border: 0; outline: none; width: 100%; font-size: 16px; background: transparent; color: var(--ink); }
.search-results { padding: var(--s3) var(--s2); overflow: auto; }
.search-grouph { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 600; padding: var(--s4) var(--s5) var(--s2); }
.search-result { display: grid; grid-template-columns: 18px 1fr auto; gap: var(--s4); align-items: center; padding: 8px 16px; border-radius: var(--r-sm); cursor: pointer; }
.search-result:hover, .search-result.sel { background: var(--paper-2); }
.search-result .res-meta { font-size: var(--text-sm); color: var(--ink-3); }

/* Empty state */
.empty-state { padding: var(--s9) var(--s7); text-align: center; }
.empty-state .greet { font-family: var(--ff-display); font-size: 22px; color: var(--ink-2); margin-bottom: 10px; font-weight: 500; }
.empty-state p { color: var(--ink-3); font-size: var(--text-md); max-width: 480px; margin: 0 auto; line-height: 1.55; }
.empty-illus { width: 80px; height: 80px; margin: 0 auto 18px; opacity: 0.3; color: var(--ws); }

/* Floating demo helper */
.helper-fab {
  position: fixed; bottom: 20px; right: 20px;
  width: 44px; height: 44px; border-radius: 999px;
  background: var(--ink); color: var(--paper);
  border: 0; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: var(--sh-3);
  z-index: 1100;
  font-family: var(--ff-display); font-size: 18px; font-weight: 500;
  transition: transform var(--t-fast), background var(--t-fast);
}
.helper-fab:hover { background: #2A2825; transform: translateY(-1px); }
.helper-fab.open { background: #2A2825; }
.helper-shade {
  position: fixed; inset: 0; z-index: 1090; background: transparent; cursor: default;
}
.helper-panel {
  position: fixed; bottom: 76px; right: 20px;
  width: 360px; max-height: 70vh;
  background: var(--surface); border: 1px solid var(--rule-2); border-radius: var(--r-md);
  box-shadow: var(--sh-3); z-index: 1100;
  display: flex; flex-direction: column;
  animation: helperIn 160ms cubic-bezier(0.2,0,0,1);
}
@keyframes helperIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.helper-head {
  padding: 14px 16px 10px; border-bottom: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: 2px;
}
.helper-sub { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.helper-body { flex: 1; overflow: auto; padding: 8px 8px 14px; }
.helper-group { margin-top: 6px; }
.helper-group-h {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); padding: 12px 12px 6px;
}
.helper-item {
  width: 100%; text-align: left;
  background: transparent; border: 0;
  padding: 8px 12px; border-radius: var(--r-sm);
  font-family: var(--ff-ui); font-size: 13px; color: var(--ink-2);
  cursor: pointer; display: flex; align-items: center;
  transition: background var(--t-fast);
}
.helper-item:hover { background: var(--paper-2); color: var(--ink); }
.helper-foot {
  padding: 10px 16px; border-top: 1px solid var(--rule);
  font-size: 11px; color: var(--ink-3);
}

/* Toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--sh-3); z-index: 1200;
  animation: toastIn 200ms cubic-bezier(0.2,0,0,1);
  max-width: calc(100vw - 100px);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast svg { color: var(--paper); opacity: 0.8; }

/* Tab dotix improvements */
.tab .dotix.active-dot { background: var(--ws); box-shadow: 0 0 0 2px var(--ws-soft); }

/* Tree leaf right-side small active dot (when not on the row but indicating activity) */
.dot-active-tiny { width: 6px; height: 6px; border-radius: 50%; background: var(--ws); }

/* ─── Pipeline (Voltura, Morosità) ─── */
.pipeline {
  display: flex; flex-direction: column; gap: 0;
  margin-top: var(--s4);
}
.pipeline-step {
  display: grid; grid-template-columns: 36px 1fr; gap: var(--s4);
  position: relative;
  padding: 14px 0;
  align-items: start;
}
.pipeline-dot {
  width: 28px; height: 28px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--paper-2); border: 1px solid var(--rule-2);
  color: var(--ink-3); font-size: 13px;
  z-index: 2; position: relative;
}
.pipeline-step.done .pipeline-dot {
  background: var(--green); border-color: var(--green);
  color: white;
}
.pipeline-step.current .pipeline-dot {
  background: var(--ws); border-color: var(--ws);
  color: white; font-weight: 600;
  box-shadow: 0 0 0 4px var(--ws-soft);
}
.pipeline-content { padding-top: 4px; }
.pipeline-label {
  font-size: 14px; font-weight: 500; color: var(--ink);
}
.pipeline-step.pending .pipeline-label { color: var(--ink-3); }
.pipeline-step.current .pipeline-label { color: var(--ink); font-weight: 600; }
.pipeline-meta {
  font-size: 12px; color: var(--ink-3); margin-top: 2px;
}
.pipeline-line {
  position: absolute; left: 17px; top: 42px; bottom: -14px; width: 2px;
  background: var(--rule-2);
  z-index: 1;
}
.pipeline-line.done { background: var(--green); }

/* ─── KPI grid (Direzione) ─── */
.kpi-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s4);
  margin-top: var(--s4);
}
.kpi-card {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-md); padding: var(--s5);
  cursor: pointer; transition: all var(--t-fast);
  display: flex; flex-direction: column; gap: 4px;
}
.kpi-card:hover {
  background: var(--surface);
  border-color: var(--rule-2);
  transform: translateY(-1px);
  box-shadow: var(--sh-2);
}
.kpi-label {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.kpi-value {
  font-family: var(--ff-display); font-size: 28px; font-weight: 500;
  color: var(--ink); line-height: 1.1; margin: 6px 0 4px;
  letter-spacing: -0.01em;
}
.kpi-delta {
  font-size: 12px; font-family: var(--ff-mono); display: inline-flex; gap: 4px; align-items: center;
}

/* ─── Back Office batch progress bar ─── */
.bo-progress {
  width: 100%; height: 12px;
  background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: 999px; overflow: hidden;
  position: relative;
}
.bo-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--ws) 0%, color-mix(in srgb, var(--ws) 80%, var(--paper)) 100%);
  transition: width 400ms cubic-bezier(0.2, 0, 0, 1);
}

/* ─── Tree row active for parent (BO/Amm/Comp navigated views) ─── */
.tree-row.parent.active {
  background: var(--ws-soft); color: var(--ink); font-weight: 600;
  margin: 0 calc(-1 * var(--s4)); padding-left: calc(var(--s4) + var(--s4));
  padding-right: var(--s4); border-radius: 0;
  box-shadow: inset 3px 0 0 var(--ws);
}

/* ─── Mappa (Tecnica) ─── */
.map-area {
  position: relative; padding: 0;
  background: var(--paper);
  min-height: 520px;
}
.map-svg {
  width: 100%; height: 520px; display: block;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.map-pin text { pointer-events: none; }
.map-pin:hover circle:nth-child(2) { transform: scale(1.15); transform-origin: center; transform-box: fill-box; }
.map-legend {
  position: absolute; top: 24px; right: 24px;
  background: var(--surface); border: 1px solid var(--rule-2); border-radius: var(--r-md);
  padding: 14px 16px; box-shadow: var(--sh-2);
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--ink-2);
}
.map-legend-row { display: inline-flex; align-items: center; gap: 8px; }
.map-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ─── Report tables (RQSII / RQTI) ─── */
.report-table th { position: sticky; top: 0; z-index: 1; }
.report-table tr td:first-child { font-weight: 500; color: var(--ink); }

/* ─── Notification bell + drawer ─── */
.notif-bell {
  position: relative;
  background: transparent; border: 0;
  width: 32px; height: 32px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--ink-2); cursor: pointer;
  transition: background var(--t-fast);
}
.notif-bell:hover { background: var(--paper-3); color: var(--ink); }
.notif-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 16px; height: 16px; border-radius: 999px;
  background: var(--red); color: white;
  font-size: 10px; font-weight: 600;
  display: grid; place-items: center;
  padding: 0 4px;
  border: 1.5px solid var(--paper-2);
}

.notif-shade {
  position: fixed; top: 48px; right: 0; bottom: 0; left: 0;
  background: rgba(27,26,23,0.10);
  z-index: 1050;
}
.notif-drawer {
  position: fixed; top: 48px; right: 0; bottom: 0;
  width: 420px;
  background: var(--surface); border-left: 1px solid var(--rule-2);
  box-shadow: var(--sh-3);
  display: flex; flex-direction: column;
  z-index: 1060;
  animation: drawerIn 200ms cubic-bezier(0.2, 0, 0, 1);
}
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.notif-head {
  padding: 14px 18px; border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 10px;
}
.notif-body { flex: 1; overflow: auto; padding: 8px 0; }
.notif-item {
  display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; align-items: start;
  padding: 12px 18px; cursor: pointer;
  transition: background var(--t-fast);
  border-bottom: 1px solid var(--rule);
}
.notif-item:hover { background: var(--paper-2); }
.notif-icon {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--paper-2);
}
.notif-icon-amber  { background: var(--amber-soft); color: var(--amber-text); }
.notif-icon-red    { background: var(--red-soft);   color: var(--red-text); }
.notif-icon-green  { background: var(--green-soft); color: var(--green-text); }
.notif-icon-ink-2  { background: var(--paper-2);    color: var(--ink-2); }
.notif-title { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.notif-body-text { font-size: 12px; color: var(--ink-3); line-height: 1.4; }
.notif-ts { font-size: 11px; color: var(--ink-3); }
.notif-foot { padding: 10px 18px; border-top: 1px solid var(--rule); }

/* ─── Vista Regionale — Rete idrica Pavone ────────────────────────────────── */
.scheda-icon {
  width: 64px; height: 64px; border-radius: var(--r-md);
  display: grid; place-items: center;
}

.rete-stats {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 0; padding: 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-2);
}
.rete-stat {
  padding: 14px 18px;
  border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: 2px;
}
.rete-stat:last-child { border-right: none; }
.rete-stat-v { font-family: var(--ff-display); font-size: 19px; font-weight: 500; color: var(--ink); letter-spacing: -0.005em; }
.rete-stat-l { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }

.rete-layers { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px var(--s7) 0; }
.rete-chip {
  padding: 6px 12px; height: 28px; border: 1px solid var(--rule-2); border-radius: 999px;
  background: var(--paper); color: var(--ink-2);
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all var(--t-fast);
}
.rete-chip:hover { border-color: var(--ink-3); color: var(--ink); }
.rete-chip.active { background: var(--ws); border-color: var(--ws); color: white; }

.rete-frame { position: relative; padding: var(--s5) var(--s7) var(--s7); display: grid; grid-template-columns: 1fr; gap: var(--s5); }
.rete-frame.with-panel { grid-template-columns: 1fr 320px; }
.rete-canvas {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  overflow: hidden;
  min-height: 640px;
}
.rete-leaflet { width: 100%; height: 640px; border-radius: var(--r-md); }
.leaflet-container { font-family: var(--ff-body); background: #DEE5EC; }
.leaflet-control-attribution { font-size: 9px !important; }
.rete-tip {
  background: rgba(27, 26, 23, 0.92) !important; color: #FAF7F2 !important;
  border: none !important; border-radius: 4px !important;
  font-size: 11px !important; padding: 4px 8px !important; box-shadow: var(--sh-2) !important;
}
.rete-tip::before { display: none; }

/* Comune markers (divIcon) */
.rete-mark-wrap { background: transparent !important; border: none !important; }
.rete-mark { display: flex; align-items: center; gap: 6px; transform: translateY(-1px); transition: opacity var(--t-fast); }
.rete-mark.dimmed { opacity: 0.35; }
.rete-mark-dot {
  width: 10px; height: 10px; border-radius: 999px;
  background: #2563B5; box-shadow: 0 0 0 2px #FAF7F2, 0 0 0 3px rgba(0,0,0,0.18);
  flex-shrink: 0;
}
.rete-mark.sel .rete-mark-dot { width: 13px; height: 13px; box-shadow: 0 0 0 2px #FAF7F2, 0 0 0 4px var(--ws); }
.rete-mark.impact .rete-mark-dot { background: #B8770F !important; box-shadow: 0 0 0 2px #FAF7F2, 0 0 0 4px #B8770F; }
.rete-mark.sorgente .rete-mark-dot {
  width: 14px; height: 14px;
  background: linear-gradient(135deg, #2563B5, #1A4A7A);
  box-shadow: 0 0 0 2px #FAF7F2, 0 0 0 4px rgba(37, 99, 181, 0.4);
}
.rete-mark.pulse .rete-mark-dot {
  animation: retePulse 1.6s ease-in-out infinite;
  background: #B8392E;
  box-shadow: 0 0 0 2px #FAF7F2, 0 0 0 4px rgba(184, 57, 46, 0.4);
}
@keyframes retePulse {
  0%,100% { box-shadow: 0 0 0 2px #FAF7F2, 0 0 0 4px rgba(184, 57, 46, 0.4); }
  50% { box-shadow: 0 0 0 2px #FAF7F2, 0 0 0 10px rgba(184, 57, 46, 0); }
}
.rete-mark-label {
  font-family: var(--ff-display); font-size: 12px; font-weight: 500;
  color: var(--ink); background: rgba(250, 247, 242, 0.92);
  backdrop-filter: blur(4px);
  padding: 2px 7px; border-radius: 3px; line-height: 1.4;
  border: 1px solid rgba(0,0,0,0.06);
  white-space: nowrap;
}
.rete-mark-label small {
  display: block; font-family: var(--ff-mono); font-size: 9.5px;
  color: #2563B5; font-style: italic; font-weight: 500; margin-top: 1px;
}
.rete-mark.sel .rete-mark-label { font-weight: 600; border-color: var(--ws); }

/* Layer chips disabled state + planning mode tag */
.rete-chip:disabled { opacity: 0.4; cursor: not-allowed; }
.rete-mode-tag {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 6px; padding: 4px 10px;
  background: color-mix(in srgb, var(--amber) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  border-radius: 999px;
  font-size: 11px; font-weight: 600; color: #8A5808;
  text-transform: uppercase; letter-spacing: 0.04em;
}

.rete-legend {
  position: absolute; top: 12px; right: 12px;
  background: rgba(250, 247, 242, 0.96);
  backdrop-filter: blur(6px);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 11px;
  min-width: 170px;
  box-shadow: var(--sh-1);
}
.rete-legend-h {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); font-weight: 600; margin-bottom: 8px;
  border-bottom: 1px solid var(--rule); padding-bottom: 6px;
}
.rete-legend-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; color: var(--ink-2); }
.rete-legend-dot {
  width: 10px; height: 10px; border-radius: 999px; display: inline-block;
}
.rete-legend-dot.tier-low  { background: var(--green); }
.rete-legend-dot.tier-mid  { background: var(--amber); }
.rete-legend-dot.tier-high { background: var(--red); }
.rete-legend-pipe { width: 18px; height: 3px; border-radius: 2px; background: #3B82A6; display: inline-block; }
.rete-legend-pipe.trunk  { height: 5px; }
.rete-legend-pipe.branch { height: 3px; }
.rete-legend-pipe.local  { height: 1.5px; opacity: 0.55; }
.rete-legend-sep { height: 1px; background: var(--rule); margin: 8px 0; }

/* Side panel */
.rete-panel {
  position: relative;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: var(--paper);
  padding: 18px 20px 16px;
  height: fit-content;
  box-shadow: var(--sh-1);
}
.rete-panel-x {
  position: absolute; top: 10px; right: 10px;
  width: 26px; height: 26px; border: none; background: transparent;
  cursor: pointer; color: var(--ink-3);
  display: grid; place-items: center; border-radius: var(--r-sm);
}
.rete-panel-x:hover { background: var(--paper-2); color: var(--ink); }
.rete-panel-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.rete-panel-title { font-size: 18px; line-height: 1.2; color: var(--ink); }
.rete-panel-tag {
  display: inline-flex; padding: 2px 8px; border-radius: 999px;
  background: var(--ws-soft); color: var(--ws); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.rete-panel-route {
  display: flex; align-items: center; gap: 6px;
  margin: 6px 0 14px; padding: 6px 10px;
  background: var(--paper-2); border-radius: var(--r-sm);
  font-size: 12px; color: var(--ink-2);
}
.rete-panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-bottom: 14px; }
.rete-kv { display: flex; flex-direction: column; gap: 2px; }
.rete-kv dt { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); font-weight: 500; margin: 0; }
.rete-kv dd { margin: 0; font-size: 13px; color: var(--ink); font-weight: 500; }
.rete-event {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: 12px; margin-bottom: 8px;
}
.rete-event.attiva { background: var(--red-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--red) 18%, transparent); }
.rete-event.attenzione { background: color-mix(in srgb, var(--amber) 12%, transparent); color: var(--ink); border: 1px solid color-mix(in srgb, var(--amber) 28%, transparent); }
.rete-panel-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rule); }
.rete-panel-feed {
  display: flex; flex-direction: column; gap: 2px;
  margin: 4px 0 2px; padding: 8px 10px;
  background: color-mix(in srgb, var(--ws) 6%, var(--paper-2));
  border: 1px solid color-mix(in srgb, var(--ws) 22%, transparent);
  border-radius: var(--r-sm);
}
.rete-panel-feed-l { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); font-weight: 500; }
.rete-panel-feed-v { font-size: 12px; color: var(--ink); }

/* Impact analysis side panel */
.rete-panel-impact { padding: 16px 18px 14px; }
.rete-panel-impact .rete-panel-title { font-size: 17px; }
.rete-panel-tag.amber {
  background: color-mix(in srgb, var(--amber) 18%, transparent);
  color: #8A5808;
}
.impact-summary {
  background: var(--paper-2);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin: 6px 0 14px;
}
.impact-summary-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0; font-size: 12px; color: var(--ink-2);
  border-bottom: 1px dashed var(--rule);
}
.impact-summary-row:last-child { border-bottom: none; }
.impact-summary-row.total {
  font-weight: 600; color: var(--ink);
  margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--rule); border-bottom: none;
}
.impact-summary-l { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.impact-summary-row.total .impact-summary-l { color: var(--ink-2); font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.impact-summary-v { font-size: 13px; }
.impact-summary-row.total .impact-summary-v { font-size: 16px; }

.impact-section-h {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); margin: 14px 0 8px;
}
.impact-section-h.impact-warn { color: var(--red-text); }

.impact-comuni { list-style: none; margin: 0 0 4px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.impact-comuni li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0; font-size: 12px;
  border-bottom: 1px dashed var(--rule); color: var(--ink-2);
}
.impact-comuni li:last-child { border-bottom: none; }
.impact-comune-meta { color: var(--ink-3); font-size: 10px; }

.impact-vuln { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.impact-vuln-item {
  border-left: 2px solid var(--red);
  background: var(--red-soft);
  padding: 7px 10px; border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.impact-vuln-item.type-istruzione { border-left-color: #4A2D7C; background: color-mix(in srgb, #4A2D7C 8%, transparent); }
.impact-vuln-item.type-fragile    { border-left-color: var(--amber); background: color-mix(in srgb, var(--amber) 10%, transparent); }
.impact-vuln-item.type-commerciale { border-left-color: var(--ink-3); background: var(--paper-2); }
.impact-vuln-item.type-morosita   { border-left-color: var(--ink-3); background: var(--paper-2); }
.impact-vuln-name { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.impact-vuln-meta { font-size: 10.5px; color: var(--ink-3); margin-top: 1px; }
.impact-vuln-detail { font-size: 11px; color: var(--ink-2); margin-top: 3px; font-style: italic; }

.impact-comm { display: flex; flex-direction: column; gap: 5px; }
.impact-comm-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--ink-2);
  padding: 4px 0;
}
.impact-comm-row strong { color: var(--ink); font-weight: 600; }

.impact-schedule {
  margin-top: 14px; padding: 10px 12px;
  background: var(--ws-soft); border: 1px solid var(--ws-edge);
  border-radius: var(--r-sm);
}
.impact-schedule-l {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ws); font-weight: 600; margin-bottom: 3px;
}
.impact-schedule-v { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.impact-schedule-v .mono { font-size: 13px; font-weight: 500; color: var(--ink); }
.impact-schedule-est { font-size: 10px; color: var(--ink-3); font-style: italic; }

/* ─── Centralino · Topbar pill ─────────────────────────────────────────────── */
/* Topbar is light (--paper-2). Pills must read against a cream background. */
.centralino-pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px;
  border-radius: 6px;
  background: var(--paper);
  border: 1px solid var(--rule-2);
  color: var(--ink-2);
  font-size: 12px;
  min-width: 0; flex-shrink: 1;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.centralino-pill.contextual { min-width: 160px; }
.centralino-pill.clickable { cursor: pointer; }
.centralino-pill.clickable:hover { background: var(--paper-3); border-color: var(--rule-3); }
.centralino-led {
  width: 6px; height: 6px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}
.centralino-led.ok   { background: #5BCB80; box-shadow: 0 0 0 2px rgba(91, 203, 128, 0.18); }
.centralino-led.live { background: #5BCB80; animation: centBlink 1.4s ease-in-out infinite; }
.centralino-led.wrap { background: #B084E8; }
@keyframes centBlink {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 2px rgba(91, 203, 128, 0.2); }
  50%      { opacity: 0.6; box-shadow: 0 0 0 6px rgba(91, 203, 128, 0); }
}
.centralino-pill-meta { display: inline-flex; flex-direction: column; line-height: 1.15; }
.centralino-pill-l {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-3); font-weight: 600;
}
.centralino-pill-num { font-size: 11px; color: var(--ink-2); }
.centralino-caller-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.centralino-action-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--green-text); font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.centralino-target {
  font-size: 13px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 160px;
}
.centralino-caller-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
/* Contextual: high-contrast green-tinted pill — dark green text on green-soft */
.centralino-pill.contextual {
  background: var(--green-soft);
  border-color: var(--green-edge);
  color: var(--green-text);
}
.centralino-pill.contextual .centralino-target { color: var(--green-text); }
.centralino-pill.contextual:hover {
  background: color-mix(in srgb, var(--green-soft) 70%, var(--green));
  border-color: var(--green);
}
.centralino-pill.ringing {
  background: var(--amber-soft);
  border-color: var(--amber-edge);
  color: var(--amber-text);
  animation: centRingPulse 1.6s ease-in-out infinite;
}
.centralino-pill.ringing .centralino-pill-l { color: var(--amber-text); }
.centralino-pill.ringing .centralino-caller-name { color: var(--ink); }
@keyframes centRingPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(184, 119, 15, 0); }
  50%      { box-shadow: 0 0 0 8px rgba(184, 119, 15, 0.18); }
}
.centralino-ring-pulse {
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--amber);
  animation: centBlink 0.8s ease-in-out infinite;
  flex-shrink: 0;
}
.centralino-pill.in-call { background: var(--green-soft); border-color: var(--green-edge); color: var(--green-text); }
.centralino-pill.in-call .centralino-pill-l { color: var(--green-text); }
.centralino-pill.in-call .centralino-caller-name { color: var(--ink); }
.centralino-pill.on-hold { background: var(--amber-soft); border-color: var(--amber-edge); color: var(--amber-text); }
.centralino-pill.on-hold .centralino-pill-l { color: var(--amber-text); }
.centralino-pill.on-hold .centralino-caller-name { color: var(--ink); }
.centralino-pill.wrap    { background: #ECE2F4; border-color: #D4C4E2; color: #4A2D7C; }
.centralino-pill.wrap .centralino-pill-l { color: #4A2D7C; }
.centralino-pill.wrap .centralino-caller-name { color: var(--ink); }
.centralino-timer {
  font-size: 12px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums;
  padding: 2px 6px; background: rgba(27,26,23,0.06); border-radius: 4px;
}
.centralino-btn {
  height: 22px; padding: 0 10px;
  border: none; border-radius: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  transition: filter var(--t-fast);
}
.centralino-btn:hover { filter: brightness(1.08); }
.centralino-btn.accept { background: var(--green); color: white; }
.centralino-btn.reject { background: rgba(27,26,23,0.08); color: var(--ink-2); }
.centralino-btn.end    { background: var(--red); color: white; }
.centralino-btn.ghost  { background: rgba(27,26,23,0.06); color: var(--ink-2); padding: 0 6px; }

/* System tab (Centralino) — distinct from regular tabs */
.tabbar .tab.system {
  background: var(--ws-soft); border-bottom-color: var(--ws);
  color: var(--ws); font-weight: 600;
}
.tabbar .tab.system.active { background: var(--paper); color: var(--ws); }
.tabbar .tab.system:not(.active):hover { background: color-mix(in srgb, var(--ws-soft) 70%, var(--ws-edge)); }

/* ─── Centralino · Tab content ─────────────────────────────────────────────── */
.cent-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-2);
}
.cent-stat {
  padding: 14px 18px;
  border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: 2px;
}
.cent-stat:last-child { border-right: none; }
.cent-stat-v { font-family: var(--ff-display); font-size: 19px; font-weight: 500; color: var(--ink); letter-spacing: -0.005em; }
.cent-stat-l { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }

.cent-grid {
  display: grid; grid-template-columns: 1fr 1.6fr;
  gap: var(--s5);
  padding: var(--s5) var(--s7) var(--s7);
}
.cent-col { display: flex; flex-direction: column; gap: var(--s5); min-width: 0; }
.cent-section {
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: var(--paper);
  overflow: hidden;
}
.cent-section-h {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--paper-2);
  border-bottom: 1px solid var(--rule);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); font-weight: 600;
}
.cent-section-h > span:first-child { color: var(--ink-2); font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.cent-section-meta { color: var(--ink-3); }
.cent-empty { padding: 20px 16px; color: var(--ink-3); text-align: center; font-size: 12px; }

.cent-queue { list-style: none; margin: 0; padding: 0; }
.cent-queue-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--rule);
}
.cent-queue-item:last-child { border-bottom: none; }
.cent-queue-name { font-size: 14px; font-weight: 500; color: var(--ink); }
.cent-queue-meta { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.cent-queue-right { display: flex; align-items: center; gap: 10px; }
.cent-queue-wait {
  font-size: 12px; font-weight: 600; color: var(--amber-text);
  padding: 2px 6px; background: color-mix(in srgb, var(--amber) 12%, transparent);
  border-radius: 4px;
}
.cent-queue-item .centralino-btn.accept { background: var(--ws); color: white; }

.cent-dialer { padding: 16px; }
.cent-display {
  height: 44px; display: flex; align-items: center; justify-content: center;
  font-size: 22px; letter-spacing: 0.06em;
  color: var(--ink); background: var(--paper-2);
  border: 1px solid var(--rule); border-radius: var(--r-sm);
  margin-bottom: 12px;
}
.cent-numpad {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-bottom: 12px;
}
.cent-numkey {
  height: 42px;
  border: 1px solid var(--rule-2); border-radius: 6px;
  background: var(--paper); color: var(--ink);
  font-size: 16px; cursor: pointer;
  transition: all var(--t-fast);
}
.cent-numkey:hover { background: var(--paper-2); border-color: var(--ink-3); }
.cent-numkey:active { background: var(--ws-soft); }
.cent-dialer-actions { display: flex; gap: 8px; justify-content: flex-end; }

.cent-log td, .cent-log th { padding: 9px 14px; }
.cent-dir {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  padding: 2px 7px; border-radius: 999px;
}
.cent-dir.in  { background: color-mix(in srgb, #3A7A4A 12%, transparent); color: #3A7A4A; }
.cent-dir.out { background: color-mix(in srgb, #4A2D7C 12%, transparent); color: #4A2D7C; }
.cent-outcome {
  font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: var(--paper-2); color: var(--ink-2);
  font-weight: 500;
}
.cent-outcome.risolta       { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green-text); }
.cent-outcome.gestita       { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green-text); }
.cent-outcome.abbandonata   { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red-text); }
.cent-outcome.sollecito     { background: color-mix(in srgb, var(--amber) 14%, transparent); color: #8A5808; }
.cent-outcome.preavviso     { background: color-mix(in srgb, var(--amber) 18%, transparent); color: #8A5808; }
.cent-outcome\.piano-rientro { background: color-mix(in srgb, #4A2D7C 12%, transparent); color: #4A2D7C; }
.cent-outcome.piano-rientro { background: color-mix(in srgb, #4A2D7C 12%, transparent); color: #4A2D7C; }

/* ─── Postazione Sportello ─────────────────────────────────────────────────── */
.scheda.postazione { overflow: visible; }
.post-stats {
  display: grid; grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-2);
}
.post-stat {
  padding: 12px 18px; border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: 2px;
}
.post-stat:last-child { border-right: none; }
.post-stat-v { font-family: var(--ff-display); font-size: 18px; font-weight: 500; color: var(--ink); }
.post-stat-l { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }

/* Current call area — varies by state */
.post-call {
  padding: 22px var(--s7);
  border-bottom: 1px solid var(--rule);
  transition: background var(--t-fast);
}
.post-call.idle { background: var(--paper); }
.post-call.ringing {
  background: color-mix(in srgb, var(--amber) 8%, var(--paper));
  border-left: 3px solid var(--amber);
  animation: postRing 1.6s ease-in-out infinite;
}
@keyframes postRing {
  0%, 100% { box-shadow: inset 4px 0 0 0 var(--amber); }
  50% { box-shadow: inset 4px 0 0 0 #E8A132, 0 0 0 0 rgba(232,161,50,0); }
}
.post-call.in-call,
.post-call.on-hold {
  background: color-mix(in srgb, var(--green) 6%, var(--paper));
  border-left: 3px solid var(--green);
}
.post-call.on-hold { background: color-mix(in srgb, var(--amber) 6%, var(--paper)); border-left-color: var(--amber-text); }
.post-call.wrap-up {
  background: color-mix(in srgb, #4A2D7C 6%, var(--paper));
  border-left: 3px solid #4A2D7C;
}

.post-call-idle { display: flex; flex-direction: column; gap: 12px; }
.post-call-idle-status {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--ink-2); font-weight: 500;
}
.post-call-idle-hint { font-size: 13px; color: var(--ink-3); line-height: 1.5; }
.post-call-idle-hint strong { color: var(--ink); font-weight: 600; }
.post-call-idle-actions { display: flex; gap: 10px; margin-top: 4px; }

.post-call-ringing { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.post-call-ringing-l {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: #8A5808; font-weight: 600;
}
.post-call-ringing-actions { display: flex; gap: 10px; margin-top: 8px; }

.post-call-active-l {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); font-weight: 600; margin-bottom: 4px;
}
.post-call-caller { font-size: 28px; font-weight: 500; color: var(--ink); line-height: 1.1; letter-spacing: -0.01em; }
.post-call-meta { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.post-call-meta .muted { color: var(--ink-3); }
.post-call-addr { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.post-call-motivo {
  display: inline-flex; padding: 4px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--amber) 14%, transparent);
  color: #8A5808; font-size: 11.5px; font-weight: 500;
}

.post-call-active-grid {
  display: grid; grid-template-columns: 1fr auto;
  gap: var(--s5); align-items: start;
  padding-bottom: 16px; border-bottom: 1px solid var(--rule);
  margin-bottom: 16px;
}
.post-call-timer-block { text-align: right; }
.post-call-timer {
  font-size: 36px; font-family: var(--ff-mono); font-weight: 500;
  color: var(--green-text); letter-spacing: 0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.post-call.on-hold .post-call-timer { color: var(--amber-text); }
.post-call-timer-l { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin-top: 4px; }
.post-call-controls { display: flex; gap: 6px; margin-top: 12px; justify-content: flex-end; }
.post-call-controls .centralino-btn { background: var(--paper); color: var(--ink-2); border: 1px solid var(--rule-2); }
.post-call-controls .centralino-btn:hover { background: var(--paper-2); }
.post-call-controls .centralino-btn.end { background: #B8392E; color: white; border: none; }

.post-context-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: var(--s5); margin-top: 4px;
}
.post-context-h {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-3); font-weight: 600; margin-bottom: 8px;
}
.post-context-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.post-context-list li {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 10px; border-radius: var(--r-sm);
  font-size: 12px; color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
}
.post-context-list li.post-open-high { border-left: 2.5px solid var(--red); }
.post-context-list li.post-open-mid  { border-left: 2.5px solid var(--amber); }
.post-context-list li.post-open-low  { border-left: 2.5px solid var(--ink-3); }

.post-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.post-history li {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12px; color: var(--ink-2);
  padding: 4px 0; border-bottom: 1px dashed var(--rule);
}
.post-history li:last-child { border-bottom: none; }
.post-history-when { font-size: 11px; color: var(--ink-3); min-width: 36px; }

.post-suggested { display: flex; flex-direction: column; gap: 6px; }
.post-suggest-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--r-sm);
  background: var(--paper); border: 1px solid var(--rule-2);
  color: var(--ink); font-size: 12.5px; font-weight: 500;
  cursor: pointer; text-align: left;
  transition: all var(--t-fast);
}
.post-suggest-btn:hover { background: var(--paper-2); border-color: var(--ink-3); }
.post-suggest-btn.priority-high {
  border-left: 3px solid var(--red);
  background: color-mix(in srgb, var(--red) 6%, var(--paper));
}
.post-suggest-btn.priority-mid {
  border-left: 3px solid var(--amber);
  background: color-mix(in srgb, var(--amber) 6%, var(--paper));
}
.post-suggest-btn.priority-low {
  border-left: 3px solid var(--ink-3);
}

.post-actions-row {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--rule);
}

.post-call-wrap { display: flex; flex-direction: column; gap: 10px; }
.post-wrap-notes {
  width: 100%; min-height: 90px; resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--rule-2); border-radius: var(--r-sm);
  background: var(--paper); color: var(--ink);
  font-family: var(--ff-body); font-size: 13px; line-height: 1.5;
  margin-top: 6px;
}
.post-wrap-notes:focus { outline: none; border-color: var(--ws); box-shadow: 0 0 0 3px var(--ws-soft); }
.post-wrap-suggestions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.post-wrap-l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); font-weight: 600; }

/* Bottom grid: Coda + Storico */
.post-bottom-grid {
  display: grid; grid-template-columns: 1fr 1.4fr;
  gap: var(--s5); padding: var(--s5) var(--s7) var(--s7);
}
.post-section {
  border: 1px solid var(--rule); border-radius: var(--r-md);
  background: var(--paper); overflow: hidden;
}
.post-section-h {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--paper-2);
  border-bottom: 1px solid var(--rule);
  font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.post-section-h .mono { color: var(--ink-3); font-weight: 500; font-size: 11px; }
.post-empty { padding: 18px; color: var(--ink-3); text-align: center; font-size: 12px; }

.post-queue { list-style: none; margin: 0; padding: 0; }
.post-queue li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 14px; border-bottom: 1px solid var(--rule); font-size: 12.5px;
}
.post-queue li:last-child { border-bottom: none; }
.post-queue-name { font-weight: 500; color: var(--ink); }
.post-queue-meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.post-queue-wait {
  font-size: 11.5px; font-weight: 600; color: var(--amber-text);
  padding: 2px 7px; background: color-mix(in srgb, var(--amber) 12%, transparent); border-radius: 4px;
}

.post-log { list-style: none; margin: 0; padding: 0; }
.post-log li {
  display: grid; grid-template-columns: 50px auto 1fr 60px auto;
  align-items: center; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid var(--rule);
  font-size: 12px; color: var(--ink-2);
}
.post-log li:last-child { border-bottom: none; }
.post-log-when { color: var(--ink-3); font-size: 11px; }
.post-log-name { color: var(--ink); }
.post-log-dur  { color: var(--ink-2); text-align: right; }

/* ─── WhatsApp · Compose modal ─────────────────────────────────────────────── */
.wa-shade {
  position: fixed; inset: 0; z-index: 980;
  background: rgba(20, 18, 14, 0.42); backdrop-filter: blur(2px);
  animation: waShadeIn 0.18s ease-out;
}
@keyframes waShadeIn { from { opacity: 0; } to { opacity: 1; } }
.wa-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 460px; z-index: 990;
  background: var(--paper);
  box-shadow: -8px 0 32px rgba(20, 18, 14, 0.18);
  display: flex; flex-direction: column;
  padding: 22px 24px 20px;
  animation: waPanelIn 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes waPanelIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.wa-head {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px;
  align-items: center; margin-bottom: 18px;
  padding-bottom: 16px; border-bottom: 1px solid var(--rule);
}
.wa-head-icon {
  width: 36px; height: 36px; border-radius: 999px;
  background: #25D366; /* WhatsApp green */
  display: grid; place-items: center;
}
.wa-head-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); font-weight: 600; margin-bottom: 2px;
}
.wa-head-meta { font-size: 14px; color: var(--ink); }
.wa-head-meta .serif { font-weight: 500; }
.wa-head-meta .muted { color: var(--ink-3); }
.wa-head-meta .mono  { font-size: 12px; color: var(--ink-2); }

.wa-section-h {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); font-weight: 600; margin: 14px 0 8px;
}

.wa-templates { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.wa-template {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  background: var(--paper); border: 1px solid var(--rule-2);
  color: var(--ink-2); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all var(--t-fast);
}
.wa-template:hover { border-color: var(--ink-3); color: var(--ink); }
.wa-template.active {
  background: #25D366; border-color: #25D366; color: white;
}

.wa-preview {
  background: #ECE5DD; /* WhatsApp chat backdrop */
  background-image:
    radial-gradient(circle at 0 0, rgba(255,255,255,0.4) 0, transparent 80px),
    radial-gradient(circle at 100% 100%, rgba(0,0,0,0.04) 0, transparent 80px);
  border-radius: var(--r-md);
  padding: 14px;
  min-height: 160px;
}
.wa-bubble {
  background: #DCF8C6; /* outgoing bubble */
  border-radius: 8px 8px 2px 8px;
  padding: 10px 12px 6px;
  max-width: 320px; margin-left: auto;
  font-size: 13px; line-height: 1.5;
  color: #1B1A17;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.wa-bubble-meta {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 3px; margin-top: 4px;
  font-size: 10px; color: rgba(0,0,0,0.45);
}
.wa-bubble-meta .mono { color: rgba(0,0,0,0.45); }

.wa-custom {
  width: 100%; min-height: 130px; resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--rule-2); border-radius: var(--r-sm);
  background: #ECE5DD; color: #1B1A17;
  font-family: var(--ff-body); font-size: 13px; line-height: 1.5;
}
.wa-custom:focus { outline: none; border-color: #25D366; box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.18); }

.wa-meta-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 12px; padding: 8px 10px;
  background: var(--paper-2); border-radius: var(--r-sm);
  font-size: 11px; color: var(--ink-3);
}

.wa-actions {
  margin-top: auto; padding-top: 14px;
  display: flex; justify-content: space-between; gap: 8px;
  border-top: 1px solid var(--rule);
}
.wa-actions .btn-primary { background: #25D366; border-color: #1FA855; color: white; }
.wa-actions .btn-primary:hover { background: #1FBA59; }

/* ─── Comms feed ───────────────────────────────────────────────────────────── */
.comms-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px var(--s7) 12px;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap; gap: 12px;
}
.comms-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.comms-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--paper); border: 1px solid var(--rule-2);
  color: var(--ink-2); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all var(--t-fast);
}
.comms-chip:hover { border-color: var(--ink-3); color: var(--ink); }
.comms-chip.active { background: var(--ws); border-color: var(--ws); color: white; }
.comms-chip-count { font-size: 10.5px; opacity: 0.75; }
.comms-chip.active .comms-chip-count { opacity: 0.9; }
.comms-toolbar-actions { display: flex; gap: 8px; }

.comms-feed { padding: 0 var(--s7) var(--s6); }
.comms-date {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); font-weight: 600;
  margin: 18px 0 8px; padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--ff-mono);
}
.comms-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

.comms-item {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--paper); border: 1px solid var(--rule);
  cursor: pointer; transition: all var(--t-fast);
}
.comms-item:hover { background: var(--paper-2); border-color: var(--rule-2); }
.comms-item.open { background: var(--paper-2); border-color: var(--ink-3); }

.comms-icon {
  width: 30px; height: 30px; border-radius: 999px;
  display: grid; place-items: center;
  flex-shrink: 0;
  position: relative;
}
.comms-icon.dir-in::after,
.comms-icon.dir-out::after {
  content: ''; position: absolute; bottom: -1px; right: -1px;
  width: 10px; height: 10px; border-radius: 999px;
  border: 2px solid var(--paper);
}
.comms-icon.dir-in::after  { background: #3A7A4A; }
.comms-icon.dir-out::after { background: #4A2D7C; }
.comms-item.open .comms-icon::after { border-color: var(--paper-2); }

.comms-body { min-width: 0; }
.comms-row1 {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-bottom: 3px;
}
.comms-summary { font-size: 13px; font-weight: 500; color: var(--ink); }
.comms-row2 { font-size: 11.5px; color: var(--ink-3); }
.comms-row2 .muted { opacity: 0.6; }
.comms-dir { color: var(--ink-2); font-weight: 500; }

.comms-status {
  display: inline-flex; padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
}
.comms-status.status-consegnato { background: color-mix(in srgb, #3A7A4A 14%, transparent); color: #3A7A4A; }
.comms-status.status-risolta    { background: color-mix(in srgb, #3A7A4A 14%, transparent); color: #3A7A4A; }
.comms-status.status-archiviato { background: var(--paper-2); color: var(--ink-3); }
.comms-status.status-aperto     { background: color-mix(in srgb, var(--ws) 14%, transparent); color: var(--ws); }
.comms-status.status-no-risposta { background: color-mix(in srgb, var(--amber) 14%, transparent); color: #8A5808; }

.comms-detail {
  margin-top: 10px; padding: 10px 12px;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  font-size: 12.5px; color: var(--ink-2); line-height: 1.55;
}
.comms-detail-foot {
  display: flex; align-items: center; gap: 6px;
  margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--rule);
  font-size: 11px; color: var(--ink-3);
}
.comms-detail-foot .serif { color: var(--ink-2); font-weight: 500; }
.comms-detail-foot .muted { opacity: 0.6; }
.comms-action {
  background: transparent; border: none; cursor: pointer; padding: 0;
  color: var(--ws); font-size: 11px; font-weight: 500;
  text-decoration: underline; text-underline-offset: 2px;
}
.comms-action:hover { color: var(--ink); }

.comms-chev { color: var(--ink-3); transition: transform var(--t-fast); flex-shrink: 0; margin-top: 6px; }
.comms-chev.open { transform: rotate(90deg); }

/* Scheda tab count chip */
.scheda-tab-count {
  display: inline-flex; align-items: center;
  margin-left: 6px; padding: 1px 6px;
  background: var(--ws-soft); color: var(--ws);
  border-radius: 999px; font-size: 10px; font-weight: 600;
}
.scheda-tab.active .scheda-tab-count { background: var(--ws); color: white; }

/* ─── Maintenance Comms Preview Modal ──────────────────────────────────────── */
.mcp-shade {
  position: fixed; inset: 0; z-index: 990;
  background: rgba(20, 18, 14, 0.55); backdrop-filter: blur(3px);
  animation: mcpShadeIn 0.2s ease-out;
}
@keyframes mcpShadeIn { from { opacity: 0; } to { opacity: 1; } }
.mcp-panel {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(96vw, 980px); max-height: 92vh;
  z-index: 1000;
  background: var(--paper);
  border-radius: var(--r-lg);
  box-shadow: 0 28px 64px rgba(20, 18, 14, 0.32);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: mcpPanelIn 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes mcpPanelIn {
  from { opacity: 0; transform: translate(-50%, -48%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

.mcp-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.mcp-head .rete-panel-x { position: absolute; top: 16px; right: 16px; }
.mcp-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); font-weight: 600; margin-bottom: 4px;
}
.mcp-title { font-size: 22px; font-weight: 500; color: var(--ink); letter-spacing: -0.01em; }

.mcp-stripe {
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule);
}
.mcp-stripe-item {
  padding: 10px 18px;
  border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: 2px;
}
.mcp-stripe-item:last-child { border-right: none; }
.mcp-stripe-l { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); font-weight: 600; }
.mcp-stripe-v { font-size: 14px; color: var(--ink); font-weight: 500; }

.mcp-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 18px 28px;
  overflow: auto;
  flex: 1;
}
.mcp-col { display: flex; flex-direction: column; gap: 14px; }

.mcp-section {
  border: 1px solid var(--rule); border-radius: var(--r-md);
  background: var(--paper); overflow: hidden;
}
.mcp-section-h {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 10px 14px;
  background: var(--paper-2); border-bottom: 1px solid var(--rule);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-3); font-weight: 600;
}
.mcp-section-h > span:first-child {
  display: flex; align-items: center; gap: 6px;
  color: var(--ink-2); font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 600;
}
.mcp-section-meta { font-size: 11px; color: var(--ink-3); }

.mcp-sms-preview { padding: 14px; }
.mcp-sms-bubble {
  background: linear-gradient(180deg, #FAF7F2 0%, #F5F1E8 100%);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px; line-height: 1.55;
  color: var(--ink);
  position: relative;
}
.mcp-sms-bubble::before {
  content: ''; position: absolute; top: -1px; left: 16px;
  width: 12px; height: 12px;
  background: linear-gradient(180deg, #FAF7F2, #FAF7F2);
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
  transform: rotate(45deg) translate(-4px, -4px);
}
.mcp-sms-from { font-weight: 600; color: var(--ink); margin-bottom: 4px; font-size: 12px; }
.mcp-sms-from strong { color: var(--ink); }
.mcp-sms-body { color: var(--ink-2); font-size: 12.5px; }
.mcp-sms-body strong { color: var(--ink); font-weight: 600; }
.mcp-sms-meta {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed var(--rule);
  font-size: 10.5px; color: var(--ink-3);
  text-align: right;
}
.mcp-sms-note {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px;
  font-size: 11px; color: var(--ink-3);
}

.mcp-recipients { list-style: none; margin: 0; padding: 0; }
.mcp-recipients li {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 10px; align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
}
.mcp-recipients li:last-child { border-bottom: none; }
.mcp-rec-icon {
  width: 28px; height: 28px; border-radius: 999px;
  display: grid; place-items: center;
}
.mcp-rec-title { font-size: 12.5px; font-weight: 500; color: var(--ink); }
.mcp-rec-meta { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.mcp-rec-count {
  font-size: 13px; font-weight: 600; color: var(--ink);
  padding: 2px 9px; background: var(--paper-2); border-radius: 6px;
  border: 1px solid var(--rule);
}

.mcp-vuln-section .mcp-section-h { background: color-mix(in srgb, var(--red) 6%, var(--paper-2)); }
.mcp-vuln-list { list-style: none; margin: 0; padding: 0; }
.mcp-vuln-list li {
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
  border-left: 3px solid var(--red);
  background: color-mix(in srgb, var(--red) 4%, transparent);
}
.mcp-vuln-list li:last-child { border-bottom: none; }
.mcp-vuln-name { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.mcp-vuln-meta { font-size: 10.5px; color: var(--ink-3); margin-top: 1px; }
.mcp-vuln-detail { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; font-style: italic; }

.mcp-costs { width: 100%; border-collapse: collapse; }
.mcp-costs td {
  padding: 8px 14px; border-bottom: 1px dashed var(--rule);
  font-size: 12.5px; color: var(--ink-2);
}
.mcp-costs td.right { text-align: right; font-weight: 500; color: var(--ink); }
.mcp-costs tr.mcp-cost-total td {
  border-bottom: none; border-top: 1px solid var(--rule);
  padding-top: 10px; font-weight: 700; color: var(--ink); font-size: 14px;
}

.mcp-timeline { list-style: none; margin: 0; padding: 0; }
.mcp-timeline li {
  display: grid; grid-template-columns: 110px 1fr;
  gap: 12px; align-items: baseline;
  padding: 8px 14px;
  border-bottom: 1px dashed var(--rule);
  font-size: 12px; color: var(--ink-2);
  position: relative;
}
.mcp-timeline li:last-child { border-bottom: none; }
.mcp-timeline li::before {
  content: ''; position: absolute;
  left: 124px; top: 50%; width: 6px; height: 6px;
  background: var(--ws); border-radius: 999px;
  transform: translateY(-50%);
}
.mcp-timeline li:has(strong)::before { background: var(--green); width: 8px; height: 8px; left: 122px; }
.mcp-tl-when {
  font-size: 11px; color: var(--ink-3); font-weight: 500;
  padding-right: 14px;
}
.mcp-timeline li strong { color: var(--ink); font-weight: 600; }

.mcp-foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px; padding: 16px 28px;
  border-top: 1px solid var(--rule);
  background: var(--paper-2);
}
.mcp-foot-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--ink-3);
}
.mcp-foot-meta strong { color: var(--ink-2); font-weight: 600; }
.mcp-foot-actions { display: flex; gap: 8px; }

/* Confirmation banner — slides down after confirm */
.mcp-confirmed {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  z-index: 1100;
  background: var(--paper);
  border: 1px solid color-mix(in srgb, var(--green) 30%, transparent);
  border-left: 4px solid var(--green);
  border-radius: var(--r-md);
  box-shadow: 0 16px 40px rgba(20, 18, 14, 0.22);
  padding: 22px 28px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  min-width: 480px; max-width: 640px;
  animation: mcpConfirmIn 0.36s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes mcpConfirmIn {
  from { opacity: 0; transform: translate(-50%, -16px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.mcp-confirmed-title { font-size: 20px; font-weight: 500; color: var(--ink); }
.mcp-confirmed-body {
  font-size: 13px; color: var(--ink-2); text-align: center; line-height: 1.5;
}
.mcp-confirmed-foot { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* ─── Role-based login (Demo D · access-control pass) ─── */
.login-roles-card {
  width: 100%; max-width: 880px; text-align: center;
}
.login-roles-card .login-mark { font-family: var(--ff-display); font-size: 22px; font-weight: 500; color: var(--ink); }
.login-roles-card .login-rule { width: 64px; height: 1px; background: var(--rule-3); margin: 18px auto 32px; }
.login-roles-card .login-hero { font-family: var(--ff-display); font-size: var(--text-4xl); font-weight: 500; line-height: 1.05; color: var(--ink); letter-spacing: -0.015em; }
.login-roles-card .login-tag  { font-size: var(--text-lg); color: var(--ink-3); margin-top: 10px; font-style: italic; }

.role-grid {
  margin-top: 56px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}
@media (max-width: 1100px) { .role-grid { grid-template-columns: repeat(2, 1fr); } }

.role-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-md);
  padding: 20px 18px 16px;
  display: flex; flex-direction: column; gap: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  box-shadow: var(--sh-1);
  min-height: 200px;
}
.role-card:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
  box-shadow: var(--sh-2);
}
.role-card:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.role-card-top {
  display: flex; align-items: center; justify-content: space-between;
}
.role-avatar {
  width: 38px; height: 38px; border-radius: 999px;
  background: var(--paper-3); color: var(--ink);
  display: grid; place-items: center;
  font-family: var(--ff-display); font-weight: 600; font-size: 13px;
  border: 1px solid var(--rule-2);
}
.role-icon {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--ink-3);
  background: var(--paper-2);
  border: 1px solid var(--rule);
}
.role-card-body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.role-card-label {
  font-family: var(--ff-display); font-size: 18px; font-weight: 500;
  color: var(--ink); line-height: 1.15;
}
.role-card-sub {
  font-size: var(--text-base); color: var(--ink-3); line-height: 1.45;
}
.role-card-cta {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-sm); font-weight: 600; color: var(--ink);
  letter-spacing: 0.01em;
  padding-top: 8px; border-top: 1px solid var(--rule);
}
.role-card:hover .role-card-cta { color: var(--ink); }

/* Role chip in topbar */
.role-chip-wrap { position: relative; }
.role-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--paper); border: 1px solid var(--rule-2);
  height: 28px; padding: 0 8px 0 4px;
  border-radius: 999px;
  cursor: pointer; font-family: inherit;
  color: var(--ink-2);
  margin-left: 6px;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.role-chip:hover, .role-chip.open { background: var(--paper-3); border-color: var(--rule-3); }
.role-chip-avatar {
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--ink); color: white;
  display: grid; place-items: center;
  font-family: var(--ff-display); font-weight: 600; font-size: 10px;
}
.role-chip-label {
  font-size: var(--text-xs); font-weight: 600; color: var(--ink-2);
  letter-spacing: 0.02em;
}

/* Compact role trigger — replaces redundant chip+avatar+label combo */
.role-trigger {
  display: inline-flex; align-items: center; gap: 2px;
  background: transparent; border: 1px solid transparent;
  height: 28px; padding: 0 6px;
  border-radius: var(--r-sm);
  cursor: pointer; font-family: inherit;
  color: var(--ink-3);
  margin-left: 4px;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.role-trigger:hover, .role-trigger.open {
  background: var(--paper-3);
  border-color: var(--rule-2);
  color: var(--ink-2);
}
.role-trigger-caret { opacity: 0.6; }
.role-trigger:hover .role-trigger-caret, .role-trigger.open .role-trigger-caret { opacity: 0.9; }

.role-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  min-width: 240px;
  padding: 10px;
  z-index: 80;
}
.role-menu-h {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 4px 8px;
}
.role-menu-avatar {
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--ink); color: white;
  display: grid; place-items: center;
  font-family: var(--ff-display); font-weight: 600; font-size: 12px;
  flex-shrink: 0;
}
.role-menu-label { font-size: var(--text-md); font-weight: 500; color: var(--ink); line-height: 1.2; }
.role-menu-sub { font-size: var(--text-xs); color: var(--ink-3); line-height: 1.3; margin-top: 2px; }
.role-menu-sep { height: 1px; background: var(--rule); margin: 4px 0; }
.role-menu-item {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 0;
  padding: 8px 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--ink-2);
  font-size: var(--text-base);
  font-family: inherit;
  text-align: left;
}
.role-menu-item:hover { background: var(--paper-2); color: var(--ink); }

/* ─── Tab pinned (Ricerca Anagrafica) ──────────────────────────────────────── */
.tab.pinned {
  background: color-mix(in srgb, var(--ws-soft) 50%, var(--paper-2));
  border-left: 2px solid var(--ws-edge);
  border-right: 1px solid var(--rule);
  margin-right: var(--s2);
}
.tab.pinned.active {
  background: var(--surface);
  border-bottom-color: var(--ws);
}
.tab.pinned .tab-pin-icon {
  display: inline-flex; align-items: center; color: var(--ws);
}
.tab .x.disabled {
  color: var(--ink-4); cursor: not-allowed; opacity: 0.55;
}
.tab .x.disabled:hover { color: var(--ink-4); }

/* ─── Ricerca Anagrafica ──────────────────────────────────────────────────── */
/* Override scheda-wrap's tighter max-width — Ricerca needs more horizontal room. */
.scheda-wrap:has(> .ricerca) {
  max-width: none; padding: 0;
}
.ricerca {
  display: flex; flex-direction: column; gap: var(--s5);
  padding: var(--s6) var(--s7); max-width: 1500px; margin: 0 auto;
}
.ricerca-head {
  display: flex; align-items: flex-end; justify-content: space-between;
}
.ricerca-title-block { display: flex; flex-direction: column; gap: 4px; }
.ricerca-title {
  font-size: var(--text-2xl); font-weight: 500; color: var(--ink);
  letter-spacing: -0.01em;
}
.ricerca-sub { font-size: 13px; color: var(--ink-3); }

/* Layer A: instant-search bar */
.ricerca-instant {
  display: flex; align-items: center; gap: var(--s3);
  background: var(--surface); border: 1px solid var(--rule-2);
  border-radius: var(--r-md); padding: 0 var(--s4);
  height: 44px; box-shadow: var(--sh-1);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.ricerca-instant:focus-within {
  border-color: var(--ws-edge); box-shadow: 0 0 0 3px var(--ws-soft);
}
.ricerca-instant-icon { color: var(--ink-3); display: inline-flex; }
.ricerca-instant-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; font-family: inherit; color: var(--ink);
}
.ricerca-instant-input::placeholder { color: var(--ink-4); }
.ricerca-instant-kbd {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border: 1px solid var(--rule-2); border-radius: 4px; background: var(--paper-2);
  font-size: 11px; color: var(--ink-3);
}

/* Layer B: multi-field form */
.ricerca-form-card {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r-md); overflow: hidden;
}
.ricerca-form-card.collapsed { background: var(--paper-2); }
.ricerca-form-head {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--rule);
}
.ricerca-form-card.collapsed .ricerca-form-head { border-bottom: none; }
.ricerca-form-toggle {
  display: inline-flex; align-items: center; gap: var(--s3);
  background: transparent; border: none; cursor: pointer;
  color: var(--ink-3); font-family: inherit;
  padding: 4px 6px; border-radius: 4px;
}
.ricerca-form-toggle:hover { background: var(--paper-2); color: var(--ink); }
.ricerca-form-chev { display: inline-flex; transition: transform var(--t-fast); color: var(--ink-3); }
.ricerca-form-chev.open { transform: rotate(90deg); }
.ricerca-form-summary {
  margin-left: auto; font-size: 11px; color: var(--ink-3);
  padding: 2px 8px; background: var(--paper); border-radius: 4px;
  border: 1px solid var(--rule);
}
.ricerca-form-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--s4) var(--s5);
  padding: var(--s5) var(--s5) var(--s4);
}
.ricerca-field {
  display: flex; flex-direction: column; gap: 4px;
}
.ricerca-field-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3);
}
.ricerca-field input,
.ricerca-field select {
  border: 1px solid var(--rule-2); border-radius: var(--r-sm);
  background: var(--paper); padding: 0 10px; height: 32px;
  font-family: inherit; font-size: var(--text-base); color: var(--ink);
  outline: none; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.ricerca-field input.mono { font-family: var(--ff-mono); font-size: 12px; }
.ricerca-field input:focus,
.ricerca-field select:focus {
  border-color: var(--ws-edge); box-shadow: 0 0 0 3px var(--ws-soft);
  background: var(--surface);
}
.ricerca-form-actions {
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s5) var(--s4);
}
.ricerca-fkeys {
  display: flex; gap: var(--s5); flex-wrap: wrap;
  border-top: 1px solid var(--rule);
  padding: var(--s3) var(--s5);
  background: var(--paper-2);
  font-size: 11px; color: var(--ink-3);
}
.ricerca-fkeys span { display: inline-flex; align-items: center; gap: 6px; }
.ricerca-fkeys kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 18px; padding: 0 5px;
  border: 1px solid var(--rule-2); border-radius: 3px;
  background: var(--surface); font-family: var(--ff-mono); font-size: 10px;
  color: var(--ink-2); font-weight: 600;
  box-shadow: 0 1px 0 var(--rule-2);
}

/* Layer C: results table */
.ricerca-table-card {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r-md); overflow: hidden;
}
.ricerca-table-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s3) var(--s5);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-2);
}
.ricerca-table-title { font-size: var(--text-base); font-weight: 600; color: var(--ink); }
.ricerca-count {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
  margin-left: 6px; border-radius: 999px; background: var(--ws-soft); color: var(--ws);
  font-size: 11px; font-weight: 600;
}
.ricerca-table-actions { display: inline-flex; align-items: center; gap: var(--s3); position: relative; }
.ricerca-mini-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--rule-2);
  border-radius: var(--r-sm); padding: 4px 10px;
  font-family: inherit; font-size: 12px; color: var(--ink-2);
  cursor: pointer; transition: all var(--t-fast);
}
.ricerca-mini-btn:hover { background: var(--paper-2); color: var(--ink); border-color: var(--rule-3); }

.ricerca-cols-shade {
  position: fixed; inset: 0; z-index: 40; background: transparent;
}
.ricerca-cols-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 41;
  background: var(--surface); border: 1px solid var(--rule-2);
  border-radius: var(--r-md); box-shadow: var(--sh-3);
  min-width: 240px; padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.ricerca-cols-menu-h {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); padding: 6px 10px 4px;
}
.ricerca-cols-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 4px; cursor: pointer;
  font-size: var(--text-base); color: var(--ink-2);
}
.ricerca-cols-row:hover { background: var(--paper-2); }
.ricerca-cols-row input { accent-color: var(--ws); }
.ricerca-cols-foot {
  border-top: 1px solid var(--rule); margin-top: 4px; padding-top: 6px;
  display: flex; justify-content: flex-end;
}

.ricerca-table-wrap { overflow: auto; max-height: 56vh; }
.ricerca-table { font-size: var(--text-base); }
.ricerca-table thead { position: sticky; top: 0; z-index: 1; }
.ricerca-table thead th {
  background: var(--paper-2); border-bottom: 1px solid var(--rule-2);
  border-top: none;
}
.ricerca-table tbody tr.ricerca-row { cursor: pointer; }
.ricerca-table tbody tr.ricerca-row:hover td { background: var(--ws-soft); }
.ricerca-table tbody tr.ricerca-row .ricerca-quick { opacity: 0; transition: opacity var(--t-fast); }
.ricerca-table tbody tr.ricerca-row:hover .ricerca-quick { opacity: 1; }

.ricerca-quick { display: inline-flex; gap: 4px; }
.ricerca-quick-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  background: var(--surface); border: 1px solid var(--rule-2);
  border-radius: var(--r-sm); cursor: pointer;
  color: var(--ink-2); transition: all var(--t-fast);
}
.ricerca-quick-btn:hover {
  background: var(--ws); color: white; border-color: var(--ws);
}
.ricerca-quick-cell { white-space: nowrap; }

.ricerca-chip {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
  border-radius: 999px; font-size: 11px; font-weight: 500; letter-spacing: 0.01em;
}

.ricerca-empty {
  text-align: center; padding: var(--s7) !important; color: var(--ink-3);
  font-size: 13px;
}
.link-btn {
  background: transparent; border: none; padding: 0;
  color: var(--ws); cursor: pointer; font-family: inherit; font-size: inherit;
  text-decoration: underline; text-underline-offset: 3px;
}

.ricerca-table-foot {
  padding: var(--s3) var(--s5);
  border-top: 1px solid var(--rule);
  background: var(--paper-2);
  font-size: 11px; color: var(--ink-3);
}

@media (max-width: 1100px) {
  .ricerca-form-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Bonus sociale idrico screen ─────────────────────────────────────────── */

.bonus-kpi-row {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s4);
  margin: var(--s5) 0;
}
.bonus-kpi {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: var(--s4) var(--s5);
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--sh-1);
}
.bonus-kpi-icon {
  position: absolute; top: var(--s4); right: var(--s4); opacity: 0.55;
}
.bonus-kpi-label {
  font-size: 11px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-3);
}
.bonus-kpi-value {
  font-family: var(--ff-display); font-size: 26px; font-weight: 500;
  color: var(--ink); letter-spacing: -0.01em; line-height: 1.1;
  margin-top: 2px;
}
.bonus-kpi-delta {
  font-size: 11px; color: var(--ink-3);
}

.bonus-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s5); margin: var(--s4) 0 var(--s4);
  flex-wrap: wrap;
}
.bonus-chips {
  display: inline-flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
}
.bonus-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px;
  border: 1px solid var(--rule-2); background: var(--surface);
  border-radius: 999px; font-size: 12px; font-weight: 500;
  color: var(--ink-2); cursor: pointer; transition: all var(--t-fast);
  font-family: inherit;
}
.bonus-chip:hover { background: var(--paper-2); }
.bonus-chip.active {
  background: var(--ws); color: white; border-color: color-mix(in srgb, var(--ws) 80%, black);
}
.bonus-chip-count {
  font-size: 10px; opacity: 0.75;
  background: rgba(0,0,0,0.06); padding: 1px 6px; border-radius: 999px;
}
.bonus-chip.active .bonus-chip-count { background: rgba(255,255,255,0.22); opacity: 0.95; }
.bonus-actions { display: inline-flex; gap: var(--s2); }

.bonus-row-highlight td {
  background: var(--amber-soft) !important;
  transition: background 1.2s ease;
}

/* Stepper inside wizard modal */
.bonus-stepper {
  display: flex; align-items: center; gap: 0;
  padding: var(--s3) 0 var(--s4);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s4);
}
.bonus-step {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-3); font-weight: 500;
}
.bonus-step.current { color: var(--ws); }
.bonus-step.done    { color: var(--green-text); }
.bonus-step-dot {
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--paper-2); border: 1px solid var(--rule-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  color: var(--ink-3);
}
.bonus-step.current .bonus-step-dot {
  background: var(--ws); border-color: var(--ws); color: white;
}
.bonus-step.done .bonus-step-dot {
  background: var(--green-text); border-color: var(--green-text); color: white;
}
.bonus-step-label { white-space: nowrap; }
.bonus-step-line {
  flex: 1; height: 2px; background: var(--rule); margin: 0 12px; min-width: 32px;
}
.bonus-step-line.done { background: var(--green-text); }

.bonus-spinner {
  width: 12px; height: 12px; border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: white;
  display: inline-block; animation: bonus-spin 0.8s linear infinite;
}
@keyframes bonus-spin { to { transform: rotate(360deg); } }

/* Inline bonus link inside Anagrafica section */
.bonus-link {
  background: transparent; border: none; padding: 0; cursor: pointer;
  color: var(--ws); font-family: inherit; font-size: 12px; font-weight: 500;
  text-decoration: underline; text-underline-offset: 3px;
  margin-left: 6px;
}
.bonus-link:hover { filter: brightness(0.9); }
.bonus-verify-btn {
  background: transparent; border: 1px solid var(--rule-2);
  border-radius: var(--r-sm); padding: 2px 8px; height: 22px;
  font-size: 11px; color: var(--ink-2); font-family: inherit;
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  margin-left: 8px;
}
.bonus-verify-btn:hover { background: var(--paper-2); color: var(--ink); }

@media (max-width: 1300px) {
  .bonus-kpi-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
  .bonus-kpi-row { grid-template-columns: repeat(2, 1fr); }
}


