/* ═══════════════════════════════════════════════════════════════════════════
   OmniPlan — Stile Pannello Amministrativo
   Progetto di Smartlands
   ═══════════════════════════════════════════════════════════════════════════ */

@font-face { font-family: 'Titillium Web'; src: url('font/TitilliumWeb-ExtraLight.ttf') format('truetype'); font-weight: 200; font-style: normal; font-display: swap; }
@font-face { font-family: 'Titillium Web'; src: url('font/TitilliumWeb-ExtraLightItalic.ttf') format('truetype'); font-weight: 200; font-style: italic; font-display: swap; }
@font-face { font-family: 'Titillium Web'; src: url('font/TitilliumWeb-Light.ttf') format('truetype'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'Titillium Web'; src: url('font/TitilliumWeb-LightItalic.ttf') format('truetype'); font-weight: 300; font-style: italic; font-display: swap; }
@font-face { font-family: 'Titillium Web'; src: url('font/TitilliumWeb-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Titillium Web'; src: url('font/TitilliumWeb-Italic.ttf') format('truetype'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Titillium Web'; src: url('font/TitilliumWeb-SemiBold.ttf') format('truetype'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Titillium Web'; src: url('font/TitilliumWeb-SemiBoldItalic.ttf') format('truetype'); font-weight: 600; font-style: italic; font-display: swap; }
@font-face { font-family: 'Titillium Web'; src: url('font/TitilliumWeb-Bold.ttf') format('truetype'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Titillium Web'; src: url('font/TitilliumWeb-BoldItalic.ttf') format('truetype'); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: 'Titillium Web'; src: url('font/TitilliumWeb-Black.ttf') format('truetype'); font-weight: 900; font-style: normal; font-display: swap; }

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

:root {
  --primary:       #1a3a5c;
  --primary-light: #2563eb;
  --primary-hover: #1e40af;
  --accent:        #0ea5e9;
  --success:       #16a34a;
  --warning:       #d97706;
  --danger:        #dc2626;
  --gray-50:       #f8fafc;
  --gray-100:      #f1f5f9;
  --gray-200:      #e2e8f0;
  --gray-300:      #cbd5e1;
  --gray-400:      #94a3b8;
  --gray-500:      #64748b;
  --gray-600:      #475569;
  --gray-700:      #334155;
  --gray-800:      #1e293b;
  --gray-900:      #0f172a;
  --sidebar-w:     240px;
  --topbar-h:      60px;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:        0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --font:          'Titillium Web', sans-serif;
}

body { font-family: var(--font); background: var(--gray-50); color: var(--gray-800); font-size: 14px; line-height: 1.5; }

.hidden { display: none !important; }

/* ── LOGIN ──────────────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1a3a5c 60%, #2563eb 100%);
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.login-logo-img {
  max-width: 220px;
  height: auto;
  display: block;
}

.login-subtitle {
  color: var(--gray-500);
  font-size: 13px;
  margin-bottom: 28px;
  line-height: 1.6;
}
.login-subtitle small { font-size: 12px; color: var(--gray-400); }

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}

.login-hint {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--gray-400);
}
.login-hint code {
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: var(--gray-600);
}

/* ── LAYOUT ─────────────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-logo-img {
  max-width: 140px;
  height: auto;
  display: block;
  filter: brightness(0) invert(1);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  overflow: visible;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: none;
  border: none;
  color: rgba(255,255,255,.7);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.1); color: white; }
.nav-item.active { background: rgba(255,255,255,.15); color: white; }
#nav-guida {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.1);
  padding-top: 12px;
  color: rgba(255,255,255,.65);
}
#nav-guida:hover { color: white; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-name { color: white; font-size: 13px; font-weight: 600; }
.user-role { color: rgba(255,255,255,.5); font-size: 11px; text-transform: capitalize; }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
  flex: 1;
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.topbar-logo-img {
  height: 36px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--gray-600);
}
.menu-toggle svg { width: 22px; height: 22px; fill: currentColor; }

.page-content {
  flex: 1;
  padding: 28px 28px 40px;
  overflow-x: hidden;
  min-width: 0;
}

/* ── BUTTONS ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, opacity .15s;
  white-space: nowrap;
  letter-spacing: .01em;
}
.btn svg { width: 16px; height: 16px; fill: currentColor; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--primary-light); color: white; box-shadow: 0 1px 4px rgba(37,99,235,.3); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: 0 3px 8px rgba(37,99,235,.4); }

.btn-secondary { background: white; color: var(--gray-700); border-color: var(--gray-300); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-400); }

.btn-danger { background: var(--danger); color: white; box-shadow: 0 1px 3px rgba(220,38,38,.3); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #15803d; }

.btn-sm   { padding: 6px 13px; font-size: 12.5px; }
.btn-full { width: 100%; justify-content: center; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius);
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,.6);
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: rgba(255,255,255,.1); color: white; }
.btn-icon svg { width: 18px; height: 18px; fill: currentColor; }
.btn-icon.dark { color: var(--gray-500); }
.btn-icon.dark:hover { background: var(--gray-100); color: var(--gray-700); }

/* ── FORMS ──────────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  color: var(--gray-800);
  background: white;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field textarea { resize: vertical; min-height: 80px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .field.full { grid-column: 1 / -1; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--gray-100);
  margin-top: 8px;
}

/* ── CARDS ──────────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}
.card-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--gray-800); }
.card-body { padding: 20px 22px; overflow-x: hidden; min-width: 0; }

/* ── STATS ──────────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; fill: white; }
.stat-icon.blue   { background: var(--primary-light); }
.stat-icon.green  { background: var(--success); }
.stat-icon.amber  { background: var(--warning); }
.stat-icon.slate  { background: var(--gray-500); }
.stat-icon.red    { background: var(--danger); }

.stat-value { font-size: 28px; font-weight: 700; color: var(--gray-800); line-height: 1; }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 3px; }

/* ── TABLE ──────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
  color: var(--gray-700);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }
tbody tr { cursor: pointer; transition: background .1s; }

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

/* ── BADGES ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }

.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-info    { background: #dbeafe; color: #2563eb; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.badge-gray    { background: var(--gray-100); color: var(--gray-500); }

/* ── SEARCH BAR ─────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-input-wrap svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  fill: var(--gray-400);
}
.search-input-wrap input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 13px;
}
.search-input-wrap input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ── PIANO DETAIL ────────────────────────────────────────────────────────────── */
.piano-header {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  padding: 24px 28px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.piano-header-info h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
}

.piano-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.piano-meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--gray-500);
}
.piano-meta-item svg { width: 13px; height: 13px; fill: currentColor; }
.piano-meta-item strong { color: var(--gray-700); }

.piano-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── FASI STEPPER ────────────────────────────────────────────────────────────── */
.fasi-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}
.fasi-grid > .fase-card { min-width: 0; max-width: 100%; }
.fasi-grid .fase-body { min-width: 0; max-width: 100%; }

.fase-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  transition: box-shadow .2s;
}
.fase-card:hover { box-shadow: var(--shadow); }

.fase-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
}

