/* ============================================================
   Design tokens — sombre, sobre, SaaS B2B
   ============================================================ */
:root {
  /* Surfaces */
  --bg:            oklch(0.16 0.004 250);
  --bg-2:          oklch(0.185 0.004 250);
  --surface:       oklch(0.205 0.004 250);
  --surface-2:     oklch(0.235 0.004 250);
  --surface-hi:    oklch(0.265 0.005 250);

  /* Borders */
  --border:        oklch(0.275 0.005 250);
  --border-strong: oklch(0.345 0.006 250);
  --border-soft:   oklch(0.245 0.004 250);

  /* Text */
  --fg:            oklch(0.965 0.003 250);
  --fg-2:          oklch(0.78 0.005 250);
  --fg-3:          oklch(0.58 0.008 250);
  --fg-4:          oklch(0.45 0.008 250);

  /* Accent — vert tempéré pour le financier */
  --accent:        oklch(0.74 0.13 150);
  --accent-2:      oklch(0.62 0.14 150);
  --accent-soft:   oklch(0.32 0.05 150);
  --accent-fg:     oklch(0.14 0.02 150);

  /* Semantics */
  --pos:           oklch(0.78 0.14 150);
  --pos-bg:        oklch(0.30 0.06 150);
  --neg:           oklch(0.72 0.16 25);
  --neg-bg:        oklch(0.30 0.07 25);
  --warn:          oklch(0.82 0.13 75);
  --warn-bg:       oklch(0.32 0.06 75);
  --info:          oklch(0.74 0.11 240);
  --info-bg:       oklch(0.30 0.06 240);

  /* Radii */
  --r-1: 4px;
  --r-2: 6px;
  --r-3: 10px;
  --r-4: 14px;
  --r-5: 20px;

  /* Spacing density */
  --dens: 1;
  --pad-card: calc(20px * var(--dens));
  --gap: calc(16px * var(--dens));
  --row-h: calc(48px * var(--dens));

  /* Type */
  --font-sans: "Geist", "Söhne", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Sidebar */
  --sidebar-w: 240px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
  letter-spacing: -0.005em;
}
button { font-family: inherit; }

/* ============================================================
   Layout
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  min-height: 720px;
}
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.main {
  display: flex; flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  background: var(--bg);
  flex-shrink: 0;
}
.content {
  flex: 1;
  overflow: auto;
  padding: 24px 28px 56px;
}
.content-wide { max-width: 1280px; margin: 0 auto; }

/* ============================================================
   Sidebar
   ============================================================ */
.s-brand {
  padding: 16px 14px 14px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-soft);
}
.s-logo {
  width: 28px; height: 28px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 7px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
  font-family: var(--font-mono);
}
.s-brand-name {
  font-weight: 600; font-size: 13.5px;
  letter-spacing: -0.01em;
}
.s-brand-sub {
  font-size: 11px; color: var(--fg-3);
  font-family: var(--font-mono);
}
.s-nav { padding: 12px 8px; flex: 1; overflow: auto; }
.s-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-4);
  padding: 14px 10px 6px;
  font-weight: 500;
}
.s-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-2);
  color: var(--fg-2);
  cursor: pointer;
  font-size: 13px;
  width: 100%;
  background: none; border: none; text-align: left;
  position: relative;
}
.s-item:hover { background: var(--surface); color: var(--fg); }
.s-item.active {
  background: var(--surface);
  color: var(--fg);
}
.s-item .s-icon { width: 16px; height: 16px; opacity: 0.9; flex-shrink: 0; }
.s-item .s-count {
  margin-left: auto;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--fg-3);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 20px; text-align: center;
}
.s-item.active .s-count { background: var(--surface-hi); color: var(--fg); }
.s-foot {
  border: 0;
  border-top: 1px solid var(--border-soft);
  padding: 12px;
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.s-foot:hover { background: var(--surface); }
.s-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-hi);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
  color: var(--fg);
}
.s-foot-name { font-size: 12.5px; font-weight: 500; }
.s-foot-sub { font-size: 11px; color: var(--fg-3); font-family: var(--font-mono); }

/* ============================================================
   Topbar
   ============================================================ */
