/* GeekLab, gestion interne.
   Direction : outil de travail dense, profondeur par bordures (pas d'ombres sur les surfaces),
   une seule teinte d'accent tirée du vert du drapeau sénégalais, chiffres tabulaires partout. */

:root {
  --font: 'Hanken Grotesk', ui-sans-serif, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', monospace;

  --canvas: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #f8f9f6;
  --input: #f9faf8;
  --hover: rgba(20, 24, 22, 0.045);
  --line: rgba(20, 26, 22, 0.09);
  --line-2: rgba(20, 26, 22, 0.16);

  --ink: #171a18;
  --ink-2: #4b524d;
  --muted: #828a84;

  --accent: #0a7a48;
  --accent-ink: #ffffff;
  --accent-hover: #086a3e;
  --accent-weak: #e5f1ea;
  --accent-line: rgba(10, 122, 72, 0.28);

  --info: #2c5fb3;
  --warn: #b86e00;
  --danger: #c23a2e;
  --danger-weak: #fbeceb;
  --done: #5e6862;

  --r-sm: 5px;
  --r: 7px;
  --r-lg: 10px;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --sidebar: 236px;
}

[data-theme='dark'] {
  --canvas: #131514;
  --surface: #191c1a;
  --surface-2: #1d201e;
  --input: #151816;
  --hover: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.075);
  --line-2: rgba(255, 255, 255, 0.14);
  --ink: #e9ece9;
  --ink-2: #b2b9b4;
  --muted: #7c847f;
  --accent: #34b27a;
  --accent-ink: #08130d;
  --accent-hover: #44c189;
  --accent-weak: rgba(52, 178, 122, 0.13);
  --accent-line: rgba(52, 178, 122, 0.35);
  --info: #6f9be6;
  --warn: #e0a040;
  --danger: #ea6b5f;
  --danger-weak: rgba(234, 107, 95, 0.12);
  --done: #8d958f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* ---------- Connexion ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px 28px 26px; }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card .muted { font-size: 13.5px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.auth-btn { height: 38px; justify-content: center; width: 100%; font-size: 14px; }