.fase-number {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  transition: background .2s, color .2s;
}
.fase-number.completata { background: var(--success); color: white; }
.fase-number.in_corso   { background: var(--primary-light); color: white; }
.fase-number.da_fare    { background: var(--gray-200); color: var(--gray-500); }

.fase-title { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; color: var(--gray-800); }
.fase-dates { font-size: 12px; color: var(--gray-400); margin-right: 8px; white-space: nowrap; flex-shrink: 0; }

.fase-body {
  padding: 0 20px 20px;
  border-top: 1px solid var(--gray-100);
  display: none;
}
.fase-body.open { display: block; padding-top: 16px; }

.fase-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fase-grid .field { margin: 0; }

.fase-note { grid-column: 1 / -1; }
.fase-note textarea { min-height: 64px; }

.fase-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--gray-100);
  flex-wrap: wrap;
  gap: 10px;
}

/* ── DOCUMENTI ───────────────────────────────────────────────────────────────── */
.doc-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.doc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  min-width: 0;
}
.doc-icon { width: 28px; height: 28px; background: var(--primary-light); border-radius: 6px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.doc-icon svg { width: 14px; height: 14px; fill: white; }
.doc-name { flex: 1 1 auto; min-width: 0; font-size: 13px; font-weight: 500; color: var(--gray-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-size { font-size: 11px; color: var(--gray-400); white-space: nowrap; flex-shrink: 0; }
.doc-item .btn-icon { flex-shrink: 0; }

.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  min-height: 90px;
}
.upload-area:hover { border-color: var(--primary-light); background: #eff6ff; }
.upload-area input { display: none; }
.upload-area svg { display: block; }
.upload-area p { font-size: 12px; color: var(--gray-400); margin: 0; }
.upload-area.sm { min-height: 56px; padding: 10px 12px; }
.upload-area.sm svg { width: 18px; height: 18px; }

/* ── CARTELLE PDF ────────────────────────────────────────────────────────────── */
.pdf-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.btn-folder-new {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-light);
  background: none;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 4px 9px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-folder-new:hover { background: #eff6ff; border-color: var(--primary-light); }
.btn-folder-new svg { width: 15px; height: 15px; fill: currentColor; }

.pdf-folder {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
  background: white;
}
.pdf-folder-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  background: var(--gray-50);
  user-select: none;
}
.pdf-folder-head:hover { background: var(--gray-100); }
.pdf-folder-chevron svg {
  width: 18px; height: 18px; fill: var(--gray-400);
  transition: transform .15s;
  transform: rotate(-90deg);
  display: block;
}
.pdf-folder.open .pdf-folder-chevron svg { transform: rotate(0deg); }
.pdf-folder-icon svg { width: 18px; height: 18px; fill: #eab308; display: block; }
.pdf-folder-name { flex: 1; font-size: 13px; font-weight: 600; color: var(--gray-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-folder-count {
  font-size: 11px; font-weight: 600; color: var(--gray-500);
  background: var(--gray-200); border-radius: 10px; padding: 1px 8px; min-width: 20px; text-align: center;
}
.pdf-folder-actions { display: flex; gap: 2px; }
.pdf-folder-actions .btn-icon { width: 26px; height: 26px; }
.pdf-folder-actions .btn-icon svg { width: 15px; height: 15px; }
.pdf-folder-body { display: none; padding: 10px; }
.pdf-folder.open .pdf-folder-body { display: block; }
.pdf-empty { font-size: 12px; color: var(--gray-400); margin: 0 0 10px; }

.pdf-move-select {
  font-size: 11px;
  color: var(--gray-500);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 3px 4px;
  background: white;
  max-width: 120px;
  cursor: pointer;
}
.pdf-move-select:hover { border-color: var(--gray-400); }

/* ── BREADCRUMB ──────────────────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--gray-400);
  margin-bottom: 20px;
}
.breadcrumb a { color: var(--primary-light); cursor: pointer; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb svg { width: 14px; height: 14px; fill: currentColor; }

/* ── EMPTY STATE ─────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state svg { width: 48px; height: 48px; fill: var(--gray-300); margin-bottom: 12px; }
.empty-state p { font-size: 14px; }
.empty-state .empty-cta { margin-top: 16px; }

/* ── MODAL ───────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--gray-900); }

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

/* ── TOAST ───────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  background: var(--gray-900);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  animation: toastIn .25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: none; }
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast svg { width: 16px; height: 16px; fill: white; flex-shrink: 0; }

/* ── TIPO PILL ───────────────────────────────────────────────────────────────── */
.tipo-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-600);
}

/* ── PROGRESS BAR ────────────────────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary-light);
  transition: width .4s ease;
}
.progress-fill.done { background: var(--success); }

/* ── CONFIRM ─────────────────────────────────────────────────────────────────── */
.confirm-body { text-align: center; padding: 8px 0 16px; }
.confirm-body p { color: var(--gray-600); margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: none;
    box-shadow: var(--shadow-lg);
  }
  .main-content { margin-left: 0; }
  .menu-toggle  { display: flex; }
  .page-content { padding: 16px; }
  .form-grid    { grid-template-columns: 1fr; }
  .fase-grid    { grid-template-columns: 1fr; }
  .stats-grid   { grid-template-columns: 1fr 1fr; }
  .piano-header { flex-direction: column; }
  /* La data della fase è ridondante nell'intestazione compressa: resta visibile
     (e modificabile) nel corpo espanso. La nascondiamo per alleggerire su mobile. */
  .fase-header  { gap: 10px; }
  .fase-dates   { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal { max-width: 100%; max-height: 100vh; border-radius: 0; }
  .modal-overlay { padding: 0; align-items: flex-end; }
}

/* ── Tabelle responsive: ogni riga diventa una scheda su mobile ──────────────── */
@media (max-width: 768px) {
  .table-card { border-collapse: separate; }
  .table-card thead { display: none; }
  .table-card,
  .table-card tbody,
  .table-card tr,
  .table-card td { display: block; width: 100%; }
  .table-card tr {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    padding: 2px 14px;
    background: #fff;
  }
  .table-card td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border: none;
    border-bottom: 1px solid var(--gray-100);
    text-align: right;
    min-height: 38px;
  }
  .table-card tr td:last-child { border-bottom: none; }
  .table-card td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--gray-400);
    text-align: left;
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .table-card td:not([data-label])::before { content: ""; }
  .table-card td .td-actions { justify-content: flex-end; flex-wrap: wrap; }
  /* riga "vuota" (es. nessun risultato) resta centrata su una colonna */
  .table-card td[colspan]::before { content: ""; }
  .table-card td[colspan] { text-align: center; justify-content: center; }

  /* Dark mode */
  body.dark-mode .table-card tr { border-color: #334155; background: #1e293b; }
  body.dark-mode .table-card td { border-bottom-color: #2a3a52; }
  body.dark-mode .table-card td::before { color: #94a3b8; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   OmniPlan v2 — Task, Link, Utenti
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── PRIORITY INDICATOR ─────────────────────────────────────────────────────── */
.priority-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.priority-alta   { background: var(--danger); }
.priority-media  { background: var(--warning); }
.priority-bassa  { background: var(--success); }

.badge-alta   { background: #fee2e2; color: var(--danger); }
.badge-media  { background: #fef3c7; color: var(--warning); }
.badge-bassa  { background: #dcfce7; color: var(--success); }
.badge-bloccata { background: #f3e8ff; color: #7c3aed; }

/* ── TASK CARDS ──────────────────────────────────────────────────────────────── */
.tasks-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
}
.tasks-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.tasks-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.task-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }

.task-card {
  border: 1px solid var(--gray-200);
  border-left: 4px solid var(--gray-300);
  border-radius: var(--radius);
  background: white;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, border-color .15s;
}
.task-card:has(.priority-dot.priority-alta)  { border-left-color: var(--danger); }
.task-card:has(.priority-dot.priority-media) { border-left-color: var(--warning); }
.task-card:has(.priority-dot.priority-bassa) { border-left-color: var(--success); }
.task-card:hover { box-shadow: var(--shadow); }

.task-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  background: white;
}
.task-card-header:hover { background: var(--gray-50); }
.task-title { flex: 1; font-size: 13.5px; font-weight: 600; color: var(--gray-800); }
.task-assignee { font-size: 11px; color: var(--gray-400); white-space: nowrap; }
.task-due { font-size: 11px; color: var(--gray-400); white-space: nowrap; }

.task-card-body {
  display: none;
  padding: 12px 16px 16px 16px;
  border-top: 2px solid var(--gray-100);
  background: var(--gray-50);
}
.task-card-body.open { display: block; }

.task-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.task-detail-item { font-size: 12px; }
.task-detail-item label { display: block; color: var(--gray-400); font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: .04em; margin-bottom: 2px; }
.task-detail-item span  { color: var(--gray-700); }

.task-sub-section { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--gray-100); }
.task-sub-title { font-size: 11px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }

.task-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 10px; }

/* ── LINK ITEMS ──────────────────────────────────────────────────────────────── */
.links-section {
  margin-top: 12px;
}
.link-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}
.link-icon {
  width: 28px; height: 28px;
  background: #0ea5e9;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.link-icon svg { width: 14px; height: 14px; fill: white; }
.link-name { flex: 1; font-size: 13px; font-weight: 500; color: var(--primary-light); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.link-name:hover { text-decoration: underline; }
.link-nota { font-size: 11px; color: var(--gray-400); }

/* ── MATERIALI INLINE ────────────────────────────────────────────────────────── */
.mat-list { display: flex; flex-direction: column; gap: 4px; }
.mat-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.mat-item .mat-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary-light); flex-shrink: 0; }
.mat-tipo { color: var(--gray-400); font-size: 11px; }

/* ── MODAL WIDE ──────────────────────────────────────────────────────────────── */
.modal.wide { max-width: 720px; }

/* ── MODAL TABS ──────────────────────────────────────────────────────────────── */
.modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 18px;
}
.modal-tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-400);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: none;
  border-top: none; border-left: none; border-right: none;
  transition: color .15s, border-color .15s;
}
.modal-tab.active { color: var(--primary-light); border-bottom-color: var(--primary-light); }
.modal-tab-panel { display: none; }
.modal-tab-panel.active { display: block; }

/* ── DYNAMIC LIST (materiali/link nel form) ──────────────────────────────────── */
.dynamic-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.dynamic-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  position: relative;
}
.dynamic-item.mat-grid { grid-template-columns: 2fr 1.5fr 2fr auto; align-items: center; }
.dynamic-item.link-grid { grid-template-columns: 1.5fr 2fr 1.5fr auto; align-items: center; }
.dynamic-item input, .dynamic-item select {
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 12px;
  background: white;
}
.dynamic-item input:focus, .dynamic-item select:focus {
  outline: none;
  border-color: var(--primary-light);
}
.btn-remove { width: 28px; height: 28px; border-radius: 50%; background: #fee2e2; border: none; color: var(--danger); cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.btn-remove:hover { background: #fecaca; }

/* ── USER MANAGEMENT ─────────────────────────────────────────────────────────── */
.user-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-right: 5px;
}
.user-status-dot.attivo   { background: var(--success); }
.user-status-dot.inattivo { background: var(--gray-400); }