.crumbs {
  display: flex; align-items: center; gap: 8px;
  color: var(--fg-3);
  font-size: 12.5px;
}
.crumbs .sep { color: var(--fg-4); }
.crumbs .cur { color: var(--fg); }
.tb-spacer { flex: 1; }
.tb-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  padding: 6px 10px;
  width: 260px;
  color: var(--fg-3);
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
}
.tb-search:hover { background: var(--surface-2); color: var(--fg-2); }
.tb-search kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--fg-3);
}
.tb-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-2);
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-2);
  font-size: 12.5px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.tb-btn:hover { background: var(--surface-2); color: var(--fg); }
.tb-btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
  font-weight: 600;
}
.tb-btn-primary:hover { background: var(--accent-2); }

/* ============================================================
   Cards & primitives
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
}
.card-pad { padding: var(--pad-card); }
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em; }
.card-sub { font-size: 11.5px; color: var(--fg-3); font-family: var(--font-mono); }

.hstack { display: flex; align-items: center; gap: 12px; }
.vstack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.muted { color: var(--fg-3); }
.muted-2 { color: var(--fg-4); }

.h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.h3 { font-size: 13.5px; font-weight: 600; }
.tiny { font-size: 11px; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; }
.num-xl { font-family: var(--font-mono); font-size: 28px; font-weight: 500; letter-spacing: -0.02em; font-feature-settings: "tnum"; }
.num-lg { font-family: var(--font-mono); font-size: 20px; font-weight: 500; font-feature-settings: "tnum"; }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--fg-2);
  border: 1px solid var(--border);
  height: 20px;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--fg-3);
}
.badge.pos { color: var(--pos); background: color-mix(in oklab, var(--pos) 12%, transparent); border-color: color-mix(in oklab, var(--pos) 25%, transparent); }
.badge.pos::before { background: var(--pos); }
.badge.neg { color: var(--neg); background: color-mix(in oklab, var(--neg) 12%, transparent); border-color: color-mix(in oklab, var(--neg) 25%, transparent); }
.badge.neg::before { background: var(--neg); }
.badge.warn { color: var(--warn); background: color-mix(in oklab, var(--warn) 12%, transparent); border-color: color-mix(in oklab, var(--warn) 25%, transparent); }
.badge.warn::before { background: var(--warn); }
.badge.info { color: var(--info); background: color-mix(in oklab, var(--info) 12%, transparent); border-color: color-mix(in oklab, var(--info) 25%, transparent); }
.badge.info::before { background: var(--info); }
.badge.plain { background: transparent; }
.badge.plain::before { display: none; }

/* Avatar group */
.av {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 600;
  border: 2px solid var(--surface);
  flex-shrink: 0;
}
.av-Omar    { background: oklch(0.55 0.13 30);  color: oklch(0.97 0 0); }
.av-Ilyece  { background: oklch(0.55 0.13 240); color: oklch(0.97 0 0); }
.av-Youssef { background: oklch(0.55 0.13 150); color: oklch(0.97 0 0); }
.av-group { display: flex; }
.av-group .av + .av { margin-left: -6px; }

/* Button */
.btn {
  height: 32px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  color: var(--fg);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary {
  background: var(--accent); color: var(--accent-fg);
  border-color: transparent; font-weight: 600;
}
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn-ghost:hover { background: var(--surface); color: var(--fg); }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn-icon { padding: 0; width: 32px; justify-content: center; }

/* Tabs */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  background: none; border: none;
  color: var(--fg-3);
  padding: 10px 14px;
  font-size: 12.5px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
}
.tab.active { color: var(--fg); border-bottom-color: var(--fg); }
.tab:hover:not(.active) { color: var(--fg-2); }
.tab .count {
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-4);
}

/* Inputs (display only) */
.field {
  display: flex; flex-direction: column; gap: 6px;
}
.field-lbl { font-size: 11.5px; color: var(--fg-3); font-weight: 500; }
.input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  padding: 8px 10px;
  color: var(--fg);
  font-family: inherit;
  font-size: 12.5px;
  height: 34px;
}
.input.mono { font-family: var(--font-mono); }
.input-suffix {
  position: relative;
}
.input-suffix .input { padding-right: 36px; }
.input-suffix span {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 12px; color: var(--fg-3);
}

