/* ═══════════════════════════════════════════════════════════════════════════════
   Sulla Soglia — Admin CSS Condiviso
   Design system editoriale v2 (2026-05-07): Inter + Fraunces, terracotta brand,
   sidebar dark #2a1410, page-head numerate, KPI Fraunces, queue cards.
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── Fonts (self-hosted, GDPR-friendly) ────────────────────────────────────── */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url('../fonts/fraunces/fraunces-latin-standard-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src:
    local('Inter Regular'),
    url('../fonts/inter-v13-latin-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src:
    local('Inter Medium'),
    url('../fonts/inter-v13-latin-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src:
    local('Inter SemiBold'),
    url('../fonts/inter-v13-latin-600.woff2') format('woff2');
}

/* ── Design tokens condivisi (allineati al sito pubblico) ──────────────────── */
:root {
  /* Brand */
  --color-primary: #d34c31;
  --color-primary-light: #e07a63;
  --color-primary-dark: #a63b26;
  --color-secondary: #6b7f5e;
  --color-accent: #c9a35c;

  /* Surfaces */
  --color-bg: #f8f6f1;
  --color-bg-warm: #f0ebe1;
  --color-bg-card: #ffffff;
  --color-surface-low: #f7f3ef;

  /* Ink */
  --color-text: #1a1a1a;
  --color-text-light: #555555;
  --color-text-muted: #6b6b6b;
  --color-text-dim: #888888;

  /* Lines */
  --color-border: #e0dbd0;
  --color-border-light: #ebe7de;

  /* Header brick */
  --color-header-bg: #5c1a0e;
  --color-header-text: #f5f0e8;

  /* Sidebar admin (dark v2) */
  --color-sidebar-bg: #2a1410;
  --color-sidebar-fg: rgba(239, 230, 220, 0.78);
  --color-sidebar-fg-hover: #ffffff;

  /* Foreground/background semantic aliases */
  --fg-1: #1a1a1a;
  --fg-2: #555555;
  --fg-3: #6b6b6b;
  --fg-inverse: #f5f0e8;

  /* Accent washes */
  --accent-wash: rgba(var(--color-primary-rgb), 0.1);
  --accent-wash-strong: rgba(var(--color-primary-rgb), 0.18);

  /* Typography */
  --font-heading: 'Fraunces', 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', 'DM Sans', 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', ui-monospace, 'Segoe UI Mono', Menlo, Consolas, monospace;

  /* Radii */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
  --shadow-soft: 0 1px 0 rgba(20, 19, 15, 0.04), 0 20px 40px -24px rgba(20, 19, 15, 0.18);

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
}

[data-theme='dark'] {
  --color-bg: #1c1916;
  --color-bg-warm: #242018;
  --color-bg-card: #2b2720;
  --color-text: #e8e4dc;
  --color-text-muted: #9a9690;
  --color-text-dim: #7a7670;
  --color-border: #3c3830;
  --color-border-light: #2c2820;
  --fg-1: #e8e4dc;
  --fg-2: #c8c4bc;
  --fg-3: #9a9690;
}

/* ────────────────────────────────────────────────────────────────────────────
   1. RESET & BASE
   ──────────────────────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-feature-settings:
    'kern' 1,
    'liga' 1;
}

/* ────────────────────────────────────────────────────────────────────────────
   2. ADMIN SIDEBAR NAVIGATION
   ──────────────────────────────────────────────────────────────────────────── */

.admin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 200px;
  background: var(--color-sidebar-bg);
  color: #e8e4dc;
  display: flex;
  flex-direction: column;
  z-index: 7000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #b53a1e;
  color: white;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  font-size: 13px;
  border: none;
  background: none;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.sidebar-link:hover {
  color: white;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-link.active {
  color: white;
  background: rgba(255, 255, 255, 0.14);
  border-right: 3px solid #c9a35c;
}

/* ── Gruppi collapsibili ─────────────────────────────────────────────── */
.sidebar-group {
  display: flex;
  flex-direction: column;
}
.sidebar-group-header {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
  padding: 10px 16px;
}
.sidebar-group-header:hover {
  color: white;
  background: rgba(255, 255, 255, 0.05);
}
.sidebar-group-header > span:not(.sidebar-group-chevron) {
  flex: 1;
}
.sidebar-group-chevron {
  display: inline-flex;
  align-items: center;
  transition: transform 0.18s ease;
  opacity: 0.7;
}
.sidebar-group.is-open .sidebar-group-chevron {
  transform: rotate(180deg);
}
.sidebar-group-items {
  display: none;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  margin-left: 16px;
  margin-bottom: 4px;
}
.sidebar-group.is-open .sidebar-group-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidebar-group-items .sidebar-link {
  padding: 7px 14px;
  font-size: 12.5px;
}
.sidebar-group-items .sidebar-link svg {
  opacity: 0.65;
}
.sidebar-group-items .sidebar-link.active svg {
  opacity: 1;
}

.sidebar-footer {
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Theme toggle icon switching */
.theme-icon-light {
  display: none;
}
[data-theme='dark'] .theme-icon-dark {
  display: none;
}
[data-theme='dark'] .theme-icon-light {
  display: block;
}

/* Mobile topbar — hidden on desktop */
.admin-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--color-sidebar-bg);
  color: white;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  z-index: 6999;
}

.topbar-menu-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}

.topbar-menu-btn .sidebar-icon {
  width: 22px;
  height: 22px;
}

.topbar-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 6998;
}
.sidebar-overlay.open {
  display: block;
}

/* Body layout offset for sidebar */
body.has-admin-sidebar {
  margin-left: 200px;
}

/* Desktop: sidebar always visible */
@media (min-width: 769px) {
  .admin-topbar {
    display: none !important;
  }
  .sidebar-overlay {
    display: none !important;
  }
}

/* Mobile: sidebar hidden, topbar visible */
@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-topbar {
    display: flex;
  }
  body.has-admin-sidebar {
    margin-left: 0;
    padding-top: 52px;
  }
}

/* Legacy header support (pages not yet migrated) */
header {
  background: #b53a1e;
  color: white;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

header h1 {
  font-size: 1rem;
  font-weight: 600;
}

.header-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-btn {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: white;
  background: transparent;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
  font-family: inherit;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.nav-btn.active {
  background: rgba(255, 255, 255, 0.25);
}

/* ────────────────────────────────────────────────────────────────────────────
   3. CONTAINER & LAYOUT
   ──────────────────────────────────────────────────────────────────────────── */

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
}

.container--xs {
  max-width: 800px;
}
.container--wide {
  max-width: 1400px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   4. TOOLBAR
   ──────────────────────────────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar h2 {
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
}

/* ────────────────────────────────────────────────────────────────────────────
   5. FORM ELEMENTS
   ──────────────────────────────────────────────────────────────────────────── */

input,
select,
textarea {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13px;
  background: white;
  color: #2c2c2a;
  font-family: inherit;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #b53a1e;
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1);
}

textarea {
  resize: vertical;
  min-height: 70px;
}

.search-box {
  flex: 1;
  max-width: 260px;
}

.q-filter,
.cat-filter {
  min-width: 160px;
}

.form-row {
  margin-bottom: 12px;
}

.form-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #888;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ────────────────────────────────────────────────────────────────────────────
   6. BUTTONS
   ──────────────────────────────────────────────────────────────────────────── */

.btn,
.filter-btn,
.btn-refresh {
  padding: 7px 16px;
  border-radius: 7px;
  border: 1px solid #ddd;
  background: white;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn:hover,
.btn-refresh:hover {
  background: #f0f0f0;
}

.filter-btn {
  padding: 6px 14px;
  font-size: 13px;
}

.filter-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background: #993c1d;
}

.btn-danger {
  border-color: #e24b4a;
  color: #a32d2d;
}

.btn-danger:hover {
  background: #fcebeb;
}

.btn-success {
  background: #49a078;
  color: white;
  border-color: #49a078;
}

.btn-success:hover {
  background: #357a5a;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* ────────────────────────────────────────────────────────────────────────────
   7. BADGES
   ──────────────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  background: #b53a1e;
  color: white;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.zero {
  background: #888;
}

.badge-bozza {
  background: #f5f5f5;
  color: #616161;
}

.badge-approvato {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-pubblicato {
  background: #e3f2fd;
  color: #1565c0;
}

.badge-rifiutato {
  background: #fcebeb;
  color: #a32d2d;
}

.badge-racconto {
  background: #ede7f6;
  color: #5e35b1;
}

.badge-proposta {
  background: #e3f2fd;
  color: #1565c0;
}

.badge-mappa_emotiva {
  background: #fff8e1;
  color: #f57f17;
}

.badge-denuncia_creativa {
  background: #fce4ec;
  color: #ad1457;
}

.badge-esperienza_rifiuto {
  background: #e0f2f1;
  color: #00695c;
}

.badge-strutturale {
  background: #f5f5f5;
  color: #616161;
}

.badge-aperto {
  background: #e3f2fd;
  color: #1565c0;
}

.badge-invitato {
  background: #ede7f6;
  color: #5e35b1;
}

.badge-cerchio_tenuto {
  background: #fff8e1;
  color: #f57f17;
}

.badge-impegno_preso {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-verificato {
  background: #c8e6c9;
  color: #1b5e20;
}

.badge-disatteso {
  background: #fcebeb;
  color: #a32d2d;
}

.badge-attivo {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-concluso {
  background: #f5f5f5;
  color: #616161;
}

.badge-sospeso {
  background: #fff8e1;
  color: #f57f17;
}

.tipo-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tipo-errore {
  background: #fcebeb;
  color: #a32d2d;
}

.tipo-mancante {
  background: #e6f1fb;
  color: #185fa5;
}

.tipo-suggerimento {
  background: #faeeda;
  color: #854f0b;
}

/* ────────────────────────────────────────────────────────────────────────────
   8. CARDS
   ──────────────────────────────────────────────────────────────────────────── */

.card {
  background: white;
  border-radius: 10px;
  border: 1px solid #e8e8e4;
  padding: 20px;
  margin-bottom: 12px;
  overflow: hidden;
}

.card.letta {
  opacity: 0.55;
}

.card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
}

.card-date {
  font-size: 11px;
  color: #888;
  margin-left: auto;
}

.card-luogo {
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
}

.card-body {
  padding: 0 16px 14px;
}

.card-desc {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #333;
  margin-bottom: 10px;
  white-space: pre-wrap;
}

.card-meta {
  font-size: 0.78rem;
  color: #888;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.btn-letta {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid #b53a1e;
  color: #b53a1e;
  background: white;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-letta:hover {
  background: #faece7;
}

.btn-letta.done {
  border-color: #888;
  color: #888;
}

.btn-poi {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid #185fa5;
  color: #185fa5;
  background: white;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 0.15s;
}

.btn-poi:hover {
  background: #e6f1fb;
}

.btn-del {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid #ddd;
  color: #888;
  background: white;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-del:hover {
  border-color: #e24b4a;
  color: #a32d2d;
  background: #fcebeb;
}

.panel {
  background: white;
  border-radius: 10px;
  border: 1px solid #e8e8e4;
  padding: 20px;
  position: sticky;
  top: 20px;
}
@media (max-width: 768px) {
  .panel {
    position: static;
  }
}

.panel h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f0efeb;
}

/* ────────────────────────────────────────────────────────────────────────────
   9. TABLES & DATA
   ──────────────────────────────────────────────────────────────────────────── */

.poi-table,
.data-table {
  background: white;
  border-radius: 10px;
  border: 1px solid #e8e8e4;
  overflow: hidden;
  overflow-x: auto;
}

/* Utility wrapper mobile-friendly per tabelle admin (ADM-P1-1). */
.table-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  background: #f8f7f4;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #e8e8e4;
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0efeb;
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #fafaf8;
}

tr.inattivo td {
  opacity: 0.45;
}

.cat-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.coords {
  font-size: 11px;
  color: #888;
  font-family: monospace;
}

.coords.missing {
  color: #e24b4a;
}

.td-actions {
  display: flex;
  gap: 6px;
}

/* ────────────────────────────────────────────────────────────────────────────
   10. AUTH MODAL
   ──────────────────────────────────────────────────────────────────────────── */

#auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
#auth-overlay.is-hidden {
  display: none;
}

#auth-box {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  width: 340px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

#auth-box h2 {
  font-size: 1rem;
  margin-bottom: 0.4rem;
  color: #2c2c2a;
}

#auth-box p {
  font-size: 0.82rem;
  color: #888;
  margin-bottom: 1.2rem;
}

#auth-input {
  width: 100%;
  border: 1.5px solid #ddd;
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 14px;
  margin-bottom: 0.8rem;
  outline: none;
}

