* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  line-height: 1.5;
}

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

.topbar {
  background: #1e293b;
  color: white;
  padding: 14px 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.logo {
  font-size: 20px;
  font-weight: 700;
  color: white;
  text-decoration: none;
}
.topbar nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.topbar nav a {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 15px;
}
.topbar nav a:hover { color: white; }
.btn-nav {
  background: #2563eb;
  padding: 6px 14px;
  border-radius: 6px;
  color: white !important;
}

main { padding: 24px 0 60px; }

h1 { margin: 0 0 16px; font-size: 26px; }
h2 { margin: 0 0 12px; font-size: 22px; }
h3 { margin: 24px 0 10px; font-size: 17px; color: #334155; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.hero {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  text-align: center;
}
.hero h1 { font-size: 30px; }
.sottotitolo { color: #64748b; margin-bottom: 24px; }

.ricerca-form {
  display: flex;
  gap: 10px;
  margin: 20px 0;
  flex-wrap: wrap;
  justify-content: center;
}
.ricerca-form input[type="text"] {
  flex: 1;
  min-width: 250px;
  padding: 12px 16px;
  font-size: 17px;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
}
.ricerca-form input[type="text"]:focus {
  outline: none;
  border-color: #2563eb;
}

.scorciatoie {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid #cbd5e1;
  background: white;
  color: #334155;
  transition: all 0.15s;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: #2563eb; color: white; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #64748b; color: white; border-color: #64748b; }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: #dc2626; color: white; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-small { padding: 6px 12px; font-size: 13px; }

.alert {
  padding: 14px 18px;
  border-radius: 8px;
  margin: 16px 0;
  font-size: 16px;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.scheda {
  background: white;
  padding: 28px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-top: 16px;
}
.scheda-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e5e7eb;
}
.codice-badge {
  background: #1e293b;
  color: white;
  padding: 5px 12px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 14px;
  font-weight: bold;
}
.scheda-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 24px;
  margin-bottom: 16px;
}
.prezzo-box {
  grid-column: 1 / -1;
  padding: 12px 16px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 8px;
}
.prezzo {
  font-size: 22px;
  font-weight: 700;
  color: #166534;
  margin-left: 8px;
}
.note-box {
  background: #fffbeb;
  padding: 12px 16px;
  border-left: 4px solid #fbbf24;
  border-radius: 4px;
  margin: 16px 0;
}
.note-box p { margin: 4px 0 0; white-space: pre-wrap; }

.accessori-lista {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
}
.accessori-lista li {
  background: #eff6ff;
  padding: 8px 12px;
  border-radius: 6px;
  color: #1e40af;
}

.galleria {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.galleria img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: transform 0.15s;
}
.galleria img:hover { transform: scale(1.02); }
.galleria.piccola img { height: 110px; }
.foto-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.muted { color: #64748b; }

.griglia-motori {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
}
.card-foto {
  height: 180px;
  background: #e5e7eb;
}
.card-foto img { width: 100%; height: 100%; object-fit: cover; }
.no-foto {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: #94a3b8;
}
.card-body { padding: 14px; flex: 1; display: flex; flex-direction: column; }
.card-body h3 { margin: 8px 0 4px; }
.card-azioni { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; padding-top: 10px; }

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
.tag-usato { background: #fef3c7; color: #92400e; }
.tag-rettificato { background: #dbeafe; color: #1e40af; }

.form-motore {
  background: white;
  padding: 28px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.form-motore label {
  display: flex;
  flex-direction: column;
  font-weight: 500;
  font-size: 14px;
  color: #334155;
  gap: 4px;
}
.form-motore input[type="text"],
.form-motore input[type="number"],
.form-motore select,
.form-motore textarea {
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 15px;
  font-family: inherit;
}
.form-motore input:focus, .form-motore select:focus, .form-motore textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.accessori-fieldset, .foto-fieldset {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 16px;
}
.accessori-fieldset legend, .foto-fieldset legend {
  font-weight: 600;
  color: #1e293b;
  padding: 0 6px;
}
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.check {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.check input { margin: 0; }
.liberi { margin-top: 6px; }

.form-azioni {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.azioni {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.user-info {
  color: #cbd5e1;
  font-size: 14px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
}
.nav-link-soft {
  font-size: 13px;
  color: #94a3b8 !important;
}
.logout-form { margin: 0; display: inline; }
.btn-logout {
  background: #dc2626;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.btn-logout:hover { background: #b91c1c; }

.login-page {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box {
  background: white;
  padding: 40px;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  max-width: 420px;
  width: 100%;
}
.login-box h1 {
  text-align: center;
  margin: 0 0 6px;
  font-size: 26px;
}
.login-box .sottotitolo {
  text-align: center;
  margin-bottom: 24px;
}
.form-login {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-login label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-weight: 500;
  font-size: 14px;
  color: #334155;
}
.form-login input {
  padding: 11px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
}
.form-login input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.btn-large {
  padding: 12px 18px;
  font-size: 16px;
  margin-top: 6px;
}
.login-hint {
  text-align: center;
  font-size: 13px;
  margin-top: 20px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  line-height: 1.6;
}

.ai-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 30px 20px;
  margin: 24px 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  color: #475569;
}
.ai-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: ai-spin 0.9s linear infinite;
}
@keyframes ai-spin {
  to { transform: rotate(360deg); }
}

.ai-intestazione {
  margin: 24px 0 8px;
  padding: 10px 14px;
  background: #eff6ff;
  border-radius: 8px;
  color: #1e40af;
  font-size: 15px;
}

.ai-card {
  margin-top: 16px;
}

.ai-warning {
  margin: 18px 0 0;
  padding: 14px 18px;
  background: #fffbeb;
  border: 1px solid #fbbf24;
  border-left: 6px solid #f59e0b;
  border-radius: 8px;
  color: #78350f;
  font-weight: 500;
  font-size: 15px;
  line-height: 1.5;
}

.footer {
  background: #1e293b;
  color: #94a3b8;
  text-align: center;
  padding: 16px;
  font-size: 13px;
  margin-top: 40px;
}
