:root {
  --bg: #f6f5f3;
  --card: #ffffff;
  --border: #e6e3de;
  --fg: #1c1917;
  --muted: #78716c;
  --accent: #ea580c;
  --accent-d: #c2410c;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
}
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 13px; }
[hidden] { display: none !important; }

/* Boutons */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s, background 0.15s;
}
.btn:hover:not(:disabled) { background: #faf9f7; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--accent-d); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--big { font-size: 16px; padding: 14px 24px; width: 100%; }

/* Connexion */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login__card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
}
.login__card h1 { font-size: 18px; }
.login__sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.login__card label { display: block; font-size: 13px; font-weight: 600; margin: 18px 0 6px; }
.login__card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 16px;
}
.login__card .btn { width: 100%; }
.login__error { color: var(--red); font-size: 13px; margin: 12px 0 0; }

/* Panneau */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
  max-width: 920px;
  margin: 0 auto;
}
.topbar__sub { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

.grid {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 24px 48px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.card--wide { grid-column: 1 / -1; }
.card--action { background: linear-gradient(135deg, #fff 0%, #fff7ed 100%); }
@media (max-width: 680px) {
  .grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
}

/* Lignes état */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.row:first-of-type { border-top: none; }
.row__label { display: flex; flex-direction: column; }
.row__hint { color: var(--muted); font-size: 12px; }

/* Interrupteur pause */
.switch {
  width: 52px; height: 30px;
  border-radius: 999px;
  border: none;
  background: #d6d3d1;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: left 0.15s;
}
.switch[data-on="true"] { background: var(--green); }
.switch[data-on="true"]::after { left: 25px; }

/* Segmented control fréquence */
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.seg button {
  border: none;
  background: #fff;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* Couverture */
#coverage-seg { flex-wrap: wrap; margin-bottom: 16px; }
#coverage-seg button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 18px; }
#coverage-seg button span { font-size: 11px; font-weight: 400; color: var(--muted); }
#coverage-seg button[aria-pressed="true"] span { color: rgba(255,255,255,0.8); }

/* Coût */
.cost { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cost__opt { border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.cost__opt--active { border-color: var(--accent); background: #fff7ed; }
.cost__opt-label { font-size: 12px; color: var(--muted); }
.cost__opt-val { font-size: 22px; font-weight: 700; }
.cost__opt-val span { font-size: 12px; font-weight: 400; color: var(--muted); }
.cost__opt-detail { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Feedback */
.feedback { font-size: 13px; margin: 12px 0 0; }
.feedback--ok { color: var(--green); }
.feedback--err { color: var(--red); }

/* Historique */
.runs { list-style: none; margin: 0; padding: 0; }
.runs li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.runs li:first-child { border-top: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot--ok { background: var(--green); }
.dot--ko { background: var(--red); }
.dot--run { background: var(--amber); }
.dot--idle { background: #d6d3d1; }
.runs__when { color: var(--muted); }
.runs__tag {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
}

/* Cibles */
.targets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.target-chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.target-chip--on {
  background: #fff7ed;
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.targets-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 4px;
}

/* Apify */
.apify-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0 8px;
}
.apify-bar__fill { height: 100%; border-radius: 999px; transition: width 0.3s; }
.apify-link { font-size: 13px; padding: 7px 12px; margin-top: 8px; }

.global-error {
  max-width: 920px;
  margin: 0 auto 32px;
  padding: 0 24px;
  color: var(--red);
  font-size: 13px;
}
