/* ============================================================
   components.css — Topbar, drawer, dropdowns, KPI, table,
   editorial card, focus banner, activity list, wizard
   ============================================================ */

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 90;
  display: flex;
  align-items: center;
  padding: 0 var(--content-pad);
  height: var(--topbar-h);
  gap: 28px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.brand-logo {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-ink) 100%);
  color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}
.brand-logo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.15) 50%, transparent 60%);
}
.brand-logo-img {
  height: 68px;
  width: auto;
  max-width: 260px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}
.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-top: 1px;
  font-family: var(--font-serif);
  font-style: italic;
}

/* NAV */
.nav { display: flex; gap: 2px; flex: 1; }
.nav-item { position: relative; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 13px;
  font-size: 14px;
  color: var(--text-soft);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition-fast);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
}
.nav-link:hover { background: var(--surface-sub); color: var(--text); }
.nav-link.active {
  background: var(--surface-sub);
  color: var(--text);
  font-weight: 600;
}
.nav-link i { font-size: 16px; }
.nav-link i.ti-chevron-down {
  font-size: 14px;
  opacity: 0.55;
  transition: transform 0.18s ease;
}
.nav-item.open .nav-link i.ti-chevron-down { transform: rotate(180deg); }
.nav-item.open .nav-link { background: var(--surface-sub); color: var(--text); }

/* TOOLS RIGHT */
.tools {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tool-clock {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 10px;
  border-right: 1px solid var(--border);
  margin-right: 4px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}
.tool-clock .date { font-size: 10px; color: var(--text-dim); }
.tool-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-soft);
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
  background: transparent;
  border: none;
}
.tool-btn:hover { background: var(--surface-sub); color: var(--text); }
.tool-btn i { font-size: 19px; }
.tool-btn .notif-dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--error);
  border: 2px solid var(--surface);
}
a.tool-btn { text-decoration: none; }

/* Dropdown notifiche */
.notif-dd { width: 340px; max-width: calc(100vw - 24px); padding: 0; overflow: hidden; }
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 700; color: var(--text);
}
.notif-count {
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
  padding: 2px 9px; border-radius: 100px; min-width: 22px; text-align: center;
}
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-loading { padding: 30px; display: flex; justify-content: center; }
.notif-item {
  display: flex; align-items: flex-start; gap: 11px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); text-decoration: none;
  color: inherit; transition: background 0.13s ease; cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-alt); }
