/* ==========================================================================
   PrismarGest — Design System
   Palette derivata dal monogramma: #01afff (blu) · #ff5101 (arancio)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Brand */
  --brand: #01afff;
  --brand-600: #0096dd;
  --brand-700: #0078b4;
  --brand-ink: #005f91;
  --brand-soft: #e6f6ff;
  --brand-soft-2: #cceeff;

  --flame: #ff5101;
  --flame-600: #e64700;
  --flame-700: #c23c00;
  --flame-ink: #a63400;
  --flame-soft: #fff0e9;
  --flame-soft-2: #ffdccc;

  /* Neutri */
  --ink: #0a1524;
  --ink-2: #16283d;
  --ink-3: #33475e;
  --muted: #647c95;
  --muted-2: #8ea1b5;

  --surface: #f1f5f9;
  --surface-2: #e7eef5;
  --surface-3: #dbe5ee;
  --panel: #ffffff;
  --panel-2: #fafcfe;

  --line: rgba(10, 21, 36, 0.08);
  --line-2: rgba(10, 21, 36, 0.14);
  --line-3: rgba(10, 21, 36, 0.22);

  /* Semantici */
  --ok: #0f9d58;
  --ok-ink: #0b7c45;
  --ok-soft: #e4f7ec;
  --warn: #b8760b;
  --warn-soft: #fdf2dd;
  --danger: #d92d20;
  --danger-ink: #b42318;
  --danger-soft: #fdeceb;
  --info: var(--brand-700);
  --info-soft: var(--brand-soft);

  /* Ombre */
  --sh-xs: 0 1px 2px rgba(10, 21, 36, 0.06);
  --sh-sm: 0 2px 8px rgba(10, 21, 36, 0.06), 0 1px 2px rgba(10, 21, 36, 0.04);
  --sh-md: 0 10px 28px rgba(10, 21, 36, 0.08), 0 2px 6px rgba(10, 21, 36, 0.04);
  --sh-lg: 0 24px 60px rgba(10, 21, 36, 0.14), 0 4px 12px rgba(10, 21, 36, 0.06);
  --sh-xl: 0 40px 90px rgba(10, 21, 36, 0.22);
  --sh-inset: inset 0 1px 2px rgba(10, 21, 36, 0.05);

  /* Ring di focus */
  --ring: 0 0 0 4px rgba(1, 175, 255, 0.18);
  --ring-danger: 0 0 0 4px rgba(217, 45, 32, 0.16);
  --ring-flame: 0 0 0 4px rgba(255, 81, 1, 0.18);

  /* Raggi */
  --r-xs: 8px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  /* Layout */
  --sidebar: 268px;
  --sidebar-collapsed: 76px;
  --topbar: 66px;

  /* Tipografia */
  --font: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 0.15s;
  --t: 0.24s;
  --t-slow: 0.42s;
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

img,
svg {
  max-width: 100%;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

p {
  margin: 0;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

::selection {
  background: var(--brand-soft-2);
  color: var(--brand-ink);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Scrollbar discreta */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border: 3px solid transparent;
  border-radius: var(--r-full);
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--muted-2);
  background-clip: content-box;
}

/* --------------------------------------------------------------------------
   3. Brand lockup
   -------------------------------------------------------------------------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-icon {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 11px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(1, 175, 255, 0.28), 0 2px 6px rgba(255, 81, 1, 0.18);
}

.brand-icon img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.brand-text b {
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.brand-text span {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.55;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   4. Autenticazione
   -------------------------------------------------------------------------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

.auth-visual {
  position: relative;
  overflow: hidden;
  padding: 44px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  background:
    radial-gradient(120% 90% at 8% 4%, rgba(1, 175, 255, 0.5), transparent 58%),
    radial-gradient(110% 90% at 96% 98%, rgba(255, 81, 1, 0.42), transparent 55%),
    linear-gradient(155deg, #071322 0%, #0b2036 52%, #071322 100%);
}

.auth-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(80% 70% at 40% 40%, #000 20%, transparent 78%);
}

.auth-visual > * {
  position: relative;
  z-index: 1;
}

.auth-glow {
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  z-index: 0;
  animation: float 14s var(--ease-in-out) infinite;
}

.auth-glow.a {
  background: var(--brand);
  top: -14%;
  left: -10%;
}

.auth-glow.b {
  background: var(--flame);
  bottom: -18%;
  right: -12%;
  animation-delay: -7s;
}

.auth-copy {
  max-width: 480px;
}

.auth-copy h1 {
  font-size: clamp(2.1rem, 3.6vw, 3.1rem);
  line-height: 1.04;
  letter-spacing: -0.04em;
  margin-bottom: 16px;
}

.auth-copy h1 em {
  font-style: normal;
  background: linear-gradient(96deg, var(--brand) 10%, var(--flame) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-copy p {
  color: rgba(255, 255, 255, 0.72);
  font-size: 1.04rem;
  line-height: 1.6;
}

.auth-points {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 26px;
}

.auth-points span {
  padding: 7px 13px;
  border-radius: var(--r-full);
  font-size: 0.8rem;
  font-weight: 550;
  color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
}

.auth-foot {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.45);
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 32px 24px;
  background: var(--panel);
}

.auth-card {
  width: min(100%, 404px);
  animation: rise var(--t-slow) var(--ease) both;
}

.auth-card h2 {
  font-size: 1.7rem;
  margin-bottom: 6px;
}

.auth-card .sub {
  color: var(--muted);
  margin-bottom: 26px;
}

.auth-hint {
  margin-top: 22px;
  padding: 13px 15px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px dashed var(--line-2);
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.6;
}

.auth-hint b {
  color: var(--ink-2);
}

/* --------------------------------------------------------------------------
   5. App shell
   -------------------------------------------------------------------------- */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  color: #dce7f2;
  background:
    radial-gradient(90% 40% at 0% 0%, rgba(1, 175, 255, 0.16), transparent 60%),
    radial-gradient(80% 40% at 100% 100%, rgba(255, 81, 1, 0.12), transparent 60%),
    linear-gradient(180deg, #08131f 0%, #0b1d2f 60%, #08131f 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar .brand {
  padding: 6px 8px 18px;
  color: #fff;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 -6px;
  padding: 0 6px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 10px;
}

.nav-label {
  padding: 14px 12px 8px;
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(220, 231, 242, 0.36);
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 0.92rem;
  font-weight: 500;
  color: rgba(220, 231, 242, 0.74);
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex: none;
  opacity: 0.72;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.055);
  color: #fff;
}

.nav-link:hover svg {
  opacity: 1;
  transform: translateX(1px);
}

.nav-link.active {
  color: #fff;
  background: linear-gradient(96deg, rgba(1, 175, 255, 0.24), rgba(1, 175, 255, 0.06));
  box-shadow: inset 0 0 0 1px rgba(1, 175, 255, 0.24);
}

.nav-link.active svg {
  opacity: 1;
  color: var(--brand);
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--brand), var(--flame));
}

.nav-link .nav-count {
  margin-left: auto;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: var(--r-full);
  text-align: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
}

.nav-link.has-alert .nav-count {
  background: var(--flame);
  color: #fff;
}

.nav-link.is-soon {
  color: rgba(220, 231, 242, 0.3);
  cursor: not-allowed;
}

.nav-link.is-soon:hover {
  background: transparent;
  color: rgba(220, 231, 242, 0.34);
}

.nav-link.is-soon::after {
  content: "presto";
  margin-left: auto;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--r-full);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-foot {
  margin-top: 10px;
  padding: 11px;
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(140deg, var(--brand), var(--brand-700));
}

.avatar.flame {
  background: linear-gradient(140deg, var(--flame), var(--flame-700));
}

.sidebar-foot .who {
  min-width: 0;
  flex: 1;
}

.sidebar-foot .who b {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-foot .who span {
  font-size: 0.75rem;
  color: rgba(220, 231, 242, 0.5);
}

.icon-btn-ghost {
  width: 32px;
  height: 32px;
  flex: none;
  border: 0;
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(220, 231, 242, 0.7);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}

.icon-btn-ghost:hover {
  background: rgba(217, 45, 32, 0.2);
  color: #fff;
}

.icon-btn-ghost svg {
  width: 16px;
  height: 16px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  font-weight: 650;
  font-size: 1.06rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  color: var(--muted);
}

.crumb svg {
  width: 13px;
  height: 13px;
  opacity: 0.5;
}

.topbar-spacer {
  flex: 1;
}

.menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--panel);
  cursor: pointer;
  place-items: center;
}

