/* GG Board — design commun à tous les dashboards
   Layout : barre haute collante, grille de modules qui passe à 1 colonne sur téléphone */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eaeef4;
  --line: #d9dfe8;
  --fg: #101a2b;
  --muted: #5b6a80;
  --accent: #c7801c;
  --accent-ink: #ffffff;
  --gain: #11865a;
  --loss: #c83a3a;
  --gain-bg: #e2f4ec;
  --loss-bg: #fbe7e7;
  --shadow: 0 1px 2px rgba(16, 26, 43, .06), 0 4px 16px rgba(16, 26, 43, .05);
  --f-display: "Unbounded", "Trebuchet MS", system-ui, sans-serif;
  --f-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #071422; --surface: #0d1d30; --surface-2: #13263d; --line: #1f3550;
    --fg: #e8eef7; --muted: #8ea0b8; --accent: #f0a93b; --accent-ink: #1a1203;
    --gain: #34c48a; --loss: #f06565; --gain-bg: rgba(52,196,138,.12); --loss-bg: rgba(240,101,101,.12);
    --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #071422; --surface: #0d1d30; --surface-2: #13263d; --line: #1f3550;
  --fg: #e8eef7; --muted: #8ea0b8; --accent: #f0a93b; --accent-ink: #1a1203;
  --gain: #34c48a; --loss: #f06565; --gain-bg: rgba(52,196,138,.12); --loss-bg: rgba(240,101,101,.12);
  --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.5 var(--f-body);
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.gain { color: var(--gain); }
.loss { color: var(--loss); }

/* Barre haute */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.wrap {
  max-width: 1280px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.top .wrap { display: flex; align-items: center; gap: 10px; padding-block: 10px; min-height: 58px; }
.brand { font-family: var(--f-display); font-weight: 600; font-size: 17px; text-decoration: none; letter-spacing: -.02em; white-space: nowrap; }
.brand b { color: var(--accent); font-weight: 600; }
.crumb { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.spacer { flex: 1; }
.status { font-size: 12px; color: var(--muted); white-space: nowrap; }
@media (max-width: 560px) { .status { display: none; } }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 8px 12px; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 38px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--loss); }
.btn.icon { width: 38px; padding: 0; }
.btn svg { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Modules */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; min-width: 0; box-shadow: var(--shadow);
}
.panel-h { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.panel-h h2 { font-family: var(--f-display); font-size: 13px; font-weight: 500; letter-spacing: .02em; margin: 0; text-transform: uppercase; color: var(--muted); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 2px; margin-left: auto; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 7px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; font-family: var(--f-num); white-space: nowrap; }
.pill.gain { background: var(--gain-bg); }
.pill.loss { background: var(--loss-bg); }
.tag { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }

/* Formulaires & tiroir */
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 11px; min-height: 40px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }

.drawer-bg { position: fixed; inset: 0; background: rgba(4, 10, 20, .45); z-index: 40; }
.drawer {
  position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(460px, 100%);
  background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-right: env(safe-area-inset-right, 0px);
}
.drawer-h { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-h h3 { margin: 0; font-family: var(--f-display); font-size: 16px; font-weight: 500; flex: 1; }
.drawer-b { padding: 16px; overflow-y: auto; display: grid; gap: 14px; align-content: start; flex: 1; }
.drawer-f { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.sect { font-family: var(--f-display); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 0 -4px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  max-width: calc(100% - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty strong { display: block; color: var(--fg); font-size: 16px; margin-bottom: 4px; }
