:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #e3e7ee;
  --accent: #1f5eff;
  --warn-bg: #fff4e5;
  --warn-text: #8a4b00;
  --err-bg: #fdecec;
  --err-text: #9b1c1c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { margin: 0; font-size: 22px; }
.muted { color: var(--muted); margin: 4px 0 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions form { margin: 0; }

button {
  font: inherit;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
}
button.secondary { background: var(--card); color: var(--accent); }
button:disabled { opacity: .55; cursor: default; }

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}
.filters input[type="search"] { flex: 1 1 280px; }
input, select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
}
.check { display: flex; gap: 6px; align-items: center; color: var(--muted); }

.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.banner.warn { background: var(--warn-bg); color: var(--warn-text); }
.banner.err { background: var(--err-bg); color: var(--err-text); }

.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.col-thumb { width: 110px; }
.thumb { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; background: #dfe3ea; display: block; }
.title { font-weight: 600; }
.desc { color: var(--muted); font-size: 13px; max-width: 420px; }
.tag {
  display: inline-block;
  padding: 1px 8px;
  margin: 1px 4px 1px 0;
  border-radius: 999px;
  background: #eef2ff;
  color: #3b4fb8;
  font-size: 12px;
}
.tag.etiq { background: #ecfdf3; color: #067647; }
.url a { color: var(--accent); word-break: break-all; }
.copy { padding: 3px 8px; font-size: 12px; margin-left: 6px; }

/* Colonnes triables */
th.sortable { padding: 0; }
.thbtn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: 0;
  border-radius: 0;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
th.num .thbtn { justify-content: flex-end; }
.thbtn:hover { color: var(--text); }
.thbtn::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #c3c9d4;
}
th.sortable[aria-sort="ascending"] .thbtn,
th.sortable[aria-sort="descending"] .thbtn { color: var(--text); }
th.sortable[aria-sort="ascending"] .thbtn::after {
  border-top: 0;
  border-bottom: 5px solid var(--accent);
}
th.sortable[aria-sort="descending"] .thbtn::after { border-top: 5px solid var(--accent); }

/* Mode superuser */
.super-only { display: none; }
body.is-super th.super-only, body.is-super td.super-only { display: table-cell; }
body.is-super .actions .super-only { display: inline-block; }
.col-sel { width: 36px; }
.banner.super { background: var(--warn-bg); color: var(--warn-text); border-left: 4px solid #e08a00; }

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: #eef2ff;
  border: 1px solid #cfd8ff;
  border-radius: 8px;
}
.selcount { font-weight: 600; margin-right: 6px; }
.selcount.over { color: var(--err-text); }
button.link {
  background: none;
  border: 0;
  color: var(--accent);
  text-decoration: underline;
  padding: 4px 6px;
}

/* Fenetres de dialogue */
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  width: min(780px, 94vw);
  max-height: 86vh;
  overflow: auto;
  background: var(--card);
  color: var(--text);
}
dialog::backdrop { background: rgba(20, 28, 40, .45); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field select { width: 100%; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
}
.plan { width: 100%; border-collapse: collapse; font-size: 14px; }
.plan td, .plan th { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.st-ok { color: #0a7a3d; font-weight: 600; }
.st-error { color: var(--err-text); font-weight: 600; }
.st-skip { color: var(--muted); }
.notice { padding: 8px 10px; border-radius: 8px; margin-bottom: 10px; background: var(--warn-bg); color: var(--warn-text); }
.notice.err { background: var(--err-bg); color: var(--err-text); }
.log-entry { border-bottom: 1px solid var(--line); padding: 8px 0; }
.log-entry summary { cursor: pointer; }

.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  width: min(380px, 92vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
}
.login-card form { display: grid; gap: 8px; margin-top: 12px; }
.login-card label { font-size: 13px; color: var(--muted); }
.login-card .error {
  background: var(--err-bg);
  color: var(--err-text);
  padding: 8px 10px;
  border-radius: 8px;
}
.login-card button { margin-top: 8px; }
