:root {
  color-scheme: dark;
  --bg: #070707;
  --panel: #121212;
  --panel-raised: #1a1a1a;
  --ink: #f7f7f5;
  --muted: #aaa9a5;
  --line: #333333;
  --accent: #f97316;
  --accent-dark: #c2410c;
  --warn: #fb923c;
  --error: #f87171;
  --done: #4ade80;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: #0d0d0d;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 16px;
}

.status,
.muted {
  color: var(--muted);
  font-size: 13px;
}

main {
  padding: 16px;
}

.page {
  display: none;
}

.page.active {
  display: grid;
  gap: 16px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tab {
  min-height: 34px;
  padding: 0 10px;
}

.tab.active {
  border-color: var(--accent);
  background: #321607;
  color: #ffad72;
  font-weight: 700;
}

.grid {
  display: grid;
  gap: 16px;
}

.job-summary {
  padding: 0 14px;
}

.pick-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 10px;
}

.pick-actions button {
  min-height: 56px;
  padding: 10px;
}

.grid.two {
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
}

.grid.two.dashboard-actions {
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 14px;
}

button,
.download {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

button:hover,
.download:hover {
  border-color: var(--accent);
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

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

.icon-button {
  width: 36px;
  min-height: 32px;
  color: var(--accent);
  font-size: 18px;
}

.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 30px;
  padding: 0 10px;
  text-decoration: none;
}

.settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 14px 14px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

input[type="number"] {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--panel-raised);
  font: inherit;
  font-size: 14px;
}

