:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1f2430;
  --text-muted: #6b7280;
  --primary: #1f5f8b;
  --primary-dark: #163f5c;
  --primary-tint: #eaf1f7;
  --accent: #e2872f;
  --danger: #c0392b;
  --success: #1f8b5f;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.sidebar {
  width: 220px;
  background: var(--primary-dark);
  color: #fff;
  padding: 24px 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  margin-bottom: 12px;
  line-height: 1.3;
}

.sidebar nav a {
  display: block;
  color: rgba(255,255,255,0.85);
  padding: 10px 20px;
  font-size: 0.92rem;
}

.sidebar nav a:hover, .sidebar nav a.active {
  background: rgba(255,255,255,0.1);
  text-decoration: none;
  color: #fff;
}

.nav-section-label {
  padding: 16px 20px 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.45);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar .user { font-size: 0.9rem; color: var(--text-muted); }
.topbar .user a { margin-left: 12px; }

.content { padding: 28px; flex: 1; }

h1 { font-size: 1.4rem; margin: 0 0 20px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card .label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.card .value { font-size: 1.6rem; font-weight: 700; margin-top: 6px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

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

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: #fafbfc; }
tr.row-selezionata td { background: #eef4fb; }

.actions-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.danger { background: var(--danger); }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 0.85rem; padding: 0; }

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: #eef1f5;
  color: var(--text-muted);
}
.pill.pos { background: #e4f5ec; color: var(--success); }
.pill.neg { background: #fbe9e7; color: var(--danger); }

.positive { color: var(--success); font-weight: 600; }
.negative { color: var(--danger); font-weight: 600; }

form.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
}
form.form-grid .full { grid-column: 1 / -1; }
form.form-grid label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 4px; }
form.form-grid label .hint { display: block; font-size: 0.78rem; font-weight: 400; color: var(--text-muted); margin-top: 2px; }
form.form-grid input, form.form-grid select, form.form-grid textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}
form.form-grid input:focus, form.form-grid select:focus, form.form-grid textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
form.form-grid textarea { min-height: 70px; }
form .form-actions { grid-column: 1 / -1; margin-top: 8px; display: flex; gap: 10px; }

/* Schermata "Nuovo progetto": identità minima con indicatore di
   percorso a 2 passi e selezione lotti come schede rimovibili. */
.lede { color: var(--text-muted); font-size: 0.92rem; margin: -10px 0 24px; max-width: 62ch; line-height: 1.5; }

.steps { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.step { display: flex; align-items: center; gap: 10px; }
.step-num { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; flex-shrink: 0; }
.step.is-current .step-num { background: var(--primary); color: #fff; }
.step.is-next .step-num { background: var(--primary-tint); color: var(--primary); }
.step-label { font-size: 0.86rem; }
.step.is-current .step-label { color: var(--text); font-weight: 600; }
.step.is-next .step-label { color: var(--text-muted); }
.step-connector { width: 32px; height: 1px; background: var(--border); }

.field { margin-bottom: 22px; }
.field:last-child { margin-bottom: 0; }
.field > label { display: block; font-size: 0.86rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.field input[type="text"] {
  width: 100%; max-width: 420px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.95rem; font-family: inherit; background: #fff; color: var(--text);
}
.field input[type="text"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }

.lotto-picker { display: flex; gap: 10px; align-items: center; }
.lotto-picker select {
  flex: 1; max-width: 420px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.92rem; font-family: inherit; background: #fff; color: var(--text);
}

.empty-hint { border: 1px dashed var(--border); border-radius: 8px; padding: 14px 16px; color: var(--text-muted); font-size: 0.86rem; margin-top: 12px; }

.chip-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chip { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fafbfc; border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.chip-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chip-info .swatch { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.chip-info .label { font-size: 0.88rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-remove { border: none; background: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 6px; display: flex; }
.chip-remove:hover { background: #fbe9e7; color: var(--danger); }

.count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--primary-tint); color: var(--primary); font-size: 0.74rem; font-weight: 700; }

.login-wrapper {
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 340px;
}
.login-box h1 { text-align: center; margin-bottom: 4px; font-size: 1.2rem; }
.login-box .subtitle { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 24px; }
.login-box .btn { width: 100%; margin-top: 8px; }

.flash-list { margin-bottom: 18px; }
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 8px;
}
.flash.success { background: #e4f5ec; color: var(--success); }
.flash.error { background: #fbe9e7; color: var(--danger); }
.flash.info { background: #eaf1f7; color: var(--primary-dark); }

.muted { color: var(--text-muted); }
.empty-state { padding: 32px; text-align: center; color: var(--text-muted); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.detail-grid .item .label { font-size: 0.76rem; color: var(--text-muted); text-transform: uppercase; }
.detail-grid .item .value { font-size: 1rem; font-weight: 600; margin-top: 2px; }

.radio-group { display: flex; gap: 24px; }
.radio-group label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--text); }
.radio-group input { width: auto; }

/* Schede (tab): usate per dividere pagine lunghe (es. dettaglio/modifica
   di un progetto) in gruppi. Markup: contenitore con `.tabs` (bottoni
   `.tab`, icona SVG + testo, con `data-tab-target="ID"`) seguito da uno
   o più `[data-tab-panel="ID"]` (più elementi possono condividere lo
   stesso ID per mostrarsi insieme). Vedi static/js/tabs.js. Stile a
   "segmented control": la scheda attiva è un riquadro chiaro sollevato
   su uno sfondo neutro, non solo una sottolineatura. */
.tabs { display: flex; gap: 6px; background: var(--bg); padding: 6px; border-radius: 12px; margin-bottom: 22px; border: 1px solid var(--border); overflow-x: auto; }
.tab { display: flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 8px; font-size: 0.86rem; font-weight: 600; color: var(--text-muted); cursor: pointer; background: none; border: none; white-space: nowrap; font-family: inherit; }
.tab svg { flex-shrink: 0; }
.tab:hover { color: var(--text); background: rgba(31,36,48,0.04); }
.tab.active { background: var(--panel); color: var(--primary); box-shadow: 0 1px 3px rgba(31,36,48,0.1); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Sotto-sezioni dentro una scheda (es. Connessione, che raggruppa
   parecchi campi): un titolo piccolo e maiuscolo separa i gruppi senza
   introdurre un altro pannello. */
.subgroup { margin-bottom: 26px; }
.subgroup:last-child { margin-bottom: 0; }
.subgroup-title { font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* Barra azioni di un form a schede, fissa in fondo mentre si scorre
   (usata da sito_form.html). Va messa come figlio diretto di un
   `.panel` che contiene il form. */
.save-bar {
  position: sticky;
  bottom: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  margin: 20px -20px -20px;
  display: flex;
  gap: 10px;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.04);
  border-radius: 0 0 var(--radius) var(--radius);
}