.menu-toggle svg {
  width: 18px;
  height: 18px;
}

/* Trigger palette comandi */
.cmd-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 12px;
  min-width: 232px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

.cmd-trigger:hover {
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.cmd-trigger svg {
  width: 16px;
  height: 16px;
  opacity: 0.6;
}

.kbd {
  margin-left: auto;
  display: inline-flex;
  gap: 2px;
  font-family: var(--mono);
  font-size: 0.68rem;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.content {
  flex: 1;
  min-width: 0;
  padding: 26px 24px 64px;
  max-width: 1560px;
  width: 100%;
}

/* --------------------------------------------------------------------------
   6. Intestazioni di pagina
   -------------------------------------------------------------------------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-head h1 {
  font-size: 1.62rem;
  margin-bottom: 5px;
}

.page-head p {
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 68ch;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 30px 0 14px;
}

.section-head h2 {
  font-size: 1.12rem;
  display: flex;
  align-items: center;
  gap: 9px;
}

.section-head h2 svg {
  width: 17px;
  height: 17px;
  color: var(--brand-700);
}

.section-head p {
  font-size: 0.85rem;
  color: var(--muted);
}

.eyebrow {
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-700);
  margin-bottom: 7px;
}

/* --------------------------------------------------------------------------
   7. Pannelli
   -------------------------------------------------------------------------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}

.panel + .panel {
  margin-top: 16px;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.panel-head h3 {
  font-size: 1.02rem;
  display: flex;
  align-items: center;
  gap: 9px;
}

.panel-head h2 svg,
.panel-head h3 svg {
  width: 17px;
  height: 17px;
  color: var(--brand-700);
}

.panel-head .sub {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 3px;
}

.panel-body {
  padding: 20px;
}

.panel-body.tight {
  padding: 14px 16px;
}

.panel-foot {
  padding: 15px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.panel-foot .left {
  margin-right: auto;
  font-size: 0.84rem;
  color: var(--muted);
}

.panel.accent {
  border-color: var(--brand-soft-2);
  box-shadow: var(--sh-sm), inset 0 2px 0 var(--brand);
}

.panel.flame {
  border-color: var(--flame-soft-2);
  box-shadow: var(--sh-sm), inset 0 2px 0 var(--flame);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.split.even {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.split.wide-right {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr);
}

.stack {
  display: grid;
  gap: 16px;
}

/* --------------------------------------------------------------------------
   8. KPI / statistiche
   -------------------------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(212px, 1fr));
  gap: 14px;
}

.kpi {
  position: relative;
  overflow: hidden;
  padding: 17px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-sm);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}

.kpi::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-700));
  opacity: 0.9;
}

.kpi.flame::after {
  background: linear-gradient(90deg, var(--flame), var(--flame-700));
}

.kpi.ok::after {
  background: linear-gradient(90deg, #3ec87d, var(--ok));
}

.kpi.danger::after {
  background: linear-gradient(90deg, #f0685c, var(--danger));
}

.kpi.muted::after {
  background: var(--surface-3);
}

.kpi .k-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 11px;
}

.kpi .k-label {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi .k-icon {
  width: 28px;
  height: 28px;
  margin-left: auto;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-700);
}

.kpi .k-icon svg {
  width: 15px;
  height: 15px;
}

.kpi.flame .k-icon {
  background: var(--flame-soft);
  color: var(--flame-ink);
}

.kpi.ok .k-icon {
  background: var(--ok-soft);
  color: var(--ok-ink);
}

.kpi.danger .k-icon {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

.kpi .k-value {
  font-size: 1.72rem;
  font-weight: 680;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.kpi .k-value small {
  font-size: 0.92rem;
  font-weight: 550;
  color: var(--muted);
  letter-spacing: 0;
}

.kpi .k-meta {
  margin-top: 7px;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  font-size: 0.8rem;
}

.trend.up {
  color: var(--ok-ink);
}

.trend.down {
  color: var(--danger-ink);
}

.trend svg {
  width: 13px;
  height: 13px;
}

/* --------------------------------------------------------------------------
   9. FORM — base
   -------------------------------------------------------------------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 16px;
}

.form-grid.g1 { grid-template-columns: minmax(0, 1fr); }
.form-grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.form-grid .full { grid-column: 1 / -1; }
.form-grid .span2 { grid-column: span 2; }

.fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 8px;
}

.fieldset > legend {
  padding: 0 0 14px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand-700);
  display: flex;
  align-items: center;
  gap: 8px;
}

.fieldset > legend svg {
  width: 15px;
  height: 15px;
}

.fieldset + .fieldset {
  margin-top: 10px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

/* Il campo */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  min-width: 0;
}

.field > label,
.field .lbl {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.845rem;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: -0.005em;
}

.field > label .req {
  color: var(--flame);
  font-weight: 700;
}

.field > label .opt {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field .hint {
  font-size: 0.79rem;
  color: var(--muted);
  line-height: 1.45;
}

.field .hint svg {
  width: 13px;
  height: 13px;
  vertical-align: -2px;
  margin-right: 3px;
  opacity: 0.7;
}

/* Il contenitore del controllo: gestisce bordo, focus, affissi */
.control {
  position: relative;
  display: flex;
  align-items: stretch;
  background: var(--panel);
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-inset);
  transition:
    border-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease),
    background var(--t) var(--ease);
}

.control:hover {
  border-color: var(--line-3);
}

.control:focus-within {
  border-color: var(--brand);
  box-shadow: var(--ring);
  background: #fff;
}

.control:focus-within .affix {
  color: var(--brand-700);
}

/* L'input vero e proprio */
.control > input,
.control > select,
.control > textarea {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 11px 13px;
  border: 0;
  background: transparent;
  border-radius: inherit;
  outline: none;
  font-size: 0.94rem;
}

.control > input::placeholder,
.control > textarea::placeholder {
  color: var(--muted-2);
}

.control > textarea {
  resize: vertical;
  min-height: 92px;
  line-height: 1.55;
}

.control > textarea.autogrow {
  resize: none;
  overflow: hidden;
}

/* Affissi (prefisso/suffisso: €, %, mq, icone) */
.affix {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  flex: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  transition: color var(--t) var(--ease);
  white-space: nowrap;
}

.affix svg {
  width: 16px;
  height: 16px;
  opacity: 0.8;
}

.affix.pre {
  border-right: 1px solid var(--line);
  border-radius: calc(var(--r-sm) - 2px) 0 0 calc(var(--r-sm) - 2px);
}

.affix.post {
  border-left: 1px solid var(--line);
  border-radius: 0 calc(var(--r-sm) - 2px) calc(var(--r-sm) - 2px) 0;
}

.affix.plain {
  background: transparent;
  border: 0;
}

.affix.mono {
  font-family: var(--mono);
  font-size: 0.84rem;
}

/* Icona interna (ricerca) */
.control.with-icon > input {
  padding-left: 40px;
}

.control .in-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--muted-2);
  pointer-events: none;
  transition: color var(--t) var(--ease);
}

.control:focus-within .in-icon {
  color: var(--brand);
}

/* Pulsante "svuota" */
.control .clear {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%) scale(0.7);
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease-spring), background var(--t) var(--ease);
}

.control.is-filled .clear {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.control .clear:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.control .clear svg {
  width: 12px;
  height: 12px;
}

/* Dimensioni */
.control.sm > input,
.control.sm > select {
  padding: 7px 10px;
  font-size: 0.86rem;
}

.control.sm .affix {
  padding: 0 9px;
  font-size: 0.8rem;
}

.control.lg > input,
.control.lg > select {
  padding: 14px 16px;
  font-size: 1.02rem;
}

/* Stati */
.control.is-error {
  border-color: var(--danger);
  background: #fffbfb;
}

.control.is-error:focus-within {
  box-shadow: var(--ring-danger);
}

.control.is-success {
  border-color: var(--ok);
}

.control.is-disabled,
.control > input:disabled,
.control > select:disabled,
.control > textarea:disabled {
  background: var(--surface);
  color: var(--muted);
  cursor: not-allowed;
}

.control.is-readonly {
  background: var(--surface);
  border-style: dashed;
  box-shadow: none;
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 550;
  color: var(--danger-ink);
  animation: shake 0.34s var(--ease-in-out);
}

.field-error svg {
  width: 14px;
  height: 14px;
  flex: none;
  margin-top: 1px;
}

.field-ok {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--ok-ink);
}