/* ── SECTION DIVIDER ─────────────────────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-400);
  margin-bottom: 10px;
  margin-top: 18px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--gray-100);
}
.section-label:first-child { margin-top: 0; }

/* ═══════════════════════════════════════════════════════════════════════════
   FIX: dimensioni SVG senza width/height espliciti
   ═══════════════════════════════════════════════════════════════════════════ */
.fase-header svg          { width: 16px; height: 16px; flex-shrink: 0; fill: var(--gray-400); }
.breadcrumb svg           { width: 14px; height: 14px; flex-shrink: 0; fill: var(--gray-400); vertical-align: middle; }
.toast svg                { width: 18px; height: 18px; flex-shrink: 0; fill: currentColor; }
.upload-area > svg        { width: 30px; height: 30px; fill: var(--gray-400); }
.stat-icon svg            { width: 22px; height: 22px; fill: white; }
.topbar .menu-toggle svg  { width: 22px; height: 22px; fill: var(--gray-600); }
.piano-meta svg           { width: 13px; height: 13px; fill: var(--gray-400); vertical-align: middle; }
.empty-state svg          { width: 40px; height: 40px; fill: var(--gray-300); }

/* ═══════════════════════════════════════════════════════════════════════════
   SOTTO-TASK
   ═══════════════════════════════════════════════════════════════════════════ */
.sotto-task-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }

