:root {
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --border: #e3e5e9;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 60px;
}

h1 { font-size: 1.25rem; margin: 0 0 2px; }
h2 { font-size: 1rem; margin: 0 0 14px; color: var(--text); }
.muted { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* --- Login --- */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  background: var(--card-bg); padding: 32px 28px; border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.08); max-width: 360px; width: 100%; text-align: center;
}
.login-card input {
  width: 100%; padding: 14px; margin: 16px 0 10px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 1rem;
}
.login-card button {
  width: 100%; padding: 14px; background: var(--accent); color: white; border: none;
  border-radius: 10px; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.error { color: var(--danger); font-size: 0.9rem; }

/* --- Topbar --- */
.topbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 20px; background: var(--card-bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.back-link { font-size: 0.85rem; color: var(--accent); text-decoration: none; }
.btn-ghost {
  font-size: 0.85rem; color: var(--muted); text-decoration: none; border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 10px; white-space: nowrap;
}
.save-indicator { font-size: 0.8rem; color: var(--ok); align-self: center; transition: opacity 0.3s; }
.save-indicator.saving { color: var(--warn); }

/* --- Progress bar --- */
.progress-bar { height: 6px; background: var(--border); }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.3s; }

/* --- Dashboard list --- */
.site-list { padding: 10px 14px 30px; max-width: 720px; margin: 0 auto; }
.lot-heading { margin: 22px 4px 8px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.site-row {
  display: flex; align-items: center; gap: 12px; background: var(--card-bg);
  padding: 16px 14px; border-radius: 12px; margin-bottom: 8px; text-decoration: none; color: var(--text);
  border: 1px solid var(--border);
}
.site-num { font-size: 0.75rem; color: var(--muted); min-width: 22px; }
.site-name { flex: 1; font-weight: 500; }
.site-status { font-size: 0.78rem; padding: 4px 10px; border-radius: 20px; background: #eef0f3; color: var(--muted); white-space: nowrap; }
.status-terminé .site-status { background: #dcfce7; color: var(--ok); }
.status-en-cours .site-status { background: #fef3c7; color: var(--warn); }

.footer { text-align: center; padding: 20px; }

.delete-btn {
  background: none; border: none; font-size: 1.1rem; cursor: pointer; padding: 8px;
  color: var(--danger); flex-shrink: 0;
}
.btn-danger {
  display: inline-block; background: var(--danger); color: white; padding: 12px 18px;
  border: none; border-radius: 10px; font-weight: 600; font-size: 1rem; cursor: pointer;
  text-align: center; width: 100%; margin-top: 10px;
}

/* --- Form --- */
.form-wrap { max-width: 640px; margin: 0 auto; padding: 16px 14px 60px; }
.card {
  background: var(--card-bg); border-radius: var(--radius); padding: 18px;
  margin-bottom: 14px; border: 1px solid var(--border);
}
.field-label { display: block; font-size: 0.82rem; color: var(--muted); margin: 12px 0 6px; }
.card > .field-label:first-child { margin-top: 0; }
.field-input, .field-select, .field-textarea {
  width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 1rem; background: #fafbfc; font-family: inherit;
}
.field-textarea { resize: vertical; }
.statut-select { font-weight: 600; font-size: 1.05rem; padding: 14px; }

.counter-row, .toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
}
.equip-block { border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 4px; }
.equip-block:last-child { border-bottom: none; margin-bottom: 0; }
.equip-block .toggle-row { padding-bottom: 6px; }
.equip-note { font-size: 0.9rem; padding: 10px; }
.counter-row:last-child { border-bottom: none; }
.counter { display: flex; align-items: center; gap: 12px; }
.counter-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  background: #fafbfc; font-size: 1.2rem; cursor: pointer; line-height: 1;
}
.counter-value { min-width: 24px; text-align: center; font-weight: 600; font-size: 1.05rem; }

.switch { position: relative; display: inline-block; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0; background: #d1d5db; border-radius: 28px; transition: 0.2s;
}
.slider::before {
  content: ""; position: absolute; height: 22px; width: 22px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* --- Buttons --- */
.btn-primary {
  display: inline-block; background: var(--accent); color: white; padding: 12px 18px;
  border: none; border-radius: 10px; font-weight: 600; font-size: 1rem; cursor: pointer;
  text-align: center; width: 100%;
}
.btn-primary:active { background: var(--accent-dark); }

/* --- Photos --- */
.photo-input { display: none; }
.photo-btn {
  display: inline-block; background: var(--accent); color: white; padding: 12px 18px;
  border-radius: 10px; font-weight: 600; cursor: pointer; text-align: center; width: 100%;
}
.photo-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.photo-thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-delete {
  position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,0.6); color: white;
  border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer;
}

@media (min-width: 640px) {
  .site-list, .form-wrap { padding-left: 0; padding-right: 0; }
}
