:root {
  --bg-primary: #0b0f19;
  --bg-surface: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(6, 182, 212, 0.5);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);
  --accent-violet: #8b5cf6;
  --accent-violet-glow: rgba(139, 92, 246, 0.25);
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.25);
  --accent-rose: #f43f5e;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Fira Code', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(6, 182, 212, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* HEADER */
.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  padding: 0.65rem 1.25rem;
  background: rgba(11, 15, 25, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 16px var(--accent-cyan-glow);
}

.brand-title {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* NAV TABS */
.nav-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.nav-tab.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.badge-tab-count {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-weight: 600;
}

.badge-tab-count.warning {
  background: var(--accent-amber);
  color: #000;
}

/* ACTIONS */
.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.8rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

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

.btn-ghost:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* MAIN LAYOUT */
.main-container {
  max-width: 1920px;
  width: 98.5%;
  margin: 0 auto;
  padding: 1.15rem 1rem;
  flex: 1;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}

.hero-bar h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.meta-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
  font-size: 0.8rem;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.green {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

/* METRICS GRID */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.card-cyan::before { background: var(--accent-cyan); box-shadow: 0 0 12px var(--accent-cyan); }
.card-violet::before { background: var(--accent-violet); box-shadow: 0 0 12px var(--accent-violet); }
.card-emerald::before { background: var(--accent-emerald); box-shadow: 0 0 12px var(--accent-emerald); }
.card-amber::before { background: var(--accent-amber); box-shadow: 0 0 12px var(--accent-amber); }

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.metric-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.metric-icon {
  font-size: 1.25rem;
}

.metric-value {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
  color: #fff;
}

.metric-value .unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
}

.metric-subtext {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* GLASS CARD */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.card-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-title-bar h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.dashboard-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .dashboard-details-grid {
    grid-template-columns: 1fr;
  }
}

.divider {
  height: 1px;
  background: var(--border-color);
  margin: 1.25rem 0;
}

/* STATS PILLS */
.stats-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.stat-pill strong {
  color: #fff;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-info {
  background: rgba(6, 182, 212, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

/* TABLES */
.table-container {
  overflow-x: auto;
  overflow-y: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  position: relative;
}

.small-table {
  max-height: 560px;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.78rem;
  text-align: left;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 20;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #111827;
  padding: 0.42rem 0.32rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid rgba(255, 255, 255, 0.15);
  white-space: normal;
  line-height: 1.18;
  text-align: center;
  vertical-align: middle;
  font-size: 0.73rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table th.sortable:hover {
  color: var(--text-main);
  background: #1a2236;
}

/* Blocca colonna Lotto (prima colonna) in orizzontale */
.data-table th:first-child {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 30;
  background: #111827;
  border-right: 1px solid var(--border-color);
  text-align: left;
}

.data-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 10;
  background: #0f172a;
  border-right: 1px solid var(--border-color);
  text-align: left;
}

.data-table td {
  padding: 0.38rem 0.32rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  white-space: nowrap;
  text-align: center;
  font-size: 0.76rem;
}

.data-table td:nth-child(2),
.data-table td:nth-child(3) {
  text-align: left;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.04);
}

.data-table tr:hover td:first-child {
  background: #1a2436;
}

.data-table td.code-cell {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #38bdf8;
}

/* STATUS ALERT BOX */
.status-alert-box {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid;
}

.status-alert-box.success {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.3);
}

.status-alert-box.warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.3);
}

.status-alert-box.info {
  background: rgba(6, 182, 212, 0.08);
  border-color: rgba(6, 182, 212, 0.3);
}

.status-alert-box.error {
  background: rgba(244, 63, 94, 0.08);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fda4af;
}

.status-icon {
  font-size: 2rem;
}

/* TOOLBAR & FILTERS */
.filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

.form-input {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  color: #fff;
  font-family: inherit;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--accent-cyan-glow);
}

.select-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-select {
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--accent-cyan);
}

/* PAGINATION */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.pagination-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-current {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0 0.5rem;
}

/* SQL EDITOR */
.sql-editor-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sql-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sql-presets {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.sql-textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  color: #38bdf8;
  resize: vertical;
  line-height: 1.5;
  outline: none;
}

.sql-textarea:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--accent-cyan-glow);
}