.sotto-task-item {
  border: 1px solid var(--gray-200);
  border-left: 3px solid var(--gray-300);
  border-radius: var(--radius);
  background: white;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  transition: box-shadow .15s;
}
.sotto-task-item:hover { box-shadow: var(--shadow-sm); }
.sotto-task-item:has(.stato-completata) { border-left-color: var(--success); }
.sotto-task-item:has(.stato-in_corso)   { border-left-color: var(--primary-light); }
.sotto-task-item:has(.stato-bloccata)   { border-left-color: var(--danger); }

.st-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  flex-wrap: wrap;
}

.st-stato {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px white, 0 0 0 3px var(--gray-200);
}
.st-stato.stato-completata { background: var(--success); box-shadow: 0 0 0 2px white, 0 0 0 3px var(--success); }
.st-stato.stato-in_corso   { background: var(--primary-light); box-shadow: 0 0 0 2px white, 0 0 0 3px var(--primary-light); }
.st-stato.stato-da_fare    { background: var(--gray-300); }
.st-stato.stato-bloccata   { background: var(--danger); box-shadow: 0 0 0 2px white, 0 0 0 3px var(--danger); }

.st-title    { font-size: 13px; font-weight: 600; flex: 1; color: var(--gray-800); min-width: 80px; }
.st-assignee { font-size: 11px; color: var(--gray-500); white-space: nowrap; background: var(--gray-100); padding: 2px 6px; border-radius: 10px; }
.st-count    { font-size: 11px; color: var(--gray-500); white-space: nowrap; background: var(--gray-100); padding: 2px 6px; border-radius: 10px; }
.st-actions  { display: flex; gap: 4px; margin-left: auto; }

/* Corpo sotto-task: allegati e link */
.st-body {
  padding: 0 12px 10px 12px;
  border-top: 1px solid var(--gray-100);
}
.st-body-section { margin-top: 8px; }
.st-body-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-400);
  margin-bottom: 5px;
}
.st-attachment {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--gray-700);
}
.st-attachment svg { width: 13px; height: 13px; fill: var(--primary-light); flex-shrink: 0; }
.st-attachment span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-att-size { font-size: 11px; color: var(--gray-400); white-space: nowrap; }
.st-link-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--primary-light);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.st-link-row:hover { background: #dbeafe; }
.st-link-row svg { width: 13px; height: 13px; fill: var(--primary-light); flex-shrink: 0; }

.btn-xs {
  padding: 3px 9px !important;
  font-size: 11px !important;
  border-radius: 5px !important;
  line-height: 1.4 !important;
  height: auto !important;
}

/* Rinominazione inline task */
.task-rename-input {
  flex: 1;
  min-width: 100px;
  padding: 3px 8px;
  border: 1px solid var(--primary-light);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  background: white;
  box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}
.task-title { cursor: text; }
.task-title:hover { color: var(--primary-light); }

/* ── PRIORITY DOT ────────────────────────────────────────────────────────────── */
.priority-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.priority-dot.priority-alta  { background: var(--danger); box-shadow: 0 0 0 2px #fee2e2; }
.priority-dot.priority-media { background: var(--warning); box-shadow: 0 0 0 2px #fef3c7; }
.priority-dot.priority-bassa { background: var(--success); box-shadow: 0 0 0 2px #dcfce7; }

/* ── TASKS SECTION HEADER ────────────────────────────────────────────────────── */
.tasks-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 2px solid var(--gray-200);
}
.tasks-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.tasks-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
}

/* ═══════════════════════════════════════════════════════════════════════════
   GUIDA
   ═══════════════════════════════════════════════════════════════════════════ */
.guide-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary-light);
  color: white;
  border: none;
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37,99,235,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  transition: background .15s, transform .15s, box-shadow .15s;
  line-height: 1;
}
.guide-fab:hover { background: var(--primary-hover); transform: scale(1.1); box-shadow: 0 6px 20px rgba(37,99,235,.55); }

.guide-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(3px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .18s ease;
}
.guide-overlay.hidden { display: none; }

@keyframes fadeIn  { from { opacity:0; } to { opacity:1; } }
@keyframes slideUp { from { opacity:0; transform:translateY(24px) scale(.97); } to { opacity:1; transform:none; } }

.guide-modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0,0,0,.22);
  width: 100%;
  max-width: 780px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp .2s ease;
}
.guide-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 2px solid var(--gray-100);
  flex-shrink: 0;
}
.guide-modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-800);
}
.guide-modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.guide-modal-close:hover { background: var(--gray-200); color: var(--gray-800); }

.guide-modal-body {
  overflow-y: auto;
  padding: 24px;
  flex: 1;
}
.guide-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
@media (max-width: 600px) { .guide-cols { grid-template-columns: 1fr; } }

.guide-col {}
.guide-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--primary-light);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid #dbeafe;
}
.guide-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 9px;
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.5;
}
.guide-num {
  min-width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary-light);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.guide-icon {
  min-width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--gray-100);
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.guide-legend-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.guide-legend-row {
  width: 100%;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.guide-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--gray-700);
  background: var(--gray-50);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--gray-200);
}
.guide-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.guide-tip {
  margin-top: 18px;
  padding: 12px 14px;
  background: #eff6ff;
  border-left: 3px solid var(--primary-light);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 12.5px;
  color: var(--gray-700);
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TICKET SYSTEM
   ═══════════════════════════════════════════════════════════════════════════ */

/* Nav badge (bubble counter) */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  margin-left: auto;
}

/* Wrapper */
.tk-wrap { padding: 24px; max-width: 1000px; }

/* Filter tabs */
.tk-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.tk-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-600);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all .18s;
}
.tk-tab:hover  { border-color: var(--primary-light); color: var(--primary-light); }
.tk-tab.active { background: var(--primary-light); border-color: var(--primary-light); color: #fff; }
.tk-tab-count {
  display: inline-block;
  min-width: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: rgba(0,0,0,.12);
  font-size: 11px;
  margin-left: 4px;
  text-align: center;
}

/* Ticket cards */
.tk-list { display: flex; flex-direction: column; gap: 10px; }
.tk-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: box-shadow .18s, border-color .18s;
}
.tk-card:hover { box-shadow: var(--shadow); border-color: var(--primary-light); }
.tk-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.tk-prio {
  flex-shrink: 0;
  width: 10px; height: 10px;
  border-radius: 50%;
}
.tk-prio-alta   { background: var(--danger); }
.tk-prio-media  { background: var(--warning); }
.tk-prio-bassa  { background: var(--success); }
.tk-title { font-weight: 600; color: var(--gray-800); flex: 1; }
.tk-author { font-size: 12px; color: var(--gray-400); flex-shrink: 0; }
.tk-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tk-comune { font-size: 12px; color: var(--gray-500); }
.tk-date   { font-size: 12px; color: var(--gray-400); margin-left: auto; }
.tk-comments { font-size: 12px; color: var(--gray-500); }
.tk-empty { text-align: center; padding: 48px 0; color: var(--gray-400); font-size: 14px; }

