/* Console AMIÀ v2 — thème SOMBRE, feuille autonome (pas de framework).
   Mise en page : barre latérale gauche (même esprit que l'admin partenaire). */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --blue: #3b82f6; --blue-dark: #2563eb;
  --bg: #0f172a;          /* fond de page */
  --panel: #111c33;       /* barre latérale */
  --card: #1e293b;        /* cartes */
  --card2: #24324a;       /* survols / éléments internes */
  --text: #e5e7eb; --muted: #94a3b8; --border: #2c3a52;
  --green: #34d399; --red: #f87171; --amber: #fbbf24; --violet: #a78bfa;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── layout: sidebar + main ── */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { padding: 18px 16px 14px; font-weight: 800; letter-spacing: 2px; font-size: 15px; color: #fff; border-bottom: 1px solid var(--border); }
.sidebar .brand .env { font-size: 10px; vertical-align: middle; margin-left: 8px; background: #dc2626; color: #fff; padding: 2px 7px; border-radius: 999px; font-weight: 700; letter-spacing: 0; }
.sidebar nav { flex: 1; padding: 10px 8px; }
.sidebar .group { margin-bottom: 14px; }
.sidebar .group-label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: #64748b; padding: 6px 10px 4px; font-weight: 700; }
.sidebar nav a { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; color: #cbd5e1; font-weight: 500; font-size: 13.5px; }
.sidebar nav a:hover { background: var(--card2); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: rgba(59, 130, 246, .18); color: #93c5fd; font-weight: 600; }
.sidebar nav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar .foot { border-top: 1px solid var(--border); padding: 12px 14px; font-size: 12px; color: var(--muted); }
.sidebar .foot button { background: none; border: none; color: var(--blue); cursor: pointer; font-size: 12px; padding: 0; margin-top: 4px; }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; max-width: 1160px; }
h1 { font-size: 20px; margin-bottom: 4px; color: #f1f5f9; }
.sub { color: var(--muted); margin-bottom: 20px; font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.card h2 { font-size: 15px; margin-bottom: 12px; color: #f1f5f9; }
.card h3 { font-size: 13px; margin-bottom: 8px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid rgba(148, 163, 184, .12); vertical-align: middle; }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover { background: var(--card2); }

.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.chip.STAGING { background: rgba(59, 130, 246, .2); color: #93c5fd; }
.chip.PRODUCTION { background: rgba(52, 211, 153, .18); color: #6ee7b7; }
.chip.TEMP { background: rgba(251, 191, 36, .16); color: #fcd34d; }
.chip.active { background: rgba(52, 211, 153, .18); color: #6ee7b7; }
.chip.disabled { background: rgba(248, 113, 113, .18); color: #fca5a5; }
.chip.draft { background: rgba(148, 163, 184, .18); color: #cbd5e1; }
.chip.server { background: rgba(167, 139, 250, .18); color: #c4b5fd; }
.chip.ok { background: rgba(52, 211, 153, .18); color: #6ee7b7; }
.chip.ko { background: rgba(248, 113, 113, .18); color: #fca5a5; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 999px; margin-right: 4px; vertical-align: middle; }
.dot.up { background: var(--green); } .dot.down { background: var(--red); } .dot.na { background: #475569; }

.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--blue); color: #fff; border: none; border-radius: 8px; padding: 8px 15px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--blue-dark); }
.btn.secondary { background: var(--card2); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #2d3d59; }
.btn.danger { background: rgba(248, 113, 113, .12); color: #fca5a5; border: 1px solid rgba(248, 113, 113, .4); }
.btn.danger:hover { background: rgba(248, 113, 113, .22); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: default; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } .sidebar { width: 190px; } .main { padding: 18px; } }
label { display: block; font-size: 12px; font-weight: 600; color: #cbd5e1; margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; background: #0f1a30; color: var(--text); }
input::placeholder, textarea::placeholder { color: #64748b; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(59, 130, 246, .35); border-color: var(--blue); }
.field { margin-bottom: 12px; }
.hint { font-size: 11px; color: var(--muted); margin-top: 3px; }

.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { font-weight: 500; word-break: break-all; }

.steps { list-style: none; }
.steps li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed rgba(148, 163, 184, .18); font-size: 13px; }
.steps .ok { color: var(--green); font-weight: 700; }
.steps .ko { color: var(--red); font-weight: 700; }
.steps .detail { color: var(--muted); }

.msg { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.msg.ok { background: rgba(52, 211, 153, .14); color: #6ee7b7; border: 1px solid rgba(52, 211, 153, .3); }
.msg.err { background: rgba(248, 113, 113, .12); color: #fca5a5; border: 1px solid rgba(248, 113, 113, .3); }

.login-box { max-width: 380px; margin: 12vh auto; }
.login-box .brand { text-align: center; font-size: 22px; font-weight: 800; letter-spacing: 3px; margin-bottom: 18px; color: #f1f5f9; }

.danger-zone { border: 1px solid rgba(248, 113, 113, .35); border-radius: 12px; padding: 18px; background: rgba(248, 113, 113, .06); }
.danger-zone h2 { color: #fca5a5; font-size: 14px; margin-bottom: 8px; }

.toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.toggle button { border: none; background: var(--card); padding: 7px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted); }
.toggle button.on { background: var(--blue); color: #fff; }

/* ── dashboard tiles (partner overview: stats / facturation / contrat) ── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 14px; margin: 16px 0; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; display: block; color: inherit; }
a.tile:hover { border-color: var(--blue); background: var(--card2); text-decoration: none; }
.tile .tlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.tile .tlabel svg { width: 14px; height: 14px; }
.tile .tmain { font-size: 22px; font-weight: 700; color: #f1f5f9; line-height: 1.2; }
.tile .tsub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile .trow { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.tile .trow + .trow { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(148, 163, 184, .14); }
.tile .tval { font-size: 17px; font-weight: 700; color: #f1f5f9; white-space: nowrap; }
.tile .tkey { font-size: 12px; color: var(--muted); }

/* invoice / sale billing statuses */
.chip.NONE { background: rgba(148, 163, 184, .18); color: #cbd5e1; }
.chip.UNEARNED { background: rgba(251, 191, 36, .16); color: #fcd34d; }
.chip.SHARE_INVOICED { background: rgba(59, 130, 246, .2); color: #93c5fd; }
.chip.SHARE_PAID { background: rgba(52, 211, 153, .18); color: #6ee7b7; }
.chip.CANCELLED { background: rgba(248, 113, 113, .18); color: #fca5a5; }
.chip.sent { background: rgba(59, 130, 246, .2); color: #93c5fd; }
.chip.paid { background: rgba(52, 211, 153, .18); color: #6ee7b7; }
.chip.cancelled { background: rgba(248, 113, 113, .18); color: #fca5a5; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin-top: 6px; }
.bars .b { flex: 1; background: linear-gradient(180deg, #3b82f6, #1d4ed8); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars-x { display: flex; gap: 4px; margin-top: 4px; }
.bars-x span { flex: 1; text-align: center; font-size: 9.5px; color: var(--muted); }

/* ── modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 18, .72); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 14px; max-width: 560px; width: 100%; box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 15px; color: #f1f5f9; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: #fff; }
.modal-body { padding: 18px 20px 20px; font-size: 13.5px; }

/* nested "included sales" table under a revenue-share invoice */
tr.sublines > td { background: rgba(15, 26, 48, .45); }
tr.sublines table th { font-size: 10px; padding: 6px 8px; }
tr.sublines table td { padding: 6px 8px; font-size: 12px; }

/* inline "Comment faire ?" style link (opens the standalone help page) */
.link-help { font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; }
.link-help svg { width: 12px; height: 12px; }

.group-head { font-size: 13px; font-weight: 700; color: #e2e8f0; margin: 18px 0 6px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