#auth-input:focus {
  border-color: #b53a1e;
}

#auth-btn {
  width: 100%;
  background: #b53a1e;
  color: white;
  border: none;
  border-radius: 7px;
  padding: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

#auth-btn:hover {
  background: #993c1d;
}

#auth-err {
  color: #a32d2d;
  font-size: 0.82rem;
  margin-top: 0.5rem;
  display: none;
}

/* Pannello TOTP (iniettato dinamicamente da admin-core.js — C2) */
#auth-totp-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#auth-totp-panel p {
  font-size: 0.85rem;
  color: var(--color-text-muted, #888);
  margin: 0;
}
#auth-totp-input {
  width: 100%;
  border: 1.5px solid var(--color-border, #ddd);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 1.2rem;
  letter-spacing: 0.25em;
  text-align: center;
  outline: none;
  min-height: 44px;
  box-sizing: border-box;
  background: var(--color-bg, #fff);
  color: var(--color-text, #2c2c2a);
}
#auth-totp-input:focus {
  border-color: var(--color-primary, #c04428);
}
#auth-totp-err {
  color: #a32d2d;
  font-size: 0.82rem;
  margin: 0;
}
#auth-totp-btn {
  width: 100%;
  background: var(--color-primary, #c04428);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 9px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}
#auth-totp-btn:hover {
  background: var(--color-primary-dark, #993c1d);
}
#auth-totp-back {
  width: 100%;
  background: transparent;
  color: var(--color-text-muted, #888);
  border: 1px solid var(--color-border, #ddd);
  border-radius: 7px;
  padding: 7px;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 44px;
}
#auth-totp-back:hover {
  color: var(--color-text, #2c2c2a);
}
[data-theme='dark'] #auth-totp-input {
  border-color: var(--color-border, #444);
  background: var(--color-bg, #1a1a18);
  color: var(--color-text, #f0ece4);
}

/* ────────────────────────────────────────────────────────────────────────────
   11. MESSAGES & FEEDBACK
   ──────────────────────────────────────────────────────────────────────────── */

.empty {
  text-align: center;
  padding: 3rem;
  color: #888;
  font-size: 0.9rem;
}

.loading {
  text-align: center;
  padding: 3rem;
  color: #888;
}

.msg {
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}

.msg.ok {
  background: #e1f5ee;
  color: #085041;
  border: 1px solid #5dcaa5;
}

.msg.err {
  background: #fcebeb;
  color: #a32d2d;
  border: 1px solid #f09595;
}

/* ────────────────────────────────────────────────────────────────────────────
   12. TOAST NOTIFICATIONS (nuovo)
   ──────────────────────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 5000;
}

.toast {
  background: white;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease;
  max-width: 320px;
}

.toast-success {
  border-left: 4px solid #49a078;
  color: #085041;
}

.toast-error {
  border-left: 4px solid #e24b4a;
  color: #a32d2d;
}

.toast-info {
  border-left: 4px solid #185fa5;
  color: #1565c0;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   13. ROLE BADGE (per giovani)
   ──────────────────────────────────────────────────────────────────────────── */

/* ────────────────────────────────────────────────────────────────────────────
   14. UTILITY CLASSES
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
}

@media (min-width: 769px) {
}

/* ────────────────────────────────────────────────────────────────────────────
   15. DASHBOARD GIOVANI — cards statistiche
   ──────────────────────────────────────────────────────────────────────────── */

.dash-card {
  background: white;
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-card .number {
  font-size: 2rem;
  font-weight: 700;
  color: #b53a1e;
  line-height: 1;
}

.dash-card .label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #2c2c2a;
}

.dash-card .sub {
  font-size: 0.75rem;
  color: #888;
}

/* ────────────────────────────────────────────────────────────────────────────
   16. DARK MODE — attivato via [data-theme="dark"] su <html>
   ──────────────────────────────────────────────────────────────────────────── */

[data-theme='dark'] body {
  background: #1c1916;
  color: #e8e4dc;
}

/* Sfondo e superfici */
[data-theme='dark'] .card,
[data-theme='dark'] .panel,
[data-theme='dark'] .poi-table,
[data-theme='dark'] .data-table {
  background: #2b2720;
  border-color: #3c3830;
}

[data-theme='dark'] .card h3,
[data-theme='dark'] .panel h3,
[data-theme='dark'] .card-luogo {
  color: #e8e4dc;
}

[data-theme='dark'] .card-desc {
  color: #c8c4bc;
}

[data-theme='dark'] .card-meta,
[data-theme='dark'] .card-date {
  color: #9a9690;
}

/* Header (mantiene terracotta, testo chiaro) */
[data-theme='dark'] header {
  background: var(--color-sidebar-bg);
}

[data-theme='dark'] .admin-sidebar {
  background: #1a0a05;
  border-right: 1px solid #2b1810;
}

[data-theme='dark'] .sidebar-brand {
  border-bottom-color: #2b1810;
}

[data-theme='dark'] .sidebar-footer {
  border-top-color: #2b1810;
}

[data-theme='dark'] .sidebar-link.active {
  background: rgba(255, 255, 255, 0.1);
}

[data-theme='dark'] .admin-topbar {
  background: #1a0a05;
}

/* Tabelle */
[data-theme='dark'] th {
  background: #242018;
  color: #9a9690;
  border-bottom-color: #3c3830;
}

[data-theme='dark'] td {
  border-bottom-color: #2c2820;
  color: #e8e4dc;
}

[data-theme='dark'] tr:hover td {
  background: #302a21;
}

[data-theme='dark'] tr.inattivo td {
  opacity: 0.35;
}

/* Form elements */
[data-theme='dark'] input,
[data-theme='dark'] select,
[data-theme='dark'] textarea {
  background: #242018;
  border-color: #3c3830;
  color: #e8e4dc;
}

[data-theme='dark'] input:focus,
[data-theme='dark'] select:focus,
[data-theme='dark'] textarea:focus {
  border-color: #e07a63;
  box-shadow: 0 0 0 3px rgba(212, 120, 95, 0.15);
}

[data-theme='dark'] .form-row label {
  color: #9a9690;
}

/* Bottoni secondari */
[data-theme='dark'] .btn,
[data-theme='dark'] .filter-btn,
[data-theme='dark'] .btn-refresh {
  background: #2b2720;
  border-color: #3c3830;
  color: #e8e4dc;
}

[data-theme='dark'] .btn:hover,
[data-theme='dark'] .btn-refresh:hover {
  background: #302a21;
}

[data-theme='dark'] .filter-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* Bottone letta / poi / del */
[data-theme='dark'] .btn-letta {
  background: #2b2720;
  border-color: #e07a63;
  color: #e07a63;
}

[data-theme='dark'] .btn-letta:hover {
  background: #3a1e18;
}

[data-theme='dark'] .btn-letta.done {
  border-color: #5c5852;
  color: #5c5852;
}

[data-theme='dark'] .btn-poi {
  background: #2b2720;
  border-color: #4a7cb5;
  color: #7caed9;
}

[data-theme='dark'] .btn-poi:hover {
  background: #1a2a3a;
}

[data-theme='dark'] .btn-del {
  background: #2b2720;
  border-color: #3c3830;
  color: #9a9690;
}

[data-theme='dark'] .btn-del:hover {
  border-color: #e24b4a;
  color: #e24b4a;
  background: #2a1515;
}

[data-theme='dark'] .btn-danger {
  border-color: #e24b4a;
  color: #e24b4a;
}

[data-theme='dark'] .btn-danger:hover {
  background: #2a1515;
}

/* Auth modal */
[data-theme='dark'] #auth-overlay {
  background: rgba(0, 0, 0, 0.75);
}

[data-theme='dark'] #auth-box {
  background: #2b2720;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

[data-theme='dark'] #auth-box h2 {
  color: #e8e4dc;
}

[data-theme='dark'] #auth-box p {
  color: #9a9690;
}

[data-theme='dark'] #auth-input {
  background: #1c1916;
  border-color: #3c3830;
  color: #e8e4dc;
}

[data-theme='dark'] #auth-input:focus {
  border-color: #e07a63;
}

[data-theme='dark'] #auth-err {
  color: #e24b4a;
}

/* Toast notifications (mantieni colori semantici) */
[data-theme='dark'] .toast {
  background: #2b2720;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme='dark'] .toast-success {
  border-left-color: #49a078;
  color: #7dd4ae;
}

[data-theme='dark'] .toast-error {
  border-left-color: #e24b4a;
  color: #f08080;
}

[data-theme='dark'] .toast-info {
  border-left-color: #4a7cb5;
  color: #7caed9;
}

/* Messaggi feedback */
[data-theme='dark'] .msg.ok {
  background: #0d2b22;
  color: #7dd4ae;
  border-color: #49a078;
}

[data-theme='dark'] .msg.err {
  background: #2a1515;
  color: #f08080;
  border-color: #e24b4a;
}

[data-theme='dark'] .empty,
[data-theme='dark'] .loading {
  color: #9a9690;
}

/* Badge status — leggibili su sfondo scuro */
[data-theme='dark'] .badge {
  background: #b53a1e;
  color: white;
}

[data-theme='dark'] .badge.zero {
  background: #5c5852;
  color: #e8e4dc;
}

[data-theme='dark'] .badge-bozza {
  background: #302a21;
  color: #b0aca4;
}

[data-theme='dark'] .badge-approvato {
  background: #0d2b22;
  color: #7dd4ae;
}

[data-theme='dark'] .badge-pubblicato {
  background: #1a2a3a;
  color: #7caed9;
}

[data-theme='dark'] .badge-rifiutato {
  background: #2a1515;
  color: #f08080;
}

[data-theme='dark'] .badge-racconto {
  background: #221a36;
  color: #b39ddb;
}

[data-theme='dark'] .badge-proposta {
  background: #1a2a3a;
  color: #7caed9;
}

[data-theme='dark'] .badge-mappa_emotiva {
  background: #2b2200;
  color: #ffd54f;
}

[data-theme='dark'] .badge-denuncia_creativa {
  background: #2a1025;
  color: #f48fb1;
}

[data-theme='dark'] .badge-esperienza_rifiuto {
  background: #0d2b28;
  color: #80cbc4;
}

[data-theme='dark'] .badge-strutturale {
  background: #302a21;
  color: #b0aca4;
}

[data-theme='dark'] .badge-attivo {
  background: #0d2b22;
  color: #7dd4ae;
}

[data-theme='dark'] .badge-concluso {
  background: #302a21;
  color: #b0aca4;
}