/* Badge con dot priorità */
.badge-dot { display: inline-flex; align-items: center; gap: 5px; }
.prio-dot  { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-danger  .prio-dot { background: var(--danger); }
.badge-warning .prio-dot { background: var(--warning); }
.badge-success .prio-dot { background: var(--success); }

/* Ticket detail (in modal wide) */
.tk-detail { display: flex; flex-direction: column; gap: 18px; }
.tk-detail-meta {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tk-meta-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tk-meta-info {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--gray-600);
}
.tk-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 6px;
}
.tk-description {
  font-size: 14px;
  color: var(--gray-700);
  line-height: 1.6;
  white-space: pre-wrap;
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 12px 14px;
}

/* Admin panel */
.tk-admin-panel {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 12px 16px;
}
.tk-admin-title { font-size: 12px; font-weight: 700; color: var(--primary); margin-bottom: 10px; }

/* Comments */
.tk-comments-list { display: flex; flex-direction: column; gap: 10px; }
.tk-comment {
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--gray-50);
  border-left: 3px solid var(--gray-300);
}
.tk-comment.mio         { border-left-color: var(--primary-light); background: #eff6ff; }
.tk-comment.admin-reply { border-left-color: var(--warning); background: #fffbeb; }
.tk-comment-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12.5px;
}
.tk-comment-date { font-size: 11px; color: var(--gray-400); margin-left: auto; }
.tk-comment-body { font-size: 13.5px; color: var(--gray-700); line-height: 1.55; }
.tk-add-comment { display: flex; flex-direction: column; }

/* ── Logo upload (form comune) ─────────────────────────────────────────────── */
.logo-upload-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--gray-50);
  border: 1px dashed var(--gray-300);
  border-radius: var(--radius);
}
.logo-preview {
  max-height: 60px;
  max-width: 180px;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  padding: 4px;
  border: 1px solid var(--gray-200);
}
.logo-placeholder {
  width: 100px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  font-size: 11px;
  color: var(--gray-400);
}
.logo-upload-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Topbar comune badge ───────────────────────────────────────────────────── */
.topbar-comune-badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-600);
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 3px 10px;
  margin-right: 8px;
  white-space: nowrap;
}

/* ── User-info sidebar (cliccabile) ────────────────────────────────────────── */
.user-info { transition: background .15s; border-radius: var(--radius); padding: 4px 6px; margin: -4px -6px; }
.user-info:hover { background: rgba(255,255,255,.08); }
.user-avatar img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
}

/* ── Profile Panel ─────────────────────────────────────────────────────────── */
.profile-wrap { display: flex; flex-direction: column; gap: 18px; }
.profile-header {
  display: flex; gap: 18px; align-items: center;
  padding: 18px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius);
  color: #fff;
}
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar-img,
.profile-avatar-letter {
  width: 84px; height: 84px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255,255,255,.15);
  border: 3px solid rgba(255,255,255,.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700;
  color: #fff;
}
.profile-avatar-upload {
  position: absolute;
  bottom: 0; right: 0;
  width: 28px; height: 28px;
  background: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .15s;
}
.profile-avatar-upload:hover { transform: scale(1.1); }
.profile-avatar-upload svg { width: 16px; height: 16px; fill: var(--primary); }
.profile-header-info { flex: 1; }
.profile-name { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.profile-username { font-size: 13px; opacity: .85; margin-bottom: 6px; }

.profile-section {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
}
.profile-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--gray-500);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-100);
}
.profile-info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0;
  font-size: 13.5px;
}
.profile-info-row span { color: var(--gray-500); }
.profile-info-row strong { color: var(--gray-800); }