.notif-ic {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.notif-ic.vote { background: var(--success-soft); color: var(--success); }
.notif-ic.cand { background: var(--gold-soft); color: var(--gold); }
.notif-ic.proclama { background: var(--accent-soft); color: var(--accent); }
.notif-ic.info { background: var(--surface-alt); color: var(--text-muted); }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3; }
.notif-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.notif-empty { padding: 36px 20px; text-align: center; color: var(--text-muted); }
.notif-empty i { font-size: 30px; color: var(--success); display: block; margin-bottom: 8px; }
.notif-empty .t { font-size: 13px; font-weight: 600; color: var(--text); }
.notif-empty .d { font-size: 12px; margin-top: 3px; }
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 10px 4px 4px;
  margin-left: 4px;
  border-radius: 100px;
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid transparent;
}
.user-chip:hover { background: var(--surface-sub); border-color: var(--border); }
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-ink));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.user-avatar-shape {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 5px;
}
.user-avatar-shape svg {
  width: 100%; height: 100%; display: block;
}
.user-chip-text {
  display: flex; flex-direction: column;
  line-height: 1.15;
  gap: 1px;
}
.user-name { font-size: 13px; font-weight: 500; color: var(--text); }
.user-region {
  font-size: 10.5px; font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Header del dropdown utente */
.user-dd-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.user-dd-shape {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  padding: 6px;
  flex-shrink: 0;
}
.user-dd-shape svg { width: 100%; height: 100%; display: block; }
.user-dd-shape-fallback {
  background: linear-gradient(135deg, var(--accent), var(--accent-ink));
  color: #fff;
  font-size: 18px; font-weight: 700;
  padding: 0;
}
.user-dd-text { flex: 1; min-width: 0; line-height: 1.2; }
.user-dd-name {
  font-size: 14px; font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.user-dd-role {
  font-size: 11px; color: var(--text-muted);
  font-weight: 500;
}
.user-dd-region {
  font-size: 11px; font-weight: 600;
  color: var(--accent);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hamburger { display: none; }

/* DROPDOWNS */
.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  z-index: 100;
  overflow: hidden;
}
.nav-item.open .dropdown { opacity: 1; visibility: visible; transform: translateY(0); }

.dropdown.mega {
  width: 640px;
  display: grid;
  grid-template-columns: 1fr 240px;
}
.dropdown.mega .mega-left { padding: 20px 22px 22px; }
.dropdown.mega .mega-right {
  padding: 20px 20px 22px;
  background: var(--surface-alt);
  border-left: 1px solid var(--border);
}
.dropdown.mega .mega-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dropdown.mega .mega-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.mega-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 16px;
}
.mega-item {
  display: flex;
  gap: 12px;
  padding: 10px 11px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
  color: inherit;
}
.mega-item:hover { background: var(--surface-sub); }
.mega-item .ic {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.mega-item .ic.g { background: var(--success-soft); color: var(--success); }
.mega-item .ic.p { background: var(--purple-soft); color: var(--purple); }
.mega-item .ic.gold { background: var(--gold-soft); color: var(--gold); }
.mega-item .ic.c { background: var(--cyan-soft); color: var(--cyan); }
.mega-item .ic.r { background: var(--rose-soft); color: var(--rose); }
.mega-item .tx b {
  font-size: 13.5px;
  font-weight: 600;
  display: block;
  letter-spacing: -0.005em;
}
.mega-item .tx span {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
  line-height: 1.4;
}

.quick-action {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-ink) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
  text-decoration: none;
  display: block;
}
.quick-action:hover { transform: translateY(-1px); box-shadow: var(--shadow); color: #fff; }
.quick-action::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 100% 0%, rgba(255,255,255,0.15), transparent 60%);
  pointer-events: none;
}
.quick-action .qa-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
  margin-bottom: 4px;
}
.quick-action .qa-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.quick-action .qa-sub {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}
.quick-action .qa-btn {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.18);
  padding: 6px 11px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
}
.quick-action .qa-btn i { font-size: 13px; }

.quick-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--text-soft);
  text-decoration: none;
}
.quick-link:hover { background: var(--surface-sub); color: var(--text); }
.quick-link i { font-size: 15px; color: var(--text-muted); }

.dropdown.compact {
  width: 240px;
  padding: 6px;
}
.dropdown.compact.right-align { left: auto; right: 0; }
.compact-group {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 11px 4px;
}
.compact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  font-size: 13px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--text);
  transition: var(--transition-fast);
  text-decoration: none;
}
.compact-item:hover { background: var(--surface-sub); color: var(--text); }
.compact-item i { font-size: 15px; color: var(--text-muted); width: 16px; text-align: center; }
.compact-item .kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
}
.compact-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.compact-item.danger { color: var(--error); }
.compact-item.danger i { color: var(--error); }

/* DRAWER MOBILE */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,22,28,0.5);
  z-index: 95;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  backdrop-filter: blur(4px);
}
.drawer-overlay.open { opacity: 1; visibility: visible; }
.drawer {
  position: fixed;
  top: 0; left: 0;
  bottom: 0;
  width: 290px;
  max-width: 88vw;
  background: var(--surface);
  z-index: 96;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 4px 0 24px rgba(0,0,0,0.08);
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.drawer-head .brand { gap: 10px; min-width: 0; flex: 1; }
.drawer-head .brand-logo-img { height: 42px; max-width: 160px; }
.drawer-head .brand-text { min-width: 0; }
.drawer-head .brand-name { font-size: 13.5px; }
.drawer-head .brand-sub { font-size: 10.5px; }
.drawer-nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.drawer-section {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 14px 12px 6px;
}
.drawer-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-soft);
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
}
.drawer-link:hover { background: var(--surface-sub); color: var(--text); }
.drawer-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.drawer-link i { font-size: 17px; }
.drawer-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
}
.drawer-footer .tool-btn { flex: 1; border: 1px solid var(--border); }

/* ============================================================
   RESPONSIVE TOPBAR
   ============================================================ */
