/* =============================================================================
   Gestionale Scuola Calcio — Design system
   Token → base → layout → componenti → pagine. Nessun framework.
   Il colore primario (--brand) è impostato dal layout da Società → Parametri.
   ============================================================================= */

/* ---------------------------------------------------------------- Token ---- */
:root {
  --brand: #0ea5e9;
  --brand-strong: color-mix(in oklab, var(--brand) 82%, #000);
  --brand-soft: color-mix(in oklab, var(--brand) 12%, transparent);
  --brand-ring: color-mix(in oklab, var(--brand) 40%, transparent);
  --on-brand: #fff;

  --bg: #f5f5f5;
  --bg-accent: radial-gradient(1200px 600px at 100% -10%, color-mix(in oklab, var(--brand) 9%, transparent), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f4f4f4;
  --surface-3: #e5e5e5;
  --glass: rgba(255, 255, 255, 0.72);
  --text: #2b2b2b;
  --text-2: #474747;
  --muted: #6b6b6b;
  --faint: #9a9a9a;
  --border: rgba(43, 43, 43, 0.08);
  --border-strong: rgba(43, 43, 43, 0.14);

  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0284c7;

  /* Palette categorie validata (daltonismo e contrasto) con lo strumento dataviz */
  --cat-maschile: #2563eb;
  --cat-femminile: #ec4899;
  --cat-agonistica: #b7860b;
  --cat-agonistica-2: #16a34a;
  /* Coppia entrate/uscite validata con lo strumento dataviz */
  --fin-entrate: #2563eb;
  --fin-uscite: #e0662b;

  --shadow-xs: 0 1px 2px rgba(43, 43, 43, 0.05);
  --shadow-sm: 0 1px 2px rgba(43, 43, 43, 0.04), 0 2px 6px rgba(43, 43, 43, 0.04);
  --shadow-md: 0 1px 2px rgba(43, 43, 43, 0.05), 0 8px 24px -6px rgba(43, 43, 43, 0.1);
  --shadow-lg: 0 2px 6px rgba(43, 43, 43, 0.06), 0 24px 48px -12px rgba(43, 43, 43, 0.22);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;

  --sb-w: 264px;
  --sb-w-espansa: 264px;
  --sb-w-compressa: 76px;
  --topbar-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --brand-strong: color-mix(in oklab, var(--brand) 78%, #fff);
  --brand-soft: color-mix(in oklab, var(--brand) 18%, transparent);
  --bg: #121212;
  --bg-accent: radial-gradient(1200px 600px at 100% -10%, color-mix(in oklab, var(--brand) 14%, transparent), transparent 60%);
  --surface: #1b1b1b;
  --surface-2: #222222;
  --surface-3: #2b2b2b;
  --glass: rgba(27, 27, 27, 0.72);
  --text: #f2f2f2;
  --text-2: #d0d0d0;
  --muted: #a3a3a3;
  --faint: #6f6f6f;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #f87171;
  --info: #38bdf8;
  --cat-maschile: #3b82f6;
  --cat-femminile: #ec4899;
  --cat-agonistica: #b7860b;
  --cat-agonistica-2: #22c55e;
  --fin-entrate: #3b82f6;
  --fin-uscite: #e0662b;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.4), 0 24px 48px -12px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

/* ----------------------------------------------------------------- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  font: 400 14px/1.55 var(--font);
  font-feature-settings: "cv11", "ss01";
  color: var(--text);
  background: var(--bg-accent), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.015em; color: var(--text); }
h1 { font-size: 24px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
.num, table { font-variant-numeric: tabular-nums; }

.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-xs { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }

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

::selection { background: var(--brand-ring); }

.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;
}
.skip-link {
  position: fixed; top: 12px; left: 12px; z-index: 100; transform: translateY(-160%);
  background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 600;
  transition: transform .2s var(--ease);
}
.skip-link:focus { transform: none; }

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

/* --------------------------------------------------------------- Layout ---- */
.app {
  display: grid;
  grid-template-columns: var(--sb-w) minmax(0, 1fr);
  min-height: 100vh;
}
html.sb-compressa { --sb-w: var(--sb-w-compressa); }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.content {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 56px;
}

/* -------------------------------------------------------------- Sidebar ---- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 40;
  overflow: hidden;
}
.sb-head {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px 0 18px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.brand-mark {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, color-mix(in oklab, var(--brand) 85%, #fff), var(--brand-strong));
  color: var(--on-brand);
  font-weight: 750; font-size: 13px; letter-spacing: .02em;
  box-shadow: 0 6px 16px -6px var(--brand-ring), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.brand-text { min-width: 0; line-height: 1.2; }
.brand-text strong { display: block; font-size: 13.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: 12px; color: var(--muted); white-space: nowrap; }

.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 10px 16px; }
.sb-label {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--faint); padding: 14px 12px 6px; white-space: nowrap;
}
.sb-link, .sb-group-btn {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 38px;
  padding: 8px 12px;
  border: 0; border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px; font-weight: 500; text-align: left;
  white-space: nowrap;
  transition: background-color .15s, color .15s;
}
.sb-link:hover, .sb-group-btn:hover { background: var(--surface-2); color: var(--text); }
.sb-link .icon, .sb-group-btn > .icon:first-child { color: var(--muted); transition: color .15s; }
.sb-link:hover .icon, .sb-group-btn:hover > .icon:first-child { color: var(--text); }
.sb-link.is-active {
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 600;
}
.sb-link.is-active .icon { color: var(--brand); }
.sb-link.is-active::before {
  content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand);
}
.sb-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sb-chevron { margin-left: auto; color: var(--faint); transition: transform .25s var(--ease); }
.sb-group.is-open > .sb-group-btn .sb-chevron { transform: rotate(90deg); }
.sb-group.has-active > .sb-group-btn { color: var(--text); }
.sb-group.has-active > .sb-group-btn > .icon:first-child { color: var(--brand); }

.sb-sub { overflow: hidden; }
.sb-group:not(.is-open) > .sb-sub { height: 0; }
.sb-sub-inner { padding: 2px 0 6px 20px; position: relative; }
.sb-sub-inner::before {
  content: ""; position: absolute; left: 21px; top: 4px; bottom: 10px; width: 1px; background: var(--border-strong);
}
.sb-sub .sb-link { min-height: 34px; padding-left: 22px; font-size: 13px; }
.sb-sub .sb-link .icon { width: 16px; height: 16px; }
.sb-sub .sb-link.is-active::before { display: none; }

.sb-foot { padding: 10px; border-top: 1px solid var(--border); flex: none; }
.sb-collapse-btn .icon-close { display: block; }
.sb-collapse-btn .icon-open { display: none; }
html.sb-compressa .sb-collapse-btn .icon-close { display: none; }
html.sb-compressa .sb-collapse-btn .icon-open { display: block; }

/* Sidebar compressa: solo icone, tooltip e menu a comparsa per le sezioni */
@media (min-width: 1024px) {
  html.sb-compressa .sb-head { padding: 0 20px; }
  html.sb-compressa .brand-text,
  html.sb-compressa .sb-text,
  html.sb-compressa .sb-chevron,
  html.sb-compressa .sb-label { opacity: 0; pointer-events: none; }
  html.sb-compressa .sb-label { height: 12px; padding: 0; }
  html.sb-compressa .sb-link, html.sb-compressa .sb-group-btn { justify-content: flex-start; padding-left: 17px; }
  html.sb-compressa .sb-nav { overflow: visible; }
  html.sb-compressa .sidebar { overflow: visible; }
  html.sb-compressa .sb-group > .sb-sub { height: 0 !important; }
  html.sb-compressa .sb-group { position: relative; }
  html.sb-compressa .sb-group:hover > .sb-flyout,
  html.sb-compressa .sb-group:focus-within > .sb-flyout { opacity: 1; visibility: visible; transform: none; }

  html.sb-compressa [data-tooltip]:hover::after,
  html.sb-compressa [data-tooltip]:focus-visible::after {
    content: attr(data-tooltip);
    position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
    background: var(--text); color: var(--bg);
    font-size: 12px; font-weight: 550; padding: 6px 10px; border-radius: var(--radius-xs);
    white-space: nowrap; box-shadow: var(--shadow-md); z-index: 60; pointer-events: none;
  }
  html.sb-compressa .sb-group:hover > [data-tooltip]::after { display: none; }
}
.sb-flyout {
  position: absolute; left: calc(100% + 8px); top: -6px; z-index: 60;
  min-width: 232px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateX(-4px);
  transition: opacity .15s, transform .2s var(--ease), visibility .15s;
}
.sb-flyout::before { content: ""; position: absolute; left: -12px; top: 0; bottom: 0; width: 12px; }
.sb-flyout-title { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 8px 10px 4px; }
.sb-flyout .sb-link { min-height: 34px; font-size: 13px; padding-left: 10px; }
.sb-flyout .sb-link .sb-text { opacity: 1 !important; }
.sb-flyout .sb-link.is-active::before { display: none; }
html:not(.sb-compressa) .sb-flyout { display: none; }

.sb-backdrop { display: none; }

/* --------------------------------------------------------------- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px 0 20px;
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-menu { display: none; }
.breadcrumb { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; color: var(--muted); }
.breadcrumb ol { display: flex; align-items: center; gap: 6px; list-style: none; margin: 0; padding: 0; min-width: 0; }
.breadcrumb li { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.breadcrumb li:not(:last-child)::after {
  content: ""; width: 5px; height: 5px; border-right: 1.5px solid var(--faint); border-top: 1.5px solid var(--faint);
  transform: rotate(45deg); margin: 0 4px 0 2px;
}
.breadcrumb a:hover { color: var(--text); }
.breadcrumb [aria-current] { color: var(--text); font-weight: 550; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }

.search-trigger {
  display: flex; align-items: center; gap: 10px;
  width: 280px; height: 38px; padding: 0 8px 0 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--muted); font-size: 13px;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.search-trigger:hover { border-color: var(--border-strong); background: var(--surface); }
.search-trigger span { flex: 1; text-align: left; }
.kbd {
  display: inline-flex; align-items: center; gap: 2px;
  font: 600 11px/1 var(--font); color: var(--muted);
  padding: 4px 6px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--border-strong);
  box-shadow: 0 1px 0 var(--border-strong);
}

/* --------------------------------------------------------------- Bottoni ---- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px;
  border: 1px solid var(--btn-bd); border-radius: 10px;
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 560; font-size: 13.5px; white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s;
  user-select: none;
}
.btn:hover { --btn-bg: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  --btn-bg: var(--brand); --btn-fg: var(--on-brand); --btn-bd: transparent;
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0));
  box-shadow: 0 1px 2px rgba(43, 43, 43, .12), 0 6px 16px -6px var(--brand-ring), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.btn-primary:hover { --btn-bg: var(--brand-strong); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { --btn-bg: var(--surface-2); color: var(--text); }
.btn-icon { width: 38px; padding: 0; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 14.5px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn .spinner { display: none; }
.btn.is-loading .spinner { display: block; animation: spin .8s linear infinite; }
.btn.is-loading .btn-label-icon { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- Avatar ---- */
.avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 650; color: #fff; letter-spacing: .02em;
  background: linear-gradient(135deg, var(--brand), color-mix(in oklab, var(--brand) 40%, #7c3aed));
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border-strong);
}
.user-btn {
  display: flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 8px 0 5px;
  border: 1px solid transparent; border-radius: 12px; background: transparent;
  transition: background-color .15s, border-color .15s;
}
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--surface-2); border-color: var(--border); }
.user-btn-text { text-align: left; line-height: 1.2; }
.user-btn-text strong { display: block; font-size: 13px; font-weight: 600; }
.user-btn-text span { font-size: 11.5px; color: var(--muted); }

/* ------------------------------------------------------- Menu a tendina ---- */
.dropdown { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 70;
  min-width: 260px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  transform-origin: top right;
}
.menu[hidden] { display: none; }
.menu-header { display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-header strong { display: block; font-size: 13.5px; }
.menu-header span { font-size: 12px; color: var(--muted); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); font-size: 13.5px; text-align: left;
}
.menu-item .icon { color: var(--muted); }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); color: var(--text); outline: none; }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger .icon { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-label { font-size: 11.5px; font-weight: 600; color: var(--faint); padding: 8px 10px 6px; }

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px;
  padding: 3px; margin: 0 6px 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.segmented button {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font-size: 12.5px; font-weight: 550;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------- Pagina ---- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { display: flex; align-items: center; gap: 14px; }
.page-icon {
  width: 44px; height: 44px; display: grid; place-items: center; flex: none;
  border-radius: 13px; background: var(--brand-soft); color: var(--brand);
  border: 1px solid color-mix(in oklab, var(--brand) 20%, transparent);
}
.page-sub { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head p { color: var(--muted); font-size: 13px; }

.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

/* Card statistica */
.stat { position: relative; padding: 18px 20px; overflow: hidden; transition: transform .2s var(--ease), box-shadow .2s; }
.stat:hover { box-shadow: var(--shadow-md); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 520; }
.stat-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--tone-soft, var(--brand-soft)); color: var(--tone, var(--brand)); }
.stat-value { font-size: 30px; font-weight: 680; letter-spacing: -0.03em; margin-top: 10px; line-height: 1.1; }
.stat-meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.stat::after {
  content: ""; position: absolute; right: -40px; bottom: -60px; width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(closest-side, var(--tone-soft, var(--brand-soft)), transparent); pointer-events: none;
}
.tone-maschile { --tone: var(--cat-maschile); --tone-soft: color-mix(in oklab, var(--cat-maschile) 14%, transparent); }
.tone-femminile { --tone: var(--cat-femminile); --tone-soft: color-mix(in oklab, var(--cat-femminile) 14%, transparent); }
.tone-agonistica { --tone: var(--cat-agonistica); --tone-soft: color-mix(in oklab, var(--cat-agonistica) 16%, transparent); }
.tone-warning { --tone: var(--warning); --tone-soft: color-mix(in oklab, var(--warning) 14%, transparent); }
.tone-danger { --tone: var(--danger); --tone-soft: color-mix(in oklab, var(--danger) 13%, transparent); }
.tone-success { --tone: var(--success); --tone-soft: color-mix(in oklab, var(--success) 13%, transparent); }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 580; white-space: nowrap;
  color: var(--tone, var(--text-2));
  background: var(--tone-soft, var(--surface-2));
  border: 1px solid color-mix(in oklab, var(--tone, var(--text-2)) 18%, transparent);
}
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.tone-agonistica {
  background: linear-gradient(90deg, color-mix(in oklab, var(--cat-agonistica) 16%, transparent), color-mix(in oklab, var(--cat-agonistica-2) 14%, transparent));
}