[data-theme='dark'] .badge-sospeso {
  background: #2b2200;
  color: #ffd54f;
}

[data-theme='dark'] .badge-verificato {
  background: #0d2b22;
  color: #7dd4ae;
}

[data-theme='dark'] .badge-disatteso {
  background: #2a1515;
  color: #f08080;
}

[data-theme='dark'] .badge-aperto {
  background: #1a2a3a;
  color: #7caed9;
}

[data-theme='dark'] .badge-invitato {
  background: #221a36;
  color: #b39ddb;
}

[data-theme='dark'] .badge-cerchio_tenuto {
  background: #2b2200;
  color: #ffd54f;
}

[data-theme='dark'] .badge-impegno_preso {
  background: #0d2b22;
  color: #7dd4ae;
}

[data-theme='dark'] .tipo-errore {
  background: #2a1515;
  color: #f08080;
}

[data-theme='dark'] .tipo-mancante {
  background: #1a2a3a;
  color: #7caed9;
}

[data-theme='dark'] .tipo-suggerimento {
  background: #2b1e00;
  color: #ffb74d;
}

/* Dashboard giovani */
[data-theme='dark'] .dash-card {
  background: #2b2720;
}

[data-theme='dark'] .dash-card .number {
  color: #e07a63;
}

[data-theme='dark'] .dash-card .label {
  color: #e8e4dc;
}

[data-theme='dark'] .dash-card .sub {
  color: #9a9690;
}

/* Panel border separator */
[data-theme='dark'] .panel h3 {
  border-bottom-color: #3c3830;
}

/* Coords */
[data-theme='dark'] .coords {
  color: #9a9690;
}

/* Nav buttons in header (su sfondo scuro header) — invariati, già su terracotta */
[data-theme='dark'] .nav-btn {
  border-color: rgba(255, 255, 255, 0.3);
  color: white;
}

/* ────────────────────────────────────────────────────────────────────────────
   15. DARK MODE TOGGLE
   ──────────────────────────────────────────────────────────────────────────── */

.dark-toggle {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  margin-left: auto;
}

.dark-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ────────────────────────────────────────────────────────────────────────────
   17. CONFIRM MODAL
   ──────────────────────────────────────────────────────────────────────────── */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.confirm-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.confirm-box {
  background: white;
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 380px;
  width: 90vw;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}
.confirm-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #2c2c2a;
}
.confirm-msg {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 20px;
  line-height: 1.5;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

[data-theme='dark'] .confirm-box {
  background: #2b2720;
}
[data-theme='dark'] .confirm-title {
  color: #e8e4dc;
}
[data-theme='dark'] .confirm-msg {
  color: #9a9690;
}

/* ────────────────────────────────────────────────────────────────────────────
   18. CHAR COUNTER
   ──────────────────────────────────────────────────────────────────────────── */

.char-counter {
  font-size: 11px;
  color: #aaa;
  text-align: right;
  margin-top: 2px;
}
.char-counter.near-limit {
  color: #c07628;
}
.char-counter.at-limit {
  color: #a32d2d;
}

[data-theme='dark'] .char-counter {
  color: #9a9690;
}
[data-theme='dark'] .char-counter.near-limit {
  color: #ffb74d;
}
[data-theme='dark'] .char-counter.at-limit {
  color: #f08080;
}

/* ────────────────────────────────────────────────────────────────────────────
   19. TABLE SORTING
   ──────────────────────────────────────────────────────────────────────────── */

thead th[data-sort='asc']::after {
  content: ' \25B2';
  font-size: 10px;
}
thead th[data-sort='desc']::after {
  content: ' \25BC';
  font-size: 10px;
}
thead th:not(.no-sort) {
  user-select: none;
}
thead th:not(.no-sort):hover {
  color: #b53a1e;
}

[data-theme='dark'] thead th:not(.no-sort):hover {
  color: #e07a63;
}

/* ────────────────────────────────────────────────────────────────────────────
   20. FIELD VALIDATION
   ──────────────────────────────────────────────────────────────────────────── */

.field-error input,
.field-error select,
.field-error textarea {
  border-color: #e24b4a !important;
  box-shadow: 0 0 0 3px rgba(226, 75, 74, 0.1) !important;
}
.field-error-msg {
  font-size: 11px;
  color: #a32d2d;
  margin-top: 3px;
  display: block;
}

[data-theme='dark'] .field-error-msg {
  color: #f08080;
}

/* ────────────────────────────────────────────────────────────────────────────
   21. ROW LOADING STATE
   ──────────────────────────────────────────────────────────────────────────── */

tr.row-loading {
  opacity: 0.5;
  pointer-events: none;
}
tr.row-loading td::after {
  content: none;
}

/* ────────────────────────────────────────────────────────────────────────────
   22. UNDO TOAST
   ──────────────────────────────────────────────────────────────────────────── */

.toast-undo {
  border-left: 4px solid #555;
  color: #333;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  transition: opacity 0.3s;
}
[data-theme='dark'] .toast-undo {
  color: #e8e4dc;
}
.toast-undo-btn {
  background: none;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  color: inherit;
  font-family: inherit;
}
.toast-undo-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

/* ────────────────────────────────────────────────────────────────────────────
   23. HAMBURGER MENU MOBILE
   ──────────────────────────────────────────────────────────────────────────── */

.hamburger {
  display: none;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: white;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.mobile-nav-drawer {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 8000;
}
.mobile-nav-drawer.open {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}
.mobile-nav-inner {
  background: #b53a1e;
  width: 260px;
  max-width: 90vw;
  min-height: 100vh;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mobile-nav-inner .nav-btn {
  display: block;
  text-align: left;
  padding: 10px 14px;
  font-size: 14px;
}
.mobile-nav-close {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: white;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 18px;
  cursor: pointer;
  align-self: flex-end;
  margin-bottom: 8px;
}

[data-theme='dark'] .mobile-nav-inner {
  background: var(--color-sidebar-bg);
}

@media (max-width: 768px) {
  .hamburger {
    display: block;
  }
  .header-nav .nav-btn,
  .header-nav .dark-toggle {
    display: none;
  }
  .header-nav {
    gap: 8px;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   24. MOBILE TOUCH TARGETS
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .td-actions .btn-sm {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .btn-letta,
  .btn-del,
  .btn-poi {
    min-height: 44px;
    padding: 10px 16px;
  }
  .topbar-menu-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }
  .filter-btn {
    min-height: 44px;
    padding: 10px 14px;
  }
}

/* ────────────────────────────────────────────────────────────────────────────
   25. MOBILE CARD LAYOUT FOR TABLES
   ──────────────────────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .poi-table,
  .data-table,
  .bandi-table,
  table {
    display: block;
  }
  thead {
    display: none;
  }
  tbody {
    display: block;
  }
  tr {
    display: block;
    background: white;
    border-radius: 10px;
    border: 1px solid #e8e8e4;
    margin-bottom: 12px;
    padding: 12px 14px;
  }
  [data-theme='dark'] tr {
    background: #2b2720;
    border-color: #3c3830;
  }
  td {
    display: flex;
    border: none;
    padding: 4px 0;
    font-size: 13px;
    align-items: center;
  }
  td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-width: 90px;
    flex-shrink: 0;
  }
  .td-actions {
    justify-content: flex-start;
    gap: 8px;
    margin-top: 8px;
  }
}

/* ── Admin dark mode supplemental (elements not covered above) ── */
[data-theme='dark'] .modal-overlay {
  background: rgba(0, 0, 0, 0.7);
}
[data-theme='dark'] .btn-secondary {
  background: #333;
  color: #e0e0e0;
}
[data-theme='dark'] .stats-grid .stat-card {
  background: #2a2a2a;
}
[data-theme='dark'] .msg {
  background: #2a2a2a;
  color: #aaa;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   N. ADMIN MODAL, DASHBOARD, CHIPS, BULK ACTIONS — design tokens + classi
   Introdotti in Fase 1 UX refactor — non rimuovere senza rifattorizzare
      admin-modal.js e pagine che li usano (admin.html hub, future migrazioni).
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
  /* Z-index scale */
  --z-sidebar: 200;
  --z-topbar: 300;
  --z-dropdown: 500;
  --z-modal-backdrop: 900;
  --z-modal: 901;
  --z-modal-nested: 911;
  --z-toast: 1000;
  --z-confirm: 1100;

  /* Modal */
  --modal-bg: #ffffff;
  --modal-backdrop: rgba(0, 0, 0, 0.55);
  --modal-radius: 12px;
  --modal-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  --modal-width-sm: 420px;
  --modal-width-md: 640px;
  --modal-width-lg: 840px;
  --modal-width-xl: 1080px;
  --modal-padding-x: 24px;
  --modal-padding-y: 20px;
  --modal-header-border: 1px solid #ece9e3;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;

  /* Dashboard card */
  --dash-card-bg: #ffffff;
  --dash-card-border: #e4e1db;
  --dash-card-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  --dash-card-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.08);

  /* Chips */
  --chip-bg: #f3f1ec;
  --chip-fg: #2c2c2a;
  --chip-active-bg: #d34c31;
  --chip-active-fg: #ffffff;
  --chip-border: #e4e1db;

  /* Bulk bar */
  --bulk-bar-bg: #2c2c2a;
  --bulk-bar-fg: #ffffff;
}

[data-theme='dark'] {
  --modal-bg: #2b2720;
  --modal-backdrop: rgba(0, 0, 0, 0.7);
  --modal-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  --modal-header-border: 1px solid #3c3830;
  --dash-card-bg: #2b2720;
  --dash-card-border: #3c3830;
  --chip-bg: #302a21;
  --chip-fg: #e8e4dc;
  --chip-border: #3c3830;
  --bulk-bar-bg: var(--color-sidebar-bg);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0ms;
    --dur-base: 0ms;
    --dur-slow: 0ms;
  }
}

/* --- Admin Modal --- */
.adm-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}
.adm-modal-overlay.open {
  opacity: 1;
}
.adm-modal-overlay.nested {
  z-index: var(--z-modal-nested);
}

.adm-modal {
  background: var(--modal-bg);
  color: var(--color-text, #2c2c2a);
  border-radius: var(--modal-radius);
  box-shadow: var(--modal-shadow);
  width: 100%;
  max-width: var(--modal-width-md);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  transform: translateY(16px) scale(0.98);
  transition: transform var(--dur-base) var(--ease-out);
  z-index: var(--z-modal);
}
.adm-modal-overlay.open .adm-modal {
  transform: translateY(0) scale(1);
}
.adm-modal--md {
  max-width: var(--modal-width-md);
}
.adm-modal--lg {
  max-width: var(--modal-width-lg);
}

.adm-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: var(--modal-padding-y) var(--modal-padding-x);
  border-bottom: var(--modal-header-border);
  flex-shrink: 0;
}
.adm-modal-title {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
  line-height: 1.3;
}
.adm-modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: #888;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--dur-fast);
}
.adm-modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #2c2c2a;
}
[data-theme='dark'] .adm-modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e8e4dc;
}

.adm-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--modal-padding-y) var(--modal-padding-x);
  min-height: 0;
}
.adm-modal-body.is-loading {
  opacity: 0.5;
  pointer-events: none;
}

.adm-modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px var(--modal-padding-x);
  border-top: var(--modal-header-border);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.adm-modal-footer .btn-ghost {
  background: transparent;
  border: 1px solid #ddd;
  color: inherit;
}
[data-theme='dark'] .adm-modal-footer .btn-ghost {
  border-color: #3c3830;
}