/* ── Fase admin controls ───────────────────────────────────────────────────── */
.fase-admin-controls {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  margin-left: 8px;
  opacity: 0;
  transition: opacity .15s;
}
.fase-header:hover .fase-admin-controls { opacity: 1; }
.btn-icon-sm {
  width: 26px; height: 26px;
  border: 1px solid var(--gray-200);
  background: #fff;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all .15s;
}
.btn-icon-sm svg { width: 14px; height: 14px; fill: var(--gray-500); }
.btn-icon-sm:hover { border-color: var(--primary-light); background: var(--gray-50); }
.btn-icon-sm:hover svg { fill: var(--primary-light); }
.btn-icon-sm.danger:hover { border-color: var(--danger); background: #fef2f2; }
.btn-icon-sm.danger:hover svg { fill: var(--danger); }
/* Placeholder per pulsante spostamento quando non disponibile (prima/ultima fase) */
.btn-icon-sm-ph { display: inline-block; width: 26px; height: 26px; }

/* Card-header con pulsante allineato a destra */
.card-header { display: flex; justify-content: space-between; align-items: center; }

/* ── Allegati: 2 colonne (PDF / altri) ─────────────────────────────────────── */
.allegati-cols {
  display: grid;
  /* Container-aware: due colonne solo se c'è spazio per ~290px ciascuna,
     altrimenti una sola colonna a tutta larghezza (evita nomi troncati). */
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.allegati-col { display: flex; flex-direction: column; min-width: 0; }
.allegati-col .upload-area small {
  display: block;
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ── Scelta tipo fase (modale aggiungi fase) ───────────────────────────────── */
.tipo-fase-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .tipo-fase-choice { grid-template-columns: 1fr; } }
.tipo-fase-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s;
  background: #fff;
}
.tipo-fase-card:hover { border-color: var(--primary-light); }
.tipo-fase-card input[type="radio"] { margin-top: 2px; flex-shrink: 0; }
.tipo-fase-card:has(input:checked) {
  border-color: var(--primary-light);
  background: #eff6ff;
}
.tipo-fase-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.tipo-fase-desc { font-size: 12px; color: var(--gray-500); line-height: 1.45; }

/* ── Fase con tabella ──────────────────────────────────────────────────────── */
.fase-card.fase-tabella .fase-number.tabella-icon {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
}
.fase-type-badge {
  display: inline-block;
  padding: 1px 7px;
  background: #ede9fe;
  color: #6d28d9;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── Fase mappa web ────────────────────────────────────────────────────────── */
.fase-card.fase-mappaweb .fase-number.map-icon {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #fff;
  font-size: 15px;
}
.fase-type-badge.badge-map { background: #e0f2fe; color: #0369a1; }

/* ── Fase metadati XML ─────────────────────────────────────────────────────── */
.fase-card.fase-metadati .fase-number.xml-icon {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  font-size: 15px;
}
.fase-type-badge.badge-xml { background: #d1fae5; color: #065f46; }

/* ── Sezioni inline: mappa e XML ───────────────────────────────────────────── */
.mappa-inline-add,
.metadati-inline-add {
  margin-top: 18px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1.5px dashed var(--gray-300);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
}
.mappa-inline-section,
.metadati-inline-section {
  margin-top: 18px;
}
.fase-map-container {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  width: 100% !important;
  max-width: 100%;
  background: #e8eef4;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
}
.fase-map-container.leaflet-container { background: #e8eef4; }
.gpkg-upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color .15s;
}
.gpkg-upload-zone:hover { border-color: var(--primary-light); }
.gpkg-upload-zone input[type="file"] { display: none; }
.gpkg-upload-zone p { margin: 0 0 4px; font-size: 14px; color: var(--gray-600); }
.gpkg-upload-zone small { font-size: 12px; color: var(--gray-400); }
.fase-map-meta { margin-top: 10px; display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.fase-map-meta span { font-size: 12px; color: var(--gray-500); }

/* ── Visualizzatore XML mini ───────────────────────────────────────────────── */
.xml-tree-mini {
  font-family: 'Courier New', monospace;
  font-size: 12.5px;
  line-height: 1.7;
  background: #f8fafc;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 420px;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  contain: layout style;
}
.xml-node { white-space: nowrap; }
.metadati-inline-section, .xml-upload-area { max-width: 100%; min-width: 0; }
.xml-children { margin-left: 0; }
.xml-children.collapsed { display: none; }
.xml-tag { color: #1a5490; }
.xml-attr-name { color: #d4730a; }
.xml-attr-val { color: #d4730a; }
.xml-val { color: #2d6a2d; }
.xml-expand {
  display: inline-block;
  width: 14px;
  font-size: 9px;
  color: var(--gray-400);
  cursor: pointer;
  user-select: none;
  transition: transform .15s;
}
.xml-upload-area {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.xml-paste-area {
  width: 100%;
  min-height: 120px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 10px;
  resize: vertical;
  margin-top: 8px;
}

/* ── Visualizzatore XML a 3 schede ─────────────────────────────────────────── */
.xml-view-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 10px;
}
.xml-view-tab {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 4px 4px 0 0;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.xml-view-tab:hover { color: var(--gray-700); }
.xml-view-tab.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary-light);
  font-weight: 600;
}
.xml-view-panel { display: none; }
.xml-view-panel.active { display: block; }

/* Pannello Sorgente */
.xml-source-block {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 380px;
  white-space: pre;
  tab-size: 2;
  margin: 0;
}
.xml-source-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* Pannello Campi */
.xml-fields-wrap {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}
.xml-fields-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.xml-fields-tbl th {
  background: var(--gray-50);
  text-align: left;
  padding: 6px 10px;
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 1;
}
.xml-fields-tbl td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}
.xml-fields-tbl tr:hover td { background: #f8fafc; }
.xml-field-name {
  color: #1a5490;
  font-family: 'Courier New', monospace;
  font-size: 11.5px;
  font-weight: 600;
  display: block;
}
.xml-field-path {
  font-size: 10px;
  color: var(--gray-400);
  font-family: 'Courier New', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
  display: block;
}
.xml-field-val {
  color: var(--gray-800);
  word-break: break-word;
  font-size: 12.5px;
}

/* ── Editor XML (modal grande) ─────────────────────────────────────────────── */
.modal.xl { max-width: 920px; max-height: 93vh; }
.xml-editor-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}
.xml-editor-status {
  margin-left: auto;
  font-size: 12px;
  padding: 3px 12px;
  border-radius: 20px;
  font-weight: 500;
  transition: background .2s, color .2s;
}
.xml-editor-status.ok  { background: #d1fae5; color: #065f46; }
.xml-editor-status.err { background: #fee2e2; color: #991b1b; }
.xml-editor-wrap {
  display: flex;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  height: 52vh;
  min-height: 260px;
}
.xml-editor-gutter {
  background: #f1f5f9;
  color: #94a3b8;
  text-align: right;
  padding: 10px 10px 10px 6px;
  user-select: none;
  overflow: hidden;
  min-width: 44px;
  border-right: 1px solid var(--gray-200);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
}
.xml-editor-area {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 10px 14px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #1e293b;
  background: #fff;
  overflow: auto;
  tab-size: 2;
  white-space: pre;
}
.xml-editor-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
}

.tab-toolbar { margin-bottom: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.tab-wrap {
  overflow-x: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: #fff;
}
table.tab-data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
table.tab-data th,
table.tab-data td {
  border-bottom: 1px solid var(--gray-200);
  border-right: 1px solid var(--gray-200);
  padding: 0;
  vertical-align: middle;
}
table.tab-data th:last-child,
table.tab-data td:last-child { border-right: none; }
table.tab-data thead th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
}
.tab-th-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
}
.tab-col-type {
  font-size: 9px;
  font-weight: 700;
  background: var(--gray-200);
  color: var(--gray-600);
  padding: 1px 5px;
  border-radius: 4px;
  text-transform: uppercase;
}
.tab-col-edit,
.tab-col-del,
.tab-row-del {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--gray-500);
  margin-left: auto;
}
.tab-col-edit:hover { background: var(--gray-200); color: var(--primary); }
.tab-col-del:hover,
.tab-row-del:hover { background: #fef2f2; color: var(--danger); }
.tab-col-add-th { background: #f0f9ff !important; padding: 4px 8px !important; }
.tab-col-add-th button { white-space: nowrap; }
.tab-row-action { width: 36px; text-align: center; }
.tab-row-action-th { width: 36px; background: var(--gray-50); }
table.tab-data tbody td input,
table.tab-data tbody td textarea {
  width: 100%;
  border: none;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
  background: transparent;
  outline: none;
  transition: background .15s;
  box-sizing: border-box;
}
table.tab-data tbody td textarea { resize: vertical; min-height: 30px; }
table.tab-data tbody td input:focus,
table.tab-data tbody td textarea:focus {
  background: #fff8e1;
  box-shadow: inset 0 0 0 2px var(--primary-light);
}
table.tab-data tbody td input.saved,
table.tab-data tbody td textarea.saved {
  background: #d1fae5;
  transition: background 1s;
}
table.tab-data tbody td input.error {
  background: #fee2e2;
}
.tab-cell-link { position: relative; }
.tab-cell-link input { padding-right: 26px !important; }
.tab-link-go {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  text-decoration: none;
  font-size: 14px;
  color: var(--primary-light);
}
.tab-empty {
  text-align: center;
  padding: 30px 12px;
  color: var(--gray-400);
  font-size: 13px;
}

/* ── Tabella inline (dentro fase procedurale) ──────────────────────────────── */
.tabella-inline-add {
  margin-top: 18px;
  padding: 14px;
  background: var(--gray-50);
  border: 1px dashed var(--gray-300);
  border-radius: var(--radius);
  text-align: center;
}
.tabella-inline-section {
  margin-top: 6px;
  padding-top: 6px;
}
.btn-link-danger {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-family: inherit;
  text-transform: none;
  letter-spacing: 0;
}
.btn-link-danger:hover { color: #991b1b; }

/* ── Import CSV: istruzioni ───────────────────────────────────────────────── */
.csv-instructions {
  background: #f8fafc;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.55;
}
.csv-instr-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-600);
  margin-bottom: 6px;
}
.csv-instructions ul { padding-left: 22px; margin: 4px 0; }
.csv-instructions ul li { margin: 4px 0; color: var(--gray-700); }
.csv-instructions code {
  background: var(--gray-100);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--gray-800);
}
.csv-example {
  background: var(--gray-900);
  color: #e2e8f0;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-family: 'Menlo','Monaco','Consolas',monospace;
  font-size: 12px;
  overflow-x: auto;
  margin: 0;
  white-space: pre;
}
.check-inline {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  font-size: 13px;
}
.check-inline input { margin: 0; }

/* ═══════════════════════════════════════════════════════════════════════════
   DARK MODE
   ═══════════════════════════════════════════════════════════════════════════ */

/* Pulsante toggle (fisso in topbar) */
.dark-toggle-btn {
  background: none; border: none; cursor: pointer;
  color: var(--gray-500);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  transition: color .15s, background .15s;
  flex-shrink: 0;
}
.dark-toggle-btn svg { width: 18px; height: 18px; fill: currentColor; pointer-events: none; }
.dark-toggle-btn:hover { color: var(--gray-700); background: var(--gray-100); }

body.dark-mode .dark-toggle-btn { color: #94a3b8; }
body.dark-mode .dark-toggle-btn:hover { color: #f1f5f9; background: #233044; }

/* Body & layout */
body.dark-mode { background: #0f172a; color: #cbd5e1; }
body.dark-mode .page-content { background: #0f172a; }

/* Topbar */
body.dark-mode .topbar { background: #1a2740; border-bottom-color: #334155; box-shadow: none; }
body.dark-mode .topbar-title { color: #e2e8f0; }
body.dark-mode .topbar-comune-badge { background: #233044; color: #94a3b8; }
body.dark-mode .menu-toggle svg { fill: #94a3b8 !important; }
body.dark-mode .btn-icon svg { fill: #94a3b8; }
body.dark-mode .btn-icon:hover svg { fill: #e2e8f0; }

/* Card e stat */
body.dark-mode .card,
body.dark-mode .stat-card { background: #1e293b; border-color: #334155; }
body.dark-mode .card-header { border-bottom-color: #334155; background: #1e293b; }
body.dark-mode .card-title { color: #e2e8f0; }
body.dark-mode .card-body { background: #1e293b; }
body.dark-mode .stat-value { color: #f1f5f9; }
body.dark-mode .stat-label { color: #64748b; }

/* Tabelle */
body.dark-mode thead th { background: #162032; color: #64748b; border-bottom-color: #334155; }
body.dark-mode tbody td { color: #cbd5e1; border-bottom-color: #233044; }
body.dark-mode tbody tr:hover td { background: #233044; }
body.dark-mode .table-wrap { background: #1e293b; }

/* Form */
body.dark-mode input:not([type=checkbox]):not([type=radio]):not([type=file]),
body.dark-mode select,
body.dark-mode textarea {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}
body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder { color: #475569; }
body.dark-mode .field label { color: #94a3b8; }

/* Bottoni */
body.dark-mode .btn-secondary {
  background: #233044; border-color: #334155; color: #cbd5e1;
}
body.dark-mode .btn-secondary:hover { background: #2d3f56; }

/* Modal */
body.dark-mode .modal { background: #1e293b; border: 1px solid #334155; }
body.dark-mode .modal-header { border-bottom-color: #334155; background: #1e293b; }
body.dark-mode .modal-header h3 { color: #e2e8f0; }
body.dark-mode .modal-body { background: #1e293b; }

/* Fase cards */
body.dark-mode .fase-card { background: #1e293b; border-color: #334155; }
body.dark-mode .fase-header { background: #1e293b !important; }
body.dark-mode .fase-title { color: #e2e8f0 !important; }
body.dark-mode .fase-body { background: #152033; }
body.dark-mode .fase-header:hover { background: #233044 !important; }
body.dark-mode .fase-type-badge { opacity: 0.85; }

/* Sezioni inline aggiunta */
body.dark-mode .metadati-inline-add,
body.dark-mode .mappa-inline-add { background: #162032; border-color: #334155; color: #94a3b8; }
body.dark-mode .metadati-inline-section,
body.dark-mode .metadati-inline-section .btn-link-danger { color: #f87171; }

/* XML */
body.dark-mode .xml-tree-mini { background: #0f172a; border-color: #334155; }
body.dark-mode .xml-tag { color: #60a5fa; }
body.dark-mode .xml-val { color: #4ade80; }
body.dark-mode .xml-attr-name,
body.dark-mode .xml-attr-val { color: #fbbf24; }
body.dark-mode .xml-expand { color: #475569; }
body.dark-mode .xml-editor-area { background: #0f172a; color: #e2e8f0; }
body.dark-mode .xml-editor-gutter { background: #1e293b; border-right-color: #334155; color: #475569; }
body.dark-mode .xml-editor-wrap { border-color: #334155; }
body.dark-mode .xml-source-block { background: #0b1629; color: #e2e8f0; }
body.dark-mode .xml-fields-wrap { border-color: #334155; }
body.dark-mode .xml-fields-tbl th { background: #162032; color: #94a3b8; border-bottom-color: #334155; }
body.dark-mode .xml-fields-tbl td { border-bottom-color: #1e293b; }
body.dark-mode .xml-fields-tbl tr:hover td { background: #1e3050; }
body.dark-mode .xml-field-name { color: #60a5fa; }
body.dark-mode .xml-field-val { color: #e2e8f0; }

/* Tabella dati */
body.dark-mode .tab-wrap { background: #1e293b; border-color: #334155; }
body.dark-mode table.tab-data th { background: #162032; color: #94a3b8; border-color: #334155; }
body.dark-mode table.tab-data td { border-color: #233044; color: #cbd5e1; }

/* Login (light sempre, non toccare) */

/* Progress, badge */
body.dark-mode .progress-bar { background: #233044; }
body.dark-mode .tipo-pill { background: #233044; color: #94a3b8; }

/* Toast */
body.dark-mode .toast { background: #233044; color: #e2e8f0; box-shadow: 0 4px 12px rgba(0,0,0,.4); }

/* Guide modal */
body.dark-mode .guide-modal { background: #1e293b; border-color: #334155; }
body.dark-mode .guide-modal-header { border-bottom-color: #334155; color: #e2e8f0; }
body.dark-mode .guide-col { background: #162032; }
body.dark-mode .guide-section-title { color: #94a3b8; }
body.dark-mode .guide-item { color: #cbd5e1; border-bottom-color: #233044; }
body.dark-mode .guide-tip { background: #233044; color: #94a3b8; }

/* ═══════════════════════════════════════════════════════════════════════════
   STRUMENTI MAPPA (OmniPlan Map Toolbar)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Barra strumenti Leaflet custom */
.omni-tool-btn {
  width: 30px; height: 30px;
  background: white;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #333;
  transition: background .15s, color .15s;
  text-decoration: none;
  outline: none;
}
.omni-tool-btn:hover { background: #f0f0f0; color: #000; }
.omni-tool-btn.active { background: #2563eb !important; color: white; }
.omni-tool-btn svg { width: 14px; height: 14px; pointer-events: none; }
body.dark-mode .leaflet-bar { border-color: #334155 !important; }
body.dark-mode .leaflet-control-zoom a,
body.dark-mode .omni-tool-btn {
  background: #1e293b !important; color: #94a3b8 !important;
  border-bottom-color: #334155 !important;
}
body.dark-mode .leaflet-control-zoom a:hover,
body.dark-mode .omni-tool-btn:hover { background: #233044 !important; color: #e2e8f0 !important; }
body.dark-mode .omni-tool-btn.active { background: #2563eb !important; color: white !important; }

/* Tooltip misura distanza */
.omni-measure-label {
  background: rgba(0,0,0,.75);
  color: white; padding: 2px 7px;
  border-radius: 4px; font-size: 11px; font-weight: 600;
  white-space: nowrap; pointer-events: none;
}
.omni-measure-label .leaflet-div-icon { background: transparent !important; border: none !important; }

/* Geocoding */
.omni-geocode-bar {
  background: white;
  border-radius: 4px;
  box-shadow: 0 1px 5px rgba(0,0,0,.4);
  overflow: visible !important;
}
.omni-geocode-wrap { display: flex; align-items: center; position: relative; }
.omni-geocode-input {
  border: none; outline: none; padding: 6px 10px;
  width: 200px; font-size: 12px;
  border-radius: 4px 0 0 4px; background: transparent; color: #333;
}
.omni-geocode-btn {
  border: none; background: none; cursor: pointer; padding: 6px 8px; color: #555; border-radius: 0 4px 4px 0;
}
.omni-geocode-btn:hover { color: #000; }
.omni-geocode-results {
  display: none; position: absolute; top: 100%; left: 0; right: 0;
  background: white; border: 1px solid #ddd;
  border-radius: 0 0 4px 4px; list-style: none; z-index: 9999;
  max-height: 200px; overflow-y: auto; margin: 0; padding: 0;
}
.omni-geocode-results li {
  padding: 7px 10px; font-size: 11px; cursor: pointer; color: #333;
  border-bottom: 1px solid #f0f0f0;
}
.omni-geocode-results li:hover { background: #f5f5f5; }
body.dark-mode .omni-geocode-bar { background: #1e293b; }
body.dark-mode .omni-geocode-input { color: #e2e8f0; }
body.dark-mode .omni-geocode-results { background: #1e293b; border-color: #334155; }
body.dark-mode .omni-geocode-results li { color: #cbd5e1; border-color: #334155; }
body.dark-mode .omni-geocode-results li:hover { background: #233044; }

/* Basemap switcher dropdown */
.omni-basemap-wrap { position: relative; }
.omni-basemap-menu {
  position: absolute; top: 0; left: 32px;
  background: white; border-radius: 4px;
  box-shadow: 0 1px 5px rgba(0,0,0,.4);
  z-index: 9000; min-width: 160px; display: none;
}
.omni-basemap-menu.open { display: block; }
.omni-basemap-item {
  padding: 8px 14px; font-size: 12px; cursor: pointer; color: #333;
  border-bottom: 1px solid #f0f0f0;
}
.omni-basemap-item:last-child { border-bottom: none; }
.omni-basemap-item:hover { background: #f5f5f5; }
.omni-basemap-item.active { font-weight: 700; color: #2563eb; }
body.dark-mode .omni-basemap-menu { background: #1e293b; }
body.dark-mode .omni-basemap-item { color: #cbd5e1; border-color: #334155; }
body.dark-mode .omni-basemap-item:hover { background: #233044; }
body.dark-mode .omni-basemap-item.active { color: #60a5fa; }

/* Filter dialog */
.omni-filter-overlay {
  position: fixed; inset: 0; z-index: 9100;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
}
.omni-filter-box {
  background: white; border-radius: 8px;
  width: 100%; max-width: 380px;
  box-shadow: 0 20px 40px rgba(0,0,0,.3); overflow: hidden;
}
.omni-filter-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid #e2e8f0;
  font-weight: 600; font-size: 14px;
}
.omni-filter-close { background: none; border: none; cursor: pointer; font-size: 18px; color: #888; }
.omni-filter-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.omni-filter-body label { font-size: 12px; font-weight: 600; color: #475569; }
.omni-filter-layer,
.omni-filter-expr {
  width: 100%; padding: 7px 10px; border: 1px solid #e2e8f0;
  border-radius: 6px; font-size: 13px; background: white; color: #333;
}
.omni-filter-actions { display: flex; gap: 8px; justify-content: flex-end; }
body.dark-mode .omni-filter-box { background: #1e293b; }
body.dark-mode .omni-filter-head { border-color: #334155; color: #e2e8f0; }
body.dark-mode .omni-filter-body label { color: #94a3b8; }
body.dark-mode .omni-filter-layer,
body.dark-mode .omni-filter-expr { background: #0f172a; border-color: #334155; color: #e2e8f0; }

/* Loading toast mappa */
.omni-load-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.8); color: white;
  padding: 8px 20px; border-radius: 20px; font-size: 13px; z-index: 9999;
  pointer-events: none;
}
