/* =================================================================
   Back-office — sobre, clair, lisible
   ================================================================= */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --ink: #0f1e2e;
  --ink-soft: #64778c;
  --line: #e4e9ef;
  --bg: #f5f7fa;
  --card: #ffffff;
  --accent: #1f6feb;
  --accent-soft: #eaf1fe;
  --danger: #d1383c;
  --ok: #12855b;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 14.5px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 15px; margin: 0 0 16px; letter-spacing: -.01em; }
.muted { color: var(--ink-soft); }
.small { font-size: 12.5px; }
.strong { font-weight: 650; color: var(--ink); text-decoration: none; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------------------------- Topbar ----------------------------- */

.admin-top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 22px; height: 58px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.admin-top-left, .admin-top-right { display: flex; align-items: center; gap: 12px; }
.admin-top form { margin: 0; }
.logo-dot {
  width: 22px; height: 22px; border-radius: 7px; display: inline-block;
  background: conic-gradient(#E4002B, #FFC845, #00A6A6, #E4002B);
}
.logo-dot.big { width: 42px; height: 42px; border-radius: 13px; margin-bottom: 14px; }
.brand-pill {
  padding: 4px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 650;
  background: color-mix(in srgb, var(--bp) 12%, #fff);
  color: var(--bp); border: 1px solid color-mix(in srgb, var(--bp) 28%, transparent);
}

/* ------------------------------ Nav ------------------------------ */

.admin-body { display: flex; align-items: flex-start; }
.admin-nav {
  position: sticky; top: 58px;
  width: 220px; flex: 0 0 220px; padding: 18px 12px;
  display: flex; flex-direction: column; gap: 2px;
  border-right: 1px solid var(--line); background: var(--card);
  min-height: calc(100dvh - 58px);
}
.nav-item {
  padding: 9px 13px; border-radius: 9px; text-decoration: none;
  color: var(--ink-soft); font-weight: 600; font-size: 14px;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: #f1f4f8; color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }

.admin-main { flex: 1; padding: 26px clamp(18px, 3vw, 34px) 70px; max-width: 1180px; min-width: 0; }

@media (max-width: 860px) {
  .admin-body { flex-direction: column; }
  .admin-nav {
    position: static; width: 100%; flex: none; min-height: 0;
    flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .nav-item { white-space: nowrap; }
}

/* ----------------------------- Cartes ---------------------------- */

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-head p { margin: 0; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(15,30,46,.04);
}
.card > .table:last-child { margin-bottom: -20px; }

.grid-form { display: block; }
.form-actions {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  position: sticky; bottom: 0; padding: 14px 0;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* ----------------------------- Champs ---------------------------- */

label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 14px; color: var(--ink); }
label.inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.field-title { display: block; font-weight: 600; font-size: 13px; margin-bottom: 7px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input:not([type]), select, textarea {
  width: 100%; margin-top: 6px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
  font: inherit; font-size: 14px; color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,111,235,.14);
}
textarea { resize: vertical; }
input[type="file"] { padding: 7px; background: #fbfcfe; }
input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--accent); }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.row-4 { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 0 14px; align-items: end; }
.row-4 button { margin-bottom: 14px; }
@media (max-width: 780px) {
  .row-2, .row-3, .row-4 { grid-template-columns: 1fr; }
}

.color-field { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.color-field input[type="color"] {
  width: 46px; height: 38px; padding: 3px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; margin: 0;
}
.hexbox { margin: 0 !important; font-family: ui-monospace, Menlo, monospace; text-transform: uppercase; }

.logo-preview {
  margin: -6px 0 14px; padding: 14px; border: 1px dashed var(--line);
  border-radius: 10px; background: #fbfcfe; min-height: 66px;
  display: flex; align-items: center; justify-content: center;
}
.logo-preview img { max-height: 44px; max-width: 220px; object-fit: contain; }

.switch-label { margin-top: 26px; }

.filters { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; }
.filters label { margin-bottom: 0; min-width: 190px; }
.filters button { margin-bottom: 1px; }

/* ----------------------------- Tables ---------------------------- */

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-soft);
  padding: 0 12px 10px; border-bottom: 1px solid var(--line);
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }

.table-edit td { padding: 6px 6px; }
.table-edit input { margin-top: 0; }
.ico { text-align: center; font-size: 17px; }
.w-num { text-align: right; }

.row-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.pwd-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.pwd-form input { margin-top: 0; width: 190px; padding: 6px 10px; font-size: 13px; }
.row-actions .btn { padding: 6px 11px; font-size: 13px; white-space: nowrap; }
.table td.right { white-space: nowrap; }

.cell-link {
  font-weight: 650; color: var(--accent); text-decoration: none; font-size: 15px;
}
.cell-link:hover { text-decoration: underline; }

.cell-brand { display: flex; align-items: center; gap: 11px; }
.cell-brand img { height: 30px; max-width: 92px; object-fit: contain; }
.swatch { width: 30px; height: 30px; border-radius: 8px; display: inline-block; }

.proba { display: flex; align-items: center; gap: 8px; position: relative; white-space: nowrap; }
.proba-bar { height: 6px; border-radius: 99px; background: var(--accent); opacity: .28; min-width: 2px; flex: 0 0 auto; max-width: 46px; }
.proba b { font-variant-numeric: tabular-nums; font-size: 13px; }

.tag {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  background: #eef2f7; font-size: 12px; color: var(--ink-soft); margin: 1px 0;
}
.code { font-family: ui-monospace, Menlo, monospace; letter-spacing: .04em; font-size: 13px; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 650; background: #eef2f7; color: var(--ink-soft);
}
.badge-on { background: #e3f6ed; color: var(--ok); }
.badge-off { background: #feecec; color: var(--danger); }
.badge-super { background: #ede9fe; color: #6d3fd4; }

/* ----------------------------- Boutons --------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  font: inherit; font-size: 14px; font-weight: 650; cursor: pointer;
  text-decoration: none; transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1a5fd0; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: #f4f7fb; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #feecec; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-icon {
  border: 0; background: transparent; color: var(--ink-soft);
  cursor: pointer; font-size: 14px; padding: 6px 9px; border-radius: 7px;
}
.btn-icon:hover { background: #feecec; color: var(--danger); }

.admin-footer {
  margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-soft);
}

/* ------------------------------ Flash ---------------------------- */

.flash {
  padding: 11px 15px; border-radius: 10px; margin-bottom: 18px;
  background: #e3f6ed; color: var(--ok); font-weight: 600; font-size: 13.5px;
  border: 1px solid #bfe8d5;
}
.flash-error { background: #feecec; color: var(--danger); border-color: #f8cfd0; }
.flash-warn { background: #fff6e5; color: #8a5a00; border-color: #f5dfb0; }
.row-exhausted { background: #fffaf2; }
.row-exhausted .proba b { color: var(--ink-soft); }
.proba .badge { margin-left: 2px; padding: 2px 7px; font-size: 11px; }
.row-exhausted .proba-bar { display: none; }

/* ------------------------------ Login ---------------------------- */

.login-body {
  display: grid; place-items: center; min-height: 100dvh; padding: 20px;
  background: radial-gradient(1000px 500px at 50% -10%, #e8effa, var(--bg));
}
.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--line); border-radius: 18px; padding: 32px;
  box-shadow: 0 20px 50px -28px rgba(15,30,46,.4);
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p { margin: 0 0 20px; font-size: 13.5px; }
.login-card label { margin-bottom: 14px; }