/* Detail fields */
.adm-detail {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.adm-detail-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.adm-detail-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
}
.adm-detail-value {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
[data-theme='dark'] .adm-detail-label {
  color: #9a9690;
}

/* Form inside modal */
.adm-form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.adm-form-row label {
  font-size: 12px;
  font-weight: 600;
  color: #555;
}
[data-theme='dark'] .adm-form-row label {
  color: #c7c3bb;
}
.adm-form-row input,
.adm-form-row select,
.adm-form-row textarea {
  border: 1px solid #ddd;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  background: #ffffff;
  color: inherit;
  width: 100%;
}
.adm-form-row input:focus,
.adm-form-row select:focus,
.adm-form-row textarea:focus {
  border-color: #d34c31;
  outline: 2px solid rgba(var(--color-primary-rgb), 0.15);
  outline-offset: 0;
}
[data-theme='dark'] .adm-form-row input,
[data-theme='dark'] .adm-form-row select,
[data-theme='dark'] .adm-form-row textarea {
  background: #1c1917;
  border-color: #44403c;
  color: #e7e5e4;
}
.adm-form-row textarea {
  min-height: 90px;
  resize: vertical;
}
.adm-form-hint {
  font-size: 11px;
  color: #888;
}
.adm-form-error {
  font-size: 12px;
  color: #991b1b;
  margin-top: 2px;
}

/* Mobile: modale full-screen */
@media (max-width: 600px) {
  .adm-modal-overlay {
    padding: 0;
    align-items: stretch;
  }
  .adm-modal {
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    transform: translateY(24px);
  }
  .adm-modal-overlay.open .adm-modal {
    transform: translateY(0);
  }
}

/* --- Dashboard hub --- */
.dash-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.dash-hub-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--dash-card-bg);
  border: 1px solid var(--dash-card-border);
  border-radius: 10px;
  box-shadow: var(--dash-card-shadow);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
  position: relative;
}
.dash-hub-card:hover,
.dash-hub-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--dash-card-shadow-hover);
  outline: none;
}
.dash-hub-card .val {
  font-size: 1.8rem;
  font-weight: 800;
  color: #d34c31;
  line-height: 1;
}
[data-theme='dark'] .dash-hub-card .val {
  color: #e07a63;
}
.dash-hub-card .lbl {
  font-size: 13px;
  font-weight: 600;
  color: inherit;
}
.dash-hub-card .sub {
  font-size: 11px;
  color: #888;
}
.dash-hub-card.is-urgent .val {
  color: #a32d2d;
}
.dash-hub-card.is-urgent::before {
  content: '';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e24b4a;
  box-shadow: 0 0 0 3px rgba(226, 75, 74, 0.2);
}
.dash-hub-card.is-zero .val {
  color: #888;
}
[data-theme='dark'] .dash-hub-card.is-zero .val {
  color: #7a7670;
}

.dash-section-title {
  font-size: 14px;
  font-weight: 700;
  color: #555;
  margin: 24px 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
[data-theme='dark'] .dash-section-title {
  color: #c7c3bb;
}

.dash-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 800px) {
  .dash-two-col {
    grid-template-columns: 1fr;
  }
}

.dash-feed {
  background: var(--dash-card-bg);
  border: 1px solid var(--dash-card-border);
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: var(--dash-card-shadow);
}
.dash-feed-item {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  line-height: 1.4;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
.dash-feed-item:last-child {
  border-bottom: none;
}
.dash-feed-item .t {
  color: #888;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
[data-theme='dark'] .dash-feed-item {
  border-bottom-color: rgba(255, 255, 255, 0.05);
}
[data-theme='dark'] .dash-feed-item .t {
  color: #9a9690;
}
.dash-feed-item .ok {
  color: #065f46;
}
.dash-feed-item .warn {
  color: #92400e;
}
.dash-feed-item .err {
  color: #991b1b;
}
[data-theme='dark'] .dash-feed-item .ok {
  color: #7dd4ae;
}
[data-theme='dark'] .dash-feed-item .warn {
  color: #fde68a;
}
[data-theme='dark'] .dash-feed-item .err {
  color: #f08080;
}

.dash-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dash-quick-actions .btn {
  justify-content: flex-start;
  text-align: left;
}

/* --- Chips --- */
.chip {
  background: var(--chip-bg);
  color: var(--chip-fg);
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--dur-fast);
}
.chip:hover {
  background: #e4e1db;
}
[data-theme='dark'] .chip:hover {
  background: #3c3830;
}
.chip.is-active {
  background: var(--chip-active-bg);
  color: var(--chip-active-fg);
  border-color: var(--chip-active-bg);
}

/* --- Bulk action bar --- */
.bulk-bar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(100px);
  background: var(--bulk-bar-bg);
  color: var(--bulk-bar-fg);
  border-radius: 10px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: var(--z-toast);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transition: transform var(--dur-base) var(--ease-out);
  font-size: 13px;
}
.bulk-bar.open {
  transform: translateX(-50%) translateY(0);
}
.bulk-bar .count {
  font-weight: 700;
}
.bulk-bar .btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: inherit;
}
.bulk-bar .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* --- Bulk selection (Fase 3) --- */
col.col-bulk {
  width: 36px;
}
.bulk-th,
.bulk-td {
  width: 36px;
  text-align: center;
  padding: 6px 4px !important;
}
.bulk-th input[type='checkbox'],
.bulk-td input[type='checkbox'] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--color-primary, #d34c31);
  margin: 0;
}
.bulk-bar-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.bulk-bar .btn {
  font-size: 13px;
  padding: 6px 12px;
}
.bulk-bar.is-busy {
  opacity: 0.6;
  pointer-events: none;
}
tr[data-bulk-selected='1'] td {
  background: rgba(var(--color-primary-rgb), 0.05);
}
[data-theme='dark'] tr[data-bulk-selected='1'] td {
  background: rgba(212, 120, 95, 0.08);
}

@media (max-width: 600px) {
  .bulk-bar {
    left: 10px;
    right: 10px;
    bottom: 12px;
    transform: translateY(120px);
  }
  .bulk-bar.open {
    transform: translateY(0);
  }
}

/* Responsive: sidebar offset already handled by .has-admin-sidebar, dashboard e modali lo ereditano */

/* Empty state condiviso per pagine admin con liste */
.admin-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
  color: var(--color-text-muted, #6b6b6b);
}
.admin-empty-state p {
  margin: 0;
  font-size: 0.95rem;
}

/* Utility condivise per sostituire CSS inline in pagine admin (P2-B6).
   Tutte usano variabili CSS per coerenza con dark mode. */