/* Select custom */
.control.select-wrap {
  position: relative;
}

.control > select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  cursor: pointer;
}

.control.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
  transition: border-color var(--t) var(--ease);
}

.control.select-wrap:focus-within::after {
  border-color: var(--brand);
}

/* Numeri: allineamento tabellare */
.control > input.num,
.control > input[type="number"] {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.control > input[type="number"] {
  -moz-appearance: textfield;
}

.control > input[type="number"]::-webkit-outer-spin-button,
.control > input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Contatore caratteri */
.counter {
  align-self: flex-end;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted-2);
}

.counter.warn {
  color: var(--warn);
}

.counter.over {
  color: var(--danger);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   10. FORM — input avanzate
   -------------------------------------------------------------------------- */

/* 10a. Stepper numerico */
.stepper {
  display: flex;
  align-items: stretch;
}

.stepper button {
  width: 38px;
  flex: none;
  border: 0;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}

.stepper button:first-child {
  border-right: 1px solid var(--line);
  border-radius: calc(var(--r-sm) - 2px) 0 0 calc(var(--r-sm) - 2px);
}

.stepper button:last-child {
  border-left: 1px solid var(--line);
  border-radius: 0 calc(var(--r-sm) - 2px) calc(var(--r-sm) - 2px) 0;
}

.stepper button:hover {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.stepper button:active {
  background: var(--brand-soft-2);
}

.stepper button svg {
  width: 14px;
  height: 14px;
}

.stepper input {
  text-align: center !important;
}

/* 10b. Toggle switch */
.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--panel);
  cursor: pointer;
  transition: border-color var(--t) var(--ease), background var(--t) var(--ease);
  user-select: none;
}

.switch:hover {
  border-color: var(--line-3);
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch .track {
  position: relative;
  width: 42px;
  height: 24px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--surface-3);
  transition: background var(--t) var(--ease);
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--sh-xs);
  transition: transform var(--t) var(--ease-spring);
}

.switch input:checked ~ .track {
  background: linear-gradient(96deg, var(--brand), var(--brand-600));
}

.switch input:checked ~ .track::after {
  transform: translateX(18px);
}

.switch input:focus-visible ~ .track {
  box-shadow: var(--ring);
}

.switch .txt {
  min-width: 0;
}

.switch .txt b {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

.switch .txt span {
  font-size: 0.78rem;
  color: var(--muted);
}

.switch:has(input:checked) {
  border-color: var(--brand-soft-2);
  background: linear-gradient(96deg, var(--brand-soft) 0%, var(--panel) 60%);
}

/* 10c. Checkbox / radio */
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  min-width: 0;
  user-select: none;
}

.check input[type="checkbox"],
.check input[type="radio"] {
  width: 19px;
  height: 19px;
  min-width: 19px;
  margin: 0;
  flex: none;
  accent-color: var(--brand);
  cursor: pointer;
}

.check.boxed {
  padding: 11px 13px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--panel);
  transition: border-color var(--t) var(--ease), background var(--t) var(--ease);
}

.check.boxed:hover {
  border-color: var(--line-3);
}

.check.boxed:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}

/* Permessi personalizzati (utenti) */
.ability-groups {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ability-group-title {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.ability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}

.ability-check {
  align-items: flex-start;
}

.ability-check > span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ability-check > span b {
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.25;
}

.ability-check.is-extra {
  border-color: var(--warn, #c9852a);
  background: color-mix(in srgb, var(--warn, #c9852a) 10%, var(--panel));
}

.ability-check.is-revoked {
  border-style: dashed;
  opacity: 0.85;
}

/* Radio "card" selezionabili */
.radio-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 10px;
}

.radio-card {
  position: relative;
  display: flex;
  gap: 11px;
  padding: 13px 14px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r);
  background: var(--panel);
  cursor: pointer;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), transform var(--t) var(--ease);
}

.radio-card:hover {
  border-color: var(--brand-soft-2);
  transform: translateY(-1px);
}

.radio-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-card .rc-icon {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--muted);
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}

.radio-card .rc-icon svg {
  width: 17px;
  height: 17px;
}

.radio-card .rc-body {
  min-width: 0;
}

.radio-card b {
  display: block;
  font-size: 0.9rem;
  font-weight: 620;
}

.radio-card span {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.radio-card:has(input:checked) {
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.radio-card:has(input:checked) .rc-icon {
  background: var(--brand);
  color: #fff;
}

.radio-card:has(input:checked)::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}

.radio-card:has(input:focus-visible) {
  box-shadow: var(--ring);
}

/* 10d. Segmented control */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  overflow-x: auto;
  max-width: 100%;
}

.segmented label {
  position: relative;
  flex: 1;
  min-width: max-content;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: calc(var(--r-sm) - 3px);
  font-size: 0.85rem;
  font-weight: 570;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--t) var(--ease), background var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

.segmented span svg {
  width: 15px;
  height: 15px;
}

.segmented label:hover span {
  color: var(--ink-2);
}

.segmented input:checked ~ span {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--sh-xs);
  font-weight: 620;
}

.segmented input:focus-visible ~ span {
  box-shadow: var(--ring);
}

.segmented.brand input:checked ~ span {
  background: linear-gradient(96deg, var(--brand), var(--brand-600));
  color: #fff;
}

.segmented.full {
  display: flex;
  width: 100%;
}

/* 10e. Combobox (select con ricerca) */
.combo {
  position: relative;
}

.combo-input {
  cursor: pointer;
}

.combo-toggle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 38px;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.combo-toggle svg {
  width: 15px;
  height: 15px;
  transition: transform var(--t) var(--ease);
}

.combo.is-open .combo-toggle svg {
  transform: rotate(180deg);
  color: var(--brand);
}

.combo-panel {
  position: absolute;
  z-index: 60;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  max-height: 296px;
  display: none;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  box-shadow: var(--sh-lg);
  overflow: hidden;
}

.combo.is-open .combo-panel {
  display: flex;
  animation: pop var(--t) var(--ease) both;
}

.combo.drop-up .combo-panel {
  top: auto;
  bottom: calc(100% + 6px);
}

.combo-search {
  padding: 9px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.combo-search input {
  width: 100%;
  padding: 8px 11px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-xs);
  outline: none;
  font-size: 0.88rem;
  background: #fff;
}

.combo-search input:focus {
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.combo-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  margin: 0;
  list-style: none;
}

.combo-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--r-xs);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background var(--t-fast) var(--ease);
}

.combo-opt .co-body {
  min-width: 0;
  flex: 1;
}

.combo-opt b {
  display: block;
  font-weight: 570;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combo-opt small {
  display: block;
  font-size: 0.77rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combo-opt mark {
  background: var(--brand-soft-2);
  color: var(--brand-ink);
  border-radius: 3px;
  padding: 0 1px;
}

.combo-opt.is-active {
  background: var(--brand-soft);
}

.combo-opt.is-selected {
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 600;
}

.combo-opt.is-selected::after {
  content: "";
  width: 14px;
  height: 8px;
  flex: none;
  border-left: 2px solid var(--brand);
  border-bottom: 2px solid var(--brand);
  transform: rotate(-45deg) translateY(-2px);
}

.combo-empty {
  padding: 22px 14px;
  text-align: center;
  font-size: 0.86rem;
  color: var(--muted);
}

.combo-foot {
  padding: 8px 9px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}

.combo-foot .btn {
  width: 100%;
}

/* 10f. Percentuale con slider */
.pct-field .pct-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pct-field .control {
  width: 118px;
  flex: none;
}

.pct-bar {
  position: relative;
  flex: 1;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  overflow: hidden;
}

.pct-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand), var(--brand-600));
  transition: width var(--t) var(--ease), background var(--t) var(--ease);
}