@media (max-width: 1280px) {
  .nav-link { padding: 7px 10px; font-size: 13.5px; }
  .nav { gap: 0; }
}
@media (max-width: 1100px) {
  .nav-link { padding: 6px 8px; font-size: 13px; }
  .user-chip { padding: 4px 8px 4px 4px; }
  .user-region { display: none; }
  .brand-logo-img { height: 56px; max-width: 200px; }
}
@media (max-width: 1024px) {
  /* Hamburger compare qui — il menu admin è già troppo affollato sotto questa soglia */
  .hamburger {
    display: flex;
    width: 40px; height: 40px;
    border-radius: var(--radius);
    align-items: center;
    justify-content: center;
    color: var(--text);
    cursor: pointer;
    margin-right: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    flex-shrink: 0;
  }
  .hamburger:hover { background: var(--surface-sub); }
  .hamburger i { font-size: 22px; }
  .nav { display: none; }
  .tools { margin-left: auto; } /* spinge tools/user a destra quando nav è nascosto */
  .tool-clock { display: none; }
  .topbar { gap: 10px; padding: 0 16px; }
  /* Topbar più compatta su mobile */
  :root { --topbar-h: 68px !important; }
  .brand-logo-img { height: 48px; max-width: 160px; }
  .brand-sub { display: none; }
  .brand-name { font-size: 13px; }
}
@media (max-width: 640px) {
  :root { --topbar-h: 60px !important; }
  .topbar { gap: 8px; padding: 0 12px; }
  .brand-logo-img { height: 42px; max-width: 130px; }
  .brand-text { display: none; } /* solo logo su mobile stretto */
  .user-name { display: none; }
  .user-chip { padding: 4px; gap: 0; }
  .user-chip i.ti-chevron-down { display: none; }
  .user-avatar { width: 36px; height: 36px; }
  .user-chip-text { display: none; }
}
@media (max-width: 380px) {
  .brand-logo-img { height: 38px; max-width: 110px; }
}

/* ============================================================
   FOCUS BANNER
   ============================================================ */
.focus-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 28px;
  display: flex;
  gap: 20px;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.focus-banner::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--gold) 0%, var(--accent) 100%);
}
.focus-banner .fb-ic {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--gold-soft);
  color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.focus-banner .fb-ic.alert { background: var(--error-soft); color: var(--error); }
.focus-banner .fb-ic.info  { background: var(--info-soft); color: var(--info); }
.focus-banner .fb-body { flex: 1; min-width: 0; }
.focus-banner h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.focus-banner p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}
.focus-banner .count {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--gold-ink);
  background: var(--gold-soft);
  padding: 1px 8px;
  border-radius: 5px;
  font-size: 13px;
}

@media (max-width: 768px) {
  .focus-banner {
    flex-direction: row;
    align-items: flex-start;
    padding: 16px 14px;
    gap: 12px;
    margin-bottom: 20px;
  }
  .focus-banner .fb-ic { width: 38px; height: 38px; font-size: 18px; border-radius: 10px; }
  .focus-banner h3 { font-size: 14.5px; line-height: 1.3; }
  .focus-banner p { font-size: 12.5px; line-height: 1.45; margin-top: 4px; }
  .focus-banner .btn { width: 100%; margin-top: 10px; justify-content: center; font-size: 13px; padding: 9px 14px; }
  .focus-banner .fb-body { width: 100%; }
  /* il bottone esce dal body e va a fondo card su mobile */
  .focus-banner { flex-wrap: wrap; }
  .focus-banner > .btn { flex-basis: 100%; }
}