.required-star {
  color: var(--color-primary);
}
.meta-dim {
  color: var(--color-text-muted, #6b6b6b);
  font-size: 12px;
}
.inline-flex {
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 640px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   UTILITIES — Sprint 7 CSS zero-inline (F1-B1)
   ============================================ */

/* Scraper log */
.scraper-section-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-text-muted, #888);
}
.log-status {
  min-width: 48px;
}
.log-fonte {
  min-width: 120px;
  font-weight: 500;
}
.log-msg {
  color: var(--color-text-muted, #888);
  flex: 1;
}
.log-time {
  color: var(--color-text-dim, #aaa);
  white-space: nowrap;
}
.log-result-row {
  padding: 2px 0;
}
.log-result-ms {
  color: var(--color-text-dim, #aaa);
}

/* Workflow form (assessment, conflitti) */
.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stack-xs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-label-sm {
  font-size: 13px;
  font-weight: 600;
}
.form-label-note {
  font-weight: 400;
  color: var(--color-text-muted, #888);
}
.wf-control {
  margin-top: 4px;
  width: 100%;
  padding: 6px;
  border-radius: 6px;
}
.wf-control-textarea {
  margin-top: 4px;
  width: 100%;
  padding: 6px;
  border-radius: 6px;
  resize: vertical;
}

/* Testo preformattato */
.pre-wrap {
  white-space: pre-wrap;
}
.pre-wrap-break {
  white-space: pre-wrap;
  word-break: break-word;
}
.pre-detail {
  white-space: pre-wrap;
  max-height: 400px;
  overflow: auto;
  font-family: monospace;
  font-size: 12px;
  background: var(--color-bg-muted, #f8f7f4);
  padding: 10px;
  border-radius: 6px;
  margin: 0;
}

/* Stato assenza dati */
.no-data-sm {
  font-size: 0.8rem;
  color: var(--color-text-muted, #888);
}

/* Conflitti mappa */
.facilitazione-badge {
  color: #059669;
  font-weight: 600;
}
.btn-detail-sm {
  margin-top: 6px;
  padding: 4px 10px;
  font-size: 12px;
}

/* Codice/monospace inline */
.code-mono {
  font-family: monospace;
  font-size: 12px;
}

/* Newsletter / tabelle numeriche */
.td-num {
  color: var(--color-text-muted, #888);
  width: 40px;
}
.td-dim {
  color: var(--color-text-muted, #888);
}

/* Segnalazioni — badge stato lettura */
.badge-letta {
  background: #d1fae5;
  color: #065f46;
}
.badge-nuova {
  background: #fef3c7;
  color: #92400e;
}
[data-theme='dark'] .badge-letta {
  background: #064e3b;
  color: #6ee7b7;
}
[data-theme='dark'] .badge-nuova {
  background: #78350f;
  color: #fde68a;
}

/* Hint/note di input */
.hint-sm {
  font-size: 0.72rem;
  color: var(--color-text-dim, #999);
  margin-top: 0.2rem;
}

/* Label checkbox */
.label-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  font-size: 13px;
}
.checkbox-input {
  width: auto;
  border: none;
  padding: 0;
  margin: 0;
}

/* Flex row con gap */
.flex-gap {
  display: flex;
  gap: 8px;
}

/* Percezioni emozioni detail */
.emo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.emo-icon {
  width: 22px;
}
.emo-label {
  width: 90px;
}
.emo-bar-bg {
  flex: 1;
  background: var(--color-border, #eee);
  border-radius: 3px;
  height: 10px;
  overflow: hidden;
}
.emo-pct {
  width: 60px;
  text-align: right;
}

/* ──────────────────────────────────────────────────────────────────
   NOTIFICATION CENTER (M2-B14)
   Badge nel sidebar-brand + dropdown panel con lista non lette.
   ────────────────────────────────────────────────────────────────── */
.sidebar-notif-btn {
  position: relative;
  margin-left: auto;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.sidebar-notif-btn:hover,
.sidebar-notif-btn[aria-expanded='true'] {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.25);
  color: white;
}
.sidebar-notif-btn:focus-visible {
  outline: 2px solid var(--color-primary, #d34c31);
  outline-offset: 2px;
}
.sidebar-notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--color-primary, #d34c31);
  color: white;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  border-radius: 9px;
  border: 2px solid #1a1a1a;
}
.sidebar-notif-badge[hidden] {
  display: none;
}

.sidebar-notif-panel {
  position: fixed;
  top: 60px;
  left: 220px;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--color-bg-card, #fff);
  color: var(--color-text);
  border: 1px solid var(--color-border, rgba(0, 0, 0, 0.12));
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  z-index: 9999;
}
.sidebar-notif-panel[hidden] {
  display: none;
}
.sidebar-notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
  position: sticky;
  top: 0;
  background: var(--color-bg-card, #fff);
}
.sidebar-notif-link {
  background: transparent;
  border: 0;
  padding: 4px 6px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--color-primary, #d34c31);
  cursor: pointer;
  text-decoration: underline;
}
.sidebar-notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar-notif-item {
  border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.06));
}
.sidebar-notif-item:last-child {
  border-bottom: 0;
}
.sidebar-notif-link-target {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  color: inherit;
}
.sidebar-notif-link-target:hover {
  background: rgba(var(--color-primary-rgb), 0.04);
}
.sidebar-notif-item.is-read .sidebar-notif-title {
  font-weight: 400;
  opacity: 0.7;
}
.sidebar-notif-cat {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(var(--color-primary-rgb), 0.08);
  color: var(--color-primary, #d34c31);
  margin-bottom: 6px;
}
.sidebar-notif-title {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.3;
  margin-bottom: 4px;
}
.sidebar-notif-body {
  font-size: 0.82rem;
  color: var(--color-text-muted, rgba(0, 0, 0, 0.6));
  line-height: 1.4;
  margin-bottom: 6px;
}
.sidebar-notif-time {
  font-size: 0.75rem;
  color: var(--color-text-muted, rgba(0, 0, 0, 0.5));
}
.sidebar-notif-empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--color-text-muted, rgba(0, 0, 0, 0.55));
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .sidebar-notif-panel {
    top: 56px;
    left: 16px;
    right: 16px;
    width: auto;
  }
}

[data-theme='dark'] .sidebar-notif-cat {
  background: rgba(var(--color-primary-rgb), 0.18);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SHELL V2 — Editorial admin design system (2026-05-07)
   Pagine target iniziali: admin.html (Dashboard), admin-analytics.html, admin-search-log.html.
   Convive con il legacy soprastante. Per usarlo, una pagina admin imposta
   data-admin-shell="v2" su <body> e usa le classi .app/.page/.kpi/.queue-card/etc.
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── App shell ─────────────────────────────────────────────────────────────── */
body[data-admin-shell='v2'] {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}
body[data-admin-shell='v2'].has-admin-sidebar {
  margin-left: 0;
}
body[data-admin-shell='v2'] table {
  border-collapse: collapse;
  width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.app-shell[data-sidebar='collapsed'] {
  grid-template-columns: 64px 1fr;
}

/* ── Sidebar v2 ────────────────────────────────────────────────────────────── */
.shell-sidebar {
  background: var(--color-sidebar-bg);
  color: #efe6dc;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.shell-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
}
.shell-sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--color-primary);
  display: grid;
  place-items: center;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
}
.shell-sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.shell-sidebar-brand-text strong {
  font-weight: 600;
  font-size: 14px;
}
.shell-sidebar-brand-text span {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(239, 230, 220, 0.55);
}
.shell-sidebar-section {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(239, 230, 220, 0.45);
  padding: 14px 10px 6px;
}
.shell-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: rgba(239, 230, 220, 0.78);
  font-size: 13.5px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  text-decoration: none;
  font-family: inherit;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.shell-sidebar-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}
.shell-sidebar-link[aria-current='page'] {
  background: var(--color-primary);
  color: #fff;
}
.shell-sidebar-link[aria-current='page']:hover {
  background: var(--color-primary);
}
.shell-sidebar-link svg,
.shell-sidebar-link .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.shell-sidebar-link .badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  font-family: var(--font-mono);
}
.shell-sidebar-link[aria-current='page'] .badge {
  background: rgba(255, 255, 255, 0.22);
}
.shell-sidebar-link.danger .badge {
  background: var(--color-primary);
  color: #fff;
}
.shell-sidebar-spacer {
  flex: 1;
}
.shell-sidebar-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-shell[data-sidebar='collapsed'] .shell-sidebar {
  padding: 20px 8px;
}
.app-shell[data-sidebar='collapsed'] .shell-sidebar-brand-text,
.app-shell[data-sidebar='collapsed'] .shell-sidebar-section,
.app-shell[data-sidebar='collapsed'] .shell-sidebar-link span:not(.badge),
.app-shell[data-sidebar='collapsed'] .shell-sidebar-link .badge {
  display: none;
}
.app-shell[data-sidebar='collapsed'] .shell-sidebar-link {
  justify-content: center;
  padding: 10px;
}

/* ── Main area + topbar ────────────────────────────────────────────────────── */
.shell-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.shell-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--color-border);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.shell-topbar-tabs {
  display: flex;
  gap: 2px;
  background: var(--color-bg-warm);
  border-radius: 999px;
  padding: 4px;
}
.shell-topbar-tab {
  padding: 7px 16px;
  border-radius: 999px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-2);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  text-decoration: none;
}
.shell-topbar-tab:hover {
  color: var(--fg-1);
}
.shell-topbar-tab[aria-current='page'] {
  background: var(--color-bg-card);
  color: var(--fg-1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.shell-topbar-tab svg,
.shell-topbar-tab .icon {
  width: 14px;
  height: 14px;
}
.shell-topbar-tab .tab-count {
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-primary);
}
.shell-topbar-spacer {
  flex: 1;
}
.shell-topbar-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  display: grid;
  place-items: center;
  color: var(--fg-2);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.shell-topbar-icon-btn svg,
.shell-topbar-icon-btn .icon {
  width: 16px;
  height: 16px;
}
.shell-topbar-icon-btn:hover {
  color: var(--fg-1);
  border-color: #c9c2b3;
}
.shell-topbar-icon-btn .dot {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 1.5px solid var(--color-bg-card);
}
.shell-topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
}
.shell-topbar-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-secondary);
  color: #fff;
  font-weight: 600;
  font-size: 11px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
}
.shell-topbar-user-name {
  font-size: 12.5px;
  font-weight: 500;
}

/* Mobile shell ─────────────────────────────────────────────────────────────── */
.shell-topbar-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  color: var(--fg-2);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.shell-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 6998;
}
.shell-sidebar-overlay.open {
  display: block;
}
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .shell-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    z-index: 7000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .shell-sidebar.open {
    transform: translateX(0);
  }
  .shell-topbar-menu-btn {
    display: inline-flex;
  }
  .shell-topbar {
    padding: 12px 16px;
  }
  .shell-topbar-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
  }
}

/* ── Page container ────────────────────────────────────────────────────────── */
.shell-page {
  padding: 28px 32px 60px;
  max-width: 1500px;
  width: 100%;
}
@media (max-width: 600px) {
  .shell-page {
    padding: 18px 16px 48px;
  }
}
.shell-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.shell-page-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.shell-page-eyebrow .pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: shell-pulse 2.4s ease-in-out infinite;
}
@keyframes shell-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.85);
  }
}
.shell-page-title {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 36px;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
  color: var(--fg-1);
}
.shell-page-title em {
  font-style: italic;
  color: var(--color-primary);
}
.shell-page-subtitle {
  font-size: 14px;
  color: var(--fg-2);
  margin-top: 6px;
  max-width: 60ch;
}
.shell-page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Buttons v2 ────────────────────────────────────────────────────────────── */
.shell-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  background: transparent;
  color: var(--fg-1);
  white-space: nowrap;
  text-decoration: none;
}
.shell-btn svg,
.shell-btn .icon {
  width: 14px;
  height: 14px;
}
.shell-btn-ghost {
  border-color: var(--color-border);
  background: var(--color-bg-card);
}
.shell-btn-ghost:hover {
  border-color: #c9c2b3;
  transform: translateY(-1px);
}
.shell-btn-primary {
  background: var(--fg-1);
  color: var(--color-bg);
  border-color: var(--fg-1);
}
.shell-btn-primary:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  transform: translateY(-1px);
}
.shell-btn-accent {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.shell-btn-accent:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  transform: translateY(-1px);
}
.shell-btn-sm {
  padding: 5px 11px;
  font-size: 12px;
}

/* ── Cards & section heads ─────────────────────────────────────────────────── */
.shell-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.shell-card-eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--fg-3);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.shell-card-eyebrow .num {
  color: var(--color-primary);
  font-weight: 600;
}
.shell-card-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.shell-card-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}
.shell-card-meta {
  font-size: 12px;
  color: var(--fg-2);
  font-family: var(--font-mono);
}

.shell-section-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: baseline;
  margin: 32px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}
.shell-section-head-num {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--color-primary);
}
.shell-section-head-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--fg-1);
}
.shell-section-head-title em {
  font-style: italic;
  color: var(--color-primary);
}
.shell-section-head-link {
  font-size: 13px;
  color: var(--fg-2);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  font-family: inherit;
}
.shell-section-head-link:hover {
  color: var(--color-primary);
}

/* ── KPI cards ─────────────────────────────────────────────────────────────── */
.shell-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.shell-kpi {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  transition:
    border-color 0.15s ease,
    transform 0.15s ease;
}
.shell-kpi:hover {
  border-color: #c9c2b3;
}
.shell-kpi-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.shell-kpi-value {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 38px;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--fg-1);
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.shell-kpi-value .unit {
  font-style: italic;
  font-size: 16px;
  color: var(--fg-3);
  font-weight: 400;
}
.shell-kpi-value.is-warn {
  color: var(--color-primary);
}
.shell-kpi-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}
.shell-kpi-meta {
  font-size: 12px;
  color: var(--fg-3);
}
.shell-kpi-delta {
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
}
.shell-kpi-delta.up {
  background: rgba(107, 127, 94, 0.15);
  color: #4d6044;
}
.shell-kpi-delta.down {
  background: rgba(var(--color-primary-rgb), 0.12);
  color: var(--color-primary-dark);
}
.shell-kpi-delta.flat {
  background: var(--color-bg-warm);
  color: var(--fg-3);
}
.shell-kpi-spark {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 38px;
  pointer-events: none;
  opacity: 0.85;
}
.app-shell[data-spark='off'] .shell-kpi-spark {
  display: none;
}
.shell-kpi.has-spark {
  padding-bottom: 42px;
}
.app-shell[data-spark='off'] .shell-kpi.has-spark {
  padding-bottom: 16px;
}

/* ── Filters bar ───────────────────────────────────────────────────────────── */
.shell-filterbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 18px;
}
.shell-filterbar-segmented {
  display: flex;
  background: var(--color-bg-warm);
  border-radius: 999px;
  padding: 3px;
}
.shell-filterbar-segmented button {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-2);
  cursor: pointer;
  font-family: inherit;
}
.shell-filterbar-segmented button[aria-pressed='true'] {
  background: var(--color-bg-card);
  color: var(--fg-1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.shell-filterbar-input {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 7px 14px 7px 32px;
  font-size: 13px;
  background: var(--color-bg)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>")
    no-repeat 11px center;
  outline: none;
  font-family: inherit;
  color: var(--fg-1);
}
.shell-filterbar-input:focus {
  border-color: var(--color-primary);
  background-color: var(--color-bg-card);
}
.shell-filterbar-select {
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 7px 28px 7px 14px;
  font-size: 12.5px;
  background: var(--color-bg-card)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>")
    no-repeat right 12px center;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  font-family: inherit;
  color: var(--fg-1);
  cursor: pointer;
}
.shell-filterbar-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--fg-2);
  padding: 0 6px;
  cursor: pointer;
}
.shell-filterbar-checkbox input {
  width: auto;
  margin: 0;
}

/* ── Tables v2 ─────────────────────────────────────────────────────────────── */
.shell-tbl-wrap {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}
.shell-tbl {
  width: 100%;
  font-size: 13px;
  border-collapse: collapse;
}
.shell-tbl th {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
  font-weight: 500;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.shell-tbl th .sort-arrow {
  opacity: 0.3;
  margin-left: 4px;
}
.shell-tbl th[aria-sort='ascending'] .sort-arrow,
.shell-tbl th[aria-sort='descending'] .sort-arrow {
  opacity: 1;
  color: var(--color-primary);
}
.shell-tbl td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}
.shell-tbl tr:last-child td {
  border-bottom: none;
}
.shell-tbl tbody tr {
  transition: background 0.1s ease;
}
.shell-tbl tbody tr:hover {
  background: var(--color-bg);
}
.shell-tbl tbody tr.is-active {
  background: rgba(var(--color-primary-rgb), 0.05);
}
.shell-tbl tbody tr.is-active:hover {
  background: rgba(var(--color-primary-rgb), 0.08);
}
.shell-tbl-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.shell-tbl-mono {
  font-family: var(--font-mono);
  font-size: 12px;
}
.shell-tbl-muted {
  color: var(--fg-3);
}