input[type="text"],
input[type="password"],
input[type="date"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: var(--panel-raised);
  font: inherit;
  font-size: 14px;
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.form {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.form.inline {
  grid-template-columns: minmax(220px, 1fr) 160px auto;
  align-items: end;
}

.toggle {
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 34px;
  color: var(--ink);
  font-size: 14px;
}

.table-wrap {
  overflow: auto;
}

.prediction-tools {
  display: flex;
  align-items: end;
  gap: 8px;
}

.sort-control {
  min-width: 190px;
}

.sort-control select {
  min-height: 32px;
  padding: 0 30px 0 9px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #191919;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.predictions-table th,
.predictions-table td {
  height: 52px;
  vertical-align: middle;
}

.predictions-table th:first-child,
.predictions-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 165px;
  background: var(--panel);
}

.predictions-table th:first-child {
  z-index: 3;
  background: #191919;
}

.explained {
  cursor: help;
  text-decoration: underline dotted #777777;
  text-underline-offset: 4px;
}

.explained::after {
  position: absolute;
  top: calc(100% - 3px);
  left: 8px;
  z-index: 10;
  display: none;
  width: 240px;
  padding: 9px 10px;
  border: 1px solid #7c2d12;
  border-radius: 6px;
  background: #22140d;
  color: var(--ink);
  box-shadow: 0 8px 24px #00000099;
  content: attr(data-help);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: normal;
}

.explained:hover::after,
.explained:focus::after,
.explained.show-help::after {
  display: block;
}

.metric-cell {
  min-width: 88px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.boolean-cell {
  text-align: center;
}

.boolean-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.boolean-state.true {
  color: #fb923c;
  font-weight: 800;
}

.boolean-state.false {
  color: var(--muted);
  font-weight: 600;
}

.logo-cell {
  width: 58px;
  text-align: center;
}

.matchup-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 80px;
}

.team-logo {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.jobs-list,
.files-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding: 12px;
}

.job,
.file {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  cursor: pointer;
}

.file {
  color: inherit;
  text-decoration: none;
}

.job strong,
.file strong {
  font-size: 13px;
}

.job small,
.file small {
  color: var(--muted);
}

.status-pill {
  width: max-content;
  padding: 2px 8px;
  border-radius: 999px;
  background: #292929;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.done {
  background: #12351f;
  color: var(--done);
}

.status-pill.running,
.status-pill.queued {
  background: #43210c;
  color: var(--warn);
}

.status-pill.done.degraded {
  background: #43210c;
  color: var(--warn);
}

.job-warnings {
  color: var(--warn);
}

.pipeline-alert {
  margin: 0 14px;
  padding: 8px 10px;
  border: 1px solid var(--warn);
  border-radius: 8px;
  color: var(--warn);
}

.status-pill.error {
  background: #451717;
  color: var(--error);
}

pre {
  min-height: 260px;
  max-height: 420px;
  margin: 0;
  overflow: auto;
  padding: 14px;
  background: #050505;
  color: #ededeb;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.visual-controls {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 8px;
  padding: 14px;
}

.visual-settings {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.gallery {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.gallery-item {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.gallery-item a {
  display: flex;
  justify-content: center;
  width: 100%;
  overflow: auto;
}

.gallery-item img {
  width: 100%;
  height: auto;
  object-fit: scale-down;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.chat-box {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 10px;
  min-height: 360px;
  max-height: 520px;
  overflow: auto;
  padding: 14px;
  background: #0b0b0b;
}

.chat-message {
  overflow-wrap: anywhere;
  width: fit-content;
  max-width: min(820px, 100%);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-raised);
  white-space: pre-wrap;
}

.chat-message.markdown {
  white-space: normal;
}

.chat-message.markdown > :first-child {
  margin-top: 0;
}

.chat-message.markdown > :last-child {
  margin-bottom: 0;
}

.chat-message.markdown p,
.chat-message.markdown ul,
.chat-message.markdown ol,
.chat-message.markdown pre,
.chat-message.markdown .chat-table {
  margin: 0 0 8px;
}

.chat-message.markdown h3,
.chat-message.markdown h4,
.chat-message.markdown h5,
.chat-message.markdown h6 {
  margin: 12px 0 6px;
  font-size: 1em;
}

.chat-message.markdown ul,
.chat-message.markdown ol {
  padding-left: 22px;
}

.chat-message.markdown li.nested {
  margin-left: 18px;
}

.chat-message.markdown code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #0b0b0b;
  font-size: 0.92em;
}

.chat-message.markdown pre {
  overflow-x: auto;
  padding: 8px;
  border-radius: 6px;
  background: #0b0b0b;
  white-space: pre;
}

.chat-message.markdown pre code {
  padding: 0;
}

.chat-message.markdown .chat-table {
  overflow-x: auto;
}

.chat-message.markdown table {
  border-collapse: collapse;
}

.chat-message.markdown th,
.chat-message.markdown td {
  padding: 4px 8px;
  border: 1px solid var(--line);
  text-align: left;
  overflow-wrap: normal;
}

.chat-message.markdown hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 10px 0;
}

.chat-actions,
.chat-share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-message.chat-share {
  display: grid;
  gap: 8px;
  width: min(820px, 100%);
  white-space: normal;
}

.chat-share textarea {
  width: 100%;
  resize: vertical;
}

.chat-message.user {
  justify-self: end;
  border-color: #7c2d12;
  background: #321607;
}

input:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[type="checkbox"] {
  accent-color: var(--accent);
}

::selection {
  background: var(--accent);
  color: #ffffff;
}

.chat-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

@media (max-width: 980px) {
  main {
    padding: 10px;
  }

  .grid.two,
  .grid.two.dashboard-actions,
  .form.inline,
  .visual-controls,
  .visual-settings {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .settings {
    grid-template-columns: 1fr;
  }

  .chat-input {
    grid-template-columns: 1fr;
  }

  .panel-title:has(.prediction-tools) {
    align-items: flex-start;
    flex-direction: column;
  }

  .prediction-tools {
    width: 100%;
  }

  .sort-control {
    flex: 1;
    min-width: 0;
  }
}
.recovery-rows { display: grid; gap: 14px; }
#page-last-stats .grid.two { align-items: start; }
.recovery-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; }
.recovery-row > strong, .recovery-row > label:first-of-type { grid-column: 1 / -1; }
.recovery-row select, .recovery-row input { width: 100%; min-width: 0; }
.form details { font-size: 13px; line-height: 1.5; }
.form summary { cursor: pointer; }
@media (max-width: 620px) { .recovery-row { grid-template-columns: 1fr; } }

/* Connexion et comptes */
.login-main { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-panel { width: 100%; max-width: 380px; }
.login-head { padding: 22px 14px 4px; }
.login-panel input { font-size: 16px; }
.login-message { margin: 12px 14px 0; padding: 10px 12px; border: 1px solid var(--error); border-radius: 6px; color: var(--error); font-size: 14px; }
.login-message.info { border-color: var(--line); color: var(--muted); }
.user-box { display: flex; align-items: center; gap: 10px; }
.user-box form { margin: 0; }
.user-box button { min-height: 32px; padding: 0 10px; }
.role-badge { padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; }
.role-badge.admin { border-color: var(--accent); color: #ffad72; }
body.role-member [data-admin-only] { display: none !important; }
.accounts-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.accounts-table th, .accounts-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.accounts-table td.account-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.accounts-table td.account-actions button { min-height: 30px; padding: 0 8px; font-size: 13px; }
.accounts-table select { width: auto; padding: 4px 6px; }
.account-feedback { margin: 0; padding: 0 14px 14px; }
@media (max-width: 620px) {
  .user-box { width: 100%; justify-content: space-between; }
  .accounts-table thead { display: none; }
  .accounts-table tr { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .accounts-table td { padding: 0 10px; border: 0; }
}
.account-panel { max-width: 460px; }
.password-generate { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.password-generate button { padding: 0 12px; }
.share-box { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--accent); border-radius: 6px; }
.share-box pre { min-height: 0; max-height: none; margin: 0; padding: 0; border: 0; background: none; white-space: pre-wrap; color: var(--ink); font-size: 13px; }
.temp-password { display: inline-flex; align-items: center; gap: 8px; }
.temp-password code { padding: 2px 6px; border: 1px dashed var(--accent); border-radius: 4px; color: #ffad72; font-size: 13px; }
.temp-password button { min-height: 28px; padding: 0 8px; font-size: 12px; }
/* Page Analyses */
.analysis-list {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
}

.analysis-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-raised);
}

.analysis-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
}

.analysis-head h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.analysis-head p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.analysis-params .wide {
  grid-column: 1 / -1;
}

.analysis-output:empty {
  display: none;
}

.analysis-output {
  padding: 0 14px 14px;
  font-size: 13px;
}

.analysis-output h4 {
  margin: 12px 0 6px;
}

.analysis-output pre {
  white-space: pre-wrap;
}

.analysis-image {
  max-width: 100%;
  border-radius: 6px;
}

.error-text {
  color: var(--error);
}

/* Sondage du jour (Dashboard) */
.poll-votes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.poll-votes li {
  display: grid;
  grid-template-columns: minmax(0, 12rem) 1fr 2rem;
  align-items: center;
  gap: 10px;
}
.poll-votes .poll-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.poll-votes .poll-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--panel-raised);
  overflow: hidden;
}
.poll-votes .poll-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.poll-votes .poll-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.poll-missing {
  margin: 0;
  color: var(--warn);
}
.poll-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.poll-actions button {
  min-height: 44px;
  padding: 10px 16px;
}
#pollPanel p {
  margin: 0;
}
#pollFeedback:empty {
  display: none;
}
.poll-members {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
}
.poll-members[hidden] {
  display: none;
}
#pollMemberToggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}
