/* Back-office WHMCS — feuille de style unique. Aucun style en ligne (CSP stricte). */
:root {
  --bg: #EEF1F3;
  --surface: #FFFFFF;
  --surface-2: #F4F6F7;
  --ink: #1B262E;
  --ink-2: #5A6872;
  --ink-3: #8B98A1;
  --line: #E1E6EA;
  --line-2: #C6CED4;
  --brand: #0F6478;
  --brand-deep: #0A4A59;
  --brand-soft: #DCEDF0;
  --brand-light: #8CC3CD;
  --side: #10262D;
  --side-ink: #C9D9DD;
  --side-muted: #6F8A91;
  --side-accent: #5CC0CC;
  --good: #1D7A4A;
  --good-soft: #DFF2E6;
  --warn: #9C5A06;
  --warn-soft: #FBEFD8;
  --crit: #B22A20;
  --crit-soft: #FBE6E3;
  --info: #0F6478;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14px/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
p { margin: 0 0 0.75em; }
table { border-collapse: collapse; width: 100%; }
button, input { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* ── Boutons et champs ─────────────────────────────────────────────── */
.btn {
  display: inline-block; padding: 10px 16px; border-radius: 6px; border: 1px solid transparent;
  cursor: pointer; font-weight: 600; line-height: 1.3; background: var(--surface-2);
}
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--surface); color: var(--ink);
}
.input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 500; margin-bottom: 6px; }

