:root {
  --primary: #0b6e4f;
  --primary-dark: #095c41;
  --accent: #e63946;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #e0e4e8;
  --text: #1d2733;
  --muted: #6b7785;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 1.5rem 1rem;
  text-align: center;
}
header h1 { margin: 0; font-size: 1.6rem; }
.subtitle { margin: 0.3rem 0 0; opacity: 0.9; }

main { max-width: 1000px; margin: 1.5rem auto; padding: 0 1rem; }
.muted { color: var(--muted); }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-value { display: block; font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-completion { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border-color: var(--primary-dark); }
.stat-completion .stat-value, .stat-completion .stat-label { color: #fff; }
.stat-robin-color { color: var(--primary); }
.stat-tony-color { color: #2563eb; }

/* Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.panel h2 { margin-top: 0; }

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.9rem;
}
label { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); gap: 0.3rem; }
input, select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}
input[type="checkbox"] { width: auto; }
.form-actions { margin-top: 1rem; display: flex; gap: 0.6rem; }
.form-message { margin: 0.6rem 0 0; min-height: 1.2em; font-size: 0.9rem; }
.form-message.error { color: var(--accent); }
.form-message.success { color: var(--primary); }

/* Buttons */
.btn {
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn:hover { background: #f0f0f0; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--accent); border-color: #f0c4c8; }
.btn-danger:hover { background: #fdecee; }
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

/* Toolbar */
.toolbar { display: flex; gap: 0.8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar input[type="search"] { flex: 1; min-width: 200px; }

/* Recherche rapide d'un sticker */
.lookup-form { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.lookup-form input[type="text"] { width: 180px; text-transform: uppercase; }
.lookup-form input[type="number"] { width: 90px; }
.lookup-card {
  margin-top: 1rem; padding: 1rem;
  border: 1px solid var(--border); border-radius: 10px; background: #fafbfc;
}
.lookup-head { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.9rem; }
.lookup-team { font-weight: 700; font-size: 1.05rem; }
.owner-toggles { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.owner-btn {
  flex: 1; min-width: 150px; padding: 0.7rem 1rem; cursor: pointer;
  border: 2px solid var(--border); border-radius: 8px; background: #fff;
  font-size: 0.95rem; font-weight: 600; transition: all 0.15s;
}
.owner-btn:hover { filter: brightness(0.97); }
.owner-robin.is-owned { background: #d7f0e4; border-color: var(--primary); color: var(--primary-dark); }
.owner-tony.is-owned  { background: #dbe7ff; border-color: #2563eb; color: #1d4ed8; }
.lookup-hint { font-size: 0.8rem; margin: 0.7rem 0 0; }

/* Groupes d'equipes */
.group-block { margin-bottom: 1.5rem; }
.group-title {
  font-size: 1rem; font-weight: 700; color: var(--primary-dark);
  border-bottom: 2px solid var(--primary); padding-bottom: 0.3rem; margin: 0 0 0.8rem;
}
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.9rem;
}
.team-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.team-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.team-titles { display: flex; flex-direction: column; flex: 1; }
.team-pct {
  font-weight: 700; font-size: 0.9rem; color: var(--primary-dark);
  background: #eef6f2; border: 1px solid #cfe7dc; border-radius: 999px;
  padding: 0.15rem 0.5rem; white-space: nowrap;
}
.team-name { font-weight: 600; }
.team-page { color: var(--muted); font-size: 0.78rem; }

/* Drapeaux */
.flag {
  width: 40px; height: 30px; object-fit: cover; border-radius: 4px;
  border: 1px solid var(--border); flex-shrink: 0;
}
.flag-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 30px; background: #eef2f5; border-radius: 4px;
  font-weight: 700; font-size: 0.7rem; color: var(--muted); flex-shrink: 0;
}

/* Barres de progression (une par personne) */
.progress-row { display: flex; align-items: center; gap: 0.5rem; margin: 0.25rem 0; }
.progress-label { font-size: 0.72rem; font-weight: 700; width: 42px; }
.progress-label.robin { color: var(--primary); }
.progress-label.tony { color: #2563eb; }
.progress { flex: 1; background: #e9edf1; border-radius: 999px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; }
.progress-bar.robin { background: var(--primary); }
.progress-bar.tony { background: #2563eb; }
.progress-text { font-size: 0.74rem; color: var(--muted); width: 92px; text-align: right; white-space: nowrap; }
.team-actions { display: flex; gap: 0.4rem; margin-top: 0.7rem; flex-wrap: wrap; }

/* Table stickers */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.5rem 0.5rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--muted); font-weight: 600; }
.col-robin { background: rgba(11, 110, 79, 0.06); }
.col-tony { background: rgba(37, 99, 235, 0.06); }
#stickers-table input[type="text"] { width: 100%; min-width: 90px; }
#stickers-table input[type="number"] { width: 64px; }
.row-saved { background: #d7f0e4 !important; transition: background 0.6s; }
.empty { text-align: center; color: var(--muted); padding: 1rem; }

/* Stickers manquants */
.missing-controls { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.missing-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.missing-row:last-child { border-bottom: none; }
.missing-team-name { font-weight: 600; min-width: 130px; }
.missing-badge {
  font-size: 0.75rem; font-weight: 700; background: var(--accent); color: #fff;
  border-radius: 999px; padding: 0.1rem 0.5rem; white-space: nowrap;
}
.missing-numbers { color: var(--muted); font-size: 0.85rem; font-family: monospace; }
