/* ==========================================================================
   iTradesk — thème inspiré d'IBM Carbon (g100 sombre / g10 clair)
   Application desktop : panneaux fixes, haute densité, IBM Plex.
   ========================================================================== */
:root, [data-theme="g100"] {
  --bg: #161616; --layer: #1e1e1e; --layer-2: #262626; --layer-3: #393939;
  --layer-hover: #2c2c2c; --layer-selected: #333d4d; --field: #262626; --field-hover: #333333;
  --border: #393939; --border-subtle: #2a2a2a; --border-strong: #6f6f6f;
  --text: #f4f4f4; --text-2: #c6c6c6; --text-3: #8d8d8d; --text-4: #6f6f6f; --text-inverse: #161616;
  --interactive: #0f62fe; --interactive-hover: #0353e9; --link: #78a9ff; --focus: #ffffff;
  --error: #fa4d56; --success: #42be65; --warning: #f1c21b; --info: #4589ff;
  --purple: #a56eff; --purple-bg: rgba(138, 63, 252, .14); --teal: #3ddbd9; --magenta: #ff7eb6; --orange: #ff832b;
  --note-bg: rgba(241, 194, 27, .08); --note-border: #8e6a00;
  --titlebar: #000000; --menubar: #161616; --statusbar: #0f62fe;
  --ai-surface: linear-gradient(160deg, rgba(69,137,255,.14) 0%, rgba(165,110,255,.10) 55%, rgba(30,30,30,0) 100%);
  --ai-edge: linear-gradient(180deg, #4589ff, #a56eff);
  --shadow: 0 8px 24px rgba(0,0,0,.55);
  color-scheme: dark;
}
[data-theme="g10"] {
  --bg: #f4f4f4; --layer: #ffffff; --layer-2: #f4f4f4; --layer-3: #e0e0e0;
  --layer-hover: #e8e8e8; --layer-selected: #d0e2ff; --field: #f4f4f4; --field-hover: #e8e8e8;
  --border: #e0e0e0; --border-subtle: #eeeeee; --border-strong: #8d8d8d;
  --text: #161616; --text-2: #525252; --text-3: #6f6f6f; --text-4: #a8a8a8; --text-inverse: #ffffff;
  --interactive: #0f62fe; --interactive-hover: #0353e9; --link: #0f62fe; --focus: #0f62fe;
  --error: #da1e28; --success: #198038; --warning: #b28600; --info: #0043ce;
  --purple: #8a3ffc; --purple-bg: rgba(138, 63, 252, .08); --teal: #007d79; --magenta: #d02670; --orange: #ba4e00;
  --note-bg: #fcf4d6; --note-border: #f1c21b;
  --titlebar: #161616; --menubar: #ffffff; --statusbar: #0f62fe;
  --ai-surface: linear-gradient(160deg, rgba(15,98,254,.07) 0%, rgba(138,63,252,.07) 55%, rgba(255,255,255,0) 100%);
  --ai-edge: linear-gradient(180deg, #0f62fe, #8a3ffc);
  --shadow: 0 8px 24px rgba(0,0,0,.18);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
  font-size: 13px; line-height: 1.4; letter-spacing: .1px;
  background: var(--bg); color: var(--text); overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 400; }
p { margin: 0 0 .6em; }
code, kbd, .mono { font-family: 'IBM Plex Mono', Menlo, monospace; }
code { font-size: 12px; background: var(--layer-3); padding: 0 4px; }
kbd { font-size: 10.5px; padding: 1px 5px; border: 1px solid var(--border-strong); color: var(--text-2); background: var(--layer-2); line-height: 1.4; }
hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
::selection { background: var(--interactive); color: #fff; }
.muted { color: var(--text-3); }
.small { font-size: 11.5px; }
.condensed { font-family: 'IBM Plex Sans Condensed', 'IBM Plex Sans', sans-serif; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* Barres de défilement fines, style desktop */
* { scrollbar-width: thin; scrollbar-color: var(--layer-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--layer-3); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--border-strong); }

.ic { width: 16px; height: 16px; flex-shrink: 0; vertical-align: -3px; }
.ic.lg { width: 20px; height: 20px; }

/* ---------------------------------------------------------------- coquille */
.app { display: grid; grid-template-rows: 32px 28px minmax(0, 1fr) 24px; height: 100vh; }
.titlebar, .menubar, .activitybar, .statusbar, .tabstrip, .pane-header, th { user-select: none; }

.titlebar { display: flex; align-items: center; background: var(--titlebar); color: #f4f4f4; border-bottom: 1px solid #262626; padding-left: 10px; gap: 12px; }
.titlebar-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; letter-spacing: .2px; }
.titlebar-brand .logo { width: 18px; height: 18px; }
.titlebar-title { color: #a8a8a8; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.titlebar-search { flex: 0 1 460px; margin-left: auto; margin-right: auto; height: 22px; display: flex; align-items: center; gap: 8px; padding: 0 8px;
  background: #262626; border: 1px solid #393939; color: #a8a8a8; font: inherit; font-size: 12px; cursor: pointer; text-align: left; }
.titlebar-search span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titlebar-search:hover { border-color: #6f6f6f; color: #f4f4f4; }
.titlebar-search kbd { background: transparent; border-color: #525252; color: #8d8d8d; }
.titlebar-spacer { display: none; }
.window-controls { display: flex; height: 100%; }
.window-controls span { width: 46px; display: grid; place-items: center; color: #c6c6c6; cursor: default; font-size: 12px; }
.window-controls span:hover { background: #393939; }
.window-controls .wc-close:hover { background: #da1e28; color: #fff; }

.menubar { display: flex; align-items: stretch; background: var(--menubar); border-bottom: 1px solid var(--border); padding-left: 4px; font-size: 12.5px; }
.menu { position: relative; }
.menu-trigger { height: 100%; padding: 0 10px; background: none; border: 0; color: var(--text); font: inherit; cursor: default; }
.menu-trigger:hover, .menu.open .menu-trigger { background: var(--layer-hover); }
.menu-list { display: none; position: absolute; top: 100%; left: 0; z-index: 60; min-width: 250px; padding: 4px 0; background: var(--layer-2); border: 1px solid var(--border); box-shadow: var(--shadow); }
.menu.open .menu-list { display: block; }
.menu-list a, .menu-list button { display: flex; align-items: center; justify-content: space-between; gap: 24px; width: 100%; height: 28px; padding: 0 14px;
  color: var(--text); background: none; border: 0; font: inherit; text-align: left; cursor: default; text-decoration: none; }
.menu-list a:hover, .menu-list button:hover { background: var(--interactive); color: #fff; }
.menu-list a:hover kbd, .menu-list button:hover kbd { color: #fff; border-color: rgba(255,255,255,.5); }
.menu-list kbd { border: 0; background: none; color: var(--text-3); padding: 0; }
.menu-list form { margin: 0; }
.menubar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; padding-right: 10px; }
.menubar-user { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.ai-chip { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; font-size: 11.5px; border: 1px solid; }
.ai-live { color: var(--purple); border-color: var(--purple); background: var(--purple-bg); }
.ai-off { color: var(--text-3); border-color: var(--border-strong); }

.workspace { display: flex; min-height: 0; }
.activitybar { width: 48px; flex-shrink: 0; display: flex; flex-direction: column; background: var(--bg); border-right: 1px solid var(--border); }
.activitybar a, .activitybar button { position: relative; height: 44px; display: grid; place-items: center; color: var(--text-3); background: none; border: 0; cursor: pointer; }
.activitybar a:hover, .activitybar button:hover { color: var(--text); background: var(--layer-hover); text-decoration: none; }
.activitybar a.active { color: var(--text); background: var(--layer); box-shadow: inset 3px 0 var(--interactive); }
.activitybar a.ai-link { color: var(--purple); }
.activitybar .badge { position: absolute; top: 5px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; line-height: 16px; font-weight: 600; background: var(--error); color: #fff; border-radius: 8px; text-align: center; }
.activitybar-spacer { flex: 1; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabstrip { height: 32px; flex-shrink: 0; display: flex; overflow-x: auto; overflow-y: hidden; background: var(--bg); border-bottom: 1px solid var(--border); scrollbar-width: none; }
.tabstrip::-webkit-scrollbar { display: none; }
.tab { display: flex; align-items: center; gap: 6px; min-width: 120px; max-width: 220px; padding: 0 6px 0 12px; font-size: 12px;
  color: var(--text-3); border-right: 1px solid var(--border); cursor: pointer; white-space: nowrap; text-decoration: none; }
.tab:hover { background: var(--layer-hover); color: var(--text); text-decoration: none; }
.tab.active { background: var(--layer); color: var(--text); box-shadow: inset 0 2px var(--interactive); }
.tab .tab-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.tab .tab-x { width: 18px; height: 18px; display: grid; place-items: center; border: 0; background: none; color: inherit; cursor: pointer; opacity: .6; }
.tab .tab-x:hover { background: var(--layer-3); opacity: 1; }
.tab .st { width: 14px; height: 14px; font-size: 9px; }

.content { flex: 1; display: flex; min-height: 0; min-width: 0; }

.statusbar { display: flex; align-items: center; gap: 0; background: var(--statusbar); color: #fff; font-size: 11.5px; padding: 0 4px; }
.sb-item { display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; height: 100%; }
.sb-item:hover { background: rgba(255,255,255,.12); }
.sb-spacer { flex: 1; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--text-3); }
.dot.ok { background: #42be65; }

/* ---------------------------------------------------------------- panneaux */
.panes { display: flex; flex: 1; min-width: 0; min-height: 0; }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--layer); border-right: 1px solid var(--border); }
.pane:last-child { border-right: 0; }
.pane.side { width: 232px; flex-shrink: 0; background: var(--bg); }
.pane.aside { width: 320px; flex-shrink: 0; }
.pane.fill { flex: 1; }
.pane.list-pane { width: 58%; flex-shrink: 0; }
.pane-header { height: 40px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--border); }
.pane-header h1 { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-header h2 { font-size: 13px; font-weight: 600; }
.pane-header .count { color: var(--text-3); font-size: 12px; }
.pane-toolbar { min-height: 40px; flex-shrink: 0; display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--border); background: var(--layer); flex-wrap: wrap; }
.pane-body { flex: 1; overflow: auto; min-height: 0; }
.pane-body.pad { padding: 16px; }
.pane-footer { flex-shrink: 0; border-top: 1px solid var(--border); padding: 6px 12px; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 8px; }
.splitter { width: 5px; margin: 0 -3px; cursor: col-resize; z-index: 5; flex-shrink: 0; position: relative; }
.splitter:hover, .splitter.dragging { background: var(--interactive); }

/* Navigation latérale (vues, catégories) */
.nav-group { padding: 8px 0 4px; }
.nav-title { padding: 4px 12px 4px 16px; font-size: 11.5px; font-weight: 600; color: var(--text-3); display: flex; justify-content: space-between; align-items: center; }
.nav-title a { color: var(--text-3); }
.nav-item { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px 0 16px; color: var(--text-2); text-decoration: none; font-size: 12.5px; position: relative; }
.nav-item:hover { background: var(--layer-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--layer-selected); color: var(--text); font-weight: 500; }
.nav-item.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--interactive); }
.nav-item .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .n { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-item.active .n { color: var(--text); }
.nav-swatch { width: 8px; height: 8px; flex-shrink: 0; }

/* ---------------------------------------------------------------- contrôles */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 14px; border: 1px solid transparent;
  font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; text-decoration: none; background: var(--interactive); color: #fff; }
.btn:hover { background: var(--interactive-hover); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secondary { background: var(--layer-3); color: var(--text); }
.btn.secondary:hover { background: var(--border-strong); }
.btn.tertiary { background: transparent; color: var(--link); border-color: var(--link); }
.btn.tertiary:hover { background: var(--interactive); color: #fff; }
.btn.ghost { background: transparent; color: var(--text); }
.btn.ghost:hover { background: var(--layer-hover); }
.btn.danger { background: #da1e28; color: #fff; }
.btn.danger:hover { background: #b81921; }
.btn.sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn.xs { height: 22px; padding: 0 8px; font-size: 11.5px; }
.btn.ai { background: transparent; color: var(--text); border: 1px solid transparent; background-image: linear-gradient(var(--layer), var(--layer)), var(--ai-edge);
  background-origin: border-box; background-clip: padding-box, border-box; }
.btn.ai .ic { color: var(--purple); }
.btn.ai:hover { background-image: linear-gradient(var(--layer-hover), var(--layer-hover)), var(--ai-edge); }
.btn.ai.busy { opacity: .7; pointer-events: none; }
.btn.ai.busy .ic { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn.ai.busy .ic { animation: none; } }
.btn-icon { width: 28px; height: 28px; display: inline-grid; place-items: center; background: none; border: 0; color: var(--text-2); cursor: pointer; }
.btn-icon:hover { background: var(--layer-hover); color: var(--text); }
.btn-group { display: inline-flex; }
.btn-group .btn + .btn { border-left: 1px solid rgba(255,255,255,.25); }

input[type=text], input[type=email], input[type=number], input[type=password], input[type=search], input[type=url], select, textarea {
  font: inherit; font-size: 13px; color: var(--text); background: var(--field); border: 0; border-bottom: 1px solid var(--border-strong);
  height: 32px; padding: 0 10px; width: 100%; border-radius: 0; outline: none; }
input:hover, select:hover, textarea:hover { background: var(--field-hover); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -2px; }
textarea { height: auto; padding: 8px 10px; line-height: 1.5; resize: vertical; }
textarea.mono { font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; }
select { padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%238d8d8d'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; }
select[multiple] { height: auto; background-image: none; padding: 4px; }
input[type=color] { width: 60px; height: 32px; padding: 2px; background: var(--field); border: 0; }
input[type=checkbox] { accent-color: var(--interactive); width: 14px; height: 14px; margin: 0; vertical-align: -2px; }
.input-sm, select.input-sm { height: 26px; font-size: 12px; padding: 0 8px; }
select.input-sm { padding-right: 24px; }
.search-field { position: relative; display: flex; align-items: center; }
.search-field .ic { position: absolute; left: 8px; color: var(--text-3); pointer-events: none; }
.search-field input { padding-left: 30px; }

.field { margin-bottom: 14px; }
.field label, .field-label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.field .help { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.field .errors { color: var(--error); font-size: 12px; margin-top: 4px; }
.field.check label { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
.field ul { list-style: none; margin: 0; padding: 0; columns: 2; }
.field ul li label { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 12.5px; margin: 0 0 4px; }
.form-errors { background: rgba(250,77,86,.12); border-left: 3px solid var(--error); padding: 8px 12px; margin-bottom: 14px; }

.prop { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 8px; margin-bottom: 6px; }
.prop > label { font-size: 12px; color: var(--text-3); }
.prop select, .prop input { height: 28px; font-size: 12.5px; }

/* ---------------------------------------------------------------- tables */
table.grid { width: 100%; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
.grid th { position: sticky; top: 0; z-index: 2; background: var(--layer-2); color: var(--text-2); text-align: left; font-weight: 600; font-size: 12px;
  height: 30px; padding: 0 8px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid th a { color: inherit; display: block; }
.grid th a:hover { color: var(--text); text-decoration: none; }
.grid th.sorted a::after { content: " ▾"; color: var(--interactive); }
.grid th.sorted.asc a::after { content: " ▴"; }
.grid td { height: 32px; padding: 0 8px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.grid td.primary { color: var(--text); }
.grid tbody tr:hover { background: var(--layer-hover); }
.grid tbody tr.selected { background: var(--layer-selected); box-shadow: inset 3px 0 var(--interactive); }
.grid tbody tr.selected td { color: var(--text); }
.grid tbody tr[data-href] { cursor: default; }
.grid tr.unread td.primary { font-weight: 600; }
.grid.compact td { height: 28px; }
.grid .col-check { width: 32px; text-align: center; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid a.row-link { color: var(--text); }
.kbd-table td { white-space: normal; height: auto; padding: 6px 8px; }

/* ---------------------------------------------------------------- badges */
.st { display: inline-grid; place-items: center; width: 18px; height: 18px; font-size: 10.5px; font-weight: 600; color: #fff; flex-shrink: 0; }
.st-new { background: #f1c21b; color: #161616; }
.st-open { background: #da1e28; }
.st-pending { background: #0f62fe; }
.st-hold { background: #161616; border: 1px solid #8d8d8d; }
.st-solved { background: #6f6f6f; }
.st-closed { background: #393939; color: #a8a8a8; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; font-size: 11.5px; border-radius: 10px; background: var(--layer-3); color: var(--text); white-space: nowrap; }
.pill.status { border-radius: 0; font-weight: 500; }
.pill.st-new, .pill.st-open, .pill.st-pending, .pill.st-hold, .pill.st-solved, .pill.st-closed { width: auto; }
.tag { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; font-size: 11px; background: var(--layer-3); color: var(--text-2); border-radius: 9px; margin-right: 3px; white-space: nowrap; }
.prio { display: inline-flex; align-items: center; gap: 6px; }
.prio::before { content: ""; width: 3px; height: 12px; background: var(--text-4); box-shadow: 4px 0 var(--text-4), 8px 0 var(--text-4); opacity: .35; margin-right: 8px; }
.prio-normal::before { background: var(--info); opacity: 1; box-shadow: 4px 0 var(--info), 8px 0 var(--layer-3); }
.prio-low::before { background: var(--text-3); opacity: 1; box-shadow: 4px 0 var(--layer-3), 8px 0 var(--layer-3); }
.prio-high::before { background: var(--orange); opacity: 1; box-shadow: 4px 0 var(--orange), 8px 0 var(--orange); }
.prio-urgent::before { background: var(--error); opacity: 1; box-shadow: 4px 0 var(--error), 8px 0 var(--error); }
.prio-urgent { color: var(--error); font-weight: 600; }
.sla { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-variant-numeric: tabular-nums; padding: 0 6px; height: 18px; }
.sla-ok { color: var(--success); border: 1px solid currentColor; }
.sla-warning { color: #161616; background: var(--warning); }
.sla-breached { color: #fff; background: #da1e28; }
.sla-met { color: var(--text-3); border: 1px solid var(--border-strong); }
.sla-none { color: var(--text-4); }
.senti { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.senti-positive { background: var(--success); }
.senti-neutral { background: var(--text-3); }
.senti-negative { background: var(--error); }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.xs { width: 20px; height: 20px; font-size: 9px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.vip { color: var(--warning); font-size: 11px; font-weight: 600; border: 1px solid currentColor; padding: 0 4px; }

/* ---------------------------------------------------------------- tuiles & tableau de bord */
.dash { flex: 1; overflow: auto; padding: 16px; display: grid; gap: 1px; grid-template-columns: repeat(12, 1fr); align-content: start; background: var(--bg); }
.tile { background: var(--layer); padding: 14px 16px; min-width: 0; border: 1px solid var(--border-subtle); }
.tile h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile h3 .muted { font-weight: 400; font-size: 12px; }
.kpi { grid-column: span 2; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; }
.kpi:hover { background: var(--layer-hover); text-decoration: none; }
.kpi .label { font-size: 12px; color: var(--text-2); }
.kpi .value { font-size: 34px; font-weight: 300; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 11.5px; color: var(--text-3); }
.kpi.alert .value { color: var(--error); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
@media (max-width: 1280px) { .kpi { grid-column: span 4; } .span-4, .span-5, .span-7, .span-8 { grid-column: span 12; } .span-3 { grid-column: span 6; } }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 8px; }
.bars .day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.bars .cols { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.bars .c, .bars .s { width: 40%; min-height: 1px; }
.bars .c { background: var(--interactive); }
.bars .s { background: var(--teal); }
.bars .d { font-size: 10px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: 120px 1fr 44px; align-items: center; gap: 8px; height: 26px; font-size: 12.5px; }
.hbar .track { height: 12px; background: var(--layer-3); }
.hbar .fill { height: 100%; background: var(--interactive); }
.hbar .fill.purple { background: var(--purple); }
.hbar .fill.teal { background: var(--teal); }
.hbar .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border-subtle); font-size: 12.5px; align-items: baseline; }
.feed li .when { color: var(--text-3); font-size: 11.5px; white-space: nowrap; margin-left: auto; }
.feed li .what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- ticket */
.ticket-head { padding: 10px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ticket-head h1 { font-size: 17px; font-weight: 400; line-height: 1.3; margin-bottom: 4px; }
.ticket-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 12px; color: var(--text-3); }
.subtabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; padding: 0 8px; }
.subtab { height: 34px; padding: 0 12px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-3); font: inherit; font-size: 12.5px; cursor: pointer; }
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--text); border-bottom-color: var(--interactive); font-weight: 500; }
.subtab .n { color: var(--text-3); margin-left: 4px; }
.conversation { padding: 12px 16px 24px; }
.msg { display: grid; grid-template-columns: 32px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.msg-author { font-weight: 600; font-size: 13px; }
.msg-when { color: var(--text-3); font-size: 11.5px; }
.msg-body { font-size: 13px; line-height: 1.55; color: var(--text); max-width: 78ch; overflow-wrap: anywhere; }
.msg-body p:last-child { margin-bottom: 0; }
.msg.internal .msg-content { background: var(--note-bg); border-left: 3px solid var(--note-border); padding: 8px 12px; margin-left: -4px; }
.msg.agent .msg-author::after { content: "Agent"; font-weight: 400; font-size: 10.5px; color: var(--text-3); border: 1px solid var(--border-strong); padding: 0 4px; margin-left: 6px; }
.msg-flag { font-size: 11px; display: inline-flex; align-items: center; gap: 3px; }
.msg-flag.ai { color: var(--purple); }
.msg-flag.note { color: var(--warning); }
.msg-flag.sent { color: var(--success); }
.msg-flag.failed { color: var(--error); }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.attachment { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px; background: var(--layer-2); border: 1px solid var(--border); font-size: 12px; color: var(--text); }

.composer { flex-shrink: 0; border-top: 1px solid var(--border); background: var(--layer); display: flex; flex-direction: column; }
.composer-tabs { display: flex; align-items: center; gap: 0; padding: 0 8px; border-bottom: 1px solid var(--border-subtle); }
.composer-tabs .subtab { height: 32px; }
.composer.internal { background: var(--note-bg); }
.composer.internal textarea { background: transparent; }
.composer textarea { border: 0; min-height: 132px; max-height: 45vh; font-size: 13px; resize: vertical; background: transparent; }
.composer textarea:hover { background: transparent; }
.composer-tools { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-top: 1px solid var(--border-subtle); flex-wrap: wrap; }
.composer-tools select { width: auto; max-width: 190px; }
.composer-tools .sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }
.ai-bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--ai-surface); border-bottom: 1px solid var(--border-subtle); }
.ai-bar input { height: 26px; font-size: 12px; background: var(--field); }
.ai-bar .ai-label { display: inline-flex; align-items: center; gap: 4px; color: var(--purple); font-weight: 600; font-size: 12px; white-space: nowrap; }
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { display: none; position: absolute; bottom: calc(100% + 4px); left: 0; z-index: 30; min-width: 220px; background: var(--layer-2); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 4px 0; }
.dropdown-menu.down { bottom: auto; top: calc(100% + 4px); }
.dropdown-menu.right { left: auto; right: 0; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu button, .dropdown-menu a { display: flex; align-items: center; gap: 8px; width: 100%; height: 30px; padding: 0 12px; background: none; border: 0; color: var(--text); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; text-decoration: none; }
.dropdown-menu button:hover, .dropdown-menu a:hover { background: var(--layer-hover); text-decoration: none; }
.dropdown-menu .dd-title { padding: 6px 12px 2px; font-size: 11px; color: var(--text-3); }

/* Panneau de propriétés & copilote */
.section { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.section-title { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 4px 8px; font-size: 12.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.person { display: flex; gap: 10px; align-items: center; }
.person .name { font-weight: 600; font-size: 13px; }
.person .sub { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 8px; height: 28px; font-size: 12.5px; border-bottom: 1px solid var(--border-subtle); }
.mini-list li a { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.mini-list li .muted { font-size: 11.5px; white-space: nowrap; }

.ai-panel { background: var(--ai-surface); position: relative; }
.ai-panel::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--ai-edge); }
.ai-title { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; }
.ai-title .ic { color: var(--purple); }
.ai-tag { font-size: 10px; font-weight: 600; letter-spacing: .3px; color: var(--purple); border: 1px solid var(--purple); padding: 0 4px; }
.ai-card { background: var(--layer); border: 1px solid var(--border); padding: 10px 12px; margin-top: 8px; font-size: 12.5px; }
.ai-card h4 { font-size: 12px; font-weight: 600; margin: 8px 0 4px; color: var(--text-2); }
.ai-card h4:first-child { margin-top: 0; }
.ai-card ul { margin: 0; padding-left: 18px; }
.ai-card li { margin-bottom: 2px; }
.ai-card .ai-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--text-3); font-size: 11.5px; }
.suggest { display: grid; grid-template-columns: 76px 1fr auto; gap: 6px; align-items: center; font-size: 12.5px; padding: 3px 0; }
.suggest .k { color: var(--text-3); }
.ai-empty { color: var(--text-3); font-size: 12px; }
.skeleton { height: 10px; background: linear-gradient(90deg, var(--layer-3), var(--layer-2), var(--layer-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite; margin: 6px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

.timeline { list-style: none; margin: 0; padding: 12px 16px; }
.timeline li { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 5px 0; font-size: 12.5px; border-bottom: 1px solid var(--border-subtle); }
.timeline .when { color: var(--text-3); font-variant-numeric: tabular-nums; }
.timeline .chg { color: var(--text-3); }
.timeline .chg b { color: var(--text); font-weight: 500; }

/* Aperçu */
.preview-empty { flex: 1; display: grid; place-items: center; color: var(--text-3); text-align: center; padding: 24px; }
.preview-empty .ic { width: 40px; height: 40px; opacity: .4; margin-bottom: 8px; }

/* Barre d'actions groupées */
.bulkbar { display: none; align-items: center; gap: 6px; padding: 4px 8px; background: var(--interactive); color: #fff; flex-shrink: 0; min-height: 40px; flex-wrap: wrap; }
.bulkbar.show { display: flex; }
.bulkbar select { width: auto; height: 26px; font-size: 12px; background-color: rgba(0,0,0,.2); color: #fff; border-bottom-color: rgba(255,255,255,.6); }
.bulkbar select option { color: #161616; background: #fff; }
.bulkbar .btn { background: rgba(0,0,0,.25); }
.bulkbar .btn:hover { background: rgba(0,0,0,.4); }

/* Filtres */
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; background: var(--layer-2); border: 1px solid var(--border); font-size: 12px; color: var(--text-2); text-decoration: none; }
.chip:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.chip.on { background: var(--layer-selected); border-color: var(--interactive); color: var(--text); }

/* Article / document */
.doc { max-width: 76ch; margin: 0 auto; padding: 24px 24px 64px; font-size: 14px; line-height: 1.65; }
.doc h1.doc-title { font-size: 28px; font-weight: 300; line-height: 1.25; margin-bottom: 8px; }
.doc h2 { font-size: 19px; font-weight: 600; margin: 1.6em 0 .5em; }
.doc h3 { font-size: 15px; font-weight: 600; margin: 1.3em 0 .4em; }
.doc h4 { font-size: 14px; font-weight: 600; margin: 1.2em 0 .3em; }
.doc ul, .doc ol { padding-left: 22px; margin: 0 0 1em; }
.doc li { margin-bottom: .3em; }

/* Assistant IA */
.chat { flex: 1; overflow: auto; padding: 20px 0; }
.chat-inner { max-width: 820px; margin: 0 auto; padding: 0 20px; }
.bubble { display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border-subtle); }
.bubble .who { font-weight: 600; font-size: 12.5px; margin-bottom: 4px; }
.bubble.ai .who { color: var(--purple); }
.bubble .text { white-space: pre-wrap; line-height: 1.6; font-size: 13.5px; }
.bubble .sources { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.ai-avatar { width: 32px; height: 32px; display: grid; place-items: center; background: var(--ai-edge); color: #fff; }
.chat-input { flex-shrink: 0; border-top: 1px solid var(--border); padding: 12px 20px; background: var(--layer); }
.chat-input form { max-width: 820px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { min-height: 44px; max-height: 200px; }
.prompt-starters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 16px; }
.prompt-starters button { text-align: left; padding: 10px 12px; background: var(--layer-2); border: 1px solid var(--border); color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; }
.prompt-starters button:hover { border-color: var(--purple); }

/* Notifications */
.toasts { position: fixed; right: 16px; bottom: 36px; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: 360px; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; background: var(--layer-2); color: var(--text); border-left: 3px solid var(--info); box-shadow: var(--shadow); font-size: 12.5px; }
.toast span { flex: 1; }
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--error); }
.toast-warning { border-left-color: var(--warning); }
.toast-ai { border-left-color: var(--purple); }
.toast-x { background: none; border: 0; color: var(--text-3); cursor: pointer; }

/* Overlays */
.overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.5); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; }
.overlay[hidden] { display: none; }
.palette, .dialog { width: 620px; max-width: calc(100vw - 32px); background: var(--layer-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow); }
.palette-input { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--border); }
.palette-input input { border: 0; background: transparent; height: 44px; font-size: 15px; }
.palette-input input:focus { outline: none; }
.palette-list { list-style: none; margin: 0; padding: 4px 0; max-height: 50vh; overflow: auto; }
.palette-list li { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 14px; cursor: pointer; font-size: 13px; }
.palette-list li .kind { font-size: 11px; color: var(--text-3); width: 64px; flex-shrink: 0; }
.palette-list li .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-list li .meta { color: var(--text-3); font-size: 12px; }
.palette-list li.active { background: var(--interactive); color: #fff; }
.palette-list li.active .kind, .palette-list li.active .meta { color: rgba(255,255,255,.8); }
.palette-foot { display: flex; gap: 6px; align-items: center; padding: 6px 12px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: 16px; }
.dialog-body { padding: 16px; max-height: 70vh; overflow: auto; }

/* Formulaire générique */
.form-page { max-width: 760px; padding: 20px 24px 60px; }
.form-page.wide { max-width: 1100px; }
.form-actions { display: flex; gap: 8px; padding-top: 8px; position: sticky; bottom: 0; background: var(--layer); padding-bottom: 8px; border-top: 1px solid var(--border); margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

.empty { padding: 40px 20px; text-align: center; color: var(--text-3); }
.empty h3 { font-size: 15px; color: var(--text-2); margin-bottom: 6px; }

/* Connexion */
.login-body { display: grid; place-items: center; height: 100vh; background: var(--bg); overflow: auto; }
.login-window { width: 420px; background: var(--layer); border: 1px solid var(--border); box-shadow: var(--shadow); }
.login-window .titlebar { height: 32px; }
.login-inner { padding: 28px 32px 32px; }
.login-inner h1 { font-size: 26px; font-weight: 300; margin-bottom: 4px; }

@media (max-width: 900px) {
  .pane.side, .pane.aside { display: none; }
  .pane.list-pane { width: 100%; }
  .preview-pane { display: none !important; }
  .titlebar-search span { display: none; }
}

/* ---------------------------------------------------------------- portail client */
body.portal { overflow: auto; background: var(--bg); display: block; }
.portal-wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; display: block; }
.portal-header { background: #161616; color: #f4f4f4; height: 48px; }
.portal-header .portal-wrap { display: flex; align-items: center; height: 100%; }
.portal-header a { color: #c6c6c6; }
.portal-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: #fff !important; }
.portal-brand span { font-weight: 400; color: #a8a8a8; }
.portal-brand .logo { width: 20px; height: 20px; }
.portal-hero { background: #0f62fe; color: #fff; padding: 48px 0 40px; }
.portal-hero h1 { font-size: 36px; font-weight: 300; margin-bottom: 18px; }
.portal-search { display: flex; max-width: 640px; position: relative; align-items: center; }
.portal-search .ic { position: absolute; left: 14px; color: #6f6f6f; }
.portal-search input { height: 48px; padding-left: 42px; background: #fff; color: #161616; font-size: 15px; border: 0; }
.portal-search .btn { height: 48px; background: #161616; }
.portal-grid { display: grid; grid-template-columns: 1fr 380px; gap: 32px; padding-top: 32px; padding-bottom: 48px; }
.portal-grid h2, .portal-card h2 { font-size: 18px; font-weight: 400; margin-bottom: 12px; }
.portal-articles { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.portal-articles a { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--border); color: var(--text); }
.portal-articles a:hover { text-decoration: none; background: var(--layer-hover); }
.portal-articles b { font-weight: 500; color: var(--link); }
.portal-articles span { font-size: 12.5px; color: var(--text-3); }
.portal-cats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); }
.portal-cat { background: var(--layer); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.portal-cat span { font-size: 12.5px; color: var(--text-3); }
.portal-card { background: var(--layer); border: 1px solid var(--border); padding: 20px; }
.portal-title { font-size: 26px; font-weight: 300; margin-bottom: 8px; }
.portal-footer { border-top: 1px solid var(--border); padding: 20px 0; font-size: 12px; color: var(--text-3); }
@media (max-width: 860px) { .portal-grid { grid-template-columns: 1fr; } }
@media print { .titlebar, .menubar, .activitybar, .statusbar, .tabstrip { display: none !important; } body { overflow: visible; } .app { display: block; } }
