/* Worksheet — feuille de style (sans CDN) */
:root {
  --navy: #0b3d66;
  --navy-dark: #072a47;
  --accent: #f28c28;
  --accent-dark: #d97a1a;
  --bg: #f3f5f8;
  --card: #ffffff;
  --border: #e2e7ee;
  --text: #1f2933;
  --muted: #6b7a8c;
  --green: #1a9e5c;
  --green-bg: #e6f6ee;
  --orange: #e08a00;
  --orange-bg: #fff3df;
  --red: #d64545;
  --red-bg: #fde8e8;
  --blue: #2f6fd6;
  --blue-bg: #e8f0fc;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 16px; }
h3 { font-size: 14px; color: var(--navy); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---- Barre supérieure ---- */
.topbar {
  background: var(--navy); color: #fff; display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 62px; position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.brand-logo { height: 36px; background: #fff; border-radius: 6px; padding: 3px 6px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; opacity: .75; }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a {
  color: #dbe7f3; padding: 8px 14px; border-radius: 8px; font-weight: 500; white-space: nowrap;
}
.mainnav a:hover { background: rgba(255,255,255,.1); text-decoration: none; color: #fff; }
.mainnav a.active { background: var(--accent); color: #fff; }
.userbox { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.userbox .user { opacity: .85; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snapshot { background: rgba(255,255,255,.12); padding: 5px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.snapshot.warn { background: var(--red); }

.page { flex: 1; width: 100%; max-width: 1800px; margin: 0 auto; padding: 20px 24px 40px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 14px; border-top: 1px solid var(--border); }

/* ---- Boutons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer;
  font: inherit; font-weight: 500; line-height: 1.1; transition: background .15s;
}
.btn:hover { background: #f6f8fb; text-decoration: none; }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-dark); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- Barre de filtres ---- */
.filterbar {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 18px;
  display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: flex-end;
}
.filterbar .field { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.filterbar label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.filterbar select, .filterbar input[type=date], .filterbar input[type=search] {
  font: inherit; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: #fff; min-width: 130px;
}
.filterbar .check { display: flex; align-items: center; gap: 6px; padding-bottom: 8px; font-size: 13px; }
.filterbar .spacer { flex: 1; }
.filterbar .actions { display: flex; gap: 8px; align-items: center; }
.filter-summary { font-size: 12px; color: var(--muted); margin: -8px 0 14px 4px; }

/* ---- KPIs ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; position: relative; overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--navy); }
.kpi.accent::before { background: var(--accent); }
.kpi.green::before { background: var(--green); }
.kpi.red::before { background: var(--red); }
.kpi.orange::before { background: var(--orange); }
.kpi.blue::before { background: var(--blue); }
.kpi .label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; color: var(--navy); }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---- Cartes ---- */
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-23 { grid-template-columns: 2fr 1fr; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head .hint { font-size: 12px; color: var(--muted); }
.chart { min-height: 280px; }
.chart-sm { min-height: 240px; }

/* ---- Tableaux ---- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.tbl th {
  background: #f7f9fc; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .03em; position: sticky; top: 0; user-select: none;
}
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--navy); }
.tbl th.sorted-asc::after { content: " ▲"; font-size: 9px; }
.tbl th.sorted-desc::after { content: " ▼"; font-size: 9px; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody tr:hover { background: #f4f7fb; }
.tbl tr.clickable { cursor: pointer; }
.tbl tfoot td { font-weight: 700; background: #f7f9fc; }
.tbl .empty { text-align: center; color: var(--muted); padding: 24px; }
.bar { display: inline-block; height: 8px; border-radius: 4px; background: var(--navy); vertical-align: middle; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.orange { background: var(--orange-bg); color: var(--orange); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.blue { background: var(--blue-bg); color: var(--blue); }
.pill.grey { background: #eef1f5; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding-top: 10px; font-size: 13px; }
.pager select { font: inherit; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--border); }

/* ---- Menu export ---- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(16,24,40,.16); min-width: 320px; padding: 8px; z-index: 40;
}
.dropdown-menu .group { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 8px 10px 4px; }
.dropdown-menu .note { font-size: 11px; color: var(--orange); padding: 0 10px 4px; }
.dropdown-menu a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.dropdown-menu a:hover { background: #f4f7fb; text-decoration: none; }
.dropdown-menu a.disabled { opacity: .45; pointer-events: none; }

/* ---- Modale ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(7,42,71,.55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: min(1100px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 16px 20px; overflow: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs button { font: inherit; background: none; border: none; padding: 8px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; }
.tabs button.active { color: var(--navy); border-bottom-color: var(--accent); }
.close { font-size: 22px; background: none; border: none; cursor: pointer; color: var(--muted); }

/* ---- Paramètres : double liste ---- */
.dual { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: stretch; }
.dual .list { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.dual .list header { padding: 8px 12px; background: #f7f9fc; font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; }
.dual .list input { border: none; border-bottom: 1px solid var(--border); padding: 8px 12px; font: inherit; }
.dual .list ul { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; }
.dual .list li { padding: 7px 12px; cursor: pointer; border-bottom: 1px solid #f0f2f5; font-size: 13px; }
.dual .list li:hover { background: var(--blue-bg); }
.dual .list li.selected { background: var(--accent); color: #fff; }
.dual .arrows { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.info-list { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; font-size: 13px; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; }
code, pre { font-family: Consolas, "JetBrains Mono", monospace; font-size: 12.5px; }
pre { background: #0f1e2e; color: #dbe7f3; padding: 12px 14px; border-radius: 8px; overflow-x: auto; }

/* ---- Divers ---- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff;
  padding: 10px 18px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 200; font-size: 13px;
}
.toast.error { background: var(--red); }
.loading { opacity: .5; pointer-events: none; }
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert.info { background: var(--blue-bg); color: var(--navy); }
.alert.warn { background: var(--orange-bg); color: #8a5600; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend .pill { font-weight: 500; }

/* ---- Connexion ---- */
.login-body { background: linear-gradient(135deg, var(--navy) 0%, #144f80 60%, var(--accent) 140%); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { background: #fff; border-radius: 16px; padding: 36px 40px; width: min(440px, 100%); text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.login-logo { height: 60px; margin-bottom: 10px; }
.login-box h1 { font-size: 22px; color: var(--navy); margin-bottom: 4px; }
.google-btn {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 22px; padding: 11px 20px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff; color: var(--text); font-weight: 600; box-shadow: var(--shadow);
}
.google-btn:hover { background: #f6f8fb; text-decoration: none; }
.error { background: var(--red-bg); color: var(--red); padding: 10px; border-radius: 8px; margin-top: 14px; font-size: 13px; }

@media (max-width: 1100px) {
  .grid-2, .grid-3, .grid-23 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  .mainnav { order: 3; width: 100%; overflow-x: auto; }
  .brand { min-width: 0; }
  .page { padding: 16px; }
  .dual { grid-template-columns: 1fr; }
  .dual .arrows { flex-direction: row; justify-content: center; }
}
@media print {
  .topbar, .filterbar, .foot, .btn, .pager { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; }
}