.alert { padding: 10px 12px; border-radius: 6px; margin-bottom: 16px; }
.alert-error { background: var(--crit-soft); color: var(--crit); }
.alert-info { background: var(--brand-soft); color: var(--brand-deep); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-detail { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }

/* ── Page de connexion ─────────────────────────────────────────────── */
.body-auth { min-height: 100vh; }
.login { display: grid; grid-template-columns: minmax(300px, 5fr) 7fr; min-height: 100vh; }
.login-brand {
  background: var(--side); color: var(--side-ink); padding: 48px 44px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.login-brand .brand { font-size: 30px; font-weight: 600; color: #fff; letter-spacing: -0.02em; display: flex; align-items: center; gap: 12px; }
.login-brand .brand::before, .side-brand::before {
  content: ""; display: inline-block; width: 9px; height: 26px; border-radius: 2px; background: var(--side-accent); flex: none;
}
.login-brand p { max-width: 34ch; font-size: 16px; line-height: 1.55; color: var(--side-ink); }
.login-brand .login-mode { color: var(--side-muted); font-size: 14px; margin: 0; }
.login-pane { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 48px 24px; gap: 32px; }
.login-form { width: 100%; max-width: 380px; }
.login-form h1 { font-size: 24px; margin-bottom: 22px; letter-spacing: -0.02em; }
.login-help { color: var(--ink-2); font-size: 13px; margin: 16px 0 0; }
.login-foot { color: var(--ink-3); font-size: 12px; }

/* ── Pages d'erreur ─────────────────────────────────────────────────── */
.error-page { max-width: 640px; margin: 12vh auto; padding: 0 24px; }
.error-page h1 { font-size: 24px; margin-bottom: 12px; }
.trace { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px; overflow: auto; font: 12px/1.5 var(--mono); }

/* ── Structure de l'application ─────────────────────────────────────── */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-ink); padding: 22px 16px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 26px;
}
.side-brand { font-size: 17px; font-weight: 600; color: #fff; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.side-brand:hover { text-decoration: none; }
.side-brand::before { height: 22px; width: 8px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-radius: 6px; color: var(--side-ink);
}
.side nav a:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.side nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.1); color: #fff; font-weight: 600; }
.side nav a.soon { color: var(--side-muted); cursor: default; }
.side nav a.soon:hover { background: none; }
.side nav a.soon small { font-size: 11px; color: var(--side-muted); opacity: 0.8; }
.side-user { margin-top: auto; font-size: 13px; border-top: 1px solid rgba(255, 255, 255, 0.1); padding: 16px 8px 0; }
.side-user-name { color: #fff; font-weight: 600; }
.side-user-sub { color: var(--side-muted); margin-bottom: 10px; overflow-wrap: anywhere; }
.logout .btn-link { color: var(--side-ink); font-size: 13px; }

.main { padding: 28px 36px 56px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; letter-spacing: -0.02em; }
.page-head .date { color: var(--ink-2); margin-top: 2px; }
.page-source { color: var(--ink-3); font-size: 13px; }

/* ── Bandeau « à traiter » ─────────────────────────────────────────── */
.ledger {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 18px; overflow: hidden;
}
.ledger > div { padding: 18px 22px 16px; border-left: 1px solid var(--line); min-width: 0; }
.ledger > div:first-child { border-left: 0; }
.ledger .n { font-size: 36px; font-weight: 500; letter-spacing: -0.03em; line-height: 1.05; }
.ledger .n.crit { color: var(--crit); }
.ledger .n.warn { color: var(--warn); }
.ledger .n.info { color: var(--brand); }
.ledger .n.zero { color: var(--ink-3); }
.ledger .l { font-weight: 600; margin-top: 8px; }
.ledger .s { color: var(--ink-2); font-size: 13px; min-height: 1.5em; }

/* ── Panneaux ──────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
.grid-2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px 16px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 15px; }
.panel-head .hint { color: var(--ink-2); font-size: 13px; }
.empty { color: var(--ink-2); padding: 8px 0 4px; }

.figures { margin: 0; display: grid; gap: 12px; }
.figures div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.figures div:last-child { border-bottom: 0; padding-bottom: 0; }
.figures dt { color: var(--ink-2); }
.figures dd { margin: 0; font-size: 20px; font-weight: 500; letter-spacing: -0.02em; text-align: right; }
.figures dd small { display: block; color: var(--ink-3); font-size: 12px; font-weight: 400; letter-spacing: 0; }

/* ── Tableaux ──────────────────────────────────────────────────────── */
.tbl th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12px; padding: 0 10px 8px 0; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl .muted { color: var(--ink-2); font-size: 13px; }
.tbl.log td:nth-child(2) { overflow-wrap: anywhere; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.badge.crit { background: var(--crit-soft); color: var(--crit); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.good { background: var(--good-soft); color: var(--good); }

/* ── Graphique ─────────────────────────────────────────────────────── */
.chart { margin: 0; }
.chart svg { width: 100%; height: 220px; display: block; overflow: visible; }
.chart figcaption { color: var(--ink-3); font-size: 12px; margin-top: 8px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--line-2); stroke-width: 1; }
.chart .axis { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--brand); }
.chart .bar.cur { fill: var(--brand-light); }
.chart .bar.nil { fill: var(--line-2); }
.chart .hit { fill: transparent; }
.chart .col:hover .bar { fill: var(--brand-deep); }
.chart .col:hover .bar.cur { fill: var(--brand); }
.table-view { margin-top: 10px; }
.table-view summary { cursor: pointer; color: var(--brand); font-size: 13px; }
.table-view table { margin-top: 8px; max-width: 320px; }
.tip {
  position: fixed; z-index: 10; pointer-events: none; background: var(--ink); color: #fff;
  padding: 6px 10px; border-radius: 6px; font-size: 12px; line-height: 1.4; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}
.tip[hidden] { display: none; }
.tip strong { font-weight: 600; }

/* ── Adaptation ────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .ledger { grid-template-columns: 1fr 1fr; }
  .ledger > div:nth-child(3) { border-left: 0; }
  .ledger > div:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .grid-2, .grid-2.even { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; }
  .side nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .side nav a.soon { display: none; }
  .side-user { margin-top: 0; border-top: 0; padding: 0; margin-left: auto; text-align: right; }
  .side-user-sub { display: none; }
  .main { padding: 20px 16px 40px; }
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 28px 24px; gap: 16px; }
  .login-brand .brand { font-size: 22px; }
  .login-brand p { font-size: 14px; }
  .login-pane { padding: 32px 20px; justify-content: flex-start; }
  .ledger .n { font-size: 30px; }
}
@media (max-width: 520px) {
  .ledger { grid-template-columns: 1fr; }
  .ledger > div { border-left: 0; border-top: 1px solid var(--line); }
  .ledger > div:first-child { border-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ── Pages de liste et fiches ──────────────────────────────────────── */
.crumb { margin: 0 0 6px; font-size: 13px; }
.crumb a { color: var(--ink-2); }
.head-status { align-self: center; }
.badge.big { font-size: 13px; padding: 4px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-size: 13px;
}
.chip span { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chip:hover { text-decoration: none; border-color: var(--brand); color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.on span { color: rgba(255, 255, 255, 0.75); }
.tbl tr.ended td { color: var(--ink-3); }
.tbl tr.ended td a { color: var(--ink-2); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 14px; margin-top: 4px; border-top: 1px solid var(--line); font-size: 13px; }
.facts { margin: 0; display: grid; gap: 0; }
.facts div { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts dd .muted { color: var(--ink-3); font-size: 13px; }
.sub { font-size: 14px; margin: 16px 0 8px; }
.usage { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.usage-label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.meter { width: 100%; height: 6px; display: block; }
.meter-bg { fill: var(--line); }
.meter-fill { fill: var(--brand); }
.meter.warn .meter-fill { fill: var(--warn); }
.meter.crit .meter-fill { fill: var(--crit); }
.panel.quiet { background: transparent; border-style: dashed; }
.prose { max-width: 72ch; color: var(--ink-2); margin: 0; }
@media (max-width: 820px) {
  .usage { grid-template-columns: minmax(0, 1fr); }
  .facts div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .tbl.services th:nth-child(4), .tbl.services td:nth-child(4) { display: none; }
}

/* ── Menu : sous-entrées et compteur ───────────────────────────────── */
.side nav a .count { background: var(--side-accent); color: var(--side); font-size: 11px; font-weight: 700; padding: 0 7px; border-radius: 999px; }
.side .subnav { display: flex; flex-direction: column; gap: 1px; margin: 0 0 4px 12px; border-left: 1px solid rgba(255, 255, 255, 0.12); padding-left: 6px; }
.side .subnav a { padding: 5px 8px; font-size: 13px; color: var(--side-muted); }
.side .subnav a small { color: var(--side-muted); opacity: 0.8; }
.side .subnav a[aria-current="page"] { background: rgba(255, 255, 255, 0.1); color: #fff; font-weight: 600; }
.ledger .l a { color: inherit; }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
form.inline { display: inline; }
.grid-2.tight { margin-bottom: 0; gap: 0 18px; }
.help { color: var(--ink-3); font-size: 12px; margin-top: 6px; }
textarea.input { resize: vertical; min-height: 120px; line-height: 1.5; }
select.input { appearance: auto; }
.form-panel { max-width: 760px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.tbl a.unread { font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); vertical-align: middle; margin-left: 4px; }

/* ── Fil d'une demande ─────────────────────────────────────────────── */
.thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.msg { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; max-width: 860px; }
.msg.staff { border-left: 3px solid var(--brand); background: #FBFDFD; }
.msg-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; }
.msg-author { font-weight: 600; }
.msg-head time { margin-left: auto; }
.msg-body { overflow-wrap: anywhere; }
.msg-body p { margin: 0 0 0.7em; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body ul, .msg-body ol { margin: 0 0 0.7em; padding-left: 22px; }
.msg-body blockquote { margin: 0 0 0.7em; padding: 4px 12px; border-left: 3px solid var(--line-2); color: var(--ink-2); }
.msg-body code { font-size: 0.92em; }
.msg-files { margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.msg-files .file { color: var(--ink); background: var(--surface-2); padding: 1px 8px; border-radius: 4px; }
.panel.reply { max-width: 860px; }

/* ── Facture ───────────────────────────────────────────────────────── */
.invoice { max-width: 900px; padding: 24px 28px; }
.invoice-parties { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 24px; margin-bottom: 22px; }
.party-title { font-weight: 600; margin-bottom: 4px; }
.invoice-meta div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 5px 0; }
.invoice-meta div:last-child { border-bottom: 0; }
.tbl.lines td { padding-top: 11px; padding-bottom: 11px; }
.totals { margin: 12px 0 0 auto; max-width: 320px; display: grid; gap: 0; }
.totals div { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.totals div:last-child { border-bottom: 0; }
.totals dt { color: var(--ink-2); }
.totals dd { margin: 0; }
.totals .total dt, .totals .total dd { font-weight: 600; color: var(--ink); font-size: 16px; }
@media (max-width: 820px) {
  .invoice-parties { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .invoice { padding: 18px; }
}

/* ── Impression (facture) ──────────────────────────────────────────── */
@media print {
  body { background: #fff; font-size: 12px; }
  .side, .no-print, .tip, .alert, .head-actions .btn { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .panel, .msg { border-color: #ccc; box-shadow: none; break-inside: avoid; }
  .invoice { max-width: none; padding: 0; border: 0; }
  a { color: inherit; text-decoration: none; }
  .badge { border: 1px solid #999; background: none !important; color: #000 !important; }
}

/* ── Accès à l'éditeur de site ─────────────────────────────────────── */
.editor-card { border-left: 4px solid var(--brand); }
.editor-card .prose { margin-bottom: 14px; color: var(--ink); }
.mini-link { display: inline-block; font-size: 13px; margin-top: 2px; }