/* ============================================================
   KPI GRID
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 36px;
}
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 24px; }
  .kpi { padding: 14px 14px 16px; }
  .kpi-head { margin-bottom: 10px; }
  .kpi-label { font-size: 11.5px; line-height: 1.25; }
  .kpi-icon { width: 28px; height: 28px; font-size: 14px; border-radius: 7px; }
  .kpi-value { font-size: 24px; }
  .kpi-trend { font-size: 10.5px; margin-top: 6px; line-height: 1.3; }
  .kpi-trend i { font-size: 11px; }
  .kpi-spark { width: 60px; height: 22px; opacity: 0.3; }
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}
.kpi:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  color: inherit;
}
.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.kpi-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}
.kpi-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  background: var(--accent-soft);
  color: var(--accent);
}
.kpi-icon.blue { background: var(--info-soft); color: var(--info); }
.kpi-icon.green { background: var(--success-soft); color: var(--success); }
.kpi-icon.gold { background: var(--gold-soft); color: var(--gold); }
.kpi-icon.purple { background: var(--purple-soft); color: var(--purple); }
.kpi-icon.rose { background: var(--rose-soft); color: var(--rose); }
.kpi-value {
  font-size: 32px;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.kpi-trend {
  font-size: 12px;
  margin-top: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--error); }
.kpi-trend i { font-size: 13px; }
.kpi-spark {
  position: absolute;
  bottom: 0; right: 0;
  width: 80px; height: 30px;
  opacity: 0.45;
  pointer-events: none;
}

/* ============================================================
   TWO COL LAYOUT (table + side)
   ============================================================ */
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
}
.col-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
@media (max-width: 1200px) {
  .two-col { grid-template-columns: 1fr; }
  .col-side { flex-direction: row; flex-wrap: wrap; }
  .col-side > * { flex: 1; min-width: 280px; }
}
@media (max-width: 768px) {
  .col-side { flex-direction: column; }
  .col-side > * { min-width: 0; }
}

/* ============================================================
   TABLE
   ============================================================ */
.toolbar-pills {
  display: flex;
  gap: 4px;
  background: var(--surface-sub);
  border-radius: 100px;
  padding: 3px;
}
.toolbar-pills button {
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-muted);
  border-radius: 100px;
  transition: var(--transition-fast);
  font-family: inherit;
}
.toolbar-pills button.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.search-input {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 12.5px;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.search-input i { font-size: 14px; }
.search-input input {
  border: none; background: none; outline: none;
  font-family: inherit; font-size: 12.5px;
  color: var(--text); width: 140px; padding: 0;
}
.search-input input::placeholder { color: var(--text-dim); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  text-align: left;
  padding: 12px 22px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th.num, .data-table td.num { text-align: right; font-family: var(--font-mono); font-feature-settings: 'tnum'; }
.data-table td {
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.1s ease; cursor: pointer; }
.data-table tbody tr:hover td { background: var(--surface-alt); }
.row-title { font-weight: 600; font-size: 13.5px; color: var(--text); }
.row-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

@media (max-width: 768px) {
  /* La tabella diventa una lista di card impilate, ordinate e leggibili */
  .data-table { font-size: 13.5px; border-collapse: separate; }
  .data-table thead { display: none; }
  .data-table tbody { display: block; width: 100%; }
  .data-table tr {
    display: block;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    padding: 14px 16px;
    background: var(--surface);
  }
  .data-table tr:last-child { margin-bottom: 0; }
  .data-table tbody tr:hover td { background: transparent; }
  .data-table td {
    display: block;
    width: 100%;
    padding: 0;
    border-bottom: none;
    text-align: left !important;
  }
  /* 1ª td = titolo + meta */
  .row-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    word-break: break-word;
    white-space: normal !important;
  }
  .row-meta {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    word-break: break-word;
    white-space: normal !important;
    margin-top: 3px;
  }
  /* 2ª + 3ª td = badge TIPO e STATO affiancati sulla stessa riga */
  .data-table td:nth-child(2),
  .data-table td:nth-child(3) {
    display: inline-flex;
    width: auto;
    margin-top: 8px;
    margin-right: 6px;
    vertical-align: middle;
  }
  /* td numeriche (Candidature/Voti) = riga testuale leggibile in fondo */
  .data-table td.num {
    display: block;
    width: 100%;
    margin-top: 8px;
    font-family: var(--font) !important;
    font-size: 12.5px;
    color: var(--text-muted);
  }
  .data-table td.num::before {
    content: attr(data-label) ' ';
    color: var(--text-dim);
    font-weight: 500;
    margin-right: 3px;
  }
  .data-table .hide-mobile { display: none !important; }
}

/* ============================================================
   EDITORIAL CARD (la citazione "premium")
   ============================================================ */
.editorial-card {
  background: linear-gradient(135deg, var(--accent-ink) 0%, var(--accent) 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 26px 24px;
  position: relative;
  overflow: hidden;
}
.editorial-card::before {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(255,255,255,0.10) 0%, transparent 70%);
  pointer-events: none;
}
.editorial-card .quote-mark {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 56px;
  line-height: 0.5;
  opacity: 0.4;
  margin-bottom: 12px;
}
.editorial-card p {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 17px;
  line-height: 1.4;
  margin-bottom: 14px;
}
.editorial-card .who {
  font-size: 12px;
  opacity: 0.8;
}

/* ============================================================
   LIST CARD — Pattern per liste verticali (regioni, config, etc)
   ============================================================ */
.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.list-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}
.list-card-head h3,
.list-card-head .lc-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.list-card-head .lc-title i { font-size: 14px; }
.list-card-head .lc-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 100px;
  border: 1px solid var(--border);
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s ease;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-alt); }
.list-row.danger { background: color-mix(in srgb, var(--error-soft) 40%, transparent); }
.list-row.danger:hover { background: var(--error-soft); }
.list-row-main { flex: 1; min-width: 0; }
.list-row-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.list-row-title .lr-icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.list-row-title .lr-icon.gold  { background: var(--gold-soft); color: var(--gold); }
.list-row-title .lr-icon.green { background: var(--success-soft); color: var(--success); }
.list-row-title .lr-icon.error { background: var(--error-soft); color: var(--error); }
.list-row-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}
.list-row-meta i { font-size: 12px; vertical-align: -1px; margin-right: 3px; }
.list-row-side {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* ============================================================
   SWITCH (toggle) — stile warm premium
   Semantica in questo progetto: checked = BLOCCATO (rosso),
   unchecked = ATTIVO/DISPONIBILE (verde).
   ============================================================ */
.switch {
  position: relative;
  display: inline-block;
  width: 46px; height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 100px;
  transition: background 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s ease;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.10),
              inset 0 0 0 1px rgba(255,255,255,0.12);
}
.switch .slider::before {
  content: '';
  position: absolute;
  height: 20px; width: 20px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.22), 0 0 0 0.5px rgba(0,0,0,0.05);
}
/* Hover: leggero alone */
.switch:hover .slider { box-shadow: inset 0 1px 2px rgba(0,0,0,0.10), 0 0 0 4px color-mix(in srgb, var(--text-muted) 14%, transparent); }
.switch input:checked + .slider { background: var(--success); }
.switch:hover input:checked + .slider { box-shadow: inset 0 1px 2px rgba(0,0,0,0.10), 0 0 0 4px color-mix(in srgb, var(--success) 16%, transparent); }
.switch input:checked + .slider::before { transform: translateX(20px); }
/* Focus accessibile da tastiera */
.switch input:focus-visible + .slider { box-shadow: inset 0 1px 2px rgba(0,0,0,0.10), 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.switch input:disabled + .slider { opacity: 0.45; cursor: not-allowed; }
.switch input:disabled ~ * { cursor: not-allowed; }

.switch-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  min-width: 64px;
  text-align: right;
  transition: color 0.2s ease;
}
.switch-label.active,   .switch-label.attiva   { color: var(--success); }
.switch-label.blocked,  .switch-label.bloccata { color: var(--error); }

