:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: oklch(0.24 0.018 257);
  --muted: oklch(0.52 0.018 257);
  --faint: oklch(0.67 0.014 257);
  --page: oklch(0.975 0.006 86);
  --surface: oklch(0.995 0.004 86);
  --surface-alt: oklch(0.955 0.009 257);
  --line: oklch(0.88 0.012 257);
  --line-strong: oklch(0.78 0.018 257);
  --accent: oklch(0.54 0.19 258);
  --accent-hover: oklch(0.47 0.19 258);
  --accent-soft: oklch(0.93 0.035 258);
  --success: oklch(0.52 0.13 151);
  --success-soft: oklch(0.93 0.035 151);
  --warning: oklch(0.65 0.14 75);
  --warning-soft: oklch(0.94 0.04 75);
  --danger: oklch(0.53 0.18 27);
  --danger-soft: oklch(0.94 0.04 27);
  --radius: 10px;
  --shadow: 0 16px 36px oklch(0.25 0.02 257 / 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
pre:focus-visible,
.skip-link:focus-visible {
  outline: 3px solid oklch(0.67 0.16 258 / 0.55);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 20;
  transform: translateY(-160%);
  padding: 9px 12px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--surface);
}

.skip-link:focus { transform: translateY(0); }

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 38px clamp(22px, 4vw, 62px) 26px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

h1, h2, p { margin: 0; }

h1 {
  margin-top: 5px;
  font-size: 1.75rem;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

h2 {
  margin-top: 3px;
  font-size: 1.16rem;
  line-height: 1.2;
  letter-spacing: -0.012em;
}

.eyebrow,
.section-kicker {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.topbar-status time {
  margin-left: 8px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
  color: var(--faint);
}

.logout-button {
  margin-left: 5px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
}

.logout-button:hover { border-color: var(--ink); color: var(--ink); }

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(410px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1 { margin: 7px 0 9px; }
.login-intro { color: var(--muted); }
.login-form { display: grid; gap: 9px; margin-top: 25px; }
.login-form label { font-size: 0.8rem; font-weight: 700; }
.login-form input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}
.login-form button {
  margin-top: 5px;
  padding: 11px 13px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 750;
}
.login-form button:hover { background: var(--accent-hover); }
.login-error { min-height: 21px; margin-top: 12px; color: var(--danger); font-size: 0.8rem; }

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--faint);
}

.status-dot--ok { background: var(--success); }
.status-dot--running { background: var(--accent); }
.status-dot--error { background: var(--danger); }

main {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 34px clamp(22px, 4vw, 62px) 72px;
}

.pipeline-section,
.client-section,
.log-section {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 21px 24px 18px;
  border-bottom: 1px solid var(--line);
}

.section-heading--compact { padding: 18px 20px 15px; }

.section-note,
.count {
  color: var(--muted);
  font-size: 0.82rem;
}
.heading-actions { display: flex; align-items: center; gap: 12px; }
.button-link { display: inline-flex; align-items: center; text-decoration: none; }

.pipeline-list { min-height: 186px; }

.pipeline-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.2fr) minmax(220px, 1fr) minmax(150px, 0.75fr) minmax(150px, 0.75fr) auto;
  align-items: center;
  gap: 24px;
  min-height: 76px;
  padding: 16px 20px 16px 24px;
  border-bottom: 1px solid var(--line);
}

.pipeline-row:last-child { border-bottom: 0; }
.pipeline-row:hover { background: oklch(0.985 0.006 257); }