/* ── Chips v2 ──────────────────────────────────────────────────────────────── */
.shell-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--color-bg-warm);
  color: var(--fg-2);
  border: 1px solid transparent;
  white-space: nowrap;
  cursor: default;
}
.shell-chip-terra {
  background: rgba(var(--color-primary-rgb), 0.1);
  color: var(--color-primary-dark);
}
.shell-chip-sage {
  background: rgba(107, 127, 94, 0.15);
  color: #4d6044;
}
.shell-chip-ochre {
  background: rgba(201, 163, 92, 0.18);
  color: #8a6f33;
}
.shell-chip-blue {
  background: #e3ecf2;
  color: #3a5a73;
}
.shell-chip-gray {
  background: var(--color-bg-warm);
  color: var(--fg-3);
}
.shell-chip-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  display: inline-block;
}
.shell-chip-close {
  background: transparent;
  border: none;
  color: inherit;
  margin-left: 4px;
  cursor: pointer;
  font-weight: 700;
  padding: 0 2px;
  font-family: inherit;
}

/* ── Bar tracks ────────────────────────────────────────────────────────────── */
.shell-bar {
  height: 6px;
  background: var(--color-bg-warm);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.shell-bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.shell-bar-fill.sage {
  background: var(--color-secondary);
}
.shell-bar-fill.ochre {
  background: var(--color-accent);
}

/* ── Empty / divider ───────────────────────────────────────────────────────── */
.shell-empty {
  padding: 40px;
  text-align: center;
  color: var(--fg-3);
  font-size: 13px;
}
.shell-divider {
  height: 1px;
  background: var(--color-border);
  margin: 18px 0;
}

/* ── Two-col layouts ───────────────────────────────────────────────────────── */
.shell-split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.shell-split-12 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
}
.shell-split-21 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}
@media (max-width: 1100px) {
  .shell-split-2,
  .shell-split-12,
  .shell-split-21 {
    grid-template-columns: 1fr;
  }
}

/* ── Today hero (Dashboard) ────────────────────────────────────────────────── */
.shell-today-hero {
  background: linear-gradient(135deg, #fff 0%, var(--color-bg-warm) 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 22px 26px;
  position: relative;
  overflow: hidden;
  margin-bottom: 22px;
}
.shell-today-hero::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 200px;
  height: 200px;
  background: radial-gradient(rgba(var(--color-primary-rgb), 0.1) 1px, transparent 1px);
  background-size: 14px 14px;
  pointer-events: none;
}
.shell-today-hero-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 28px;
  align-items: center;
  position: relative;
}
@media (max-width: 1000px) {
  .shell-today-hero-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}
.shell-today-hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.shell-today-hero-eyebrow .pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: shell-pulse 2.4s ease-in-out infinite;
}
.shell-today-hero-headline {
  font-family: var(--font-heading);
  font-size: 26px;
  letter-spacing: -0.018em;
  line-height: 1.2;
  margin: 0;
  text-wrap: pretty;
  font-weight: 400;
}
.shell-today-hero-headline em {
  font-style: italic;
  color: var(--color-primary);
}
.shell-today-hero-stat {
  border-left: 1px solid var(--color-border);
  padding-left: 22px;
}
@media (max-width: 1000px) {
  .shell-today-hero-stat {
    border-left: none;
    border-top: 1px solid var(--color-border);
    padding-left: 0;
    padding-top: 16px;
  }
}
.shell-today-hero-stat-num {
  font-family: var(--font-heading);
  font-size: 44px;
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--fg-1);
}
.shell-today-hero-stat-num em {
  font-style: italic;
  font-size: 22px;
  color: var(--fg-3);
}
.shell-today-hero-stat-num .unit {
  font-size: 24px;
  color: var(--fg-3);
  font-weight: 400;
}
.shell-today-hero-stat-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-top: 6px;
}
.shell-today-hero-stat-meta {
  font-size: 12px;
  color: var(--fg-2);
  margin-top: 4px;
}
.shell-today-hero-stat-meta em {
  font-style: italic;
  color: var(--color-primary);
}

/* ── Action queue (Dashboard) ──────────────────────────────────────────────── */
.shell-queue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.shell-page[data-layout='list'] .shell-queue-grid {
  grid-template-columns: 1fr;
}
.shell-queue-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.shell-queue-card:hover {
  border-color: #c9c2b3;
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}
.shell-queue-card.urgent {
  border-left-color: var(--color-primary);
}
.shell-queue-card.warn {
  border-left-color: var(--color-accent);
}
.shell-queue-card.ok {
  border-left-color: var(--color-secondary);
}
.shell-queue-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.shell-queue-card-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.shell-queue-card-num {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.025em;
  color: var(--fg-1);
  line-height: 1;
}
.shell-queue-card-num.zero {
  color: var(--fg-3);
}
.shell-queue-card-meta {
  font-size: 12px;
  color: var(--fg-3);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.shell-queue-card-action {
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-primary);
  font-weight: 500;
}
.shell-queue-card-action::after {
  content: '  →';
}

.shell-page[data-layout='list'] .shell-queue-card {
  display: grid;
  grid-template-columns: 80px 1fr auto auto;
  gap: 16px;
  align-items: center;
}
.shell-page[data-layout='list'] .shell-queue-card-num {
  font-size: 22px;
  text-align: right;
}
.shell-page[data-layout='list'] .shell-queue-card-action {
  margin-top: 0;
}

/* ── Activity stream ───────────────────────────────────────────────────────── */
.shell-stream {
  display: flex;
  flex-direction: column;
}
.shell-stream-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 9px 4px;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 13px;
}
.shell-stream-row:last-child {
  border-bottom: none;
}
.shell-stream-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.shell-stream-text {
  color: var(--fg-1);
}
.shell-stream-text strong {
  font-weight: 500;
}
.shell-stream-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-3);
}

/* ── Health checks ─────────────────────────────────────────────────────────── */
.shell-health {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.shell-health-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 9px 4px;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 13px;
}
.shell-health-row:last-child {
  border-bottom: none;
}
.shell-health-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
}
.shell-health-icon.ok {
  background: rgba(107, 127, 94, 0.18);
  color: #4d6044;
}
.shell-health-icon.warn {
  background: rgba(201, 163, 92, 0.22);
  color: #8a6f33;
}
.shell-health-icon.err {
  background: rgba(var(--color-primary-rgb), 0.15);
  color: var(--color-primary-dark);
}
.shell-health-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
}

/* ── Heatmap ───────────────────────────────────────────────────────────────── */
.shell-heatmap {
  display: grid;
  grid-template-columns: 36px repeat(24, 1fr);
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
}
.shell-heatmap-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--color-bg-warm);
  transition: transform 0.1s ease;
  position: relative;
}
.shell-heatmap-cell[data-level='1'] {
  background: rgba(var(--color-primary-rgb), 0.12);
}
.shell-heatmap-cell[data-level='2'] {
  background: rgba(var(--color-primary-rgb), 0.28);
}
.shell-heatmap-cell[data-level='3'] {
  background: rgba(var(--color-primary-rgb), 0.5);
}
.shell-heatmap-cell[data-level='4'] {
  background: rgba(var(--color-primary-rgb), 0.72);
}
.shell-heatmap-cell[data-level='5'] {
  background: rgba(var(--color-primary-rgb), 0.92);
}
.shell-heatmap-cell:hover {
  transform: scale(1.4);
  z-index: 2;
  outline: 1px solid var(--fg-1);
}
.shell-heatmap-day {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-3);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
}
.shell-heatmap-hours {
  display: grid;
  grid-template-columns: 36px repeat(24, 1fr);
  gap: 2px;
  margin-top: 6px;
  font-size: 9px;
  color: var(--fg-3);
  font-family: var(--font-mono);
}
.shell-heatmap-hours > div {
  text-align: center;
}
.shell-heatmap-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-3);
  letter-spacing: 0.05em;
  margin-top: 10px;
}
.shell-heatmap-legend-scale {
  display: flex;
  gap: 2px;
}
.shell-heatmap-legend-scale > div {
  width: 14px;
  height: 12px;
  border-radius: 2px;
}

/* ── Donut + bar list ──────────────────────────────────────────────────────── */
.shell-donut-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.shell-donut {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}
.shell-donut-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 160px;
}
.shell-donut-row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
}
.shell-donut-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.shell-donut-row .pct {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}
.shell-donut-row .val {
  font-family: var(--font-heading);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.shell-bar-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.shell-bar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 12.5px;
}
.shell-bar-row-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.shell-bar-row-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.shell-bar-row-name .lbl {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}
.shell-bar-row-name .lbl-sub {
  font-size: 11.5px;
  color: var(--fg-3);
}
.shell-bar-row-val {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}
.shell-bar-row-val b {
  color: var(--fg-1);
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 500;
}

/* ── Pages list (Analytics) ────────────────────────────────────────────────── */
.shell-pages-list {
  display: flex;
  flex-direction: column;
}
.shell-pages-row {
  display: grid;
  grid-template-columns: 1fr 70px 70px 110px;
  gap: 12px;
  align-items: center;
  padding: 9px 4px;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 12.5px;
  cursor: pointer;
}
.shell-pages-row:hover {
  background: var(--color-bg);
}
.shell-pages-row:last-child {
  border-bottom: none;
}
.shell-pages-row-head {
  cursor: default;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
  border-bottom: 1px solid var(--color-border);
}
.shell-pages-row-head:hover {
  background: transparent;
}
.shell-pages-path {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shell-pages-row .meta-small {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-3);
  margin-left: 4px;
}
.shell-pages-row .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.shell-pages-row .scroll-bar {
  display: grid;
  grid-template-columns: 1fr 32px;
  gap: 6px;
  align-items: center;
}
.shell-pages-row .scroll-bar .shell-bar {
  height: 5px;
}