.sql-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 800px;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  animation: fadeIn 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-close:hover {
  color: #fff;
}

.modal-body {
  padding: 1.5rem;
  max-height: 70vh;
  overflow-y: auto;
}

/* TOASTS */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 300;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid var(--border-color);
  color: #fff;
  font-size: 0.85rem;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* UTILITIES */
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-center { text-align: center; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.highlight { color: var(--accent-cyan); font-weight: 600; }

/* SEDE SWITCHER */
.sede-switch-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.sede-switch-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.sede-switch-pills {
  display: flex;
  gap: 4px;
}

.sede-pill {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.sede-pill:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.sede-pill.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.25), rgba(139, 92, 246, 0.25));
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

/* ACTION FORM ROWS */
.action-form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  background: rgba(0, 0, 0, 0.2);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group.flex-1 {
  flex: 1;
  min-width: 300px;
}

.form-group.align-end {
  justify-content: flex-end;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* PROGRESS BARS & TARGETS */
.progress-bar-wrapper {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-emerald));
  box-shadow: 0 0 10px var(--accent-cyan-glow);
  transition: width 0.6s ease;
}

.progress-legend {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 0.45rem 1.15rem;
  background: rgba(255, 255, 255, 0.02);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.text-emerald { color: #34d399; }
.text-amber { color: #fbbf24; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1.5rem; }

/* TARGET SUBSECTIONS DIVISION */
.target-subsections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.target-subcard {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  transition: all 0.2s ease;
  position: relative;
}

.target-subcard:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.target-subcard.active {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.07);
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.15);
}

.target-subcard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

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

.target-subcard-val {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.target-subcard-val .unit {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
}

.target-subcard-stats {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.target-tabs-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.target-tab-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.target-tab-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.target-tab-btn.active {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: #000;
  font-weight: 600;
}

/* THUMBNAILS GALLERY */
.thumbs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.thumb-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease;
  display: flex;
  flex-direction: column;
}

.thumb-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-cyan);
}

.thumb-img-wrap {
  position: relative;
  width: 100%;
  height: 170px;
  background: #050811;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.thumb-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.thumb-count-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(11, 15, 25, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #38bdf8;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}

.thumb-card-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.thumb-card-title {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: #38bdf8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thumb-card-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.thumb-modal-item {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  text-align: center;
}

.thumb-modal-item img {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 4px;
  background: #050811;
}

.thumb-modal-caption {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  word-break: break-all;
}

/* THUMBS TREE WORKSPACE */
.thumbs-workspace {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  margin-top: 0.75rem;
}

.thumbs-tree-panel {
  width: 290px;
  flex-shrink: 0;
  background: rgba(11, 15, 25, 0.75);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 680px;
  display: flex;
  flex-direction: column;
}

.thumbs-tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  font-weight: 600;
}

.thumbs-tree-body {
  padding: 0.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tree-node-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0.42rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-main);
  transition: background 0.15s ease, color 0.15s ease;
  user-select: none;
}

.tree-node-row:hover {
  background: rgba(255, 255, 255, 0.07);
}

.tree-node-row.active {
  background: rgba(6, 182, 212, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(6, 182, 212, 0.45);
  font-weight: 600;
}

.tree-node-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-node-count {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  flex-shrink: 0;
}

.tree-children {
  margin-left: 0.9rem;
  padding-left: 0.5rem;
  border-left: 1px dashed rgba(255, 255, 255, 0.14);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.thumbs-main-panel {
  flex: 1;
  min-width: 0;
}

.thumbs-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

/* HIGHLIGHT ROWS WITH THUMBS IN ESPLORA DATI */
.data-table tr.row-has-thumb td {
  background: rgba(6, 182, 212, 0.06);
}

.data-table tr.row-has-thumb td:first-child {
  box-shadow: inset 3px 0 0 var(--accent-cyan);
}

.btn-thumb-highlight {
  background: rgba(6, 182, 212, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(6, 182, 212, 0.45);
  font-weight: 600;
}

.btn-thumb-highlight:hover {
  background: rgba(6, 182, 212, 0.32);
  color: #fff;
}

@media (max-width: 900px) {
  .thumbs-workspace {
    flex-direction: column;
  }
  .thumbs-tree-panel {
    width: 100%;
    max-height: 280px;
  }
}