.pipeline-name {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.pipeline-name strong {
  display: block;
  font-size: 0.94rem;
}

.pipeline-name span,
.pipeline-detail {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
}

.pipeline-detail b {
  display: block;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 650;
}

.pipeline-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.run-button,
.log-button,
.text-button {
  min-height: 36px;
  border-radius: 7px;
  cursor: pointer;
  transition: background-color 170ms cubic-bezier(0.16, 1, 0.3, 1), border-color 170ms cubic-bezier(0.16, 1, 0.3, 1);
}

.run-button {
  padding: 8px 13px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: oklch(0.985 0.006 258);
  font-size: 0.82rem;
  font-weight: 700;
}

.run-button:hover { background: var(--accent-hover); }
.run-button:disabled { cursor: not-allowed; opacity: 0.55; }

.log-button {
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.82rem;
}

.log-button:hover { background: var(--surface-alt); }

.text-button {
  min-height: 30px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.text-button:hover { color: var(--accent-hover); }
.journal-actions { display: flex; align-items: center; gap: 12px; }
.live-badge { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.72rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.04em; }
.live-badge .status-dot { width: 7px; height: 7px; }

.schedule-control {
  display: flex;
  align-items: center;
  gap: 7px;
}

.schedule-control input[type="time"] {
  width: 104px;
  min-height: 35px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(480px, 1.2fr) minmax(360px, 0.8fr);
  gap: 22px;
  margin-top: 22px;
  align-items: start;
}

.ai-controls { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 8px; }
.ai-controls label { color: var(--muted); font-size: 0.68rem; font-weight: 700; }
.ai-controls select,
.field input,
.field select,
.field textarea,
.metric-grid input {
  width: 100%;
  min-height: 36px;
  margin-top: 4px;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}
.deterministic-note { max-width: 26ch; color: var(--muted); font-size: 0.78rem; }

.client-list-head,
.client-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.25fr) minmax(150px, 1fr) 64px minmax(120px, 0.8fr) 68px minmax(100px, auto);
  gap: 18px;
  align-items: center;
}
.client-list-head { padding: 9px 20px; border-bottom: 1px solid var(--line); background: var(--surface-alt); color: var(--muted); font-size: 0.68rem; font-weight: 750; letter-spacing: 0.05em; text-transform: uppercase; }
.client-row { min-height: 62px; padding: 11px 20px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.client-row:last-child { border-bottom: 0; }
.client-row { cursor: pointer; transition: background-color 170ms cubic-bezier(0.16, 1, 0.3, 1); }
.client-row:hover { background: oklch(0.975 0.012 257); }
.client-row:hover .client-edit { color: var(--accent-hover); text-decoration-color: currentColor; }
.client-row:focus-visible { outline: 3px solid oklch(0.67 0.16 258 / 0.45); outline-offset: -3px; }
.client-row strong, .client-row small { display: block; }
.client-row small { margin-top: 2px; color: var(--muted); }
.client-state { display: flex; align-items: center; gap: 7px; font-size: 0.78rem; }
.client-edit { color: var(--accent); font-size: 0.77rem; font-weight: 750; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
.muted, .empty-state { color: var(--muted); }
.empty-state { padding: 22px; }

.client-view { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.breadcrumb { display: flex; gap: 8px; padding: 14px 24px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 0.78rem; }
.breadcrumb a { color: var(--accent); text-decoration: none; font-weight: 700; }
.client-page-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 26px 30px; border-bottom: 1px solid var(--line); }
.client-page-header h2 { font-size: 1.55rem; }
.client-page-actions { display: flex; align-items: center; gap: 16px; }
.client-config { max-width: 1100px; }
.config-section { display: grid; grid-template-columns: minmax(220px, 0.7fr) minmax(360px, 1.3fr); gap: 42px; padding: 26px 30px; border-bottom: 1px solid var(--line); }
.config-section:last-child { border-bottom: 0; }
.config-section h3 { margin: 0 0 5px; font-size: 1rem; }
.config-section > div > p { max-width: 46ch; color: var(--muted); font-size: 0.8rem; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 10px 18px; margin: 0; padding: 0; border: 0; }
.choice-grid label, .inline-toggle { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 0.84rem; }
.choice-grid input, .inline-toggle input { width: 17px; height: 17px; accent-color: var(--accent); }
.field { display: block; color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.field--wide { width: 100%; }
.field textarea { min-height: 130px; resize: vertical; line-height: 1.45; }
.form-stack { display: grid; gap: 18px; }
.form-grid { display: grid; gap: 12px; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
.form-grid--2 { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
.subsection-label { margin-bottom: 9px; color: var(--muted); font-size: 0.72rem; font-weight: 750; letter-spacing: 0.05em; text-transform: uppercase; }
.metric-grid { display: grid; grid-template-columns: minmax(120px, 1fr) repeat(3, minmax(80px, 0.8fr)); gap: 7px 10px; align-items: center; }
.metric-grid b { color: var(--muted); font-size: 0.7rem; text-align: center; }
.metric-grid label { color: var(--ink); font-size: 0.78rem; }
.metric-grid input { margin: 0; }
.client-run-actions--inline { display: flex; flex-wrap: wrap; align-items: center; margin: 0; }
.client-run-actions--inline button { padding: 9px 12px; }
.account-list { display: grid; gap: 10px; }
.account-row { display: grid; grid-template-columns: minmax(150px, 0.9fr) minmax(190px, 1.1fr) auto; gap: 10px; align-items: end; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.account-row:last-child { padding-bottom: 0; border-bottom: 0; }
.remove-account { min-height: 36px; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--danger); cursor: pointer; font-size: 0.74rem; font-weight: 700; }
.remove-account:hover { border-color: var(--danger); background: var(--danger-soft); }
.add-account-button { justify-self: start; }
.secret-field { max-width: 360px; }
.secret-field span::after { content: " · jamais affiché"; color: var(--faint); font-weight: 500; }
[readonly] { background: var(--surface-alt) !important; color: var(--muted) !important; cursor: not-allowed; }
[hidden] { display: none !important; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th, td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: var(--surface-alt);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: oklch(0.985 0.006 257); }
.align-right { text-align: right; }

.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.source-tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 650;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.client-field select,
.specificities-editor textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.client-field select { min-width: 138px; padding: 7px 28px 7px 9px; }

.specificities-editor,
.client-run-menu { min-width: 115px; }

.specificities-editor summary,
.client-run-menu summary {
  color: var(--accent);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
}

.specificities-editor[open] {
  min-width: 240px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-alt);
}

.specificities-editor label span {
  display: block;
  margin: 8px 0 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

.specificities-editor textarea { resize: vertical; padding: 8px; line-height: 1.4; }

.save-client-button,
.client-run-actions button {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
}

.save-client-button { margin-top: 7px; padding: 6px 9px; }
.client-run-menu { margin-top: 7px; }
.client-run-actions { display: grid; gap: 5px; margin-top: 7px; }
.client-run-actions button { padding: 6px 8px; text-align: left; }
.save-client-button:hover,
.client-run-actions button:hover { border-color: var(--accent); color: var(--accent); }
.client-field select:focus-visible,
.specificities-editor textarea:focus-visible,
.save-client-button:focus-visible,
.client-run-actions button:focus-visible,
.specificities-editor summary:focus-visible,
.client-run-menu summary:focus-visible { outline: 3px solid oklch(0.67 0.16 258 / 0.45); outline-offset: 2px; }

.toggle {
  position: relative;
  display: inline-flex;
  width: 40px;
  height: 23px;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle span {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-alt);
  cursor: pointer;
  transition: background-color 170ms cubic-bezier(0.16, 1, 0.3, 1);
}

.toggle span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 4px oklch(0.22 0.02 257 / 0.2);
  transition: transform 170ms cubic-bezier(0.16, 1, 0.3, 1);
}

.toggle input:checked + span { border-color: var(--accent); background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(17px); }
.toggle input:focus-visible + span { outline: 3px solid oklch(0.67 0.16 258 / 0.55); outline-offset: 2px; }

.log-meta {
  min-height: 42px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

.log-output {
  min-height: 420px;
  max-height: 640px;
  margin: 0;
  overflow: auto;
  padding: 18px 20px 24px;
  background: oklch(0.25 0.018 257);
  color: oklch(0.9 0.012 257);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.73rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.84rem;
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-alt), oklch(0.985 0.006 257), var(--surface-alt));
  background-size: 220% 100%;
  animation: loading 1.4s ease-in-out infinite;
}

.skeleton--row { height: 75px; border-bottom: 1px solid var(--line); }
.skeleton--cell { width: 70%; height: 18px; border-radius: 5px; }

@keyframes loading { to { background-position: -220% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

@media (max-width: 980px) {
  .pipeline-row { grid-template-columns: minmax(200px, 1fr) minmax(210px, 1fr) auto; }
  .pipeline-row > .pipeline-detail { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .log-output { min-height: 300px; }
  .client-list-head, .client-row { grid-template-columns: minmax(150px, 1.3fr) minmax(140px, 1fr) 64px 68px minmax(96px, auto); }
  .client-list-head span:nth-child(4), .client-row > span:nth-child(4) { display: none; }
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; flex-direction: column; padding-top: 26px; }
  .topbar-status { flex-wrap: wrap; }
  .pipeline-row { grid-template-columns: 1fr; gap: 12px; padding: 18px; }
  .pipeline-actions { justify-content: flex-start; }
  .schedule-control { justify-content: space-between; }
  .section-heading { align-items: flex-start; }
  th, td { padding-inline: 14px; }
  .client-list-head { display: none; }
  .client-row { grid-template-columns: 1fr auto; gap: 8px 16px; padding: 14px 18px; }
  .client-row > span:nth-child(2), .client-row > span:nth-child(3) { grid-column: 1; }
  .client-row > span:nth-child(5) { grid-column: 2; grid-row: 1; }
  .client-row > span:nth-child(6) { grid-column: 2; grid-row: 2 / span 2; align-self: end; }
  .client-page-header { align-items: flex-start; flex-direction: column; padding: 22px; }
  .config-section { grid-template-columns: 1fr; gap: 16px; padding: 22px; }
  .form-grid--3 { grid-template-columns: 1fr; }
  .form-grid--2 { grid-template-columns: 1fr; }
  .account-row { grid-template-columns: 1fr; }
  .remove-account { justify-self: start; }
  .metric-grid { grid-template-columns: minmax(95px, 1fr) repeat(3, minmax(65px, 0.75fr)); gap: 6px; }
}