/* Tabella semplice */
.table { width: 100%; border-collapse: collapse; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 10px 20px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.table td { padding: 12px 20px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.cell-person { display: flex; align-items: center; gap: 10px; }
.cell-person small { display: block; color: var(--muted); font-size: 12px; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.table-wrap { overflow-x: auto; }

/* Liste */
.list { list-style: none; margin: 0; padding: 6px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius-sm); }
.list-item:hover { background: var(--surface-2); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item small { color: var(--muted); display: block; font-size: 12px; }

/* Barre per categoria */
.bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--tone, var(--brand)); transform-origin: left; }
.tone-agonistica.bar > span, .bar.tone-agonistica > span { background: linear-gradient(90deg, var(--cat-agonistica), var(--cat-agonistica-2)); }

/* Empty state / in costruzione */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 56px 24px; gap: 14px;
}
.empty-art { width: 200px; height: auto; margin-bottom: 4px; }
.empty h2 { font-size: 19px; }
.empty p { color: var(--muted); max-width: 520px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 999px; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); }

/* -------------------------------------------------------------- Toast ---- */
.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 120;
  display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 40px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 14px 14px 16px;
  background: var(--glass); backdrop-filter: blur(16px) saturate(160%); -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.toast .icon { color: var(--tone, var(--info)); margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-body strong { display: block; font-size: 13.5px; font-weight: 620; }
.toast-body p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.toast-close { border: 0; background: transparent; color: var(--faint); padding: 2px; border-radius: 6px; }
.toast-close:hover { color: var(--text); background: var(--surface-2); }

/* ---------------------------------------------------- Command palette ---- */
.cmdk-overlay {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(20, 20, 20, 0.42);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 16px;
}
.cmdk-overlay[hidden] { display: none; }
.cmdk {
  width: min(640px, 100%);
  background: var(--glass); backdrop-filter: blur(24px) saturate(170%); -webkit-backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--border-strong); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.cmdk-input-wrap { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.cmdk-input-wrap .icon { color: var(--muted); }
.cmdk-input { flex: 1; height: 58px; border: 0; background: transparent; font-size: 16px; }
.cmdk-input::placeholder { color: var(--faint); }
.cmdk-results { max-height: min(420px, 55vh); overflow-y: auto; padding: 8px; }
.cmdk-group { font-size: 11.5px; font-weight: 600; color: var(--faint); padding: 10px 10px 6px; text-transform: uppercase; letter-spacing: .05em; }
.cmdk-item {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; color: var(--text-2);
  cursor: pointer;
}
.cmdk-item[aria-selected="true"] { background: var(--brand-soft); color: var(--text); }
.cmdk-item-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); flex: none; }
.cmdk-item[aria-selected="true"] .cmdk-item-icon { color: var(--brand); border-color: color-mix(in oklab, var(--brand) 30%, transparent); }
.cmdk-item-text { flex: 1; min-width: 0; }
.cmdk-item-text strong { display: block; font-size: 13.5px; font-weight: 560; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-item-text span { font-size: 12px; color: var(--muted); }
.cmdk-enter { opacity: 0; color: var(--muted); }
.cmdk-item[aria-selected="true"] .cmdk-enter { opacity: 1; }
.cmdk-empty { padding: 32px; text-align: center; color: var(--muted); }
.cmdk-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.cmdk-foot span { display: inline-flex; align-items: center; gap: 6px; }

/* ------------------------------------------------------------- Form ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 560; color: var(--text-2); display: flex; justify-content: space-between; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .icon { position: absolute; left: 13px; color: var(--faint); pointer-events: none; transition: color .15s; }
.input {
  width: 100%; height: 44px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 11px;
  font-size: 14px; color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.input-wrap > .icon + .input { padding-left: 40px; }
.input::placeholder { color: var(--faint); }
.input:hover { border-color: color-mix(in oklab, var(--text) 22%, transparent); }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.input-wrap:focus-within > .icon { color: var(--brand); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px color-mix(in oklab, var(--danger) 25%, transparent); }
.input-action { position: absolute; right: 6px; height: 32px; width: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.input-action:hover { background: var(--surface-2); color: var(--text); }
.field-error { font-size: 12.5px; color: var(--danger); min-height: 0; }

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--tone, var(--info));
  background: var(--tone-soft, color-mix(in oklab, var(--info) 10%, transparent));
  border: 1px solid color-mix(in oklab, var(--tone, var(--info)) 25%, transparent);
}
.alert p { color: var(--text); }

/* ------------------------------------------------------------- Login ---- */
.auth { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(420px, 1fr); min-height: 100vh; }
.auth-visual {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 40px 48px;
  color: #fff;
  background:
    radial-gradient(900px 500px at 15% 0%, color-mix(in oklab, var(--brand) 55%, #fff 0%), transparent 60%),
    linear-gradient(160deg, color-mix(in oklab, var(--brand) 92%, #1f1f1f) 0%, color-mix(in oklab, var(--brand) 45%, #161616) 55%, #0e0e0e 100%);
}
.auth-pitch { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 650; }
.auth-brand .brand-mark { background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .28); box-shadow: none; backdrop-filter: blur(8px); }
.auth-claim { max-width: 520px; }
.auth-claim h2 { color: #fff; font-size: clamp(28px, 3.2vw, 40px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.auth-claim p { color: rgba(255, 255, 255, .78); font-size: 15px; margin-top: 14px; max-width: 440px; }
.auth-features { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.auth-features span {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px;
  border-radius: 999px; font-size: 12.5px; font-weight: 550;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2);
  backdrop-filter: blur(10px);
}
.auth-foot { font-size: 12.5px; color: rgba(255, 255, 255, .6); }

.auth-panel { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 24px; position: relative; }
.auth-card { width: min(400px, 100%); }
.auth-logo { width: 56px; height: 56px; border-radius: 16px; font-size: 18px; margin-bottom: 22px; }
.auth-card h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; }
.auth-card .page-sub { margin: 6px 0 26px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-help { margin-top: 22px; font-size: 12.5px; color: var(--muted); text-align: center; }
.auth-theme { position: absolute; top: 20px; right: 20px; }
.auth-secure { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 28px; font-size: 12px; color: var(--faint); }

/* -------------------------------------------------------- Pagine errore ---- */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.error-box { text-align: center; max-width: 520px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.error-code {
  font-size: 92px; font-weight: 800; letter-spacing: -0.06em; line-height: 1;
  background: linear-gradient(180deg, var(--brand), color-mix(in oklab, var(--brand) 30%, var(--text)));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.error-box p { color: var(--muted); }
.error-debug { width: 100%; text-align: left; font: 12px/1.5 var(--font-mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; overflow: auto; max-height: 320px; white-space: pre-wrap; }

/* ----------------------------------------------------------- Motion ---- */
/* Prima che GSAP sia pronto il contenuto parte invisibile; se lo script non
   si carica, un'animazione CSS di sicurezza lo rende visibile comunque. */
html.motion-ok:not(.js-ready) [data-page] { opacity: 0; animation: reveal-fallback 0s 1.2s forwards; }
@keyframes reveal-fallback { to { opacity: 1; } }

.press { transition: transform .12s var(--ease); }
.press:active { transform: scale(.97); }

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

/* ------------------------------------------------------- Responsive ---- */
@media (max-width: 1180px) {
  .grid-2 { grid-template-columns: 1fr; }
  .search-trigger { width: 220px; }
  .user-btn-text { display: none; }
}

@media (max-width: 1023px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 288px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    transition: transform .3s var(--ease);
  }
  html.sb-aperta .sidebar { transform: none; }
  .sb-backdrop {
    display: block; position: fixed; inset: 0; z-index: 35;
    background: rgba(20, 20, 20, .45); opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s;
  }
  html.sb-aperta .sb-backdrop { opacity: 1; visibility: visible; }
  .sb-collapse-btn { display: none; }
  .topbar-menu { display: inline-flex; }
  .content { padding: 22px 20px 48px; }
  .auth { grid-template-columns: 1fr; }
  .auth-visual { min-height: 220px; padding: 28px 24px; }
  .auth-claim h2 { font-size: 26px; }
  .auth-claim p, .auth-features { display: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 12px; gap: 6px; }
  .breadcrumb { display: none; }
  .search-trigger { width: 38px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger .kbd { display: none; }
  .btn-new-label { display: none; }
  .content { padding: 18px 16px 40px; }
  h1 { font-size: 21px; }
  .stat-value { font-size: 26px; }
  .page-header { align-items: flex-start; }
  .table th, .table td { padding: 10px 14px; }
  .hide-sm { display: none; }
}

/* =============================================================================
   Fase 3 — Form multi-step, upload, dettaglio scheda, modali
   ============================================================================= */

.muted { color: var(--muted); }
.icon-flip { transform: scaleX(-1); }
.is-upper { text-transform: uppercase; }
.is-upper::placeholder { text-transform: none; }
.btn.is-danger { color: var(--danger); }
.btn.is-danger:hover { --btn-bg: color-mix(in oklab, var(--danger) 10%, transparent); }
.req { color: var(--danger); font-weight: 600; }
.field-help { font-size: 12px; color: var(--muted); }
.field.has-error .label { color: var(--danger); }
.field-warning { font-size: 12.5px; color: var(--warning); }

/* Griglia a 12 colonne */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px 16px; }
.form-grid > * { grid-column: span 12; }
.col-2 { grid-column: span 2 !important; } .col-3 { grid-column: span 3 !important; } .col-4 { grid-column: span 4 !important; }
.col-5 { grid-column: span 5 !important; } .col-6 { grid-column: span 6 !important; } .col-7 { grid-column: span 7 !important; }
.col-8 { grid-column: span 8 !important; } .col-12 { grid-column: span 12 !important; }

.select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px; background-repeat: no-repeat;
}
.textarea { height: auto; min-height: 92px; padding: 11px 14px; resize: vertical; line-height: 1.5; }
.input.is-readonly { display: flex; align-items: center; background: var(--surface-2); color: var(--text-2); font-weight: 600; box-shadow: none; }

/* Scelta a pulsanti (radio) */
.choice { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; min-height: 44px; }
.choice-item { flex: 1; position: relative; display: flex; }
.choice-item input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice-item span {
  flex: 1; display: grid; place-items: center; padding: 0 12px; border-radius: 9px;
  font-size: 13.5px; font-weight: 550; color: var(--muted); white-space: nowrap;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.choice-item input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.choice-item input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Interruttore */
.switch-row { display: flex; align-items: flex-start; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; transition: border-color .15s, background-color .15s; }
.switch-row:hover { border-color: var(--border-strong); }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; flex: none; width: 40px; height: 24px; border-radius: 999px; background: var(--surface-3); transition: background-color .2s; margin-top: 1px; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(43, 43, 43, .25); transition: transform .25s var(--ease); }
.switch-row input:checked + .switch { background: var(--brand); }
.switch-row input:checked + .switch::after { transform: translateX(16px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch-text strong { display: block; font-size: 13.5px; font-weight: 600; }
.switch-text span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.field.has-error .switch-row { border-color: var(--danger); }

/* Checklist */
.checklist { display: grid; gap: 8px; }
.check-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; font-size: 13.5px; transition: border-color .15s, background-color .15s; }
.check-item:hover { border-color: var(--border-strong); }
.check-item input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-item em { color: var(--muted); font-style: normal; }
.check-box { flex: none; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; color: transparent; background: var(--surface); transition: background-color .15s, border-color .15s, color .15s; }
.check-item input:checked ~ .check-box, .doc-check.is-done .check-box { background: var(--brand); border-color: var(--brand); color: #fff; }
.check-item input:checked ~ span:last-child { color: var(--text); }
.check-item:has(input:checked) { border-color: color-mix(in oklab, var(--brand) 35%, transparent); background: var(--brand-soft); }
.check-item input:focus-visible ~ .check-box { outline: 2px solid var(--brand); outline-offset: 2px; }
.check-item .badge { margin-left: auto; }

/* Upload */
.upload { display: flex; flex-direction: column; gap: 6px; }
.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.upload-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  min-height: 112px; padding: 18px; border: 1.5px dashed var(--border-strong); border-radius: 14px;
  background: var(--surface-2); color: var(--text-2); font-size: 13.5px; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.upload-drop small { color: var(--muted); font-size: 12px; }
.upload-drop u { color: var(--brand); text-decoration: none; font-weight: 600; }
.upload-drop:hover, .upload.is-dragover .upload-drop { border-color: var(--brand); background: var(--brand-soft); }
.upload-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); color: var(--brand); margin-bottom: 4px; }
.upload-file { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-xs); }
.upload-thumb { width: 44px; height: 44px; flex: none; border-radius: 10px; overflow: hidden; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.upload-thumb img { width: 100%; height: 100%; object-fit: cover; }
.upload-meta { flex: 1; min-width: 0; }
.upload-meta strong { display: block; font-size: 13.5px; font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-meta small { color: var(--muted); font-size: 12px; }
.upload-state .icon { color: var(--success); }
.upload.is-uploading .upload-state .icon { color: var(--brand); animation: spin .8s linear infinite; }

/* Wizard */
.wizard { display: flex; flex-direction: column; gap: 18px; padding-bottom: 96px; }
.wizard-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.wizard-title h1 { margin-top: 10px; }
.autosave { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; color: var(--muted); box-shadow: var(--shadow-xs); }
.autosave[data-state="saving"] .icon { color: var(--brand); animation: spin .8s linear infinite; }
.autosave[data-state="saved"] .icon { color: var(--success); }
.autosave[data-state="error"] { color: var(--danger); border-color: color-mix(in oklab, var(--danger) 30%, transparent); }
.autosave[data-state="dirty"] .icon { color: var(--warning); }

.stepper { position: relative; padding: 4px 0; }
.stepper ol { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); list-style: none; margin: 0; padding: 0; }
.stepper-track { position: absolute; left: 10%; right: 10%; top: 22px; height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.stepper-fill { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--brand), color-mix(in oklab, var(--brand) 60%, #8b5cf6)); transform-origin: left; transform: scaleX(0); }
.stepper-item { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; padding: 0; color: var(--muted); font-size: 12.5px; font-weight: 550; }
.stepper-dot { position: relative; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1.5px solid var(--border-strong); font-weight: 650; color: var(--muted); transition: border-color .25s, background-color .25s, color .25s, box-shadow .25s; }
.stepper-check { display: none; }
.stepper-item.is-done .stepper-dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.stepper-item.is-done .stepper-num { display: none; }
.stepper-item.is-done .stepper-check { display: block; }
.stepper-item.is-current .stepper-dot { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 5px var(--brand-soft); }
.stepper-item.is-current { color: var(--text); }
.stepper-item.has-error .stepper-dot { border-color: var(--danger); color: var(--danger); box-shadow: 0 0 0 5px color-mix(in oklab, var(--danger) 14%, transparent); }
.stepper-item.has-error .stepper-check { display: none; }
.stepper-item.has-error .stepper-num { display: block; }

.wizard-body { position: relative; }
.step { padding: 26px 28px 28px; }
.step-head { margin-bottom: 22px; }
.step-head p { color: var(--muted); margin-top: 4px; }
.step-section { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--border); }
.step-section h3 { margin-bottom: 12px; }
.step-note { color: var(--muted); font-size: 13px; margin: -6px 0 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h3 { margin: 0; }
.cf-hint { align-self: end; font-size: 12.5px; color: var(--warning); padding-bottom: 12px; }

.parent-block { padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.parent-block + .parent-block { margin-top: 14px; }
.parent-block h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.parent-block-head { display: flex; align-items: center; justify-content: space-between; }
.add-parent { margin-top: 14px; border-style: dashed; }

.quota-card { display: grid; grid-template-columns: 1.3fr 1fr 1fr; margin-top: 20px; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--surface); }
.quota-card > div { padding: 16px 20px; display: flex; flex-direction: column; gap: 2px; }
.quota-card > div + div { border-left: 1px solid var(--border); }
.quota-card span { font-size: 12.5px; color: var(--muted); }
.quota-card strong { font-size: 22px; font-weight: 680; letter-spacing: -0.02em; }
.quota-card small { font-size: 12px; color: var(--muted); }
.quota-netta { background: var(--brand-soft); }
.quota-netta strong { color: var(--brand-strong); }

.rate-table td { padding: 8px 12px; }
.rate-table th { padding: 10px 12px; }
.rate-table .input { height: 38px; font-size: 13.5px; }
.rate-table tfoot th, .rate-table tfoot td { background: var(--surface-2); font-weight: 650; padding: 12px; }
.rate-table .rate-diff { color: var(--danger); font-weight: 600; margin-left: 8px; }
.rate-state { display: flex; gap: 4px; }
.rate-state .choice { min-height: 38px; padding: 3px; }

.summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.summary-block { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.summary-block h4 { display: flex; align-items: center; justify-content: space-between; margin: 0; padding: 10px 14px; font-size: 13px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.summary-block h4 button { border: 0; background: none; color: var(--brand); font-weight: 600; font-size: 12.5px; padding: 0; }
.summary-block dl { margin: 0; padding: 6px 14px 10px; }
.summary-block dl div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.summary-block dl div:last-child { border-bottom: 0; }
.summary-block dt { color: var(--muted); }
.summary-block dd { margin: 0; text-align: right; font-weight: 550; }

.wizard-foot {
  position: fixed; left: var(--sb-w); right: 0; bottom: 0; z-index: 25;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 32px calc(14px + env(safe-area-inset-bottom));
  background: var(--glass); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--border);
}
.wizard-step-count { font-size: 12.5px; color: var(--muted); }
.wizard-actions { margin-left: auto; display: flex; gap: 8px; }

/* Scelta modulo */
.module-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.module-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 24px; overflow: hidden; transition: box-shadow .2s, border-color .2s, transform .2s var(--ease); }
.module-card:hover { box-shadow: var(--shadow-lg); border-color: color-mix(in oklab, var(--tone) 35%, transparent); transform: translateY(-2px); }
.module-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--tone); }
.module-card.tone-agonistica::before { background: linear-gradient(90deg, var(--cat-agonistica), var(--cat-agonistica-2)); }
.module-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); }
.module-card .badge { align-self: flex-start; }
.module-card p { color: var(--muted); }
.module-price { display: flex; flex-direction: column; padding: 12px 0; border-top: 1px solid var(--border); margin-top: 4px; }
.module-price strong { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.module-price span { font-size: 12.5px; color: var(--muted); }
.module-rate { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.module-rate li { display: flex; justify-content: space-between; gap: 10px; color: var(--text-2); }
.module-rate li span:last-child { color: var(--muted); text-align: right; }
.module-cta { margin-top: auto; padding-top: 10px; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--tone); }

/* Dettaglio scheda */
.detail-hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px; flex-wrap: wrap; }
.detail-person { display: flex; align-items: center; gap: 18px; min-width: 0; }
.detail-photo { width: 76px; height: 76px; border-radius: 20px; object-fit: cover; flex: none; box-shadow: var(--shadow-md); }
.detail-initials { display: grid; place-items: center; font-size: 24px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--tone), color-mix(in oklab, var(--tone) 55%, #1f1f1f)); }
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.detail-main, .detail-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stat-value-sm { margin-top: 12px; }
.tone-muted { --tone: var(--muted); --tone-soft: var(--surface-2); }
.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; padding: 4px 20px 12px; }
.dl > div { padding: 10px 0; border-bottom: 1px solid var(--border); }
.dl > div:nth-last-child(-n+2) { border-bottom: 0; }
.dl dt { font-size: 12px; color: var(--muted); }
.dl dd { margin: 2px 0 0; font-size: 13.5px; font-weight: 520; word-break: break-word; }
.dl-stack { grid-template-columns: 1fr; }
.dl-stack > div:nth-last-child(-n+2) { border-bottom: 1px solid var(--border); }
.dl-stack > div:last-child { border-bottom: 0; }
.doc-check .check-box { color: transparent; }
.doc-check:not(.is-done) .grow { color: var(--muted); }
.file-list { display: grid; gap: 8px; padding-top: 4px; }
.file-chip { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; transition: border-color .15s, background-color .15s; }
.file-chip:hover { border-color: var(--border-strong); background: var(--surface-2); }
.file-chip .icon { color: var(--brand); }
.file-chip strong { display: block; font-size: 13px; }
.file-chip small { display: block; font-size: 12px; color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline { list-style: none; margin: 0; padding: 12px 20px 16px; position: relative; }
.timeline li { position: relative; padding: 0 0 14px 20px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.timeline li::after { content: ""; position: absolute; left: 3.5px; top: 18px; bottom: 0; width: 1px; background: var(--border-strong); }
.timeline li:last-child::after { display: none; }
.timeline strong { display: block; font-weight: 600; }
.timeline span { color: var(--muted); font-size: 12px; }

/* Modale di conferma */
.modal-overlay { position: fixed; inset: 0; z-index: 130; display: grid; place-items: center; padding: 16px; background: rgba(20, 20, 20, .45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal { width: min(440px, 100%); padding: 24px; background: var(--glass); backdrop-filter: blur(24px) saturate(170%); -webkit-backdrop-filter: blur(24px) saturate(170%); border: 1px solid var(--border-strong); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); }
.modal-icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; margin-bottom: 14px; background: var(--tone-soft, var(--brand-soft)); color: var(--tone, var(--brand)); }
.modal h2 { font-size: 18px; }
.modal p { color: var(--muted); margin-top: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: transparent; }
.btn-danger:hover { --btn-bg: color-mix(in oklab, var(--danger) 85%, #000); }

@media (max-width: 1180px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1023px) {
  .wizard-foot { left: 0; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); }
  .stepper-label { display: none; }
}
@media (max-width: 760px) {
  .form-grid > [class*="col-"] { grid-column: span 12 !important; }
  .form-grid > .col-2, .form-grid > .col-3, .form-grid > .col-4 { grid-column: span 6 !important; }
  .step { padding: 20px 16px; }
  .summary, .upload-grid, .dl { grid-template-columns: 1fr; }
  .dl > div:nth-last-child(2) { border-bottom: 1px solid var(--border); }
  .quota-card { grid-template-columns: 1fr; }
  .quota-card > div + div { border-left: 0; border-top: 1px solid var(--border); }
  .wizard-step-count { display: none; }
  .wizard-foot .btn { padding: 0 12px; }
  .stepper-dot { width: 34px; height: 34px; }
  .stepper-track { top: 19px; }
}

/* =============================================================================
   Fase 4 — Archivio schede, drawer filtri, skeleton, grafico dashboard
   ============================================================================= */

.avatar-sm { width: 32px; height: 32px; font-size: 11.5px; box-shadow: none; }
.avatar-lg { width: 52px; height: 52px; font-size: 16px; border-radius: 16px; }
.avatar.tone-maschile, .avatar.tone-femminile, .avatar.tone-agonistica { background: linear-gradient(135deg, var(--tone), color-mix(in oklab, var(--tone) 60%, #1f1f1f)); }
.avatar-img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; display: block; }
.avatar-img.avatar-lg { width: 52px; height: 52px; border-radius: 16px; }
.badge-inline { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; color: var(--tone, var(--muted)); }
.input-sm { height: 32px; font-size: 13px; border-radius: 8px; padding: 0 30px 0 10px; background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px; }

a.stat-link { display: block; color: inherit; }
a.stat-link:hover { border-color: color-mix(in oklab, var(--tone, var(--brand)) 35%, transparent); transform: translateY(-2px); }

/* Toolbar */
.archive { display: flex; flex-direction: column; gap: 14px; }
.archive-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; flex-wrap: wrap; }
.archive-tools { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; min-width: 280px; }
.archive-search { flex: 1; max-width: 420px; }
.archive-search .input { height: 40px; }

.segmented-lg { margin: 0; padding: 4px; grid-auto-columns: auto; }
.segmented-lg button { height: 34px; padding: 0 14px; font-size: 13.5px; gap: 8px; }
.segmented-lg .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tone); }
.segmented-lg .count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-3); border-radius: 999px; padding: 1px 7px; min-width: 22px; text-align: center; }
.segmented-lg button[aria-pressed="true"] .count { background: var(--brand-soft); color: var(--brand-strong); }
.segmented-icons { margin: 0; padding: 3px; }
.segmented-icons button { width: 36px; height: 32px; }
.count-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 700; }

/* Barra selezione */
.selection-bar {
  position: sticky; top: calc(var(--topbar-h) + 10px); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px 10px 18px; border-radius: 14px;
  background: color-mix(in oklab, var(--brand) 92%, #1f1f1f); color: #fff;
  box-shadow: 0 12px 30px -10px var(--brand-ring);
}
.selection-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.selection-bar .btn { --btn-bg: rgba(255, 255, 255, .14); --btn-fg: #fff; --btn-bd: rgba(255, 255, 255, .22); box-shadow: none; }
.selection-bar .btn:hover { --btn-bg: rgba(255, 255, 255, .24); }

/* Risultati */
.archive-results { position: relative; overflow: hidden; }
.archive-results.is-loading [data-pannello] { opacity: .45; transition: opacity .2s; }
.archive-table th { white-space: nowrap; }
.archive-table td { padding-top: 10px; padding-bottom: 10px; }
.archive-table tbody tr { cursor: pointer; }
.archive-table tbody tr.is-selected, .scheda-card.is-selected { background: var(--brand-soft); }
.cell-check { width: 44px; padding-right: 0 !important; }
.cell-photo { width: 48px; padding-right: 0 !important; }
.cell-name { font-weight: 600; color: var(--text); display: block; }
.cell-name:hover { color: var(--brand-strong); }
.cell-stack { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.cell-stack small { font-size: 11.5px; color: var(--muted); }
.cell-actions { display: inline-flex; gap: 2px; white-space: nowrap; }
.archive-table .cell-actions { opacity: .55; transition: opacity .15s; }
.archive-table tr:hover .cell-actions, .archive-table tr:focus-within .cell-actions { opacity: 1; }
.th-sort { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; font: inherit; color: inherit; }
.th-sort .icon { opacity: 0; transition: opacity .15s, transform .2s var(--ease); }
.th-sort:hover .icon { opacity: .5; }
.th-sort.is-active { color: var(--text); }
.th-sort.is-active .icon { opacity: 1; color: var(--brand); }
.th-sort.is-asc .icon { transform: rotate(180deg); }

.mini-check { position: relative; display: inline-flex; cursor: pointer; }
.mini-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mini-check input:checked + .check-box { background: var(--brand); border-color: var(--brand); color: #fff; }
.mini-check input:indeterminate + .check-box { background: var(--brand); border-color: var(--brand); }
.mini-check input:indeterminate + .check-box::after { content: ""; width: 8px; height: 2px; border-radius: 2px; background: #fff; position: absolute; }
.mini-check input:indeterminate + .check-box .icon { display: none; }
.mini-check input:focus-visible + .check-box { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Card */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; padding: 16px; }
.scheda-card { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 16px; cursor: pointer; overflow: hidden; box-shadow: var(--shadow-xs); transition: box-shadow .2s, transform .2s var(--ease), border-color .2s; }
.scheda-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--tone); }
.scheda-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.scheda-card-top { display: flex; align-items: center; justify-content: space-between; }
.scheda-card-person { display: flex; align-items: center; gap: 12px; }
.scheda-card-person > div { flex: 1; min-width: 0; }
.scheda-card-person small { display: block; font-size: 12px; }
.scheda-card-stati { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; padding: 12px 0; border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); }
.scheda-card-stati dt { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.scheda-card-stati dd { margin: 0; }
.scheda-card-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }

/* Skeleton */
.skeleton { position: absolute; inset: 52px 0 0; z-index: 2; padding: 6px 20px; background: color-mix(in oklab, var(--surface) 70%, transparent); }
.skeleton-row { display: grid; grid-template-columns: 24px 110px 1.4fr 1fr 1fr; gap: 20px; align-items: center; height: 56px; border-bottom: 1px solid var(--border); }
.skeleton-row span { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton-row span:first-child { width: 18px; height: 18px; border-radius: 5px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Piè di pagina e paginazione */
.archive-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager-info { display: flex; align-items: center; gap: 18px; font-size: 13px; color: var(--muted); }
.pager-per { display: inline-flex; align-items: center; gap: 8px; }
.pager-per .input { width: 74px; }
.pager { display: flex; align-items: center; gap: 4px; }
.pager .btn { min-width: 32px; padding: 0 8px; }
.pager .btn.is-current { --btn-bg: var(--brand); --btn-fg: #fff; --btn-bd: transparent; }
.pager-gap { color: var(--faint); padding: 0 2px; }

/* Drawer */
.drawer-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(20, 20, 20, .4); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 95; width: min(420px, 100vw);
  background: var(--glass); backdrop-filter: blur(24px) saturate(170%); -webkit-backdrop-filter: blur(24px) saturate(170%);
  border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
}
.drawer-form { display: flex; flex-direction: column; height: 100%; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); }
.drawer-head p { font-size: 13px; margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 20px; }
.drawer-foot { display: flex; justify-content: space-between; gap: 8px; padding: 14px 22px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.filter-group { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
.filter-group legend { margin-bottom: 8px; }
.check-compact { padding: 9px 12px; }
.range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Dashboard e grafico */
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.dashboard-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.list a.list-item { color: inherit; }
.list .list-item strong { font-size: 13.5px; font-weight: 600; }
.chart-card { min-width: 0; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; list-style: none; margin: 0; padding: 14px 20px 0; font-size: 13px; color: var(--text-2); }
.chart-legend li { display: inline-flex; align-items: center; gap: 8px; }
.chart-legend strong { color: var(--text); }
.swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--tone); display: inline-block; flex: none; }
.chart-wrap { position: relative; padding: 8px 14px 6px 6px; }
.chart-wrap svg { width: 100%; height: auto; overflow: visible; }
.chart-grid line { stroke: var(--border); stroke-width: 1; }
.chart-grid line.baseline { stroke: var(--border-strong); }
.chart-grid text, .chart-x { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.seg { fill: var(--tone); }
.chart-hit { fill: transparent; cursor: pointer; outline: none; }
.chart-hit.is-hover, .chart-hit:focus-visible { fill: color-mix(in oklab, var(--text) 5%, transparent); }
.chart-tooltip {
  position: absolute; left: 0; top: 0; z-index: 5; min-width: 180px; pointer-events: none;
  display: flex; flex-direction: column; gap: 4px; padding: 10px 12px;
  background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-md); font-size: 12.5px;
}
.chart-tooltip strong { font-size: 13px; margin-bottom: 2px; }
.chart-tooltip span { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.chart-tooltip b { margin-left: auto; color: var(--text); font-weight: 650; }
.chart-tooltip .swatch { width: 8px; height: 8px; }
.chart-tooltip-total { border-top: 1px solid var(--border); padding-top: 4px; margin-top: 2px; font-weight: 600; }

@media (max-width: 1180px) {
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .archive-tools { min-width: 0; width: 100%; }
  .segmented-lg { width: 100%; overflow-x: auto; }
  .segmented-lg button { padding: 0 10px; }
  .archive-table .hide-sm, .archive-table td:nth-child(3), .archive-table th:nth-child(3) { display: none; }
  .pager-info { gap: 10px; flex-wrap: wrap; }
}

.archive-table th, .archive-table td { padding-left: 12px; padding-right: 12px; }
.archive-table .mono, .archive-table .num { white-space: nowrap; }
.archive-table td:nth-child(4) { min-width: 180px; }
@media (max-width: 1440px) {
  .archive-table th:nth-child(9), .archive-table td:nth-child(9) { display: none; }
}

@media (max-width: 760px) {
  .chart-grid text, .chart-x { font-size: 17px; }
  .chart-tooltip { min-width: 160px; font-size: 12px; }
}

/* =============================================================================
   Fase 5 — Anagrafiche generiche, editor schemi, import, calendario
   ============================================================================= */

.toolbar-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter-select { width: auto; min-width: 150px; max-width: 220px; }
.filter-range { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.filter-range .input { width: 112px; padding-right: 10px; }
.registry-table .cell-main { min-width: 200px; }
.registry-table tbody tr[data-modifica] { cursor: pointer; }
.cell-person { display: flex; align-items: center; gap: 10px; }
.cell-person small { display: block; font-size: 11.5px; }
.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: 0; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border-strong); }
.count-link { font-weight: 650; color: var(--brand-strong); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in oklab, var(--brand) 40%, transparent); }
tr.is-flash td { animation: flash-row 1.6s var(--ease); }
@keyframes flash-row { 0%, 30% { background: var(--brand-soft); } 100% { background: transparent; } }
.btn.is-active { --btn-bg: var(--brand-soft); --btn-fg: var(--brand-strong); --btn-bd: color-mix(in oklab, var(--brand) 35%, transparent); }

.drawer-wide { width: min(560px, 100vw); }
.drawer-section { border: 0; margin: 0; padding: 0; }
.drawer-section + .drawer-section { padding-top: 20px; border-top: 1px solid var(--border); }
.drawer-section legend { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 12px; }
.drawer .form-grid { gap: 14px 12px; }
.color-field { display: flex; gap: 8px; }
.color-swatch { width: 44px; height: 44px; padding: 3px; border: 1px solid var(--border-strong); border-radius: 11px; background: var(--surface); cursor: pointer; }
.color-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.color-swatch::-webkit-color-swatch { border: 0; border-radius: 8px; }
.input-wrap.has-suffix .input { padding-right: 34px; }
.input-suffix { position: absolute; right: 14px; color: var(--muted); font-size: 13px; pointer-events: none; }
.input[type="time"] { padding-right: 10px; }

/* Editor schemi */
.pitch-editor { display: flex; flex-direction: column; gap: 10px; }
.pitch { width: 100%; max-width: 320px; margin: 0 auto; display: block; touch-action: none; user-select: none; }
.pitch-grass { fill: #15803d; }
:root[data-theme="dark"] .pitch-grass { fill: #14532d; }
.pitch .pitch-lines { stroke: rgba(255, 255, 255, .7); stroke-width: .5; }
.player { cursor: grab; outline: none; }
.player circle { fill: #fff; stroke: var(--brand-strong); stroke-width: .9; transition: r .15s; }
.player.is-keeper circle { fill: #facc15; stroke: #854d0e; }
.player text { font: 700 3.6px var(--font); fill: #1f1f1f; pointer-events: none; }
.player.is-dragging { cursor: grabbing; }
.player.is-dragging circle, .player:focus-visible circle { r: 5.6; stroke-width: 1.2; }
.pitch-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* Import */
.import { display: flex; flex-direction: column; gap: 16px; }
.import-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.import-step { display: flex; gap: 16px; padding: 22px; }
.import-num { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--brand-soft); color: var(--brand-strong); }
.import-step-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.import-step-body .upload { width: 100%; }
.import-loading { display: flex; align-items: center; gap: 10px; padding: 26px; justify-content: center; border: 1.5px dashed var(--brand); border-radius: 14px; background: var(--brand-soft); color: var(--brand-strong); font-weight: 550; }
.spin { animation: spin .8s linear infinite; }
.import-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.import-totals > div { padding: 14px 20px; display: flex; flex-direction: column; gap: 2px; color: var(--tone, var(--text)); }
.import-totals > div + div { border-left: 1px solid var(--border); }
.import-totals span { font-size: 12.5px; color: var(--muted); }
.import-totals strong { font-size: 22px; font-weight: 700; }
.tone-info { --tone: var(--info); }
.import-table-wrap { max-height: 420px; overflow-y: auto; }
.import-table thead th { position: sticky; top: 0; z-index: 1; }
.import-table td:first-child { width: 70px; }
.import-table td:nth-child(2) { width: 120px; }
.import-table tr.has-error td { background: color-mix(in oklab, var(--danger) 5%, transparent); }
.import-errors { margin: 0; padding-left: 18px; color: var(--danger); font-size: 12.5px; display: grid; gap: 2px; }
.import-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.switch-compact { padding: 8px 12px; align-items: center; }
.result-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: color-mix(in oklab, var(--success) 14%, transparent); color: var(--success); }
.import-result-errors { width: 100%; max-width: 640px; text-align: left; }
.import-result-errors summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }

/* Calendario */
.calendar { display: flex; flex-direction: column; gap: 14px; }
.calendar-nav { display: flex; align-items: center; gap: 8px; }
.calendar-title { font-size: 17px; margin-left: 8px; }
.calendar-legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); }
.calendar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: start; }
.day { padding: 10px; min-height: 220px; display: flex; flex-direction: column; gap: 8px; }
.day.is-today { border-color: color-mix(in oklab, var(--brand) 45%, transparent); box-shadow: 0 0 0 3px var(--brand-soft); }
.day-head { display: flex; align-items: baseline; justify-content: space-between; padding: 2px 4px 6px; border-bottom: 1px solid var(--border); }
.day-name { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.day-num { font-size: 20px; font-weight: 700; }
.day.is-today .day-num { color: var(--brand); }
.day-events { display: flex; flex-direction: column; gap: 6px; }
.day-empty { font-size: 12px; color: var(--faint); text-align: center; padding: 18px 0; }
.event { position: relative; padding: 8px 9px 8px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.event::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--tone, var(--brand)); }
.event strong { font-size: 12.5px; font-weight: 620; line-height: 1.3; }
.event small { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 11.5px; }
.event-time { display: flex; align-items: center; gap: 5px; font-weight: 650; color: var(--text-2); font-size: 11.5px; }
.event-turno { background: transparent; border-style: dashed; }
.event-partita { background: color-mix(in oklab, var(--warning) 9%, var(--surface)); }
.event-allenamento { background: color-mix(in oklab, var(--tone, var(--brand)) 8%, var(--surface)); }

@media (max-width: 1280px) {
  .week { grid-template-columns: repeat(7, 200px); overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
  .day { scroll-snap-align: start; }
}
@media (max-width: 760px) {
  .import-steps { grid-template-columns: 1fr; }
  .import-totals { grid-template-columns: repeat(2, 1fr); }
  .week { grid-template-columns: 1fr; overflow: visible; }
  .day { min-height: 0; }
}

@media print {
  .sidebar, .topbar, .page-actions, .calendar-toolbar .toolbar-filters, .calendar-nav .btn, .toasts, .sb-backdrop { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .week { grid-template-columns: repeat(7, 1fr); gap: 4px; overflow: visible; }
  .card { box-shadow: none; }
  [data-page] { opacity: 1 !important; }
}

/* Fase 6 — righe annidate, totali, magazzino */
.repeater { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.repeater-head, .repeater-row { display: grid; grid-template-columns: 28px 1.3fr 1fr 1fr 36px; gap: 8px; align-items: start; padding: 8px 10px; }
.repeater-head { background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 11.5px; font-weight: 600; color: var(--muted); }
.repeater-row + .repeater-row { border-top: 1px dashed var(--border); }
.repeater-num { align-self: center; font-weight: 650; color: var(--muted); text-align: center; }
.repeater-cell .input { height: 36px; }
.repeater-cell.has-error .input { border-color: var(--danger); }
.repeater-cell .field-error { font-size: 11.5px; }
.repeater-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border-top: 1px solid var(--border); background: var(--surface-2); }
.repeater-sum { font-size: 13px; font-weight: 600; }
.repeater-sum .ok { color: var(--success); }
.repeater-rows:empty::before { content: "Nessuna rata: aggiungine almeno una oppure lascia vuoto per il solo pagamento in unica soluzione."; display: block; padding: 14px; font-size: 12.5px; color: var(--muted); }

.totals { display: flex; flex-wrap: wrap; gap: 10px; }
.total-chip { display: flex; flex-direction: column; gap: 2px; padding: 12px 18px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-xs); min-width: 160px; }
.total-chip span { font-size: 12.5px; color: var(--muted); }
.total-chip strong { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }

.qty { font-weight: 700; }
.qty-in { color: var(--success); }
.qty-out { color: var(--danger); }

@media (max-width: 760px) {
  .repeater-head { display: none; }
  .repeater-row { grid-template-columns: 24px 1fr 36px; }
  .repeater-row .repeater-cell { grid-column: 2; }
}

/* ==========================================================================
   Fase 7 — Attività e Amministrazione
   ========================================================================== */
.tone-entrate { --tone: var(--fin-entrate); --tone-soft: color-mix(in oklab, var(--fin-entrate) 14%, transparent); }
.tone-uscite { --tone: var(--fin-uscite); --tone-soft: color-mix(in oklab, var(--fin-uscite) 14%, transparent); }
.bar.tone-entrate > span, .bar.tone-uscite > span { background: var(--tone); }

/* Importi con segno: il colore accompagna segno e icona, mai da solo */
.mov { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.mov-icon { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; flex: none; }
.mov-in .mov-icon { background: color-mix(in oklab, var(--success) 14%, transparent); color: var(--success); }
.mov-out .mov-icon { background: color-mix(in oklab, var(--danger) 12%, transparent); color: var(--danger); }
.mov-transfer .mov-icon { background: var(--surface-3); color: var(--text-2); }
.mov-out .num { color: var(--text); }
td.mov-in { color: var(--success); }
td.mov-out { color: var(--text-2); }
.mov-dest { display: block; margin-top: 2px; }
.amount-strong { font-weight: 700; }
.is-negative { color: var(--danger); }
.total-chip.is-positive strong { color: var(--success); }
.total-chip.is-negative strong { color: var(--danger); }

/* Risultato partita */
.score { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.score strong { font-size: 15px; letter-spacing: 0.02em; }
.score .badge { min-width: 24px; justify-content: center; padding: 0 6px; }

/* Bilancio */
.bilancio-filtri { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 14px 18px; }
.bilancio-filtri .field { width: 170px; margin: 0; }
.bilancio-rapidi { display: flex; flex-wrap: wrap; gap: 6px; margin-right: auto; padding-bottom: 4px; }
.bilancio-rapidi .chip { text-decoration: none; transition: background .15s, color .15s; }
.bilancio-rapidi .chip:hover { background: var(--brand-soft); color: var(--brand-strong); }
.bilancio-voci { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.table-compact th, .table-compact td { padding-top: 10px; padding-bottom: 10px; }
.table-compact tbody th { font-weight: 500; }
.table-compact td small { display: block; font-size: 11.5px; }
.table tfoot th, .table tfoot td { border-top: 1px solid var(--border-strong); font-weight: 600; }
.voce-nome { display: flex; gap: 8px; align-items: baseline; }
.bar-thin { display: block; height: 4px; margin-top: 6px; max-width: 240px; }
.cell-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; font-weight: 550; }
.cell-link:hover { color: var(--brand-strong); text-decoration: underline; }
.empty-inline { padding: 18px 20px; margin: 0; }
.stat-value.num { font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .bilancio-filtri .field { width: calc(50% - 8px); }
  .bilancio-filtri .btn { width: 100%; justify-content: center; }
}
/* Prima colonna con un codice (es. numero fattura): niente larghezza minima */
.registry-table td.cell-main:has(> .mono) { min-width: 0; white-space: nowrap; }

/* ==========================================================================
   Fase 8 — Società, utenti e profilo
   ========================================================================== */

/* Allegati nel drawer */
.attachment { display: flex; flex-direction: column; gap: 8px; }
.attachment-drop {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; padding: 14px;
  border: 1.5px dashed var(--border-strong); border-radius: 14px; background: var(--surface-2);
  color: var(--text-2); font-size: 13px; cursor: pointer; transition: border-color .15s, background-color .15s;
}
.attachment-drop:hover, .attachment-drop.is-over, .attachment-drop:focus-within { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }
.attachment-drop.is-loading { pointer-events: none; opacity: .7; }
.attachment-file { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 10px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-xs); }
.attachment-thumb { width: 44px; height: 44px; flex: none; border-radius: 10px; overflow: hidden; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); }
.attachment-thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.attachment-ext { font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.attachment-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 560; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.attachment-name:hover { color: var(--brand-strong); text-decoration: underline; }
.file-chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: 11.5px; font-weight: 650; text-decoration: none; }
.file-chip:hover { border-color: var(--brand); color: var(--brand-strong); }

/* Pagine impostazioni (Parametri, Profilo) */
.notice { display: flex; align-items: center; gap: 10px; padding: 12px 16px; margin-bottom: 16px; border-radius: 14px; background: var(--tone-soft, var(--brand-soft)); color: var(--text); border: 1px solid color-mix(in oklab, var(--tone, var(--brand)) 30%, transparent); font-size: 13.5px; }
.notice .icon { color: var(--tone, var(--brand)); }
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 16px; align-items: start; }
.settings-main, .settings-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.settings-side { position: sticky; top: 84px; }
.settings-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.settings-fieldset[disabled] { opacity: .85; }
.settings-card { padding: 20px 22px 22px; }
.settings-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.settings-head h2 { font-size: 16px; }
.settings-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.settings-icon { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); }
.settings-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.settings-note { font-size: 12.5px; margin-top: 14px; }
.season-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.season-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); font-size: 13px; }
.season-list li .badge { margin-left: auto; }
.season-form { padding-top: 14px; border-top: 1px solid var(--border); }
.brand-preview { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.brand-preview strong { display: block; font-size: 14px; }
.brand-preview small { font-size: 12px; }
.brand-mark img { background: #fff; }

/* Robustezza password */
.strength { display: flex; align-items: center; gap: 12px; }
.strength-bar { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.strength-bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--danger); transition: width .3s ease, background-color .3s; }
.strength-bar span[data-livello="2"] { background: var(--warning); }
.strength-bar span[data-livello="3"], .strength-bar span[data-livello="4"] { background: var(--success); }
.strength-text { font-size: 12.5px; min-width: 150px; text-align: right; }
.timeline-icons { padding: 0; }
.timeline-icons li { padding-left: 34px; }
.timeline-icons li::before { display: none; }
.timeline-icons li::after { left: 11px; top: 26px; }
.timeline-icons .timeline-icon { position: absolute; left: 0; top: 0; width: 23px; height: 23px; border-radius: 8px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); }
.timeline-icons small { display: block; font-size: 12px; }
.timeline-icons div { min-width: 0; }

/* Archivio documenti */
.docs-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.docs-folders { padding: 8px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 84px; }
.docs-folder { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-size: 13.5px; transition: background-color .15s, color .15s; }
.docs-folder span:nth-of-type(1) { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.docs-folder:hover { background: var(--surface-2); color: var(--text); }
.docs-folder.is-active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.docs-count { font-size: 12px; color: var(--muted); }
.docs-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.docs-toolbar .archive-search { flex: 1; }
.docs-drop { padding: 18px 20px 20px; }
.docs-drop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.docs-drop-head h2 { font-size: 16px; }
.docs-upload { min-height: 140px; }
.docs-upload.is-over { border-color: var(--brand); background: var(--brand-soft); }
.docs-queue { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.docs-queue-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.docs-queue-item span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.docs-queue-item.is-ok .icon { color: var(--success); }
.docs-queue-item.is-error { background: color-mix(in oklab, var(--danger) 10%, transparent); }
.docs-queue-item.is-error .icon, .docs-queue-item.is-error small { color: var(--danger); }
.doc-name { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: 0; }
.doc-name strong { font-weight: 600; }
.doc-name:hover strong { color: var(--brand-strong); text-decoration: underline; }
.doc-icon { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.doc-icon.ext-pdf { color: var(--danger); }
.doc-icon.ext-xlsx, .doc-icon.ext-ods { color: var(--success); }
.doc-icon.ext-docx, .doc-icon.ext-odt { color: var(--info); }
.docs-table td { vertical-align: middle; }

/* Registro attività */
.registro-filtri { justify-content: flex-start; }
.registro-filtri .archive-search { flex: 1 1 220px; }
.registro-filtri .select { width: auto; min-width: 170px; }
.input-date { width: 140px; }
.registro-campi { display: block; margin-top: 2px; font-size: 12px; }
.pagination { display: flex; align-items: center; gap: 10px; }

@media (max-width: 1100px) {
  .settings-layout, .docs-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-side, .docs-folders { position: static; }
  .docs-folders { flex-direction: row; overflow-x: auto; }
  .docs-folder { flex: none; }
}
.docs-folders { min-width: 0; }
.docs-toolbar { min-width: 0; }
/* I <caption class="sr-only"> (assoluti) restano dentro il contenitore che scorre */
.table-wrap { position: relative; }

/* Login: su PC il pallone sta sopra il titolo; su tablet e telefono resta nella posizione originale */
.pitch-trail-desktop { display: none; }
@media (min-width: 1024px) {
  .pitch-ball-pos { transform: translate(80px, -145px); }
  .pitch-trail-mobile { display: none; }
  .pitch-trail-desktop { display: inline; }
}

/* Logo caricato (spesso a sfondo trasparente): niente riquadro colorato dietro */
.brand-mark:has(img) { background: transparent; box-shadow: none; border-radius: 0; }
.brand-mark:has(img) img { background: transparent; border-radius: 0; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .18)); }
.auth-logo:has(img) { width: 88px; height: 88px; }
.auth-brand .brand-mark:has(img) { width: 52px; height: 52px; background: transparent; border: 0; backdrop-filter: none; }
aside .brand-mark:has(img), .sidebar .brand-mark:has(img) { width: 40px; height: 40px; }

/* ==========================================================================
   Scadenzario, avvisi, spazi pubblicitari, piano rate annuale
   ========================================================================== */

/* Campanella nella topbar */
.bell-btn { position: relative; }
.bell-count {
  position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; display: grid; place-items: center;
  background: var(--warning); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 1;
  box-shadow: 0 0 0 2px var(--surface);
}
.bell-count.is-danger { background: var(--danger); }
.menu-avvisi { width: min(360px, calc(100vw - 24px)); }
.menu-empty { padding: 10px 12px; font-size: 13px; margin: 0; }
.avviso { align-items: flex-start; }
.avviso-icon { width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.avviso.is-scaduta .avviso-icon { background: color-mix(in oklab, var(--danger) 14%, transparent); color: var(--danger); }
.avviso.is-in_arrivo .avviso-icon { background: color-mix(in oklab, var(--warning) 16%, transparent); color: var(--warning); }
.avviso-testo { display: flex; flex-direction: column; min-width: 0; }
.avviso-testo strong { font-weight: 560; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avviso-testo small { font-size: 12px; color: var(--muted); }
.avviso.is-scaduta .avviso-testo small { color: var(--danger); }
.menu-item-all { border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); margin-top: 4px; font-weight: 600; color: var(--brand-strong); }

/* Scadenzario */
.stat.is-selected { outline: 2px solid var(--brand); outline-offset: -2px; }
.scad-list-card { padding: 0 0 8px; min-width: 0; }
.scad-list-card .card-head { padding: 18px 20px 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.segmented-item {
  display: flex; align-items: center; justify-content: center; height: 30px; padding: 0 14px; border-radius: 7px;
  color: var(--muted); font-size: 12.5px; font-weight: 550; text-decoration: none; transition: background-color .15s, color .15s;
}
.segmented-item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.scad-list-card .segmented { margin: 0; }
.scad-list { list-style: none; margin: 0; padding: 0 8px; }
.scad-month { padding: 14px 12px 6px; font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.scad-item a {
  display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 12px;
  color: inherit; text-decoration: none; transition: background-color .15s;
}
.scad-item a:hover, .scad-item a:focus-visible { background: var(--surface-2); }
.scad-date { width: 44px; flex: none; display: flex; flex-direction: column; align-items: center; padding: 4px 0; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.scad-date strong { font-size: 17px; line-height: 1.1; }
.scad-date small { font-size: 10.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.scad-item.is-scaduta .scad-date { border-color: color-mix(in oklab, var(--danger) 45%, transparent); background: color-mix(in oklab, var(--danger) 8%, transparent); }
.scad-item.is-in_arrivo .scad-date { border-color: color-mix(in oklab, var(--warning) 50%, transparent); background: color-mix(in oklab, var(--warning) 9%, transparent); }
.scad-icon { width: 30px; height: 30px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); }
.scad-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.scad-body strong { font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scad-body small { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scad-item .badge { flex: none; white-space: nowrap; }
.scad-go { color: var(--faint); flex: none; }
@media (max-width: 640px) {
  .scad-item a { flex-wrap: wrap; gap: 10px; }
  .scad-icon, .scad-go { display: none; }
  .scad-body { flex-basis: calc(100% - 60px); }
  .scad-item .badge { margin-left: 54px; }
}

/* Spazi pubblicitari: scelte con nota */
.choices { display: flex; flex-direction: column; gap: 12px; }
.choice-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-chip { position: relative; cursor: pointer; }
.choice-chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice-chip span {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 550;
  transition: background-color .15s, border-color .15s, color .15s;
}
.choice-chip span .icon { display: none; }
.choice-chip input:checked + span { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); }
.choice-chip input:checked + span .icon { display: inline-block; }
.choice-chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-ring); }
.choice-notes { display: flex; flex-direction: column; gap: 8px; }
.choice-notes:not(:has(.choice-note:not([hidden]))) { display: none; }
.choice-note { display: grid; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.choice-note-label { font-size: 13px; font-weight: 600; color: var(--text); }
@media (max-width: 640px) { .choice-note { grid-template-columns: 1fr; gap: 6px; } }
.chip-list { display: flex; flex-wrap: wrap; gap: 4px; max-width: 260px; }

/* Piano rate annuale */
.plan-gen { margin: 10px 0; padding: 14px; border-radius: 14px; border: 1px solid color-mix(in oklab, var(--brand) 35%, transparent); background: var(--brand-soft); display: flex; flex-direction: column; gap: 12px; }
.plan-gen-head { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.plan-gen-head strong { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
.plan-gen-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.plan-gen-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.plan-gen-preview { font-size: 13px; margin: 0; }
.plan-gen-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 640px) { .plan-gen-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Topbar più affollata con la campanella: ricerca compatta sugli schermi medi */
.search-trigger span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1100px) {
  .search-trigger { width: 38px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger .kbd { display: none; }
}

/* Telefono: i menu della topbar si aprono centrati a tutta larghezza (con margini) */
@media (max-width: 640px) {
  .topbar .menu, .topbar .menu-avvisi {
    position: fixed; top: calc(var(--topbar-h) + 4px); left: 12px; right: 12px;
    width: auto; min-width: 0; max-width: 420px; margin-inline: auto;
    max-height: calc(100dvh - var(--topbar-h) - 24px); overflow-y: auto;
  }
}

/* Breadcrumb: si accorcia (con …) invece di finire sotto la ricerca */
.breadcrumb { flex: 0 1 auto; overflow: hidden; }
.breadcrumb ol { overflow: hidden; }
.breadcrumb li { flex: none; }
.breadcrumb li:last-child { flex: 0 1 auto; min-width: 0; overflow: hidden; }
.breadcrumb li:last-child > * { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-trigger, .topbar .dropdown { flex: none; }
@media (max-width: 1280px) {
  /* Schermi medi: solo le ultime due briciole */
  .breadcrumb li:not(:nth-last-child(-n+2)) { display: none; }
}

/* Campanella: elenco scorrevole, "Apri lo scadenzario" sempre visibile in fondo (PC e telefono) */
.topbar .menu-avvisi {
  display: flex; flex-direction: column;
  max-height: calc(100dvh - var(--topbar-h) - 24px); overflow: hidden;
}
.menu-avvisi > .menu-label, .menu-avvisi > .menu-item-all { flex: none; }
.menu-avvisi [data-campanella-voci] { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

/* ==========================================================================
   Archivio documenti a cartelle
   ========================================================================== */
.docs-folders { max-height: calc(100dvh - var(--topbar-h) - 40px); overflow-y: auto; }
.tree, .tree-children { list-style: none; margin: 0; padding: 0; }
.tree-children { display: none; }
.tree-item.is-open > .tree-children { display: block; }
.tree-row { display: flex; align-items: center; gap: 2px; padding-left: calc(var(--livello, 0) * 14px); }
.tree-row .docs-folder { flex: 1; min-width: 0; }
.tree-toggle, .tree-toggle-spacer { width: 22px; height: 22px; flex: none; }
.tree-toggle { display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; transition: transform .15s, background-color .15s; }
.tree-toggle:hover { background: var(--surface-2); color: var(--text); }
.tree-item.is-open > .tree-row .tree-toggle { transform: rotate(90deg); }
.docs-folder-root { margin-bottom: 4px; }
.docs-folder.is-drop, tr.is-drop td { background: var(--brand-soft) !important; outline: 2px dashed var(--brand); outline-offset: -2px; }

.docs-toolbar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; flex-wrap: wrap; }
.docs-toolbar .archive-search { flex: 1 1 240px; }
.docs-path { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; font-size: 14px; color: var(--muted); }
.docs-path a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); text-decoration: none; border-radius: 6px; padding: 2px 4px; }
.docs-path a:hover { background: var(--surface-2); color: var(--text); }
.docs-path strong { color: var(--text); font-weight: 650; padding: 2px 4px; }

.docs-row-folder .doc-name strong { font-weight: 650; }
.doc-icon-folder { color: var(--warning); background: color-mix(in oklab, var(--warning) 12%, transparent); border-color: color-mix(in oklab, var(--warning) 30%, transparent); }

.docs-progress { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.docs-progress-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.docs-progress-bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--brand); transition: width .25s ease; }
.docs-progress .num { font-size: 12.5px; white-space: nowrap; }
.docs-queue { max-height: 220px; overflow-y: auto; }
.docs-queue-item .btn { margin-left: auto; }

@media (max-width: 640px) {
  .docs-toolbar .btn { width: 100%; justify-content: center; }
  .page-actions .btn { flex: 1 1 auto; justify-content: center; }
}
@media (max-width: 1100px) {
  /* Albero in colonna anche su tablet e telefono, con altezza contenuta */
  .docs-folders { flex-direction: column; overflow-x: hidden; max-height: 280px; }
}

/* Archivio: file usati altrove (logo della società, loghi sponsor, verbali) */
.doc-uso { display: inline-flex; align-items: center; gap: 4px; margin-top: 3px; font-size: 12px !important; font-weight: 600; color: var(--warning) !important; }

/* Tema personalizzato */
.tema-modal { width: min(460px, 100%); }
.tema-sezione { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.tema-colori { display: flex; flex-wrap: wrap; gap: 10px; }
.tema-colore { position: relative; width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--surface); background: var(--c, var(--surface-2)); box-shadow: 0 0 0 1px var(--border-strong); display: grid; place-items: center; color: #fff; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.tema-colore:hover { transform: scale(1.08); }
.tema-colore .icon { opacity: 0; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.tema-colore[aria-checked="true"], .tema-colore.is-selected { box-shadow: 0 0 0 2px var(--text); }
.tema-colore[aria-checked="true"] .icon { opacity: 1; }
.tema-colore:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring), 0 0 0 1px var(--border-strong); }
.tema-colore-libero { background: conic-gradient(from 0deg, #ef4444, #f59e0b, #22c55e, #0ea5e9, #8b5cf6, #ec4899, #ef4444); }
.tema-colore-libero.is-selected { background: var(--c); }
.tema-colore-libero input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.tema-colore-libero .icon { opacity: 1; }
.tema-modal .segmented-lg { margin: 0; justify-self: start; display: inline-grid; }
.tema-anteprima { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); pointer-events: none; }
.tema-anteprima-link { color: var(--brand-strong); font-weight: 600; text-decoration: underline; font-size: 13.5px; }
.tema-colori { align-items: center; }
.tema-colore-logo { width: 44px; height: 44px; }
.tema-logo-nota { display: flex; flex-direction: column; gap: 1px; margin-left: 6px; font-size: 13px; line-height: 1.3; }
.tema-logo-nota small { color: var(--muted); font-size: 11.5px; }

/* Promemoria certificati (WhatsApp) */
.promemoria-list { list-style: none; margin: 0; padding: 0 8px 4px; }
.promemoria-item { display: flex; align-items: flex-start; gap: 14px; padding: 12px; border-radius: 12px; transition: background-color .15s, opacity .2s; }
.promemoria-item + .promemoria-item { border-top: 1px solid var(--border); border-radius: 0; }
.promemoria-item.is-done { opacity: .6; }
.promemoria-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.promemoria-top { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.promemoria-top strong { font-weight: 600; }
.promemoria-atleti { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.promemoria-atleti a { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); text-decoration: none; }
.promemoria-atleti a:hover { color: var(--brand-strong); text-decoration: underline; }
.promemoria-testo summary { cursor: pointer; font-size: 12.5px; color: var(--muted); width: fit-content; }
.promemoria-testo p { margin-top: 6px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); max-width: 62ch; }
.promemoria-azioni { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.promemoria-azioni .btn.is-disabled { pointer-events: none; opacity: .5; }
.promemoria-impostazioni { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 16px; align-items: start; padding: 4px 20px 20px; }
.promemoria-impostazioni .settings-card { box-shadow: none; }
.promemoria-test { position: sticky; top: 84px; }
.promemoria-url { padding: 14px 0 0; grid-template-columns: minmax(0, 1fr); }
.promemoria-url dd { word-break: break-all; font-size: 12.5px; }
@media (max-width: 900px) {
  .promemoria-impostazioni { grid-template-columns: minmax(0, 1fr); padding: 4px 12px 16px; }
  .promemoria-test { position: static; }
}
@media (max-width: 640px) {
  .promemoria-item { flex-wrap: wrap; }
  .promemoria-body { flex-basis: calc(100% - 60px); }
  .promemoria-azioni { width: 100%; align-items: stretch; }
}
.promemoria-schede { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.promemoria-schede::-webkit-scrollbar { display: none; }
.promemoria-schede .segmented-item { flex: none; white-space: nowrap; }
@media (max-width: 640px) {
  .scad-list-card .card-head .promemoria-schede { width: 100%; }
  .promemoria-schede .segmented-item { flex: 1 0 auto; padding: 0 10px; }
}
.promemoria-impostazioni.is-singola { grid-template-columns: minmax(0, 760px); }

/* Barra di scorrimento della pagina nascosta (PC e telefono): la pagina scorre normalmente
   con rotellina, touch e tastiera. Le aree interne (menu, elenchi) mantengono la loro barra sottile. */
html, body { scrollbar-width: none; -ms-overflow-style: none; }
html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; width: 0; height: 0; }
.settings-layout.is-singola { grid-template-columns: minmax(0, 860px); }