.pct-field input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

.pct-field input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand) var(--pct, 0%), var(--surface-2) var(--pct, 0%));
}

.pct-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  margin-top: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand);
  box-shadow: var(--sh-sm);
  transition: transform var(--t) var(--ease-spring);
}

.pct-field input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.14);
}

.pct-field input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(0.94);
}

.pct-field input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: var(--r-full);
  background: var(--surface-2);
}

.pct-field input[type="range"]::-moz-range-progress {
  height: 8px;
  border-radius: var(--r-full);
  background: var(--brand);
}

.pct-field input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand);
}

.pct-marks {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.pct-marks button {
  padding: 4px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-full);
  background: var(--panel);
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--t) var(--ease);
}

.pct-marks button:hover {
  border-color: var(--brand);
  color: var(--brand-ink);
  background: var(--brand-soft);
}

/* 10g. Tags input */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  align-items: center;
}

.tags .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border-radius: var(--r-full);
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 0.82rem;
  font-weight: 550;
  animation: pop var(--t) var(--ease-spring) both;
}

.tags .tag button {
  width: 17px;
  height: 17px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 95, 145, 0.14);
  color: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--t) var(--ease);
}

.tags .tag button:hover {
  background: var(--danger);
  color: #fff;
}

.tags .tag button svg {
  width: 9px;
  height: 9px;
}

.tags > input {
  flex: 1;
  min-width: 96px;
  border: 0;
  outline: none;
  padding: 4px 2px;
  background: transparent;
  font-size: 0.9rem;
}

/* 10h. Dropzone file */
.dropzone {
  position: relative;
  padding: 30px 20px;
  border: 2px dashed var(--line-3);
  border-radius: var(--r);
  background: var(--panel-2);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t) var(--ease), background var(--t) var(--ease), transform var(--t) var(--ease);
}

.dropzone:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.dropzone.is-over {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: scale(1.01);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone .dz-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-700);
}

.dropzone .dz-icon svg {
  width: 22px;
  height: 22px;
}

.dropzone b {
  display: block;
  font-size: 0.94rem;
  margin-bottom: 4px;
}

.dropzone span {
  font-size: 0.82rem;
  color: var(--muted);
}

.dz-file {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 10px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel);
}

.dz-file .fi {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--flame-soft);
  color: var(--flame-ink);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
}

.dz-file .fn {
  min-width: 0;
  flex: 1;
}

.dz-file .fn b {
  display: block;
  font-size: 0.87rem;
  font-weight: 570;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dz-file .fn span {
  font-size: 0.76rem;
  color: var(--muted);
}

/* 10i. Barra azioni appiccicosa per form lunghe */
.form-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  margin: 20px -20px -20px;
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.form-bar .left {
  margin-right: auto;
  font-size: 0.84rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.dirty-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--flame);
  animation: pulse 2s var(--ease-in-out) infinite;
}

/* Toolbar filtri */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
}

.toolbar .search {
  flex: 1;
  min-width: 218px;
}

.toolbar .grow {
  flex: 1;
}

/* --------------------------------------------------------------------------
   11. Bottoni
   -------------------------------------------------------------------------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1.5px solid transparent;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-weight: 620;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition:
    transform var(--t-fast) var(--ease),
    background var(--t) var(--ease),
    box-shadow var(--t) var(--ease),
    border-color var(--t) var(--ease),
    color var(--t) var(--ease);
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(178deg, #ff6a26, var(--flame) 55%, var(--flame-600));
  color: #fff;
  box-shadow: 0 6px 18px rgba(255, 81, 1, 0.28);
}

.btn-primary:hover {
  background: linear-gradient(178deg, var(--flame), var(--flame-700));
  box-shadow: 0 8px 24px rgba(255, 81, 1, 0.34);
}

.btn-brand {
  background: linear-gradient(178deg, #2bbcff, var(--brand) 55%, var(--brand-600));
  color: #fff;
  box-shadow: 0 6px 18px rgba(1, 175, 255, 0.28);
}

.btn-brand:hover {
  background: linear-gradient(178deg, var(--brand), var(--brand-700));
  box-shadow: 0 8px 24px rgba(1, 175, 255, 0.32);
}

.btn-dark {
  background: linear-gradient(178deg, var(--ink-2), var(--ink));
  color: #fff;
  box-shadow: var(--sh-sm);
}

.btn-dark:hover {
  background: var(--ink);
}

.btn-secondary {
  background: var(--panel);
  color: var(--ink-2);
  border-color: var(--line-2);
  box-shadow: var(--sh-xs);
}

.btn-secondary:hover {
  border-color: var(--line-3);
  background: var(--panel-2);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: rgba(10, 21, 36, 0.05);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger-ink);
  border-color: rgba(217, 45, 32, 0.2);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-ok {
  background: var(--ok-soft);
  color: var(--ok-ink);
  border-color: rgba(15, 157, 88, 0.2);
}

.btn-ok:hover {
  background: var(--ok);
  color: #fff;
  border-color: var(--ok);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.83rem;
  border-radius: var(--r-xs);
  gap: 6px;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-lg {
  padding: 13px 22px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 0;
  width: 36px;
  height: 36px;
  flex: none;
}

.btn-icon.btn-sm {
  width: 30px;
  height: 30px;
}

/* Stato caricamento */
.btn.is-loading {
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  color: #fff;
  animation: spin 0.6s linear infinite;
}

.btn-secondary.is-loading::after,
.btn-ghost.is-loading::after {
  color: var(--ink-2);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

/* Gruppo bottoni unito */
.btn-group {
  display: inline-flex;
}

.btn-group .btn {
  border-radius: 0;
  margin-left: -1.5px;
}

.btn-group .btn:first-child {
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  margin-left: 0;
}

.btn-group .btn:last-child {
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

/* --------------------------------------------------------------------------
   12. Badge / chip
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 0.75rem;
  font-weight: 620;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.badge.dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge svg {
  width: 12px;
  height: 12px;
}

.badge-ok { background: var(--ok-soft); color: var(--ok-ink); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger-ink); }
.badge-info { background: var(--brand-soft); color: var(--brand-ink); }
.badge-brand { background: var(--brand-soft); color: var(--brand-ink); }
.badge-flame { background: var(--flame-soft); color: var(--flame-ink); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-dark { background: var(--ink-2); color: #fff; }

.badge-lg {
  padding: 6px 13px;
  font-size: 0.82rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--line-2);
  background: var(--panel);
  font-size: 0.83rem;
  font-weight: 550;
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--t) var(--ease);
}

.chip:hover {
  border-color: var(--brand);
  color: var(--brand-ink);
}

.chip.active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.chip .x {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid;
  place-items: center;
}

.chip .x svg {
  width: 8px;
  height: 8px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

/* --------------------------------------------------------------------------
   13. Tabelle
   -------------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Combobox in tabella: il pannello è fixed via JS (sfugge a .panel overflow:hidden) */
.table-wrap.is-combo-friendly {
  overflow: visible;
}

table.data.ddt-lines td.ddt-article-cell {
  min-width: 280px;
  max-width: 380px;
  vertical-align: top;
}

table.data.ddt-lines .combo[data-combo-fixed].is-open {
  z-index: 5;
}

/* Spazio sotto il form DDT: il combo articoli (fixed) non finisce sul bordo pagina */
.ddt-form {
  padding-bottom: 340px;
}

table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

table.data th,
table.data td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.data thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  font-size: 0.71rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  background: var(--panel-2);
  white-space: nowrap;
  border-bottom: 1px solid var(--line-2);
}

table.data tbody tr {
  transition: background var(--t-fast) var(--ease);
}

table.data tbody tr:hover {
  background: var(--brand-soft);
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

table.data tbody tr.is-selected {
  background: var(--brand-soft);
}

table.data .num,
table.data th.num {
  text-align: right;
  font-family: var(--mono);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

table.data th.num {
  font-family: var(--font);
}

table.data .actions {
  text-align: right;
  white-space: nowrap;
}

table.data.compact th,
table.data.compact td {
  padding: 8px 12px;
}

table.data tfoot td {
  padding: 13px 16px;
  font-weight: 650;
  background: var(--panel-2);
  border-top: 2px solid var(--line-2);
  border-bottom: 0;
}

/* Colonna ordinabile */
th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  color: var(--ink-2);
}

th.sortable::after {
  content: "";
  display: inline-block;
  margin-left: 6px;
  width: 0;
  height: 0;
  border: 4px solid transparent;
  border-top-color: var(--muted-2);
  opacity: 0.4;
  vertical-align: middle;
}

th.sortable.asc::after {
  border-top-color: transparent;
  border-bottom-color: var(--brand);
  opacity: 1;
  transform: translateY(-2px);
}

th.sortable.desc::after {
  border-top-color: var(--brand);
  opacity: 1;
}

/* Cella con titolo + sottotitolo */
.cell-main {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.cell-main .t {
  min-width: 0;
}

.cell-main b {
  display: block;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.cell-main span {
  display: block;
  font-size: 0.79rem;
  color: var(--muted);
  margin-top: 1px;
}

.sq {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--ink-3);
}

.sq.brand { background: var(--brand-soft); color: var(--brand-ink); }
.sq.flame { background: var(--flame-soft); color: var(--flame-ink); }
.sq.ok { background: var(--ok-soft); color: var(--ok-ink); }
.sq.danger { background: var(--danger-soft); color: var(--danger-ink); }

/* --------------------------------------------------------------------------
   14. Progressi
   -------------------------------------------------------------------------- */
.bar {
  position: relative;
  height: 7px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  overflow: hidden;
}

.bar > i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand), var(--brand-600));
  transition: width var(--t-slow) var(--ease);
}

