:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --line: #e3e8f0;
  --text: #1c2430;
  --muted: #6b7686;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --ok: #0e9f6e;
  --warn: #b45309;
  --err: #c81e1e;
  --info: #0369a1;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 4px 14px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* L'attribut HTML hidden doit TOUJOURS gagner sur display:* (ex. drawer/modal fermés). */
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ── Barre supérieure ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; cursor: pointer; }
.logo { font-size: 20px; }
.topbar-right { display: flex; gap: 10px; align-items: center; }
.pill {
  background: var(--accent); color: #fff; border-radius: 99px;
  padding: 1px 8px; font-size: 12px; margin-left: 4px;
}

/* ── Boutons / champs ── */
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f0f3f9; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1e4fd8; }
.btn.danger { color: var(--err); border-color: #f3c1c1; }
.btn.danger:hover { background: #fdecec; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #eef1f6; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.small { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.icon-btn {
  border: 0; background: transparent; font-size: 15px; cursor: pointer;
  color: var(--muted); padding: 4px 8px; border-radius: 6px;
}
.icon-btn:hover { background: #eef1f6; color: var(--text); }

input[type="text"], input[type="url"], input[type="password"], input[type="search"],
textarea, select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff; color: var(--text);
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
label { font-size: 12px; color: var(--muted); display: block; margin: 10px 0 4px; }
.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Layout principal ── */
main { max-width: 1180px; margin: 0 auto; padding: 20px; }

/* ── Cartes comptes ── */
.account-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden;
}
.account-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fafbff, #f5f7fd);
  flex-wrap: wrap;
}
.account-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.account-meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.quota-wrap { display: flex; gap: 14px; flex-wrap: wrap; padding: 0 16px; }
.quota {
  min-width: 230px; flex: 1 1 230px; padding: 10px 0;
}
.quota .bar { height: 7px; background: #edf1f7; border-radius: 99px; overflow: hidden; margin: 5px 0 2px; }
.quota .bar > span { display: block; height: 100%; border-radius: 99px; }
.quota-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.quota-label b { color: var(--text); }

/* ── Propriétés ── */
.prop { border-top: 1px solid var(--line); padding: 14px 16px; }
.prop-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.prop-url { font-weight: 600; word-break: break-all; }
.prop-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; word-break: break-all; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip {
  font-size: 12px; padding: 3px 9px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--line); background: #f7f9fc; user-select: none;
}
.chip .n { font-weight: 700; }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.prop-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Badges d'état */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px;
  border-radius: 99px; padding: 2px 9px; font-weight: 600; white-space: nowrap;
}
.badge.indexed { background: #d9f5e9; color: #087a52; }
.badge.pending { background: #e8eefb; color: #33508f; }
.badge.submitted { background: #fdeed0; color: #8a5a00; }
.badge.not_indexed { background: #fee2e2; color: #a11f1f; }
.badge.unknown { background: #eef0f3; color: #5c6675; }
.badge.error { background: #f7d5d5; color: #9b1c1c; }
.badge.removed { background: #ececec; color: #6b7280; text-decoration: line-through; }
.badge.info { background: #d7ecf9; color: #04567f; }
.badge.warn { background: #fdeed0; color: #8a5a00; }

/* ── Table URLs ── */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.toolbar .search { flex: 1; min-width: 200px; position: relative; }
table.urls { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
table.urls th, table.urls td {
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top;
}
table.urls th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfd; }
table.urls tr:hover td { background: #f8faff; }
.url-cell { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.url-cell a { color: var(--accent); text-decoration: none; }
.url-cell a:hover { text-decoration: underline; }
td .sub { color: var(--muted); font-size: 12px; margin-top: 3px; word-break: break-word; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 10px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }

/* ── Encart best-effort ── */
.best-effort {
  background: #fff7e6; border: 1px solid #f4d391; color: #7c4a03;
  border-radius: 8px; padding: 10px 12px; font-size: 13px; display: flex; gap: 8px; align-items: flex-start;
}
.best-effort b { display: block; }
.notice { border-radius: 8px; padding: 9px 12px; font-size: 13px; margin: 8px 0; }
.notice.warn { background: #fff7e6; border: 1px solid #f4d391; color: #7c4a03; }
.notice.err { background: #fdecec; border: 1px solid #f3c1c1; color: #9b1c1c; }
.notice.ok { background: #e5f8f0; border: 1px solid #bfe8d8; color: #087a52; }
.notice.info { background: #e8f1fb; border: 1px solid #c7dcf3; color: #04567f; }

/* ── Modale ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 40; overflow-y: auto;
}
.modal {
  background: var(--panel); border-radius: 14px; width: 100%; max-width: 620px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .25); overflow: hidden;
}
.modal.wide { max-width: 860px; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 15px;
}
.modal-body { padding: 16px 18px; max-height: 70vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); background: #fafbfd; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin-top: 12px; }
.check input { width: auto; }

/* ── Jobs drawer ── */
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(460px, 94vw);
  background: var(--panel); border-left: 1px solid var(--line); z-index: 30;
  box-shadow: -8px 0 30px rgba(15, 23, 42, .12); display: flex; flex-direction: column;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 15px; }
.jobs-list { overflow-y: auto; padding: 12px; flex: 1; }
.job-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.job-card .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.job-title { font-weight: 700; font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.job-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.progress { height: 6px; background: #edf1f7; border-radius: 99px; margin-top: 8px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.job-actions { margin-top: 8px; display: flex; gap: 6px; }
.job-events { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 6px; max-height: 220px; overflow-y: auto; }
.job-events .ev { font-size: 12px; color: var(--muted); padding: 2px 0; display: flex; gap: 6px; }
.job-events .ev.warn { color: var(--warn); }
.job-events .ev.error { color: var(--err); }
.job-events .t { white-space: nowrap; color: #a2adbd; }

/* ── Toasts ── */
#toast-root { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1f2937; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 520px;
  animation: rise .18s ease-out;
}
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }
.toast.warn { background: var(--warn); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(37,99,235,.25);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  main { padding: 12px; }
  table.urls { display: block; overflow-x: auto; }
  .account-head { flex-direction: column; align-items: flex-start; }
}
