:root {
  --bg: #f7f7f8;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #666666;
  --border: #dddddd;
  --accent: #2f6f4f;
  --accent-hover: #24593f;
  --error: #b3261e;
  --error-bg: #fdecea;
  --success: #1e6b3c;
  --success-bg: #eaf7ee;
}

* { box-sizing: border-box; }

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

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  align-items: center;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav a {
  color: var(--text);
  text-decoration: none;
  padding: 6px 4px;
  font-size: 0.95rem;
}

.nav a.active { color: var(--accent); font-weight: 600; }
.nav .brand { font-weight: 700; margin-right: auto; }

.nav-logout {
  background: none;
  border: none;
  color: var(--text);
  text-decoration: none;
  padding: 6px 4px;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
}
.nav-logout:hover { color: var(--accent); }

.layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 28px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.container {
  max-width: 900px;
  width: 100%;
}

.stepper-wrap {
  width: 210px;
  flex-shrink: 0;
  position: sticky;
  top: 70px;
}

.stepper {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stepper li {
  position: relative;
  padding: 0 0 26px 32px;
}

.stepper li:last-child { padding-bottom: 0; }

.stepper li::before {
  content: attr(data-step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper li::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 23px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.stepper li:last-child::after { display: none; }

.stepper li.active::before { background: var(--accent); color: #fff; }

.stepper a { text-decoration: none; color: inherit; }
.stepper .step-title { font-weight: 600; font-size: 0.87rem; }
.stepper li.active .step-title { color: var(--accent); }
.stepper .step-desc { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .stepper-wrap { width: 100%; position: static; }
  .stepper { display: flex; flex-wrap: wrap; gap: 10px 18px; }
  .stepper li { padding: 0 0 0 30px; flex: 1 1 45%; }
  .stepper li::after { display: none; }
}

h1 { font-size: 1.4rem; margin: 0 0 8px; }
h2 { font-size: 1.1rem; margin: 24px 0 8px; }

.hint { color: var(--muted); font-size: 0.9rem; }
.hint code { background: #eee; padding: 1px 4px; border-radius: 3px; }

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

.card-narrow { max-width: 360px; margin: 60px auto; }

form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

label { font-weight: 600; font-size: 0.9rem; margin-top: 4px; }

input[type="text"],
input[type="password"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
  background: #000;
  color: #eaeaea;
}

textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.9rem;
  resize: vertical;
  background: #000;
  color: #eaeaea;
}

select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font-size: 0.9rem;
}

.json-editor {
  min-height: 55vh;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

.text-editor { min-height: 30vh; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { display: contents; }

button {
  appearance: none;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover { background: var(--accent-hover); }

button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

button.danger {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
}

button.danger:hover { background: var(--error-bg); }

.btn-link {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn-link.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.panel {
  margin: 18px 0;
}

.panel summary.btn-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  width: fit-content;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.panel summary.btn-summary::-webkit-details-marker { display: none; }
.panel summary.btn-summary::before { content: "▸"; font-size: 0.75em; }
.panel[open] summary.btn-summary::before { content: "▾"; }
.panel[open] summary.btn-summary { margin-bottom: 14px; }

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.flash-error { background: var(--error-bg); color: var(--error); }
.flash-success { background: var(--success-bg); color: var(--success); }

.history-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.history-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  flex-wrap: wrap;
}

.history-name { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
.history-links a { margin-left: 12px; color: var(--accent); text-decoration: none; font-weight: 600; }

.offre-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.offre-list li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  flex-wrap: wrap;
}

.offre-main { flex: 1; min-width: 220px; }
.offre-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.offre-numero { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; color: var(--muted); }
.offre-intitule { font-weight: 600; }

.offre-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.offre-badge-non_postule { background: var(--border); color: var(--muted); }
.offre-badge-postule { background: var(--success-bg); color: var(--success); }
.offre-badge-donne_suite { background: #fff4dd; color: #8a5a00; }
.offre-badge-trop_galere { background: var(--error-bg); color: var(--error); }

.offre-lien { display: block; margin-top: 4px; font-size: 0.85rem; color: var(--accent); word-break: break-all; }
.offre-details { color: var(--muted); font-size: 0.85rem; margin-top: 4px; white-space: pre-wrap; }

.offre-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.offre-actions select { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--card); color: var(--text); }
.offre-delete { padding: 6px 10px; line-height: 1; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --card: #1f2126;
    --text: #eaeaea;
    --muted: #9a9a9a;
    --border: #33363c;
    --accent: #4caf7d;
    --accent-hover: #5fc491;
    --error-bg: #3a1f1d;
    --success-bg: #1c3324;
  }
  .hint code { background: #2a2c31; }
  .offre-badge-donne_suite { background: #3a2f14; color: #e0b354; }
}
