/* ARKHEE — Console web (desktop-first).
   Reprend intégralement les tokens du design system (tokens.css) : aucune
   couleur en dur ici. Densité assumée : c'est l'outil de travail, pas l'app. */

* { box-sizing: border-box; }
html, body { height: 100%; }
html { background: var(--bg-deep); }   /* sinon blanc sous les pages plus hautes que l'écran */
body {
  margin: 0;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.error { color: var(--danger); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ── Connexion ───────────────────────────────────────────────────────── */
.gate { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.gate-card {
  width: min(380px, 100%); background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow-lg);
}
.gate-logo { width: 52px; height: 52px; border-radius: 12px; }
.gate-card h1 { font-family: var(--font-display); font-size: 22px; margin: 14px 0 4px; }
.gate-card label { display: block; margin: 14px 0 0; font-size: 13px; color: var(--text-soft); }
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit;
  color: var(--text); background: var(--bg-elev2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
textarea { min-height: 110px; resize: vertical; }

/* ── Coque ───────────────────────────────────────────────────────────── */
.shell {
  display: grid; min-height: 100vh;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 58px 1fr;
  grid-template-areas: "side top" "side view";
}
.sidebar {
  grid-area: side; background: var(--bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand strong { display: block; letter-spacing: .12em; font-size: 15px; }
/* Bronze = la voix d'ARKHEE (même grammaire que l'app : cyan pour le système,
   bronze pour la marque, les repères éditoriaux et les moments de décision). */
.brand span { color: var(--gold); font-size: 11px; letter-spacing: .16em;
  text-transform: uppercase; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: var(--radius-sm); color: var(--text-soft); font-size: 13.5px;
}
#nav a span { width: 18px; text-align: center; color: var(--text-muted); }
#nav a:hover { background: var(--bg-elev); text-decoration: none; }
#nav a.active { background: var(--accent-dim); color: var(--text); }
#nav a.active span { color: var(--accent); }
#nav em {
  margin-left: auto; font-style: normal; font-size: 11px; font-weight: 600;
  background: var(--gold-dim); color: var(--gold-bright);
  border-radius: 999px; padding: 1px 7px;
}
#nav em:empty { display: none; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px;
  padding: 12px 8px 0; border-top: 1px solid var(--border-soft); }

.topbar {
  grid-area: top; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 22px; background: var(--bg);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.ws { display: flex; align-items: center; gap: 10px; }
.ws select { width: auto; min-width: 220px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.view { grid-area: view; padding: 22px 26px 60px; max-width: 1500px; }
.view h1 { font-family: var(--font-display); font-size: 24px; margin: 0 0 4px; }
.view h2 {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 700; letter-spacing: .15em;
  text-transform: uppercase; color: var(--gold); margin: 28px 0 12px;
}
.view h2::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--gold-dim), transparent);
}
.head { display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

/* ── Briques ─────────────────────────────────────────────────────────── */
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.card.pad0 { padding: 0; overflow: hidden; }
.kpi .label { color: var(--text-muted); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .1em; }
.kpi .value { font-family: var(--font-display); font-size: 25px;
  font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.bar { height: 7px; border-radius: 999px; background: var(--bg-elev2); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--grad-ring); }
.bar i.warn { background: linear-gradient(90deg, var(--warning), var(--danger)); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border-soft);
  vertical-align: middle; }
th { color: var(--text-muted); font-weight: 500; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; }
tbody tr:hover { background: var(--bg-elev2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px;
  border: 1px solid var(--border-strong); color: var(--text-soft); white-space: nowrap;
}
.pill.live { background: rgba(62, 207, 142, .13); border-color: var(--success); color: var(--success); }
.pill.off { background: var(--bg-elev2); }
.pill.warn { background: rgba(231, 181, 73, .13); border-color: var(--warning); color: var(--warning); }
.pill.bad { background: rgba(228, 88, 107, .13); border-color: var(--danger); color: var(--danger); }
.pill.gold { background: var(--gold-dim); border-color: var(--gold-deep); color: var(--gold-bright); }

.btn {
  font: inherit; font-size: 13px; padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-elev2);
  color: var(--text); cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--grad-ring); color: var(--ink); border: none; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.wide { width: 100%; margin-top: 18px; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.linkish { background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 0; font: inherit; text-align: left; }
.linkish:hover { color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0 14px; }
.filters select, .filters input { width: auto; margin: 0; }

.thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 8px;
  background: var(--bg-elev2); border: 1px solid var(--border-soft); }
.empty { color: var(--text-muted); padding: 26px; text-align: center; }
.spinner { color: var(--text-muted); padding: 26px; }

/* ── Modale & toasts ─────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3, 9, 15, .72);
  display: grid; place-items: center; padding: 24px; z-index: 40;
}
.modal {
  width: min(620px, 100%); max-height: 86vh; overflow: auto;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-lg);
}
.modal h3 { margin: 0 0 6px; font-size: 17px; font-family: var(--font-display);
  color: var(--gold-bright); }
.modal label { display: block; margin-top: 12px; font-size: 13px; color: var(--text-soft); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

#toast-root { position: fixed; right: 20px; bottom: 20px; display: flex;
  flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent); border-radius: var(--radius-sm);
  padding: 11px 15px; box-shadow: var(--shadow); max-width: 380px; font-size: 13px;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

/* ── Détails ─────────────────────────────────────────────────────────── */
.split { display: grid; gap: 16px; grid-template-columns: 2fr 1fr; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.note { border-left: 2px solid var(--gold-deep); padding: 2px 0 2px 12px;
  color: var(--text-soft); font-size: 13px; }
/* Décision : le bloc « ce qu'ARKHEE va faire » reprend le cuivre de l'app. */
.modal .note { background: var(--gold-dim); border-color: var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 8px 12px; }
.gate-card h1 { color: var(--gold-bright); }
#nav a.active { border-left: 2px solid var(--gold); }
.comment { border-bottom: 1px solid var(--border-soft); padding: 10px 0; font-size: 13px; }
.comment.sys { color: var(--text-muted); font-size: 12px; }
.tag { font-size: 11px; color: var(--text-muted); }

@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-areas: "top" "side" "view"; }
  .sidebar { position: static; height: auto; }
  #nav { flex-direction: row; overflow-x: auto; }
}

/* Marge : montant à perte */
.bad-text { color: var(--danger); }

/* Cases à cocher : à côté de leur texte, pas en champ pleine largeur */
input[type="checkbox"] { width: auto; margin: 0 8px 0 0; vertical-align: middle; }
label:has(> input[type="checkbox"]) { display: flex; align-items: center; margin: 10px 0; }

/* ── Rapport client (feuille claire, imprimable, aux couleurs de l'agence) ── */
.client-report {
  --brand: #b8935a;
  background: #fff; color: #1d1d1f; border-radius: 14px; padding: 36px 40px;
  max-width: 900px; margin: 18px 0; font-family: var(--font-body, system-ui), sans-serif;
}
.client-report .muted { color: #6e6e73; }
.cr-head { display: flex; gap: 20px; align-items: center; border-bottom: 3px solid var(--brand); padding-bottom: 18px; }
.cr-head img { max-height: 64px; max-width: 180px; object-fit: contain; }
.cr-kicker { color: var(--brand); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; margin: 0; font-weight: 600; }
.client-report h2 { color: #1d1d1f; font-size: 26px; margin: 4px 0; text-transform: none; letter-spacing: 0; }
.client-report h2::after { display: none; }
.cr-period { margin: 0; color: #6e6e73; }
.client-report h3 { color: var(--brand); font-size: 15px; margin: 26px 0 10px; text-transform: uppercase; letter-spacing: .06em; }
.cr-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.cr-kpi { border: 1px solid #e5e5ea; border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.cr-kpi > span:first-child { font-size: 12px; color: #6e6e73; }
.cr-kpi strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.cr-kpi .delta, .cr-kpi .muted { font-size: 12px; }
.delta.up { color: #1a7f37; } .delta.down { color: #c4314b; }
.cr-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 14px; }
.cr-table th { text-align: left; color: #6e6e73; font-weight: 500; border-bottom: 1px solid #e5e5ea; padding: 6px 8px; }
.cr-table td { border-bottom: 1px solid #f2f2f5; padding: 7px 8px; font-variant-numeric: tabular-nums; }
.cr-sub { font-weight: 600; margin: 14px 0 0; }
.cr-actions { padding-left: 18px; margin: 6px 0; } .cr-actions li { margin: 6px 0; }
.cr-foot { margin-top: 28px; padding-top: 12px; border-top: 1px solid #e5e5ea; font-size: 11px; color: #6e6e73; }
@media (max-width: 640px) { .client-report { padding: 20px 16px; } }
@media print {
  html, body { background: #fff !important; }
  .sidebar, .topbar, .no-print, #toast-root, #modal-root { display: none !important; }
  .shell, .view { display: block !important; padding: 0 !important; max-width: none !important; }
  .client-report { margin: 0; border-radius: 0; padding: 0; max-width: none; }
  .client-report section, .cr-table tr { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 12px 0; }