.bar.flame > i { background: linear-gradient(90deg, #ff7d3d, var(--flame)); }
.bar.ok > i { background: linear-gradient(90deg, #45cd88, var(--ok)); }
.bar.danger > i { background: linear-gradient(90deg, #ef7369, var(--danger)); }
.bar.thick { height: 10px; }
.bar.thin { height: 5px; }

.bar-labeled {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 132px;
}

.bar-labeled .bar {
  flex: 1;
}

.bar-labeled .v {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Anello di progresso */
.ring {
  position: relative;
  width: 96px;
  height: 96px;
  flex: none;
}

.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring circle {
  fill: none;
  stroke-width: 9;
  stroke-linecap: round;
}

.ring .track {
  stroke: var(--surface-2);
}

.ring .val {
  stroke: url(#ringGrad);
  transition: stroke-dashoffset 0.9s var(--ease);
}

.ring .mid {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
}

.ring .mid b {
  display: block;
  font-size: 1.34rem;
  font-weight: 680;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.ring .mid span {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.ring.lg {
  width: 132px;
  height: 132px;
}

.ring.lg .mid b {
  font-size: 1.9rem;
}

/* Barra a segmenti (ripartizione costi) */
.stack-bar {
  display: flex;
  height: 12px;
  border-radius: var(--r-full);
  overflow: hidden;
  background: var(--surface-2);
}

.stack-bar > i {
  transition: width var(--t-slow) var(--ease);
}

.stack-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

.stack-legend div {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.83rem;
}

.stack-legend em {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: none;
}

.stack-legend b {
  font-family: var(--mono);
  font-size: 0.82rem;
  margin-left: 2px;
}

/* --------------------------------------------------------------------------
   15. Coppie chiave/valore
   -------------------------------------------------------------------------- */
.kv {
  display: grid;
  grid-template-columns: minmax(120px, 38%) 1fr;
  gap: 0;
  margin: 0;
}

.kv dt {
  padding: 10px 0;
  font-size: 0.85rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.kv dd {
  margin: 0;
  padding: 10px 0;
  font-weight: 550;
  border-bottom: 1px solid var(--line);
  text-align: right;
  min-width: 0;
  word-break: break-word;
}

.kv dt:last-of-type,
.kv dd:last-of-type {
  border-bottom: 0;
}

.kv.plain dt,
.kv.plain dd {
  border: 0;
  padding: 5px 0;
}

.kv dd.mono {
  font-family: var(--mono);
  font-size: 0.87rem;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   15b. Card informative — schede di dettaglio leggibili a blocchi
   -------------------------------------------------------------------------- */
.infocards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(288px, 1fr));
  gap: 14px;
  align-items: start;
}

.infocard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-xs);
  overflow: hidden;
}

.infocard.wide {
  grid-column: 1 / -1;
}

.infocard.hot {
  border-color: color-mix(in srgb, var(--flame) 35%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--flame) 18%, transparent);
}

.infocard > header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 15px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  font-size: 0.71rem;
  font-weight: 680;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.infocard > header svg {
  width: 15px;
  height: 15px;
  color: var(--brand-700);
  flex: none;
}

.infocard > header .ic-tag {
  margin-left: auto;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 550;
}

.ic-body {
  padding: 4px 15px 8px;
}

.ic-body .kv {
  grid-template-columns: minmax(104px, 44%) 1fr;
}

.ic-body .kv dt,
.ic-body .kv dd {
  padding: 9px 0;
  font-size: 0.845rem;
}

.ic-foot {
  padding: 12px 15px 14px;
  border-top: 1px solid var(--line);
}

.ic-empty {
  padding: 16px 15px 18px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Striscia di cifre economiche */
.figures {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--line-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}

.figure {
  flex: 1 1 158px;
  min-width: 0;
  padding: 13px 16px;
  background: var(--panel);
}

.figure .f-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 660;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.figure .f-label svg {
  width: 13px;
  height: 13px;
  opacity: 0.75;
}

.figure .f-value {
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 1.02rem;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.figure .f-note {
  margin-top: 3px;
  font-size: 0.755rem;
  color: var(--muted);
}

.figure.strong {
  background: var(--brand-soft);
}

.figure.strong .f-label {
  color: var(--brand-ink);
}

.figure.strong .f-value {
  font-size: 1.16rem;
  color: var(--brand-ink);
}

.figure .f-value.pos { color: var(--ok-ink); }
.figure .f-value.neg { color: var(--danger-ink); }
.figure .f-value.none { color: var(--muted-2); font-family: var(--font); font-weight: 550; }

/* Eroe di dettaglio */
.detail-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  padding: 22px;
  background: linear-gradient(120deg, var(--panel) 55%, var(--brand-soft));
  border-bottom: 1px solid var(--line);
}

.detail-hero .dh-main {
  flex: 1;
  min-width: 220px;
}

.detail-hero h1 {
  font-size: 1.42rem;
  margin-bottom: 7px;
}

.detail-hero .dh-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-size: 0.86rem;
  color: var(--muted);
}

.detail-hero .dh-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.detail-hero .dh-meta svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

/* --------------------------------------------------------------------------
   16. Tab
   -------------------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  background: var(--panel);
}

.tab {
  position: relative;
  padding: 13px 15px;
  font-size: 0.9rem;
  font-weight: 570;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color var(--t) var(--ease);
}

.tab svg {
  width: 16px;
  height: 16px;
}

.tab:hover {
  color: var(--ink-2);
}

.tab.active {
  color: var(--brand-ink);
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2.5px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(90deg, var(--brand), var(--flame));
  animation: grow var(--t) var(--ease) both;
}

.tab .n {
  padding: 1px 7px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
}

.tab.active .n {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.tab-panel,
[data-tab-panel] {
  display: none;
}

.tab-panel.active,
[data-tab-panel].active {
  display: block;
  animation: fade var(--t) var(--ease) both;
}

/* --------------------------------------------------------------------------
   17. Timeline (storico movimenti)
   -------------------------------------------------------------------------- */
.timeline {
  position: relative;
  padding-left: 26px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: linear-gradient(180deg, var(--brand-soft-2), var(--surface-2));
}

.tl-item {
  position: relative;
  padding: 0 0 20px;
}

.tl-item:last-child {
  padding-bottom: 0;
}

.tl-item::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 4px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--panel);
  border: 2.5px solid var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.tl-item.flame::before { border-color: var(--flame); box-shadow: 0 0 0 3px var(--flame-soft); }
.tl-item.ok::before { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.tl-item.danger::before { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.tl-item.muted::before { border-color: var(--muted-2); box-shadow: 0 0 0 3px var(--surface-2); }

.tl-item .tl-time {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
  margin-bottom: 3px;
}

.tl-item .tl-title {
  font-weight: 600;
  font-size: 0.92rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tl-item .tl-body {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   18. Avvisi
   -------------------------------------------------------------------------- */
.alert {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: var(--panel);
  font-size: 0.9rem;
  margin-bottom: 16px;
  animation: rise var(--t) var(--ease) both;
}

.alert .a-icon {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
}

.alert .a-icon svg {
  width: 19px;
  height: 19px;
}

.alert .a-body {
  min-width: 0;
  flex: 1;
}

.alert b {
  display: block;
  font-weight: 620;
  margin-bottom: 2px;
}

.alert p {
  color: inherit;
  opacity: 0.86;
  line-height: 1.5;
}

.alert-success {
  background: var(--ok-soft);
  border-color: rgba(15, 157, 88, 0.22);
  color: var(--ok-ink);
}

.alert-error {
  background: var(--danger-soft);
  border-color: rgba(217, 45, 32, 0.22);
  color: var(--danger-ink);
}

.alert-warn {
  background: var(--warn-soft);
  border-color: rgba(184, 118, 11, 0.22);
  color: var(--warn);
}

.alert-info {
  background: var(--brand-soft);
  border-color: var(--brand-soft-2);
  color: var(--brand-ink);
}

.alert-flame {
  background: var(--flame-soft);
  border-color: var(--flame-soft-2);
  color: var(--flame-ink);
}

.alert .a-close {
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
}

.alert .a-close:hover {
  opacity: 1;
}

.alert .a-close svg {
  width: 13px;
  height: 13px;
}

/* --------------------------------------------------------------------------
   19. Stati vuoti / skeleton
   -------------------------------------------------------------------------- */
.empty {
  padding: 52px 24px;
  text-align: center;
}

.empty .e-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--muted-2);
}

.empty .e-icon svg {
  width: 27px;
  height: 27px;
}

.empty b {
  display: block;
  font-size: 1.02rem;
  font-weight: 620;
  margin-bottom: 5px;
}

.empty p {
  color: var(--muted);
  font-size: 0.89rem;
  max-width: 44ch;
  margin: 0 auto 18px;
  line-height: 1.55;
}

.skeleton {
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  height: 14px;
}

/* --------------------------------------------------------------------------
   20. Modali & drawer
   -------------------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(6, 15, 26, 0.5);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t) var(--ease);
}

.overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  position: fixed;
  z-index: 100;
  left: 50%;
  top: 50%;
  width: min(100% - 32px, 560px);
  max-height: min(86vh, 760px);
  transform: translate(-50%, -46%) scale(0.97);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xl);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease-spring);
}

.modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.modal.wide {
  width: min(100% - 32px, 880px);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  font-size: 1.1rem;
  flex: 1;
}

.modal-head .sub {
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 3px;
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-foot {
  padding: 15px 22px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal-foot .left {
  margin-right: auto;
}

.x-btn {
  width: 32px;
  height: 32px;
  flex: none;
  border: 0;
  border-radius: var(--r-xs);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}

.x-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.x-btn svg {
  width: 15px;
  height: 15px;
}

/* Drawer laterale */
.drawer {
  position: fixed;
  z-index: 100;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(100%, 460px);
  transform: translateX(100%);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  box-shadow: var(--sh-xl);
  transition: transform var(--t-slow) var(--ease);
}

.drawer.open {
  transform: translateX(0);
}

/* --------------------------------------------------------------------------
   21. Toast
   -------------------------------------------------------------------------- */
.toast-host {
  position: fixed;
  z-index: 120;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100% - 36px, 372px);
  pointer-events: none;
}

.toast {
  display: flex;
  gap: 11px;
  padding: 13px 15px;
  border-radius: var(--r);
  background: var(--panel);
  border: 1px solid var(--line-2);
  box-shadow: var(--sh-lg);
  pointer-events: auto;
  animation: slide-in var(--t-slow) var(--ease-spring) both;
}

.toast.leaving {
  animation: slide-out var(--t) var(--ease) both;
}

.toast .t-icon {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 7px;
  display: grid;
  place-items: center;
}

.toast .t-icon svg {
  width: 14px;
  height: 14px;
}

.toast .t-body {
  flex: 1;
  min-width: 0;
}

.toast b {
  display: block;
  font-size: 0.9rem;
  font-weight: 620;
}

.toast p {
  font-size: 0.83rem;
  color: var(--muted);
  margin-top: 2px;
}

.toast.success .t-icon { background: var(--ok-soft); color: var(--ok-ink); }
.toast.error .t-icon { background: var(--danger-soft); color: var(--danger-ink); }
.toast.warn .t-icon { background: var(--warn-soft); color: var(--warn); }
.toast.info .t-icon { background: var(--brand-soft); color: var(--brand-ink); }

.toast::after {
  content: "";
  position: absolute;
}

/* --------------------------------------------------------------------------
   22. Palette comandi
   -------------------------------------------------------------------------- */
.cmdk {
  position: fixed;
  z-index: 110;
  left: 50%;
  top: 13vh;
  width: min(100% - 32px, 600px);
  transform: translate(-50%, -12px);
  background: var(--panel);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xl);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}

.cmdk.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.cmdk-input {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.cmdk-input svg {
  width: 19px;
  height: 19px;
  color: var(--muted-2);
  flex: none;
}

.cmdk-input input {
  flex: 1;
  border: 0;
  outline: none;
  font-size: 1.02rem;
  background: transparent;
}

.cmdk-list {
  max-height: 54vh;
  overflow-y: auto;
  padding: 8px;
}

.cmdk-group {
  padding: 10px 11px 5px;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 11px;
  border-radius: var(--r-xs);
  cursor: pointer;
  font-size: 0.92rem;
}

.cmdk-item .ci-icon {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--ink-3);
}

.cmdk-item .ci-icon svg {
  width: 15px;
  height: 15px;
}

.cmdk-item .ci-body {
  flex: 1;
  min-width: 0;
}

.cmdk-item b {
  display: block;
  font-weight: 570;
}

.cmdk-item small {
  font-size: 0.77rem;
  color: var(--muted);
}

.cmdk-item.is-active {
  background: var(--brand-soft);
}

.cmdk-item.is-active .ci-icon {
  background: var(--brand);
  color: #fff;
}

.cmdk-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  display: flex;
  gap: 16px;
  font-size: 0.76rem;
  color: var(--muted);
}

.cmdk-foot span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* --------------------------------------------------------------------------
   23. Tooltip
   -------------------------------------------------------------------------- */
[data-tip] {
  position: relative;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translate(-50%, 4px);
  padding: 6px 10px;
  border-radius: var(--r-xs);
  background: var(--ink);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 70;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}

[data-tip]:hover::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --------------------------------------------------------------------------
   24. Paginazione
   -------------------------------------------------------------------------- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 15px 20px;
  border-top: 1px solid var(--line);
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line-2);
  background: var(--panel);
  font-size: 0.87rem;
  font-weight: 550;
  color: var(--ink-2);
  transition: all var(--t) var(--ease);
}

.pagination a:hover {
  border-color: var(--brand);
  color: var(--brand-ink);
  background: var(--brand-soft);
}

.pagination .active span {
  background: linear-gradient(178deg, var(--brand), var(--brand-600));
  border-color: var(--brand-600);
  color: #fff;
}

.pagination .disabled span {
  opacity: 0.42;
}

.pagination .info {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 400;
}

/* --------------------------------------------------------------------------
   24b. Computo metrico
   -------------------------------------------------------------------------- */

/* Tabella del computo: densa, con la designazione che respira. */
table.computo {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.87rem;
}

table.computo th,
table.computo td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.computo thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-2);
  font-size: 0.68rem;
  font-weight: 680;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--line-2);
  vertical-align: bottom;
}