/* ── Trend list / gap card / drill panel (Ricerche) ────────────────────────── */
.shell-trend-list {
  display: flex;
  flex-direction: column;
}
.shell-trend-row {
  display: grid;
  grid-template-columns: 1fr 70px 90px 70px;
  gap: 12px;
  align-items: center;
  padding: 9px 4px;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 13px;
}
.shell-trend-row:last-child {
  border-bottom: none;
}
.shell-trend-row-head {
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.shell-trend-term {
  font-weight: 500;
}
.shell-trend-term em {
  font-style: italic;
  color: var(--color-primary);
}
.shell-trend-spark {
  width: 90px;
  height: 22px;
}
.shell-trend-row .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.shell-gap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.shell-gap-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}
.shell-gap-card.priority {
  border-left: 3px solid var(--color-primary);
}
.shell-gap-card-term {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 22px;
  color: var(--color-primary);
  letter-spacing: -0.01em;
  line-height: 1.1;
  word-break: break-word;
}
.shell-gap-card-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.shell-gap-card-meta strong {
  color: var(--fg-1);
  font-weight: 600;
}
.shell-gap-card-meta-pages {
  font-family: var(--font-body);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg-3);
}
.shell-gap-card-meta-pages code {
  margin-right: 4px;
  font-size: 11px;
  background: var(--color-bg-warm);
  padding: 1px 5px;
  border-radius: 4px;
}
.shell-gap-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.shell-gap-card-actions button {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--fg-2);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.shell-gap-card-actions button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.shell-drill {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-top: 10px;
  position: sticky;
  bottom: 16px;
  box-shadow: var(--shadow-soft);
  z-index: 10;
}
.shell-drill-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.shell-drill-term {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 24px;
  color: var(--color-primary);
}
.shell-drill-stats {
  display: flex;
  gap: 22px;
  font-size: 12.5px;
  color: var(--fg-2);
  margin-left: auto;
  flex-wrap: wrap;
}
.shell-drill-stats b {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 16px;
  color: var(--fg-1);
  margin-right: 2px;
}
.shell-drill-close {
  background: transparent;
  border: 1px solid var(--color-border);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--fg-3);
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  line-height: 1;
}
.shell-drill-close:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.shell-drill-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Pagination ────────────────────────────────────────────────────────────── */
.shell-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--fg-2);
}
.shell-pager-controls {
  display: flex;
  gap: 6px;
}
.shell-pager button {
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--fg-2);
  cursor: pointer;
  font-family: inherit;
}
.shell-pager button:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.shell-pager button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Misc utilities v2 ─────────────────────────────────────────────────────── */
.shell-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.shell-muted {
  color: var(--fg-3);
}
.shell-text-right {
  text-align: right;
}
.shell-tabular {
  font-variant-numeric: tabular-nums;
}
.shell-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ── Daily/area chart ──────────────────────────────────────────────────────── */
.shell-area-chart {
  width: 100%;
  height: 180px;
  display: block;
}
.shell-area-chart .area-fill {
  fill: rgba(var(--color-primary-rgb), 0.12);
}
.shell-area-chart .area-line {
  stroke: var(--color-primary);
  stroke-width: 2;
  fill: none;
}
.shell-area-chart .area-grid {
  stroke: var(--color-border);
  stroke-width: 1;
  stroke-dasharray: 2 4;
  opacity: 0.6;
}
.shell-area-chart .area-axis {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--fg-3);
}