@media (max-width: 640px) {
  .list-row { padding: 14px 16px; gap: 10px; }
  .list-card-head { padding: 14px 16px; }
  .switch-label { display: none; }
}

/* SIDE CARD */
.side-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}
.side-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.005em;
}
.side-card h3 i { font-size: 16px; color: var(--text-muted); }

/* ACTIVITY LIST */
.activity-list { display: flex; flex-direction: column; gap: 16px; }
.activity-item { display: flex; gap: 12px; align-items: flex-start; }
.activity-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface-sub);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.activity-dot.success { background: var(--success-soft); color: var(--success); }
.activity-dot.warning { background: var(--warning-soft); color: var(--warning); }
.activity-dot.info { background: var(--info-soft); color: var(--info); }
.activity-dot.gold { background: var(--gold-soft); color: var(--gold); }
.activity-body { flex: 1; min-width: 0; }
.activity-body p {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.activity-body strong { font-weight: 600; }
.activity-time {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
  font-family: var(--font-mono);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
}
.empty-state-icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--surface-sub);
  color: var(--text-dim);
  font-size: 24px;
}
.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  font-family: var(--font-serif);
}
.empty-state-desc { font-size: 13px; max-width: 380px; margin: 0 auto 16px; line-height: 1.5; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20,22,28,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  backdrop-filter: blur(4px);
}
@media (max-width: 768px) {
  /* Solo il wizard va fullscreen su mobile. I modal piccoli restano centrati. */
  .modal-overlay { padding: 12px; }
  .modal-overlay > .wizard-modal {
    max-width: 100% !important;
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }
  /* I modal normali: non più alti della viewport reale, scroll interno */
  .modal-overlay .modal {
    max-height: 100vh !important;
    max-height: calc(100dvh - 24px) !important;
  }
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  max-width: 480px;
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  font-family: var(--font-serif);
}
.modal-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
}
.modal-close:hover { background: var(--surface-sub); color: var(--text); }
.modal-close i { font-size: 18px; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  max-width: 380px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  animation: fadeUp 0.2s ease;
  min-width: 280px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--error); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--info); }