.auth-btn:disabled { opacity: 0.6; cursor: progress; }
.auth-err { color: var(--danger); font-size: 13px; background: var(--danger-weak); border-radius: var(--r); padding: 8px 10px; margin: 0; }
.auth-foot { margin-top: 18px; font-size: 12px; color: var(--muted); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: var(--r); cursor: pointer; border: 0; background: transparent; width: 100%; text-align: left; }
.user-chip:hover { background: var(--hover); }
.user-chip .n { font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-chip .r { font-size: 11.5px; color: var(--muted); line-height: 1.2; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: auto; flex: none; }
.sync-dot.off { background: var(--danger); }
.sidebar-foot .menu-pop { top: auto; bottom: calc(100% + 6px); left: 0; right: auto; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.012em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { flex: none; display: block; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.nowrap { white-space: nowrap; }
.danger-text { color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Coque ---------- */
.app { display: block; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  padding: 14px 10px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--ink); color: var(--canvas);
  display: grid; place-items: center; font-family: var(--mono); font-size: 13px; font-weight: 600; letter-spacing: -0.04em;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.02em; line-height: 1.1; }
.brand-sub { font-size: 11.5px; color: var(--muted); line-height: 1.2; }
.nav-group { margin-top: 14px; }
.nav-label { font-size: 11.5px; color: var(--muted); padding: 0 10px 4px; font-weight: 500; }
.nav a {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: var(--r);
  color: var(--ink-2); font-weight: 500; font-size: 13.5px; border: 1px solid transparent;
}
.nav a .ic { color: var(--muted); }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a[aria-current='page'] { background: var(--surface); border-color: var(--line); color: var(--ink); }
.nav a[aria-current='page'] .ic { color: var(--accent); }
.nav .count { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav .count.alert { color: var(--danger); font-weight: 600; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5; height: 54px; display: flex; align-items: center; gap: 12px;
  padding: 0 28px; background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); min-width: 0; }
.crumbs a:hover { color: var(--ink); }
.crumbs .cur { color: var(--ink); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-btn {
  margin-left: auto; display: flex; align-items: center; gap: 8px; height: 32px; width: 280px; padding: 0 8px 0 10px;
  border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--r); color: var(--muted); cursor: pointer; font-size: 13px;
}
.search-btn:hover { border-color: var(--ink-2); }
kbd {
  font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--ink-2); margin-left: auto;
}

.page { padding: 26px 28px 64px; max-width: 1360px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; line-height: 1.2; }
.page-head .sub { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: background-color 120ms var(--ease), border-color 120ms var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-2); }
.btn:active { transform: translateY(0.5px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); background: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--hover); border-color: transparent; }
.btn-ghost.danger { color: var(--danger); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn-icon {
  width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: var(--r);
  border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer;
}
.btn-icon:hover { background: var(--hover); color: var(--ink); }

/* ---------- Segmented / onglets ---------- */
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); gap: 2px; }
.seg button {
  height: 26px; padding: 0 10px; border: 1px solid transparent; background: transparent; border-radius: 5px;
  font-size: 12.5px; font-weight: 500; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed='true'] { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.seg .n { color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs a { padding: 8px 0 10px; font-size: 13.5px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current='true'] { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------- Barre d'outils ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filter {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 1px solid var(--line-2);
  border-radius: var(--r); background: var(--surface); width: 240px; color: var(--muted);
}
.filter input { border: 0; outline: 0; background: transparent; width: 100%; height: 100%; font-size: 13px; color: var(--ink); }
.toolbar select, .select-inline {
  height: 32px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); padding: 0 8px; font-size: 13px;
}

/* ---------- Panneaux ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.panel-head h3 { font-size: 13.5px; }
.panel-head .meta { color: var(--muted); font-size: 12.5px; }
.panel-head .end { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.panel-body { padding: 16px; }
.panel-foot { border-top: 1px solid var(--line); padding: 10px 16px; font-size: 12.5px; color: var(--muted); }
.link { color: var(--accent); font-weight: 500; font-size: 12.5px; }
.link:hover { text-decoration: underline; }

.grid { display: grid; gap: 16px; align-items: start; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.g-side { grid-template-columns: minmax(0, 1fr) 320px; }

/* ---------- Indicateurs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { padding: 14px 16px; border-left: 1px solid var(--line); }
.kpi:first-child { border-left: 0; }
.kpi .lbl { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi .val { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .val small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.delta.up { color: var(--accent); }
.delta.down { color: var(--danger); }

.hero { display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.hero-main { padding: 20px; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.hero-main .lbl { color: var(--ink-2); font-weight: 500; font-size: 13px; }
.hero-main .big { font-size: 38px; font-weight: 600; letter-spacing: -0.035em; line-height: 1.1; margin: 8px 0 6px; font-variant-numeric: tabular-nums; }
.hero-main .big small { font-size: 15px; color: var(--muted); font-weight: 500; letter-spacing: 0; margin-left: 4px; }
.hero-split { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 16px; border-top: 1px dashed var(--line-2); }
.hero-split .lbl { font-size: 12px; color: var(--muted); }
.hero-split .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.hero-chart { padding: 14px 16px 10px; min-width: 0; position: relative; }

/* ---------- Graphique ---------- */
.chart { width: 100%; height: 210px; display: block; overflow: visible; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .axis-t { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--accent); opacity: 0.9; }
.chart .bar.dim { fill: var(--accent); opacity: 0.35; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart g:hover .bar { opacity: 1; }
.chart .bar-label { fill: var(--ink); font-size: 11px; font-weight: 600; }
.tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--canvas); font-size: 12px; padding: 6px 9px;
  border-radius: 6px; white-space: nowrap; transform: translate(-50%, -100%); opacity: 0; transition: opacity 100ms; z-index: 3;
}
.tip.on { opacity: 1; }
.tip b { font-weight: 600; }