/* Table */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
.table th {
  text-align: left;
  font-weight: 500;
  color: var(--fg-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.table th:first-child { border-top-left-radius: var(--r-3); }
.table th:last-child { border-top-right-radius: var(--r-3); }
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--fg);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr.clickable:hover td { background: var(--surface-2); cursor: pointer; }
.table .num { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.table .right { text-align: right; }

/* Grid */
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-dash { grid-template-columns: 2fr 1fr; }

/* Stat card */
.stat-card { padding: 18px; }
.stat-lbl { font-size: 11.5px; color: var(--fg-3); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-val { font-family: var(--font-mono); font-size: 26px; font-weight: 500; letter-spacing: -0.02em; margin-top: 8px; font-feature-settings: "tnum"; }
.stat-delta { font-family: var(--font-mono); font-size: 11.5px; margin-top: 6px; display: inline-flex; gap: 4px; align-items: center; }
.stat-delta.pos { color: var(--pos); }
.stat-delta.neg { color: var(--neg); }

/* Vehicle card */
.veh {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  overflow: hidden;
  display: flex; flex-direction: column;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.veh:hover { border-color: var(--border-strong); }
.veh-img {
  height: 140px;
  position: relative;
  background: var(--surface-2);
  background-image: repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in oklab, var(--fg-4) 8%, transparent) 14px 15px);
  display: grid; place-items: center;
  border-bottom: 1px solid var(--border);
}
.veh-img-tag {
  position: absolute; bottom: 8px; left: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-3);
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
}
.veh-img-state {
  position: absolute; top: 10px; left: 10px;
}
.veh-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.veh-title { font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em; }
.veh-meta { font-size: 11.5px; color: var(--fg-3); font-family: var(--font-mono); display: flex; gap: 10px; }
.veh-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-2);
}
.veh-foot .num { font-family: var(--font-mono); font-size: 13px; }

/* Progress bar */
.prog {
  height: 6px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden;
  display: flex;
}
.prog-fill { background: var(--accent); height: 100%; }
.prog-seg { height: 100%; }

/* Chart base */
.chart-wrap { padding: 0 18px 18px; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--border-soft); stroke-width: 1; }
.chart-axis { fill: var(--fg-4); font-family: var(--font-mono); font-size: 10px; }
.chart-bar { fill: var(--accent); }
.chart-bar-2 { fill: var(--accent-soft); }
.chart-line { stroke: var(--accent); stroke-width: 1.5; fill: none; }
.chart-area { fill: color-mix(in oklab, var(--accent) 14%, transparent); }
.chart-dot { fill: var(--accent); }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 24px; padding: 4px 18px 18px; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.donut-lg-item { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.donut-sw { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* Timeline */
.tl { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 14px; position: relative; padding-bottom: 22px; }
.tl-item:not(:last-child)::before {
  content: ""; position: absolute;
  left: 9px; top: 22px; bottom: 0;
  width: 1px; background: var(--border);
}
.tl-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  flex-shrink: 0; margin-top: 2px;
  display: grid; place-items: center;
}
.tl-dot.done { background: var(--accent); border-color: var(--accent); }
.tl-dot.cur { border-color: var(--accent); background: var(--surface); }
.tl-dot.cur::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.tl-body { flex: 1; padding-top: 1px; }
.tl-title { font-size: 13px; font-weight: 500; }
.tl-meta { font-size: 11.5px; color: var(--fg-3); margin-top: 2px; font-family: var(--font-mono); }
.tl-detail { margin-top: 6px; color: var(--fg-2); font-size: 12.5px; }

/* Vote bars */
.vote-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.vote-row:last-child { border-bottom: none; }
.vote-name { width: 100px; display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.vote-bar-wrap { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; position: relative; }
.vote-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.vote-amt { width: 90px; text-align: right; font-family: var(--font-mono); font-size: 12.5px; }

/* Comment */
.comment {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.comment:last-child { border-bottom: none; }
.comment .av { width: 28px; height: 28px; font-size: 11px; border: none; }
.comment-body { flex: 1; }
.comment-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 2px; }
.comment-name { font-weight: 600; font-size: 12.5px; }
.comment-time { font-size: 11px; color: var(--fg-4); font-family: var(--font-mono); }
.comment-text { font-size: 12.5px; color: var(--fg-2); line-height: 1.55; }

/* Splits / ratio bar */
.ratio-bar {
  height: 10px; border-radius: 999px; overflow: hidden;
  display: flex; background: var(--surface-2);
}

/* Misc utilities */
.divider { height: 1px; background: var(--border-soft); margin: 16px 0; }
.kpi-row { display: flex; gap: 24px; padding: 14px 18px; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi-lbl { font-size: 11px; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
.kpi-val { font-family: var(--font-mono); font-size: 18px; font-weight: 500; font-feature-settings: "tnum"; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