/* ── Sparkline ─────────────────────────────────────────────────────────────── */
.shell-sparkline {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Utility tipografiche v2 (zero CSS inline nelle pagine target) ─────────── */
.shell-em {
  font-style: italic;
  color: var(--color-primary);
}
.shell-italic {
  font-style: italic;
}
.shell-fw-500 {
  font-weight: 500;
}
.shell-cap {
  text-transform: capitalize;
}
.shell-num-tiny {
  font-size: 11px;
}
.shell-code-tiny {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--color-bg-warm);
  padding: 1px 5px;
  border-radius: 4px;
}
.shell-help-text {
  font-size: 13px;
  color: var(--fg-2);
  margin-top: -6px;
  margin-bottom: 14px;
  max-width: 70ch;
}
.shell-hero-lead {
  font-size: 13px;
  color: var(--fg-2);
  margin-top: 10px;
  max-width: 48ch;
}
.shell-card-stack-md {
  margin-bottom: 16px;
}
.shell-card-stack-lg {
  margin-bottom: 20px;
}
.shell-card-stack-top {
  margin-top: 16px;
}
.shell-stat-bold,
.shell-stat-bold-md,
.shell-stat-bold-lg {
  font-family: var(--font-heading);
  font-weight: 500;
  color: var(--fg-1);
}
.shell-stat-bold {
  font-size: 14px;
}
.shell-stat-bold-md {
  font-size: 16px;
}
.shell-stat-bold-lg {
  font-size: 18px;
}
.shell-row-gap-sm {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Quick actions: bottoni full-row, allineati a sinistra */
.shell-quick-action {
  margin-bottom: 6px;
  display: inline-flex;
  width: 100%;
  justify-content: flex-start;
}

/* Donut swatch dinamico via custom property (no style hardcoded) */
.shell-donut-swatch[style*='--swatch'] {
  background: var(--swatch, var(--color-primary));
}

/* Tabella log search: marker "vuota" inline + clicked italic + page code */
.shell-tag-empty {
  margin-left: 6px;
  font-size: 10px;
}
.shell-pill-active {
  font-size: 12px;
}

/* Bar row with referrer-count column */
.shell-bar-row--ref {
  grid-template-columns: 1fr 70px;
}

/* Allineamento valori numerici tabellari nelle card di analytics */
.shell-bar-row-num-lg {
  font-family: var(--font-heading);
  font-size: 18px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Dark mode adjustments per shell v2 ────────────────────────────────────── */
[data-theme='dark'] .shell-today-hero {
  background: linear-gradient(135deg, var(--color-bg-card) 0%, #221d18 100%);
}
[data-theme='dark'] .shell-topbar {
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
}
[data-theme='dark'] .shell-topbar-tab[aria-current='page'] {
  background: var(--color-bg-card);
}
[data-theme='dark'] .shell-chip-blue {
  background: #1a2a3a;
  color: #7caed9;
}

/* ════════════════════════════════════════════════════════════════════════════
   A14 — DENSITY TOGGLE (compact / comfortable)
   ══════════════════════════════════════════════════════════════════════════ */

[data-admin-page] {
  --adm-row-padding: 12px 16px;
}

[data-admin-page][data-density='compact'] {
  --adm-row-padding: 5px 10px;
}

/* Applica padding variabile su td e tr delle tabelle admin */
[data-admin-page] table td,
[data-admin-page] table th {
  padding: var(--adm-row-padding);
}

.adm-density-btn {
  font-size: 12px;
  color: var(--color-sidebar-fg);
}

/* ════════════════════════════════════════════════════════════════════════════
   A15 — DATE RANGE (saved-views toolbar wrap)
   ══════════════════════════════════════════════════════════════════════════ */

/* Saved views wrap — barra toolbar con bottone Viste */
.adm-sv-wrap {
  position: relative;
  display: inline-block;
}

.adm-sv-btn {
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body, sans-serif);
  padding: 6px 12px;
  border: 1px solid var(--color-border, #e0dbd0);
  border-radius: var(--radius-sm, 8px);
  background: var(--color-bg-card, #fff);
  color: var(--color-text, #1a1a1a);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  transition: border-color 0.15s;
}

.adm-sv-btn:hover {
  border-color: var(--color-primary, #d34c31);
}

.adm-sv-chevron {
  font-size: 9px;
  color: var(--color-text-muted, #6b6b6b);
}

.adm-sv-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 500;
  background: var(--color-bg-card, #fff);
  border: 1px solid var(--color-border, #e0dbd0);
  border-radius: var(--radius-sm, 8px);
  box-shadow: var(--shadow-md, 0 4px 20px rgba(0, 0, 0, 0.07));
  width: 260px;
  overflow: hidden;
}

.adm-sv-save-row {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border-light, #ebe7de);
}

.adm-sv-name-input {
  flex: 1;
  font-size: 13px;
  font-family: var(--font-body, sans-serif);
  padding: 5px 8px;
  border: 1px solid var(--color-border, #e0dbd0);
  border-radius: 6px;
  background: var(--color-bg, #f8f6f1);
  color: var(--color-text, #1a1a1a);
  min-width: 0;
}

.adm-sv-name-input:focus {
  outline: 2px solid var(--color-primary, #d34c31);
  outline-offset: 1px;
  border-color: var(--color-primary, #d34c31);
}

.adm-sv-save-btn {
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-body, sans-serif);
  padding: 5px 10px;
  border: 1px solid var(--color-primary, #d34c31);
  border-radius: 6px;
  background: var(--color-primary, #d34c31);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.adm-sv-list {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px 0;
}

.adm-sv-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--color-text-muted, #6b6b6b);
}

.adm-sv-item {
  display: flex;
  align-items: center;
  padding: 2px 8px;
}

.adm-sv-apply {
  flex: 1;
  text-align: left;
  font-size: 13px;
  font-family: var(--font-body, sans-serif);
  padding: 7px 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text, #1a1a1a);
  border-radius: 4px;
  transition: background 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adm-sv-apply:hover {
  background: var(--color-surface-low, #f7f3ef);
}

.adm-sv-delete {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--color-text-muted, #6b6b6b);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background 0.1s,
    color 0.1s;
}

.adm-sv-delete:hover {
  background: #fef2f2;
  color: #dc2626;
}

[data-theme='dark'] .adm-sv-dropdown {
  background: var(--color-bg-card, #2b2720);
  border-color: var(--color-border, #3c3830);
}

[data-theme='dark'] .adm-sv-name-input {
  background: var(--color-bg, #1c1916);
  border-color: var(--color-border, #3c3830);
  color: var(--color-text, #e8e4dc);
}

[data-theme='dark'] .adm-sv-apply:hover {
  background: rgba(255, 255, 255, 0.06);
}

[data-theme='dark'] .adm-sv-delete:hover {
  background: rgba(220, 38, 38, 0.15);
  color: #f87171;
}

/* ════════════════════════════════════════════════════════════════════════════
   A16 — EMPTY STATES + SKELETON
   ══════════════════════════════════════════════════════════════════════════ */

.adm-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-muted, #6b6b6b);
}

.adm-empty-state__icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-surface-low, #f7f3ef);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 22px;
}

.adm-empty-state__title {
  font-family: var(--font-heading, serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text, #1a1a1a);
  margin-bottom: 6px;
}

.adm-empty-state__lead {
  font-size: 13px;
  color: var(--color-text-muted, #6b6b6b);
  max-width: 36ch;
  line-height: 1.5;
  margin-bottom: 20px;
}

.adm-empty-state__cta {
  display: inline-flex;
  align-items: center;
  padding: 8px 18px;
  border-radius: var(--radius-sm, 8px);
  background: var(--color-primary, #d34c31);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.adm-empty-state__cta:hover {
  background: var(--color-primary-dark, #a63b26);
}

/* Skeleton row */
.adm-skeleton td {
  padding: var(--adm-row-padding);
}

.adm-skeleton-cell {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--color-surface-low, #f7f3ef) 25%,
    var(--color-border-light, #ebe7de) 50%,
    var(--color-surface-low, #f7f3ef) 75%
  );
  background-size: 200% 100%;
  animation: adm-shimmer 1.4s infinite;
}

@keyframes adm-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

[data-theme='dark'] .adm-skeleton-cell {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.09) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: adm-shimmer 1.4s infinite;
}

/* ════════════════════════════════════════════════════════════════════════════
   A17 — TOAST CON AZIONE / COUNTDOWN
   ══════════════════════════════════════════════════════════════════════════ */

.adm-toast__action-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  color: inherit;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-body, sans-serif);
  cursor: pointer;
  padding: 3px 10px;
  margin-left: 10px;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}

.adm-toast__action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.adm-toast__countdown {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 0 0 0 4px;
  transition: width linear;
}

/* Toast con azione ha layout flex */
.toast-with-action {
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
}

/* ════════════════════════════════════════════════════════════════════════════
   A19 — PRINT MODE STANDARDIZZATO
   ══════════════════════════════════════════════════════════════════════════ */

@media print {
  /* Nascondi elementi navigazione e UI */
  .admin-sidebar,
  .admin-topbar,
  .sidebar-overlay,
  .adm-cmd-dialog,
  .adm-shortcuts-dialog,
  .confirm-overlay,
  #auth-overlay,
  .toast-container,
  #toast-container,
  .toolbar,
  .adm-toolbar,
  .page-head-actions,
  .page-head .btn,
  .page-head button,
  .page-actions,
  [data-no-print],
  .pagination,
  .adm-pagination,
  .sidebar-notif-panel {
    display: none !important;
  }

  /* Layout: rimuovi sidebar offset */
  body,
  .admin-main,
  .page-content,
  main {
    margin-left: 0 !important;
    padding-left: 0 !important;
    font-size: 11pt;
    color: #000;
    background: #fff;
  }

  /* Header print: mostra nome pagina */
  body::before {
    content: 'Sulla Soglia — ' attr(data-admin-page);
    display: block;
    font-family: Georgia, serif;
    font-size: 14pt;
    font-weight: bold;
    margin-bottom: 12pt;
    padding-bottom: 8pt;
    border-bottom: 1px solid #ccc;
  }

  /* Tabelle: no page-break dentro righe */
  table {
    border-collapse: collapse;
    width: 100%;
  }

  table,
  tr,
  td,
  th {
    page-break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }

  td,
  th {
    border: 1px solid #ccc;
    padding: 6px 8px;
  }

  /* Link: mostra URL */
  a[href]::after {
    content: none;
  }

  /* Colori reset per stampa */
  * {
    color: #000 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  td,
  th {
    border-color: #999 !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   B13 — BADGE STATO UNIFICATI
   Token CSS per badge di stato riusabili cross-pagina admin.
   Uso: <span class="adm-badge adm-badge--waiting">In attesa</span>
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
  /* Waiting / In attesa / Nuova */
  --adm-badge-bg-waiting: #fef3c7;
  --adm-badge-fg-waiting: #92400e;
  /* Progress / In lavorazione / In corso */
  --adm-badge-bg-progress: #dbeafe;
  --adm-badge-fg-progress: #1e40af;
  /* Done / Completato / Integrata / Risolta */
  --adm-badge-bg-done: #d1fae5;
  --adm-badge-fg-done: #065f46;
  /* Alert / Rifiutata / Rimossa / Archiviata urgente */
  --adm-badge-bg-alert: #fee2e2;
  --adm-badge-fg-alert: #991b1b;
  /* Muted / Archiviata / Disattiva */
  --adm-badge-bg-muted: #f1f5f9;
  --adm-badge-fg-muted: #475569;
  /* Info / Accolta / Pronta */
  --adm-badge-bg-info: #ede9fe;
  --adm-badge-fg-info: #5b21b6;
}

[data-theme='dark'] {
  --adm-badge-bg-waiting: #451a03;
  --adm-badge-fg-waiting: #fcd34d;
  --adm-badge-bg-progress: #1e3a5f;
  --adm-badge-fg-progress: #93c5fd;
  --adm-badge-bg-done: #064e3b;
  --adm-badge-fg-done: #6ee7b7;
  --adm-badge-bg-alert: #450a0a;
  --adm-badge-fg-alert: #fca5a5;
  --adm-badge-bg-muted: #1e293b;
  --adm-badge-fg-muted: #94a3b8;
  --adm-badge-bg-info: #2e1065;
  --adm-badge-fg-info: #c4b5fd;
}

.adm-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.adm-badge--waiting {
  background: var(--adm-badge-bg-waiting);
  color: var(--adm-badge-fg-waiting);
}

.adm-badge--progress {
  background: var(--adm-badge-bg-progress);
  color: var(--adm-badge-fg-progress);
}

.adm-badge--done {
  background: var(--adm-badge-bg-done);
  color: var(--adm-badge-fg-done);
}

.adm-badge--alert {
  background: var(--adm-badge-bg-alert);
  color: var(--adm-badge-fg-alert);
}

.adm-badge--muted {
  background: var(--adm-badge-bg-muted);
  color: var(--adm-badge-fg-muted);
}

.adm-badge--info {
  background: var(--adm-badge-bg-info);
  color: var(--adm-badge-fg-info);
}

/* Alias semantici per stati dominio */
.adm-badge--nuova,
.adm-badge--pending,
.adm-badge--bozza {
  background: var(--adm-badge-bg-waiting);
  color: var(--adm-badge-fg-waiting);
}

.adm-badge--in_lavorazione,
.adm-badge--in_valutazione,
.adm-badge--in_corso,
.adm-badge--processing {
  background: var(--adm-badge-bg-progress);
  color: var(--adm-badge-fg-progress);
}

.adm-badge--integrata,
.adm-badge--risolta,
.adm-badge--conclusa,
.adm-badge--sent,
.adm-badge--attiva {
  background: var(--adm-badge-bg-done);
  color: var(--adm-badge-fg-done);
}

.adm-badge--rifiutata,
.adm-badge--failed,
.adm-badge--rimossa {
  background: var(--adm-badge-bg-alert);
  color: var(--adm-badge-fg-alert);
}

.adm-badge--archiviata,
.adm-badge--letta,
.adm-badge--canceled,
.adm-badge--disattiva {
  background: var(--adm-badge-bg-muted);
  color: var(--adm-badge-fg-muted);
}

.adm-badge--accolta,
.adm-badge--pronta,
.adm-badge--progettazione {
  background: var(--adm-badge-bg-info);
  color: var(--adm-badge-fg-info);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   B10 — PAGINATOR
   ═══════════════════════════════════════════════════════════════════════════════ */

.adm-pager {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 0;
  font-size: 0.85rem;
  color: var(--color-text-muted, #6b7280);
}

.adm-pager-info {
  min-width: 120px;
}

.adm-pager-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.adm-pager-btn {
  padding: 4px 10px;
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: 6px;
  background: var(--color-surface, #fff);
  color: var(--color-text, #1a1a1a);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  min-width: 32px;
  min-height: 32px;
  transition: background 0.15s;
}

.adm-pager-btn:hover:not(:disabled) {
  background: var(--color-hover, #f3f4f6);
}

.adm-pager-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.adm-pager-pages {
  display: flex;
  align-items: center;
  gap: 2px;
}

.adm-pager-page-btn {
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text, #1a1a1a);
  cursor: pointer;
  font-size: 0.85rem;
  min-width: 32px;
  min-height: 32px;
  transition: background 0.15s;
}

.adm-pager-page-btn:hover {
  background: var(--color-hover, #f3f4f6);
}

.adm-pager-page-btn--active {
  background: var(--color-primary, #c04428);
  color: #fff;
  border-color: var(--color-primary, #c04428);
  font-weight: 600;
}

.adm-pager-ellipsis {
  padding: 0 4px;
  color: var(--color-text-muted, #6b7280);
}

.adm-pager-pp-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.adm-pager-pp-select {
  padding: 3px 6px;
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: 6px;
  background: var(--color-surface, #fff);
  color: var(--color-text, #1a1a1a);
  font-size: 0.85rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   B6 — BULK BAR v2
   ═══════════════════════════════════════════════════════════════════════════════ */

.adm-bulk-bar {
  position: fixed;
  bottom: -80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--bulk-bar-bg, #2c2c2a);
  color: var(--bulk-bar-fg, #fff);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  z-index: 1100;
  transition: bottom 0.25s ease;
  min-height: 52px;
  max-width: calc(100vw - 32px);
  white-space: nowrap;
}

.adm-bulk-bar.open {
  bottom: 24px;
}

.adm-bulk-bar.is-busy {
  opacity: 0.7;
  pointer-events: none;
}

.adm-bulk-count-label {
  font-size: 0.875rem;
  font-weight: 600;
}

.adm-bulk-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.adm-bulk-action-btn {
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transition: background 0.15s;
}

.adm-bulk-action-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.adm-bulk-action-btn.btn-danger {
  background: var(--adm-badge-bg-alert, #fee2e2);
  color: var(--adm-badge-fg-alert, #991b1b);
  border-color: transparent;
}

.adm-bulk-action-btn.btn-primary {
  background: var(--color-primary, #c04428);
  color: #fff;
  border-color: transparent;
}

.adm-bulk-clear {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  border-radius: 8px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 0.8rem;
  min-height: 32px;
  transition: background 0.15s;
}

.adm-bulk-clear:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Checkbox bulk nelle tabelle */
.adm-bulk-th,
.adm-bulk-td {
  width: 36px;
  text-align: center;
  padding: 6px 4px !important;
}

.adm-bulk-all,
.adm-bulk-cb {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--color-primary, #c04428);
}

tr[data-bulk-selected] {
  background: color-mix(in srgb, var(--color-primary, #c04428) 8%, transparent);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   B7 — INLINE EDIT
   ═══════════════════════════════════════════════════════════════════════════════ */

td.adm-ie-cell {
  cursor: pointer;
  position: relative;
}

td.adm-ie-cell:hover {
  background: color-mix(in srgb, var(--color-primary, #c04428) 6%, transparent);
}

td.adm-ie-cell::after {
  content: '✎';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  font-size: 0.7rem;
  color: var(--color-text-muted, #6b7280);
  transition: opacity 0.15s;
  pointer-events: none;
}

td.adm-ie-cell:hover::after {
  opacity: 0.6;
}

td.adm-ie-active {
  padding: 2px 4px !important;
  vertical-align: middle;
}

td.adm-ie-active::after {
  display: none;
}

td.adm-ie-error {
  outline: 2px solid var(--adm-badge-fg-alert, #991b1b);
}

td.adm-ie-saving {
  opacity: 0.6;
}

.adm-ie-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.adm-ie-input,
.adm-ie-select,
.adm-ie-textarea {
  flex: 1;
  min-width: 0;
  padding: 3px 6px;
  border: 1px solid var(--color-primary, #c04428);
  border-radius: 4px;
  font-size: inherit;
  background: var(--color-surface, #fff);
  color: var(--color-text, #1a1a1a);
  outline: none;
}

.adm-ie-textarea {
  resize: vertical;
}

.adm-ie-ok,
.adm-ie-cancel {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.adm-ie-ok {
  background: var(--adm-badge-bg-done, #d1fae5);
  color: var(--adm-badge-fg-done, #065f46);
}

.adm-ie-cancel {
  background: var(--adm-badge-bg-muted, #f1f5f9);
  color: var(--adm-badge-fg-muted, #475569);
}

/* ── B18 drag&drop ────────────────────────────────────────────────────────── */

[data-dnd] .adm-dnd-item {
  cursor: grab;
  transition:
    transform 0.15s,
    opacity 0.15s;
  user-select: none;
  -webkit-user-select: none;
}

[data-dnd] .adm-dnd-item:active {
  cursor: grabbing;
}

[data-dnd] .adm-dnd-item.adm-dnd-dragging {
  opacity: 0.4;
  cursor: grabbing;
}

[data-dnd] .adm-dnd-item.adm-dnd-over {
  background: var(--color-bg-card-alt, #f1f5f9);
  outline: 2px dashed var(--color-primary);
  outline-offset: -2px;
  transform: scale(1.01);
}

/* Handle grip visivo (opzionale: aggiungere .adm-dnd-handle all'interno dell'item) */
.adm-dnd-handle {
  cursor: grab;
  color: var(--color-text-muted);
  padding: 0 6px;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.adm-dnd-handle:active {
  cursor: grabbing;
}

/* Ghost clone durante drag touch */
.adm-dnd-ghost {
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

/* Dark mode */
[data-theme='dark'] [data-dnd] .adm-dnd-item.adm-dnd-over {
  background: var(--color-bg-card-alt, #1e2a35);
}

/* Indicatore ordine (numero badge opzionale) */
.adm-dnd-ordine {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-bg-card-alt, #e2e8f0);
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

/* C1 — RBAC: voci sidebar disabilitate per ruolo insufficiente */
.adm-nav-disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: not-allowed;
  user-select: none;
}

.adm-nav-disabled:focus {
  outline: none;
}