.hbar { display: grid; grid-template-columns: 150px minmax(0, 1fr) 84px; align-items: center; gap: 12px; padding: 7px 0; }
.hbar .track { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; position: relative; overflow: hidden; }
.hbar .fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 0 3px 3px 0; }
.hbar .fill.over { background: var(--warn); }
.hbar .cap { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: 0.55; }

/* ---------- Tableaux ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); height: 36px; padding: 0 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2);
}
.tbl th:first-child { border-top-left-radius: var(--r-lg); }
.tbl th:last-child { border-top-right-radius: var(--r-lg); }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl td { height: 46px; padding: 6px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--surface-2); }
.tbl .t-title { font-weight: 500; }
.tbl .t-sub { font-size: 12.5px; color: var(--muted); }
.tbl tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); }
.tbl.compact td { height: 38px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 48px; }
.list li:last-child { border-bottom: 0; }
.list li.click { cursor: pointer; }
.list li.click:hover { background: var(--surface-2); }
.list .l-main { min-width: 0; flex: 1; }
.list .l-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .l-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-chip { width: 40px; text-align: center; flex: none; border: 1px solid var(--line); border-radius: 6px; line-height: 1.1; padding: 4px 0; background: var(--surface-2); }
.date-chip b { display: block; font-size: 14px; }
.date-chip span { font-size: 10.5px; color: var(--muted); }
.date-chip.late { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.date-chip.late b { color: var(--danger); }

/* ---------- Étiquettes ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 500; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap;
}
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex: none; }
.tag.t-accent::before { background: var(--accent); }
.tag.t-info::before { background: var(--info); }
.tag.t-warn::before { background: var(--warn); }
.tag.t-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: var(--danger-weak); }
.tag.t-danger::before { background: var(--danger); }
.tag.t-done::before { background: transparent; border: 1.5px solid var(--done); width: 5px; height: 5px; }
.tag.plain::before { display: none; }
.prio { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.prio i { width: 3px; background: var(--line-2); border-radius: 1px; }
.prio i:nth-child(1) { height: 5px; } .prio i:nth-child(2) { height: 8px; } .prio i:nth-child(3) { height: 12px; }
.prio.w1 i:nth-child(-n+1), .prio.w2 i:nth-child(-n+2) { background: var(--ink-2); }
.prio.w3 i { background: var(--danger); }

.avatar {
  width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em; color: var(--ink); border: 1px solid var(--line-2);
}
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatars { display: inline-flex; }
.avatars .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); }
.avatars .avatar:first-child { margin-left: 0; }

.progress { height: 5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; min-width: 60px; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.prog-row { display: flex; align-items: center; gap: 8px; }
.prog-row .num { font-size: 12px; color: var(--ink-2); width: 34px; text-align: right; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty h4 { color: var(--ink); font-size: 14px; margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }

/* ---------- Kanban ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 8px; min-height: 160px; }
.col.drop { border-color: var(--accent); background: var(--accent-weak); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-size: 13px; font-weight: 600; }
.col-head .n { color: var(--muted); font-weight: 500; }
.col-head .btn-icon { margin-left: auto; width: 26px; height: 26px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; margin-bottom: 6px;
  cursor: grab; display: flex; flex-direction: column; gap: 8px;
}
.card:hover { border-color: var(--line-2); }
.card.dragging { opacity: 0.45; }
.card-title { font-weight: 500; font-size: 13.5px; line-height: 1.35; }
.card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.card-meta .proj { font-family: var(--mono); font-size: 11px; }
.card-meta .late { color: var(--danger); font-weight: 500; }

/* ---------- Pipeline ---------- */
.pipe { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 10px; overflow-x: auto; }
.pipe .col-head .sum { margin-left: auto; font-weight: 500; color: var(--muted); font-size: 12px; }