table.computo .num {
  text-align: right;
  font-family: var(--mono);
  font-size: 0.83rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

table.computo th.num { font-family: var(--font); }

table.computo tbody tr:hover { background: var(--brand-soft); }
table.computo tbody tr.is-done { background: rgba(15, 157, 88, 0.045); }
table.computo tbody tr.is-done:hover { background: var(--ok-soft); }

table.computo .c-ord {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  width: 1%;
}

table.computo .c-tariff {
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: nowrap;
  width: 1%;
}

table.computo .c-desc { min-width: 260px; }

table.computo .c-desc b {
  display: block;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

table.computo .c-desc .more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin-top: 3px;
  font-size: 0.79rem;
  color: var(--muted);
  line-height: 1.45;
}

table.computo .c-desc .more svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
}

table.computo .c-actions {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}

/* Riga di intestazione di categoria */
table.computo tr.group > td {
  padding: 12px 12px 9px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-2);
  border-top: 1px solid var(--line-2);
}

table.computo tr.group .g-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.79rem;
  font-weight: 680;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
}

table.computo tr.group .g-name svg {
  width: 14px;
  height: 14px;
  color: var(--brand-700);
}

table.computo tr.group .g-sum {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 5px;
  font-size: 0.78rem;
  color: var(--muted);
}