.toast-icon { flex-shrink: 0; margin-top: 1px; font-size: 18px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon   { color: var(--error); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon    { color: var(--info); }
.toast-body { flex: 1; min-width: 0; line-height: 1.4; color: var(--text); }
.toast-close { color: var(--text-muted); cursor: pointer; padding: 2px; display: flex; flex-shrink: 0; }
.toast-close:hover { color: var(--text); }
.toast-close i { font-size: 14px; }

/* ============================================================
   TOOLTIP (i)
   ============================================================ */
.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--surface-sub);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font);
  cursor: help;
  border: 1px solid var(--border);
  transition: var(--transition-fast);
  margin-left: 5px;
  vertical-align: middle;
  user-select: none;
}
.info-tip:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.info-tip::before { content: 'i'; font-style: italic; }
.tooltip-pop {
  position: absolute;
  background: var(--text);
  color: var(--surface);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: var(--radius);
  max-width: 280px;
  min-width: 160px;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font);
}
.tooltip-pop.visible { opacity: 1; }
.tooltip-pop::before {
  content: '';
  position: absolute;
  width: 0; height: 0;
  border: 5px solid transparent;
}
.tooltip-pop.pos-top::before    { top: 100%; left: 50%; margin-left: -5px; border-top-color: var(--text); }
.tooltip-pop.pos-bottom::before { bottom: 100%; left: 50%; margin-left: -5px; border-bottom-color: var(--text); }

/* ============================================================
   STEPPER (wizard)
   ============================================================ */
.stepper {
  display: flex;
  align-items: center;
  margin-bottom: 28px;
}
.stepper-item {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
}
.stepper-item:not(:last-child)::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 10px;
  transition: background 0.25s ease;
}
.stepper-item.completed::after { background: var(--success); }
.stepper-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  flex-shrink: 0;
  transition: var(--transition);
}
.stepper-item.active .stepper-circle {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.stepper-item.completed .stepper-circle {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}
.stepper-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 10px;
  white-space: nowrap;
}
.stepper-item.active .stepper-label { color: var(--text); font-weight: 600; }
.stepper-item.completed .stepper-label { color: var(--text-soft); }
@media (max-width: 768px) {
  .stepper-label { display: none; }
  .stepper-item:not(:last-child)::after { margin: 0 6px; }
}
.wizard-step { display: none; animation: fadeUp 0.2s ease; }
.wizard-step.active { display: block; }
.wizard-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   RANKING (classifica risultati)
   ============================================================ */
.ranking {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ranking-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s ease;
}
.ranking-row:last-child { border-bottom: none; }
.ranking-row:hover { background: var(--surface-alt); }
.ranking-position {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 36px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.ranking-row.top-1 .ranking-position { color: #C9A227; }
.ranking-row.top-2 .ranking-position { color: #A0A0A0; }
.ranking-row.top-3 .ranking-position { color: #B8731A; }
.ranking-info { flex: 1; min-width: 0; }
.ranking-name { font-size: 15px; font-weight: 600; color: var(--text); }
.ranking-meta { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.ranking-votes {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 70px;
}

/* ============================================================
   ELECTION CARD (lista elezioni)
   ============================================================ */
.election-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-bottom: 12px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 16px;
}
.election-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.election-card-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
}
.election-card-body { flex: 1; min-width: 0; }
.election-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.election-card-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.election-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.election-card-meta i { font-size: 13px; }
.election-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
@media (max-width: 768px) {
  .election-card { flex-direction: column; align-items: flex-start; }
  .election-card-actions { width: 100%; }
}
