:root {
  --brand:       #3b82f6;
  --brand-dark:  #1d4ed8;
  --sidebar-bg:  #1e293b;
  --sidebar-txt: #94a3b8;
  --sidebar-act: #f1f5f9;
  --card-radius: 10px;
}

/* ── Layout ── */
body {
  margin: 0;
  min-height: 100vh;
  background: #f1f5f9;
  font-family: 'Inter', system-ui, sans-serif;
}

.cms-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.cms-sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  padding: 0;
}

.cms-sidebar .sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid #334155;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: .02em;
  text-decoration: none;
}

.cms-sidebar nav { flex: 1; padding: 12px 0; }

.cms-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-txt);
  text-decoration: none;
  font-size: .9rem;
  border-left: 3px solid transparent;
  transition: all .15s;
}

.cms-sidebar nav a:hover,
.cms-sidebar nav a.active {
  color: var(--sidebar-act);
  background: rgba(255,255,255,.06);
  border-left-color: var(--brand);
}

.cms-sidebar nav a svg { opacity: .7; flex-shrink: 0; }
.cms-sidebar nav a.active svg, .cms-sidebar nav a:hover svg { opacity: 1; }

.cms-sidebar .sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid #334155;
  font-size: .8rem;
  color: #475569;
}

.cms-main {
  margin-left: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: calc(100vw - 240px);
  max-width: calc(100vw - 240px);
}

.cms-topbar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 16px 32px;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-sizing: border-box;
  width: 100%;
}

.cms-topbar h1 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
}

.cms-content {
  padding: 32px;
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}

/* ── Cards ── */
.cms-card {
  background: #fff;
  border-radius: var(--card-radius);
  border: 1px solid #e2e8f0;
  padding: 24px;
  margin-bottom: 20px;
  width: 100%;
  box-sizing: border-box;
}

.cms-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.cms-card-title {
  font-size: .95rem;
  font-weight: 600;
  color: #0f172a;
}

/* ── Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--card-radius);
  border: 1px solid #e2e8f0;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue  { background: #eff6ff; color: #2563eb; }
.stat-icon.green { background: #f0fdf4; color: #16a34a; }
.stat-icon.amber { background: #fffbeb; color: #d97706; }

.stat-label { font-size: .78rem; color: #64748b; margin-bottom: 2px; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: #0f172a; }

/* ── Tabelle ── */
.cms-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.cms-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
}
.cms-table td {
  padding: 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}
.cms-table tr:last-child td { border-bottom: none; }
.cms-table tr:hover td { background: #f8fafc; }

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-amber  { background: #fef3c7; color: #92400e; }

/* ── Bottoni ── */
.btn-cms {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
}
.btn-primary  { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-outline  { background: transparent; border: 1px solid #cbd5e1; color: #334155; }
.btn-outline:hover { background: #f1f5f9; }
.btn-danger   { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover  { background: #fecaca; }
.btn-sm { padding: 5px 10px; font-size: .78rem; }

/* ── Form ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .82rem; font-weight: 500; color: #374151; margin-bottom: 5px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font-size: .875rem;
  color: #1e293b;
  background: #fff;
  transition: border .15s;
  box-sizing: border-box;
}
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Alert ── */
.alert {
  padding: 12px 16px;
  border-radius: 7px;
  font-size: .875rem;
  margin-bottom: 16px;
  display: none;
}
.alert.show { display: block; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 20px;
}

/* ── Toggle switch ── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle {
  position: relative;
  width: 40px; height: 22px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  cursor: pointer;
  transition: .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
}
.toggle input:checked + .toggle-slider { background: var(--brand); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Galeria immagini ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.gallery-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
  background: #f1f5f9;
}
.gallery-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-item-actions {
  position: absolute;
  top: 6px; right: 6px;
  display: flex; gap: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.gallery-item:hover .gallery-item-actions { opacity: 1; }

/* ── Upload area ── */
.upload-area {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  color: #64748b;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--brand);
  background: #eff6ff;
  color: var(--brand);
}
.upload-area input { display: none; }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
.login-box {
  background: #fff;
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 25px 60px rgba(0,0,0,.35);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
}
.login-logo p { color: #64748b; font-size: .85rem; margin: 4px 0 0; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .cms-shell { display: block; }
  .cms-sidebar { width: 100%; min-height: auto; position: static; }
  .cms-main {
    margin-left: 0;
    width: 100%;
    max-width: none;
  }
  .cms-topbar {
    padding: 14px 18px;
    min-height: 64px;
  }
  .cms-content { padding: 18px; }
  .stats-grid { grid-template-columns: 1fr; }
}
