:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --ink: #18191b;
  --muted: #6a6e75;
  --line: #e3e1da;
  --accent: #1f4fd8;
  --accent-ink: #ffffff;
  --accent-soft: #e8eeff;
  --danger: #c2341b;
  --ok: #1d7a46;
  --warn: #a96a00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 4px 16px rgba(20, 20, 20, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131416;
    --surface: #1c1d20;
    --ink: #ecebe7;
    --muted: #9a9ea6;
    --line: #2d2f33;
    --accent: #6d8dff;
    --accent-ink: #0d0f14;
    --accent-soft: #1f2640;
    --danger: #ff7a5c;
    --ok: #5fcf8e;
    --warn: #f0b44c;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 6px; border-radius: 2px; background: var(--surface); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; font-weight: 500; }
.nav a:hover { color: var(--ink); background: var(--bg); text-decoration: none; }
.nav a.on { color: var(--ink); background: var(--bg); }
.who { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.who form { margin: 0; }
.who-name { color: var(--ink); font-weight: 500; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
button.link:hover { color: var(--ink); text-decoration: underline; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.back { display: inline-block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap; line-height: 1.3;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* Alerts & badges */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid var(--line); background: var(--surface); }
.alert-ok { border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); }
.alert-error { border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.alert-info { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); font-size: 13px; font-weight: 500; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge-dev { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.badge-review { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); border-color: transparent; }
.badge-done { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); border-color: transparent; }
.badge-paused, .badge-off { color: var(--muted); }
.badge-admin { color: var(--ink); }
.badge-error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: transparent; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.card-off { opacity: .7; }
.card-top { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.card h2 { font-size: 18px; margin: 0 0 6px; }
.card h2 a { color: var(--ink); }
.card .desc { color: var(--muted); margin: 0 0 10px; }
.card .meta { font-size: 13px; color: var(--muted); margin: auto 0 14px; padding-top: 6px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty { text-align: center; padding: 56px 24px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty p { margin: 4px 0; }
.error-page { max-width: 520px; margin: 40px auto; }
.error-code { font-size: 44px; font-weight: 800; color: var(--muted); letter-spacing: -.02em; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table td.right { text-align: right; }
.row-off td { opacity: .6; }

/* Forms */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.panel.narrow { max-width: 480px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.form.cols .panel { display: flex; flex-direction: column; gap: 14px; }
.form.cols .panel h2 { margin-bottom: 0; }
.span2, .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 14px; }
label small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input:not([type]), select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: 0; border-color: var(--accent); }
textarea { resize: vertical; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; }
label.check input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row.prefix { gap: 0; }
.input-row .pre { display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--line); border-right: 0; border-radius: 8px 0 0 8px; background: var(--bg); color: var(--muted); font-size: 13px; white-space: nowrap; }
.input-row.prefix input { border-radius: 0 8px 8px 0; }
.checklist { display: flex; flex-direction: column; gap: 10px; }
.grid-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.hint { font-size: 13px; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); }
details summary { cursor: pointer; }
details ul { padding-left: 18px; margin: 8px 0 0; }
details li { margin-bottom: 4px; }
.danger-zone { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); }

/* Auth */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px; box-shadow: var(--shadow); }
.auth-card .brand { margin-bottom: 28px; }
.auth-card h1 { font-size: 22px; }
.auth-card .muted { margin: 0 0 20px; }

/* Viewer */
body.viewer { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.viewer-title { font-size: 15px; }
.devices { margin-left: auto; display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.devices button { font: inherit; font-size: 13px; padding: 5px 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.devices button + button { border-left: 1px solid var(--line); }
.devices button.on { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.viewer-stage { flex: 1; display: flex; justify-content: center; background: var(--bg); overflow: auto; }
.viewer-stage iframe { width: 100%; height: 100%; border: 0; background: #fff; transition: width .2s ease; }
.viewer-stage.framed { padding: 20px 0; }
.viewer-stage.framed iframe { border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }

@media (max-width: 760px) {
  .topbar { padding: 10px 16px; gap: 12px; }
  .who { margin-left: 0; width: 100%; justify-content: space-between; }
  .wrap { padding: 24px 16px 48px; }
  .form.cols { grid-template-columns: 1fr; }
  .devices { display: none; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
}

/* Langues */
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; flex: none; }
.lang-switch a { font-size: 12px; font-weight: 600; letter-spacing: .03em; padding: 4px 8px; color: var(--muted); }
.lang-switch a + a { border-left: 1px solid var(--line); }
.lang-switch a:hover { color: var(--ink); text-decoration: none; background: var(--bg); }
.lang-switch a.on { color: var(--ink); background: var(--accent-soft); }
.auth-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 28px; }
.auth-card .auth-head .brand { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* Onglets de description */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 500; font-size: 14px; }
.field-label small { font-weight: 400; color: var(--muted); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.tab { font: inherit; font-size: 13px; padding: 6px 12px; border: 0; background: none; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