table.computo tr.group .g-sum b {
  font-family: var(--mono);
  font-weight: 620;
  color: var(--ink-2);
}

table.computo tfoot td {
  padding: 13px 12px;
  background: var(--panel-2);
  border-top: 2px solid var(--line-2);
  border-bottom: 0;
  font-weight: 650;
}

/* Cella di avanzamento editabile in linea */
.pct-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  min-width: 132px;
}

.pct-cell input {
  width: 62px;
  padding: 5px 7px;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xs);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.pct-cell input:hover { border-color: var(--line-3); }

.pct-cell input:focus {
  outline: 0;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.pct-cell input.is-dirty {
  border-color: var(--flame);
  background: var(--flame-soft);
  font-weight: 620;
}

.pct-cell .bar {
  width: 52px;
  flex: none;
}

/* Barra di azioni fissa per il salvataggio degli avanzamenti */
.progress-bar-sticky {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  background: var(--panel);
  border-top: 1px solid var(--line-2);
  box-shadow: 0 -8px 22px rgba(10, 21, 36, 0.07);
}

.progress-bar-sticky .pb-info {
  margin-right: auto;
  font-size: 0.85rem;
  color: var(--muted);
}

.progress-bar-sticky .pb-info b {
  color: var(--ink);
  font-family: var(--mono);
}

/* Un campo calcolato dal sistema si distingue da uno digitabile. */
.control input:read-only:not([type="range"]) {
  background: var(--surface-2);
  color: var(--ink-3);
  cursor: default;
}

/* Editor delle misurazioni */
.measure {
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}

.measure-head,
.measure-row {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) repeat(4, minmax(72px, 0.85fr)) minmax(88px, 1fr) 78px;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
}

.measure-head {
  background: var(--panel-2);
  border-bottom: 1px solid var(--line-2);
  font-size: 0.67rem;
  font-weight: 680;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.measure-head span:nth-child(n + 2) { text-align: right; }
.measure-head span:last-child { text-align: center; }

.measure-row { border-bottom: 1px solid var(--line); }
.measure-row:last-child { border-bottom: 0; }
.measure-row.is-deduction { background: var(--danger-soft); }

.measure-row input[type="text"] {
  width: 100%;
  padding: 7px 9px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xs);
  font-size: 0.85rem;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.measure-row input[type="text"]:focus {
  outline: 0;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.measure-row input.dim {
  text-align: right;
  font-family: var(--mono);
  font-size: 0.83rem;
  font-variant-numeric: tabular-nums;
}

.measure-row .m-result {
  text-align: right;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.measure-row.is-deduction .m-result { color: var(--danger-ink); }

.measure-row .m-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.measure-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  background: var(--panel-2);
  border-top: 1px solid var(--line-2);
}

.measure-total {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.79rem;
  color: var(--muted);
}

.measure-total b {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Mappatura delle colonne in import */
.mapper {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: 11px;
}

.mapper .map-field {
  padding: 11px 13px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.mapper .map-field.is-set {
  background: var(--brand-soft);
  border-color: var(--brand-soft-2);
}

.mapper .map-field.is-required.is-unset {
  border-color: var(--flame-soft-2);
  background: var(--flame-soft);
}

.mapper .map-field label {
  display: block;
  font-size: 0.74rem;
  font-weight: 660;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.mapper .map-field select {
  width: 100%;
  padding: 7px 9px;
  font-size: 0.86rem;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xs);
}

.mapper .map-field select:focus {
  outline: 0;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

/* Anteprima del foglio caricato */
.sheet-preview {
  overflow: auto;
  max-height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--r);
}

table.sheet {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.79rem;
  font-family: var(--mono);
  white-space: nowrap;
}

table.sheet th,
table.sheet td {
  padding: 5px 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

table.sheet thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 680;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  text-align: center;
}

table.sheet thead th.is-mapped {
  background: var(--brand-soft-2);
  color: var(--brand-ink);
}

table.sheet tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--panel-2);
  font-family: var(--font);
  font-size: 0.7rem;
  color: var(--muted);
  text-align: right;
}

table.sheet tr.is-header td {
  background: var(--flame-soft);
  font-weight: 620;
  color: var(--flame-ink);
}

/* --------------------------------------------------------------------------
   25. Utility
   -------------------------------------------------------------------------- */
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.tiny { font-size: 0.76rem; }
.bold { font-weight: 650; }
.tabnum { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.pos { color: var(--ok-ink); }
.neg { color: var(--danger-ink); }
.flame-t { color: var(--flame-ink); }
.brand-t { color: var(--brand-ink); }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 26px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.mb-4 { margin-bottom: 26px; }

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   26. Animazioni
   -------------------------------------------------------------------------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes grow {
  from { transform: scaleX(0); }
  to { transform: none; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.86); }
}

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(22px, -26px); }
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: none; }
}

@keyframes slide-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateX(28px); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* --------------------------------------------------------------------------
   27. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .split,
  .split.even,
  .split.wide-right {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    display: none;
  }

  .form-grid,
  .form-grid.g3,
  .form-grid.g4 {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid .span2 {
    grid-column: auto;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(84vw, var(--sidebar));
    transform: translateX(-102%);
    transition: transform var(--t-slow) var(--ease);
    box-shadow: var(--sh-xl);
  }

  body.nav-open .sidebar {
    transform: none;
  }

  .menu-toggle {
    display: grid;
  }

  .cmd-trigger {
    min-width: 0;
    width: 38px;
    padding: 0;
    justify-content: center;
  }

  .cmd-trigger span,
  .cmd-trigger .kbd {
    display: none;
  }

  .content {
    padding: 20px 16px 56px;
  }

  .topbar {
    padding: 0 16px;
  }

  .crumb {
    display: none;
  }
}