/* ---------- Fiches / détail ---------- */
.facts { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.detail-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; }
.detail-head .code { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.detail-head h1 { font-size: 22px; margin-top: 2px; }
.detail-head .actions { margin-left: auto; display: flex; gap: 8px; }
.desc { color: var(--ink-2); max-width: 70ch; }

.stat-line { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); margin-bottom: 16px; }
.stat-line > div { padding: 12px 16px; border-left: 1px solid var(--line); }
.stat-line > div:first-child { border-left: 0; }
.stat-line .lbl { font-size: 12px; color: var(--muted); }
.stat-line .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ---------- Feuille de temps ---------- */
.week-nav { display: flex; align-items: center; gap: 4px; }
.week-nav .lbl { font-weight: 600; min-width: 190px; text-align: center; }
.ts { width: 100%; border-collapse: collapse; }
.ts th, .ts td { border-bottom: 1px solid var(--line); padding: 0 10px; height: 44px; }
.ts th { font-size: 12px; font-weight: 500; color: var(--muted); text-align: right; background: var(--surface-2); }
.ts th:first-child, .ts td:first-child { text-align: left; }
.ts td { text-align: right; font-variant-numeric: tabular-nums; }
.ts td.cell { cursor: pointer; color: var(--ink-2); }
.ts td.cell:hover { background: var(--accent-weak); color: var(--ink); }
.ts td.zero { color: var(--line-2); }
.ts td.off { background: repeating-linear-gradient(135deg, transparent 0 5px, var(--line) 5px 6px); }
.ts th.today { color: var(--accent); }
.ts tfoot td { font-weight: 600; background: var(--surface-2); }

/* ---------- Facture ---------- */
.doc {
  background: #fff; color: #161816; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 44px 48px; max-width: 820px;
  font-size: 13px;
}
.doc-top { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 28px; border-bottom: 1px solid #e3e5e2; }
.doc-brand { display: flex; gap: 12px; align-items: flex-start; }
.doc-brand .brand-mark { background: #161816; color: #fff; }
.doc h2 { font-size: 26px; letter-spacing: -0.03em; }
.doc .meta-r { text-align: right; }
.doc .meta-r .mono { color: #5b625d; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 24px 0; }
.doc-parties .lbl { font-size: 11.5px; color: #7d847f; margin-bottom: 4px; }
.doc table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.doc th { text-align: left; font-size: 11.5px; color: #7d847f; font-weight: 500; padding: 8px 0; border-bottom: 1px solid #161816; }
.doc td { padding: 11px 0; border-bottom: 1px solid #e3e5e2; vertical-align: top; }
.doc th.r, .doc td.r { text-align: right; }
.doc-totals { margin-left: auto; width: 300px; margin-top: 16px; }
.doc-totals div { display: flex; justify-content: space-between; padding: 5px 0; }
.doc-totals .ttc { border-top: 1px solid #161816; margin-top: 4px; padding-top: 10px; font-weight: 700; font-size: 15px; }
.doc-foot { margin-top: 40px; padding-top: 16px; border-top: 1px solid #e3e5e2; font-size: 11.5px; color: #7d847f; }

.lines-edit { width: 100%; border-collapse: collapse; }
.lines-edit th { font-size: 12px; color: var(--muted); font-weight: 500; text-align: left; padding: 0 6px 6px; }
.lines-edit td { padding: 3px; }
.lines-edit input { width: 100%; }

/* ---------- Formulaires & dialogues ---------- */
input:not([type]), input[type='password'], input[type='text'], input[type='email'], input[type='tel'], input[type='number'], input[type='date'], input[type='search'], select, textarea {
  height: 34px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--input); padding: 0 10px; font-size: 13.5px; outline: 0;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
input[type='checkbox'] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

.dlg {
  border: 1px solid var(--line-2); border-radius: 12px; padding: 0; width: min(580px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px -12px rgba(10, 14, 12, 0.28);
}
.dlg[open] { animation: dlg-in 200ms var(--ease); }
.dlg::backdrop { background: rgba(14, 17, 15, 0.38); animation: fade 160ms var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(6px) scale(0.99); } }
@keyframes fade { from { opacity: 0; } }
.dlg-sm { width: min(420px, calc(100vw - 32px)); }
.dlg-wide { width: min(860px, calc(100vw - 32px)); }
.dlg-form { display: flex; flex-direction: column; max-height: calc(100vh - 50px); }
.dlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 6px; }
.dlg-head h2, .dlg-body > h2 { font-size: 16px; }
.dlg-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.dlg-head .btn-icon { margin-left: auto; margin-top: -4px; }
.dlg-body { padding: 14px 20px 18px; overflow-y: auto; }
.dlg-body > p { margin-top: 6px; }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 12px 12px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.span2, .form-grid > .span2 { grid-column: span 2; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field label em { font-style: normal; color: var(--muted); font-weight: 400; }
.field small { color: var(--muted); font-size: 12px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--input); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }

/* Palette de commandes : pas d'animation, utilisée plusieurs fois par jour */
.cmdk { width: min(620px, calc(100vw - 32px)); margin-top: 12vh; animation: none !important; }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.cmdk-input input { border: 0; background: transparent; box-shadow: none !important; height: 52px; font-size: 15px; flex: 1; padding: 0; }
.cmdk-list { max-height: 380px; overflow-y: auto; padding: 6px; }
.cmdk-sec { font-size: 11.5px; color: var(--muted); padding: 8px 10px 4px; font-weight: 500; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.cmdk-item .ic { color: var(--muted); }
.cmdk-item .k { margin-left: auto; font-size: 12px; color: var(--muted); }
.cmdk-item[aria-selected='true'] { background: var(--hover); }
.cmdk-foot { border-top: 1px solid var(--line); padding: 8px 14px; font-size: 12px; color: var(--muted); display: flex; gap: 14px; }

#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  display: flex; align-items: center; gap: 8px; background: var(--ink); color: var(--canvas); padding: 9px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500; animation: toast-in 180ms var(--ease);
}
.toast-ok .ic { color: #5fd39b; }
.toast-err .ic { color: #ff8f84; }
.toast.out { opacity: 0; transition: opacity 180ms; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 200px; padding: 4px; background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 9px; box-shadow: 0 12px 32px -8px rgba(10, 14, 12, 0.22); display: none;
}
.menu.open .menu-pop { display: block; animation: fade 120ms var(--ease); }
.menu-pop button { display: flex; width: 100%; align-items: center; gap: 9px; height: 32px; padding: 0 10px; border: 0; background: transparent; border-radius: 6px; font-size: 13px; cursor: pointer; text-align: left; }
.menu-pop button:hover { background: var(--hover); }
.menu-pop .ic { color: var(--muted); }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.notice .ic { color: var(--warn); margin-top: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 1100px) {
  .g-main, .g-side, .g-3 { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .hero-main { border-right: 0; border-bottom: 1px solid var(--line); }
  .stat-line { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand, .nav-label, .sidebar-foot { display: none; }
  .nav-group { margin: 0; display: flex; }
  .nav { display: flex; }
  .nav a { white-space: nowrap; }
  .topbar { padding: 0 16px; }
  .search-btn { width: auto; }
  .search-btn .txt, .search-btn kbd { display: none; }
  .page { padding: 18px 16px 48px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .g-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span2 { grid-column: auto; }
  .tbl-wrap { overflow-x: auto; }
  .hbar { grid-template-columns: 100px 1fr 70px; }
  .stat-line { grid-template-columns: 1fr 1fr; }
}

@media print {
  body { background: #fff; }
  .topnav, .crumbline, .no-print, #toasts { display: none !important; }
  .app { display: block; }
  .page { padding: 0; max-width: none; }
  .doc { border: 0; padding: 0; max-width: none; }
  .grid { display: block; }
}


/* ================================================================
   Navigation supérieure
   Rail central avec repère glissant, présence des collègues,
   touches de raccourci révélées en maintenant Alt.
   ================================================================ */
.topnav {
  position: sticky; top: 0; z-index: 20; height: 60px;
  display: flex; align-items: center; gap: 18px; padding: 0 22px;
  background: color-mix(in srgb, var(--canvas) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.tn-brand { display: flex; align-items: center; gap: 10px; flex: none; }
.tn-brand .brand-name { font-size: 15.5px; }
.tn-end { display: flex; align-items: center; gap: 10px; flex: none; margin-left: auto; }

.rail {
  position: relative; display: flex; align-items: center; gap: 2px; padding: 3px;
  margin: 0 auto; min-width: 0; flex: 0 1 auto; overflow-x: auto; scrollbar-width: none;
  background: var(--hover); border: 1px solid var(--line); border-radius: 11px;
}
.rail::-webkit-scrollbar { display: none; }
.rail a {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px;
  border-radius: 8px; color: var(--ink-2); font-size: 13.5px; font-weight: 500; white-space: nowrap; flex: none;
  transition: color 160ms var(--ease);
}
.rail a .ic { color: var(--muted); transition: color 160ms var(--ease); }
.rail a:hover { color: var(--ink); }
.rail a[aria-current='page'] { color: var(--ink); }
.rail a[aria-current='page'] .ic { color: var(--accent); }
.rail .sep { width: 1px; height: 16px; background: var(--line-2); margin: 0 5px; flex: none; }
.rail-ind {
  position: absolute; z-index: 0; top: 3px; left: 0; height: 32px; width: 0; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--line-2);
  transition: transform 260ms var(--ease), width 260ms var(--ease), opacity 160ms;
}
.rail-ind.instant { transition: none; }
.rail .badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line);
}
.rail .badge.alert { background: var(--danger); border-color: var(--danger); color: #fff; }
.rail .k {
  display: none; font-family: var(--mono); font-size: 10.5px; font-weight: 600; width: 17px; height: 17px;
  place-items: center; border-radius: 4px; border: 1px solid var(--line-2); border-bottom-width: 2px;
  background: var(--surface); color: var(--ink);
}
.rail.hints .k { display: inline-grid; }
.rail.hints .badge, .rail.hints a .ic { display: none; }

/* Présence : qui est connecté en ce moment */
.presence { display: flex; align-items: center; gap: 8px; padding-right: 4px; }
.presence .avatars .avatar { width: 26px; height: 26px; position: relative; }
.presence .avatars .avatar::after {
  content: ''; position: absolute; right: -1px; bottom: -1px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--canvas);
}
.presence .lbl { font-size: 12px; color: var(--muted); white-space: nowrap; }
.presence .lbl b { color: var(--ink-2); font-weight: 600; }

.tn-search {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 7px 0 10px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--muted); font-size: 13px; cursor: pointer;
}
.tn-search:hover { border-color: var(--ink-2); color: var(--ink-2); }
.tn-search kbd { margin-left: 6px; }

.me-btn { position: relative; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-2); padding: 0; cursor: pointer; background: var(--accent-weak); color: var(--ink); font-size: 12px; font-weight: 600; }
.me-btn:hover { border-color: var(--ink-2); }
.me-btn .sync-dot { position: absolute; right: -1px; bottom: -1px; box-shadow: 0 0 0 2px var(--canvas); }
#user-menu .menu-pop { min-width: 250px; }
.me-head { padding: 10px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.me-head .n { font-weight: 600; }
.me-head .e { font-size: 12px; color: var(--muted); }
.me-head .tag { margin-top: 6px; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.crumbline { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: -6px 0 14px; }
.crumbline a:hover { color: var(--ink); }
.crumbline .ic { opacity: 0.6; }

@media (max-width: 1580px) {
  .tn-search .txt, .tn-search kbd, .presence .lbl { display: none; }
  .tn-search { padding: 0 9px; }
}
@media (max-width: 1180px) {
  .rail a .ic { display: none; }
  .tn-brand .brand-name { display: none; }
}
@media (max-width: 760px) {
  .topnav { height: auto; flex-wrap: wrap; row-gap: 8px; padding: 10px 14px; }
  .rail { order: 3; flex: 1 1 100%; margin: 0; }
  .rail a .ic { display: block; }
  .tn-brand .brand-name { display: inline; }
  #new-btn .txt, .presence { display: none; }
}