@media (max-width: 620px) {
  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .page-actions .btn {
    flex: 1;
  }

  .kpi-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .kv {
    grid-template-columns: minmax(0, 1fr);
  }

  .kv dt {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .kv dd {
    text-align: left;
    padding-top: 2px;
  }

  .modal {
    width: calc(100% - 20px);
  }

  .toast-host {
    right: 10px;
    left: 10px;
    bottom: 10px;
    width: auto;
  }
}

/* --------------------------------------------------------------------------
   28. Stampa
   -------------------------------------------------------------------------- */
@media print {
  .sidebar,
  .topbar,
  .page-actions,
  .toolbar,
  .pagination,
  .form-bar,
  .toast-host {
    display: none !important;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .panel {
    box-shadow: none;
    border-color: #ccc;
    break-inside: avoid;
  }

  body {
    background: #fff;
  }
}

/* --------------------------------------------------------------------------
   29. Modulo SAL
   -------------------------------------------------------------------------- */
.sal-board tr.is-ready {
  background: var(--flame-soft);
}

.sal-board tr.is-ready:hover {
  background: color-mix(in srgb, var(--flame-soft) 70%, var(--brand-soft));
}

.sal-meter {
  min-width: 180px;
}

.sal-meter-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.sal-meter-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #3ec4ff);
}

.sal-meter.is-hot .sal-meter-bar > span {
  background: linear-gradient(90deg, var(--flame), #ff8a4c);
}

.sal-meter-label {
  margin-top: 5px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.sal-meter-label b {
  color: var(--ink);
  font-weight: 620;
}

.sal-gauge-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.sal-gauge-head b {
  display: block;
  margin-top: 2px;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.sal-gauge-head .mono {
  font-size: 1.35rem;
  font-weight: 650;
  color: var(--brand-ink);
}

.sal-gauge-track {
  height: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.sal-gauge-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #5ad0ff);
  transition: width 0.35s var(--ease);
}

.sal-gauge-track > span.hot {
  background: linear-gradient(90deg, var(--flame), #ff9a62);
}

.sal-gauge-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.76rem;
  color: var(--muted);
  font-family: var(--mono);
}

.sal-form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

table.data tr.is-muted {
  opacity: 0.62;
}

table.data tr.note-row td {
  padding-top: 0;
  padding-bottom: 12px;
  border-top: 0;
  background: var(--surface-1);
}

table.data td.actions,
table.data th.actions {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}

table.data td.actions .btn,
table.data td.actions form {
  display: inline-flex;
  vertical-align: middle;
}

table.data td.actions form.inline {
  display: inline;
}

.form-stack {
  display: block;
}

.pad-0 { padding: 0 !important; }

.btn.danger,
.btn-ghost.danger {
  color: var(--danger-ink);
}

.btn-ghost.danger:hover {
  background: var(--danger-soft);
}

.link-strong {
  color: var(--ink);
  font-weight: 620;
  text-decoration: none;
}

.link-strong:hover {
  color: var(--brand-ink);
}

@media (max-width: 960px) {
  .sal-form-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --------------------------------------------------------------------------
   30. Magazzino
   -------------------------------------------------------------------------- */
.wh-feed {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wh-feed li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.wh-feed li:last-child {
  border-bottom: 0;
}

.wh-feed-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wh-feed-body b {
  font-weight: 620;
  letter-spacing: -0.01em;
}

.pos { color: var(--ok-ink); }
.neg { color: var(--danger-ink); }

.panel-body.tight {
  padding-top: 8px;
  padding-bottom: 8px;
}

/* ------------------------------------------------------------------ */
/* Modulo 8 — Rapportini                                              */
/* ------------------------------------------------------------------ */
.labor-upload-grid,
.labor-review-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.85fr);
  gap: 18px;
  align-items: start;
}

@media (max-width: 960px) {
  .labor-upload-grid,
  .labor-review-grid {
    grid-template-columns: 1fr;
  }
}

.labor-dropzone {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 24px;
}

.labor-dropzone.has-file {
  border-style: solid;
  border-color: var(--brand);
  background: var(--brand-soft);
}

.labor-photo-preview {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--panel-2);
}

.labor-photo-preview img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: #0f1218;
}

.labor-photo-preview .btn {
  margin: 10px;
}

.labor-advanced {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  background: var(--panel-2);
}

.labor-advanced summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-2);
}

.labor-steps {
  margin: 0;
  padding-left: 1.15rem;
  line-height: 1.7;
  color: var(--ink-2);
}

.labor-steps li + li {
  margin-top: 6px;
}

.labor-entries {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 18px;
}

.labor-entry {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel-2);
  padding: 12px 14px;
  transition: border-color var(--t) var(--ease), background var(--t) var(--ease);
}

.labor-entry.is-matched {
  border-color: rgba(15, 157, 88, 0.35);
  background: linear-gradient(0deg, var(--ok-soft), var(--panel-2) 55%);
}

.labor-entry-main {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 110px 120px 40px;
  gap: 10px;
  align-items: end;
}

.labor-entry-main.no-cost {
  grid-template-columns: minmax(0, 1.6fr) 110px 40px;
}

@media (max-width: 720px) {
  .labor-entry-main {
    grid-template-columns: 1fr 1fr auto;
  }
  .labor-entry-main .field:first-child {
    grid-column: 1 / -1;
  }
}

.labor-entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.labor-entry-meta .control-inline {
  flex: 1 1 160px;
  min-width: 140px;
}

.labor-side-photo {
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0f1218;
}

.labor-side-photo img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
}

.dropzone-sm {
  padding: 18px 14px;
  min-height: 0;
}

.dropzone-sm .dz-icon {
  width: 36px;
  height: 36px;
  margin-bottom: 8px;
}

.labor-processing {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(12, 16, 24, 0.55);
  backdrop-filter: blur(6px);
  padding: 24px;
}

body.labor-busy {
  overflow: hidden;
}

.labor-processing-card {
  width: min(420px, 100%);
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--r) + 4px);
  padding: 28px 24px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.labor-processing-card h2 {
  margin: 14px 0 6px;
  font-size: 1.2rem;
}

.labor-processing-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.labor-spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid var(--line-3);
  border-top-color: var(--brand);
  animation: labor-spin 0.8s linear infinite;
}

@keyframes labor-spin {
  to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------------ */
/* Timbrature geolocalizzate                                          */
/* ------------------------------------------------------------------ */
.app-shell.is-operator .sidebar {
  width: min(100%, 280px);
}

.attendance-hero .panel-body {
  padding: 22px;
}

.attendance-status {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.attendance-status[data-tone="ok"] {
  background: var(--ok-soft);
  border-color: rgba(15, 157, 88, 0.22);
}

.attendance-status[data-tone="warn"] {
  background: var(--warn-soft);
  border-color: rgba(184, 118, 11, 0.22);
}

.attendance-dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.attendance-status[data-tone="ok"] .attendance-dot {
  background: var(--ok-ink);
  box-shadow: 0 0 0 4px rgba(15, 157, 88, 0.15);
}

.attendance-status[data-tone="warn"] .attendance-dot {
  background: var(--warn);
}

.attendance-section-title {
  font-size: 1rem;
  margin: 0 0 12px;
}

.attendance-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.attendance-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
}

.attendance-item.is-inside {
  border-color: rgba(15, 157, 88, 0.35);
  background: linear-gradient(0deg, var(--ok-soft), var(--panel) 60%);
}

.attendance-item-body {
  min-width: 0;
  flex: 1;
}

.attendance-item-top {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.attendance-punch-btn {
  flex: none;
  min-width: 110px;
  min-height: 48px;
}

.attendance-punch-btn.out {
  min-width: 150px;
  background: var(--flame);
  border-color: var(--flame);
}

.attendance-open {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 16px;
  border-radius: var(--r);
  border: 1px solid rgba(15, 157, 88, 0.28);
  background: var(--ok-soft);
}

.attendance-open-title {
  margin: 6px 0 4px;
  font-size: 1.35rem;
}

.attendance-empty {
  padding: 18px;
  text-align: center;
  border: 1px dashed var(--line-3);
  border-radius: var(--r);
}

@media (max-width: 640px) {
  .attendance-item {
    flex-direction: column;
    align-items: stretch;
  }
  .attendance-punch-btn {
    width: 100%;
  }
  .attendance-open {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ------------------------------------------------------------------ */
/* Modulo 9 — Scadenzario                                             */
/* ------------------------------------------------------------------ */
.schedule-table td.bold {
  font-weight: 650;
}

.schedule-table tr.is-muted {
  opacity: 0.72;
}

.schedule-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.schedule-postpone {
  position: relative;
}

.schedule-postpone > summary {
  list-style: none;
  cursor: pointer;
}

.schedule-postpone > summary::-webkit-details-marker {
  display: none;
}

.schedule-postpone-form {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  display: flex;
  gap: 6px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
  min-width: 220px;
}

.schedule-postpone-form input[type="date"] {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--panel-2);
  color: var(--ink);
  font: inherit;
}

/* ------------------------------------------------------------------ */
/* Analisi dei costi: righe risorse editabili                          */
/* ------------------------------------------------------------------ */
.cost-section table.data td {
  padding: 6px 8px;
  vertical-align: middle;
}

.cost-section input[type="text"] {
  width: 100%;
  padding: 7px 9px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xs);
  font-size: 0.85rem;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.cost-section input[type="text"]:focus {
  outline: 0;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.cost-section input.num {
  text-align: right;
  font-family: var(--mono);
  font-size: 0.83rem;
  font-variant-numeric: tabular-nums;
}

.cost-section .table-wrap {
  margin-bottom: 6px;
}
