/* ==========================================================================
   KairStore — console d'administration
   Feuille de style écrite à la main. Grille de 4 px, rayons 6 px, bordures 1 px.
   Palette issue du logo (cf. docs/SPEC.md §9).
   ========================================================================== */

/* --- Polices (auto-hébergées, IBM Plex — SIL OFL 1.1) -------------------- */
@font-face { font-family: "Plex Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-ext-400-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-ext-500-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-ext-600-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../fonts/ibm-plex-mono-latin-ext-400-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(../fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* --- Jetons --------------------------------------------------------------- */
:root {
  /* palette de marque */
  --ink-950: #15171A; --ink-900: #1E2024; --ink-800: #262A2E;
  --forest-900: #163127; --forest-700: #264E34; --pine-600: #366956;
  --leaf-600: #408556; --leaf-500: #619F60; --moss-400: #71A966; --sage-300: #93C074; --snow-50: #F2F6EE;
  --ochre: #C99A3B; --terracotta: #C4553F; --lake: #4F7F8F;

  --font: "Plex Sans", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Plex Mono", "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --r: 6px; --r-sm: 4px;
  --sidebar-w: 236px; --topbar-h: 52px;

  /* thème clair (défaut) */
  color-scheme: light;
  --bg: #F3F5F0;
  --surface: #FFFFFF;
  --surface-2: #F8F9F6;
  --surface-3: #EEF1EA;
  --hover: #F1F4EE;
  --border: #DCE1D6;
  --border-strong: #C5CCBD;
  --text: #1A1E1B;
  --text-2: #4B534D;
  --text-3: #7B847C;
  --primary: var(--leaf-600);
  --primary-hover: #35714A;
  --on-primary: #FFFFFF;
  --link: #2F6B44;
  --focus: rgba(64, 133, 86, .38);
  --success: var(--leaf-600);
  --success-bg: #E8F2E6;
  --warn: #9E7421;
  --warn-dot: var(--ochre);
  --warn-bg: #F8F0DD;
  --danger: #B04732;
  --danger-dot: var(--terracotta);
  --danger-bg: #F8E6E1;
  --info: var(--lake);
  --info-bg: #E4EEF1;
  --neutral-dot: #A3ABA4;
  --sidebar-bg: #FAFBF8;
  --sidebar-text: #3F4741;
  --sidebar-text-2: #7B847C;
  --sidebar-active: #E7EEE2;
  --sidebar-active-text: #1F4A2F;
  --sidebar-border: var(--border);
  --code-bg: #F1F3EE;
  --backdrop: rgba(21, 23, 26, .42);
  --banner-bg: #F3E6C6;
  --banner-text: #5D4310;
  --banner-border: #DDC48A;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--ink-900);
  --surface: #23262A;
  --surface-2: #272B2F;
  --surface-3: #2C3135;
  --hover: #2A2F33;
  --border: #33383D;
  --border-strong: #41474D;
  --text: var(--snow-50);
  --text-2: #B5BDB3;
  --text-3: #858D86;
  --primary: var(--sage-300);
  --primary-hover: #A7CE8C;
  --on-primary: var(--ink-950);
  --link: var(--sage-300);
  --focus: rgba(147, 192, 116, .45);
  --success: var(--sage-300);
  --success-bg: rgba(97, 159, 96, .16);
  --warn: #E0B65E;
  --warn-dot: var(--ochre);
  --warn-bg: rgba(201, 154, 59, .15);
  --danger: #E07A65;
  --danger-dot: var(--terracotta);
  --danger-bg: rgba(196, 85, 63, .16);
  --info: #7FAFBF;
  --info-bg: rgba(79, 127, 143, .2);
  --neutral-dot: #6A726B;
  --sidebar-bg: var(--forest-900);
  --sidebar-text: #D5DED1;
  --sidebar-text-2: #8FA594;
  --sidebar-active: rgba(147, 192, 116, .13);
  --sidebar-active-text: #E6F0DE;
  --sidebar-border: #1D3D31;
  --code-bg: #2B3034;
  --backdrop: rgba(0, 0, 0, .58);
  --banner-bg: #3A2F17;
  --banner-text: #F0D493;
  --banner-border: #5C4A22;
}

/* --- Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 14px/1.45 var(--font); font-feature-settings: "kern" 1;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.005em; }
h1 { font-size: 19px; line-height: 1.3; }
h2 { font-size: 15px; line-height: 1.35; }
h3 { font-size: 13.5px; }
p { margin: 0 0 12px; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, kbd, .mono { font-family: var(--mono); font-size: .92em; }
small { font-size: 12px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
::selection { background: rgba(147, 192, 116, .35); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 3px; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden, [hidden] { display: none !important; }

/* --- Icônes --------------------------------------------------------------- */
.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.i-sm { width: 14px; height: 14px; }
.i-lg { width: 20px; height: 20px; }

/* --- Coquille applicative ------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  background: var(--sidebar-bg); color: var(--sidebar-text); border-right: 1px solid var(--sidebar-border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px; color: inherit; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 6px; display: block; }
.brand-name { font-weight: 600; font-size: 14.5px; letter-spacing: -.01em; line-height: 1.1; }
.brand-sub { display: block; font-size: 11px; color: var(--sidebar-text-2); font-weight: 400; letter-spacing: .01em; }

.ctx-switch { margin: 4px 12px 10px; }
.ctx-switch label { display: block; font-size: 11px; color: var(--sidebar-text-2); margin: 0 0 4px 2px; }
.ctx-switch select {
  width: 100%; height: 32px; border-radius: var(--r); border: 1px solid var(--sidebar-border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; padding: 0 8px;
}
:root[data-theme="dark"] .ctx-switch select { background: rgba(0,0,0,.18); color: var(--sidebar-text); }
.ctx-current { margin: 2px 12px 10px; padding: 8px 10px; border: 1px solid var(--sidebar-border); border-radius: var(--r); font-size: 12.5px; }
.ctx-current b { display: block; font-weight: 600; font-size: 13px; color: var(--sidebar-active-text); }

.nav { padding: 4px 8px 16px; flex: 1; }
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 2px; }
.nav-label { font-size: 11px; font-weight: 500; color: var(--sidebar-text-2); padding: 0 10px 4px; letter-spacing: .02em; }
.nav a {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: var(--r);
  color: var(--sidebar-text); font-size: 13.5px; text-decoration: none;
}
.nav a:hover { background: var(--sidebar-active); text-decoration: none; }
.nav a.active { background: var(--sidebar-active); color: var(--sidebar-active-text); font-weight: 500; }
.nav a.active .i { color: var(--primary); }
:root[data-theme="dark"] .nav a.active .i { color: var(--sage-300); }
.nav a .count { margin-left: auto; font-size: 11.5px; color: var(--sidebar-text-2); font-variant-numeric: tabular-nums; }
.nav a .count.alert { color: var(--warn); font-weight: 600; }
.sidebar-foot { padding: 10px 16px 14px; font-size: 11px; color: var(--sidebar-text-2); border-top: 1px solid var(--sidebar-border); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: 16px;
  padding: 0 24px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); min-width: 0; white-space: nowrap; overflow: hidden; }
.crumbs a { color: var(--text-2); }
.crumbs .sep { color: var(--text-3); }
.crumbs span:last-child { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.search { position: relative; width: 300px; }
.search .i { position: absolute; left: 9px; top: 8px; color: var(--text-3); }
.search input[type="search"] {
  width: 100%; height: 32px; padding: 0 44px 0 30px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}
.search input[type="search"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.search kbd { position: absolute; right: 8px; top: 7px; font-size: 11px; color: var(--text-3); border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; line-height: 16px; background: var(--surface-2); }

.usermenu { position: relative; }
.usermenu > button {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px 0 4px; border: 1px solid transparent; border-radius: var(--r);
  background: none; color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.usermenu > button:hover { border-color: var(--border); background: var(--surface); }
.avatar { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--forest-700); color: var(--snow-50); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.menu {
  position: absolute; right: 0; top: 38px; min-width: 240px; padding: 6px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r);
  box-shadow: 0 6px 24px rgba(0,0,0,.08);
}
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-head b { display: block; font-weight: 600; }
.menu-head span { font-size: 12px; color: var(--text-2); }
.menu a, .menu button.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: var(--r-sm);
  color: var(--text); font: inherit; font-size: 13px; background: none; border: 0; cursor: pointer; text-align: left;
}
.menu a:hover, .menu button.menu-item:hover { background: var(--hover); text-decoration: none; }
.menu .theme-row { display: flex; gap: 4px; padding: 6px 10px 8px; }
.menu .theme-row button { flex: 1; height: 28px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); border-radius: var(--r-sm); cursor: pointer; display: grid; place-items: center; }
.menu .theme-row button[aria-pressed="true"] { border-color: var(--primary); color: var(--text); background: var(--surface); }
.menu hr { margin: 4px 0; }
.menu .menu-label { font-size: 11.5px; color: var(--text-3); padding: 2px 10px 0; }

.support-banner {
  display: flex; align-items: center; gap: 12px; padding: 8px 24px; font-size: 13px;
  background: var(--banner-bg); color: var(--banner-text); border-bottom: 1px solid var(--banner-border);
}
.support-banner .i { color: var(--ochre); }
.support-banner form { margin-left: auto; }
.support-banner button { height: 26px; padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--banner-border); background: transparent; color: inherit; font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; }
.support-banner button:hover { background: rgba(0,0,0,.05); }

.content { padding: 22px 24px 48px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-head .titles { min-width: 0; flex: 1; }
.page-head p.sub { margin: 4px 0 0; color: var(--text-2); font-size: 13px; max-width: 760px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.title-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* --- Boutons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--r); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger-dot); }
.btn-danger.solid { background: var(--terracotta); border-color: var(--terracotta); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-block { width: 100%; height: 36px; }
.btn-icon { width: 28px; padding: 0; height: 28px; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inline { display: inline; margin: 0; }

/* --- Panneaux ------------------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.panel + .panel, .panel + .grid, .grid + .panel, .panel + .table-wrap, .table-wrap + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--border); min-height: 44px; }
.panel-head h2 { font-size: 13.5px; }
.panel-head .hint { font-size: 12.5px; color: var(--text-2); }
.panel-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.panel-body { padding: 16px; }
.panel-body > :last-child { margin-bottom: 0; }
.panel-foot { padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; color: var(--text-2); border-radius: 0 0 var(--r) var(--r); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.stack > * + * { margin-top: 16px; }

/* chiffres clés (bandeau compact, pas de cartes) */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 16px; }
.metric { padding: 12px 16px; border-left: 1px solid var(--border); min-width: 0; }
.metric:first-child { border-left: 0; }
.metric .label { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.metric .value { font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.01em; margin-top: 2px; line-height: 1.25; }
.metric .value small { font-size: 12.5px; color: var(--text-2); font-weight: 400; margin-left: 4px; }
.metric a { color: inherit; }

/* barre de répartition (conformité) */
.bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--surface-3); margin-top: 8px; }
.bar span { display: block; height: 100%; }
.bar .ok { background: var(--leaf-500); }
.bar .warn { background: var(--ochre); }
.bar .bad { background: var(--terracotta); }
.bar .none { background: var(--neutral-dot); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--text-2); }

/* --- Tableaux ------------------------------------------------------------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.table-wrap > table.data:first-child thead th:first-child { border-top-left-radius: var(--r); }
.table-wrap > table.data:first-child thead th:last-child { border-top-right-radius: var(--r); }
.panel .table-wrap { border: 0; border-radius: 0; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.data th {
  position: sticky; top: var(--topbar-h); z-index: 2; text-align: left; font-weight: 500; font-size: 12px; color: var(--text-2);
  background: var(--surface-2); padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.panel table.data th { top: 0; }
table.data td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--hover); }
table.data td.actions { text-align: right; white-space: nowrap; width: 1%; }
table.data td.actions .btn-group { justify-content: flex-end; flex-wrap: nowrap; }
table.data .primary-cell { font-weight: 500; color: var(--text); }
table.data .primary-cell a { color: inherit; }
table.data .sub { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; }
table.data td.min, table.data th.min { width: 1%; white-space: nowrap; }
table.data tr.row-muted td { color: var(--text-3); }
table.compact td, table.compact th { padding: 6px 12px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); border-radius: var(--r) var(--r) 0 0; }
.toolbar .grow { flex: 1; }
.toolbar input[type="search"], .toolbar select, .toolbar input[type="date"] { height: 30px; font-size: 13px; }
.toolbar input[type="search"] { width: 240px; }
.toolbar .count { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.filter-chips { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r); overflow: hidden; }
.filter-chips a { padding: 0 10px; height: 28px; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); border-left: 1px solid var(--border); }
.filter-chips a:first-child { border-left: 0; }
.filter-chips a:hover { background: var(--hover); text-decoration: none; }
.filter-chips a.on { background: var(--surface-3); color: var(--text); font-weight: 500; }
.filter-chips .n { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.pager { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.pager .btn-group .btn { height: 26px; }

/* --- Statuts, codes, puces ------------------------------------------------ */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; color: var(--text); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--neutral-dot); flex: none; }
.status.ok::before { background: var(--leaf-500); }
.status.warn::before { background: var(--warn-dot); }
.status.bad::before { background: var(--danger-dot); }
.status.info::before { background: var(--lake); }
.status.off { color: var(--text-3); }
.status.ring::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--neutral-dot); }

.code {
  font-family: var(--mono); font-size: 12.5px; letter-spacing: .02em; padding: 1px 6px; border-radius: var(--r-sm);
  background: var(--code-bg); border: 1px solid var(--border); color: var(--text); white-space: nowrap; font-weight: 500;
}
.fp { font-family: var(--mono); font-size: 12px; color: var(--text-2); word-break: break-all; }
.pkg { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11.5px; font-weight: 500; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.tag.beta { background: var(--info-bg); color: var(--info); }
.tag.req { background: var(--success-bg); color: var(--success); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--danger-bg); color: var(--danger); }

.app-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-icon { width: 28px; height: 28px; border-radius: 7px; flex: none; background: var(--surface-3); object-fit: cover; border: 1px solid var(--border); }
.app-icon.lg { width: 48px; height: 48px; border-radius: 11px; }
.app-icon.ph { display: grid; place-items: center; color: var(--text-3); font-size: 12px; font-weight: 600; }

/* --- Paires clé / valeur -------------------------------------------------- */
dl.kv { display: grid; grid-template-columns: minmax(140px, 200px) minmax(0, 1fr); margin: 0; font-size: 13px; }
dl.kv dt { color: var(--text-2); padding: 8px 16px; border-bottom: 1px solid var(--border); }
dl.kv dd { margin: 0; padding: 8px 16px 8px 0; border-bottom: 1px solid var(--border); min-width: 0; overflow-wrap: anywhere; }
dl.kv dt:last-of-type, dl.kv dd:last-of-type { border-bottom: 0; }
dl.kv.tight dt, dl.kv.tight dd { padding-top: 6px; padding-bottom: 6px; }

/* --- Onglets -------------------------------------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 12px 9px; font-size: 13px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--primary); font-weight: 500; }
.tabs .n { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* --- Formulaires ---------------------------------------------------------- */
.form { max-width: 640px; }
.form.wide { max-width: none; }
.field { margin-bottom: 16px; }
.field > label, .field > .label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.field .help { font-size: 12.5px; color: var(--text-2); margin-top: 5px; }
.field .error { font-size: 12.5px; color: var(--danger); margin-top: 5px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger-dot); }
.optional { font-weight: 400; color: var(--text-3); font-size: 12px; margin-left: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"],
input[type="search"], input[type="date"], input[type="datetime-local"], select, textarea {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px;
}
textarea { height: auto; min-height: 88px; padding: 8px 10px; line-height: 1.45; resize: vertical; }
select { padding-right: 28px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input[readonly] { background: var(--surface-2); }
input.code-input { font-family: var(--mono); font-size: 16px; letter-spacing: .12em; text-transform: uppercase; }
input.otp { font-family: var(--mono); font-size: 20px; letter-spacing: .32em; text-align: center; height: 44px; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input { margin: 2px 0 0; width: 15px; height: 15px; accent-color: var(--leaf-600); flex: none; }
.check .help { margin-top: 2px; }
.radio-cards { display: grid; gap: 8px; }
.radio-cards label { display: flex; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r); cursor: pointer; }
.radio-cards label:hover { background: var(--hover); }
.radio-cards input { accent-color: var(--leaf-600); margin-top: 3px; }
.radio-cards b { display: block; font-weight: 500; font-size: 13.5px; }
.radio-cards span { font-size: 12.5px; color: var(--text-2); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.form-actions { display: flex; gap: 8px; align-items: center; padding-top: 4px; }
.form-actions .grow { flex: 1; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; }
.section-title { font-size: 12px; font-weight: 500; color: var(--text-2); margin: 20px 0 10px; letter-spacing: .02em; }

/* --- Alertes / notes ------------------------------------------------------ */
.note { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; color: var(--text-2); margin-bottom: 16px; }
.note .i { margin-top: 1px; }
.note.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.note.bad { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.note.ok { background: var(--success-bg); border-color: transparent; color: var(--success); }
.note.info { background: var(--info-bg); border-color: transparent; color: var(--info); }
.note b { color: var(--text); font-weight: 600; }
.note p { margin: 0; }
.note > div > p + p { margin-top: 4px; }

.empty { padding: 32px 24px; text-align: left; color: var(--text-2); font-size: 13px; }
.empty h3 { color: var(--text); font-size: 13.5px; margin-bottom: 4px; }
.empty p { max-width: 560px; }

.secret-box { font-family: var(--mono); font-size: 13px; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: var(--r); background: var(--surface-2); word-break: break-all; display: flex; gap: 10px; align-items: center; }
.secret-box span { flex: 1; }
.codes-grid { display: grid; grid-template-columns: repeat(2, max-content); gap: 6px 28px; font-family: var(--mono); font-size: 14px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }

/* --- Journal / timeline --------------------------------------------------- */
.log { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.log li { display: grid; grid-template-columns: 120px 18px minmax(0, 1fr); gap: 8px; padding: 7px 16px; border-bottom: 1px solid var(--border); align-items: baseline; }
.log li:last-child { border-bottom: 0; }
.log time { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.log .lvl { width: 7px; height: 7px; border-radius: 50%; background: var(--neutral-dot); align-self: start; justify-self: center; margin-top: 8px; /* aligné sur la première ligne, même si le message passe à la ligne */ }
.log .lvl.info { background: var(--leaf-500); }
.log .lvl.warn { background: var(--ochre); }
.log .lvl.error { background: var(--terracotta); }
.log .what { min-width: 0; }
.log .what b { font-weight: 500; }
.log .what .muted { font-size: 12.5px; }
pre.logbox { margin: 0; padding: 12px 16px; font: 12px/1.6 var(--mono); white-space: pre-wrap; color: var(--text-2); max-height: 520px; overflow: auto; }

/* --- Dialogues ------------------------------------------------------------ */
dialog {
  padding: 0; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text);
  width: min(460px, calc(100vw - 32px)); box-shadow: 0 16px 48px rgba(0,0,0,.18);
}
dialog::backdrop { background: var(--backdrop); }
dialog .dlg-body { padding: 18px 20px 6px; }
dialog h2 { font-size: 15px; margin-bottom: 8px; }
dialog p { color: var(--text-2); font-size: 13.5px; }
dialog .dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; }
dialog.wide { width: min(640px, calc(100vw - 32px)); }

/* --- Toasts --------------------------------------------------------------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 40px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px 10px 14px; border-radius: var(--r);
  background: var(--ink-800); color: var(--snow-50); font-size: 13px; border: 1px solid #383D42;
  box-shadow: 0 8px 28px rgba(0,0,0,.2); animation: toast-in .16s ease-out;
}
.toast .i { margin-top: 1px; }
.toast.success .i { color: var(--sage-300); }
.toast.warn .i, .toast.info .i { color: #E0B65E; }
.toast.error .i { color: #E8907D; }
.toast button { margin-left: auto; background: none; border: 0; color: #9BA39C; cursor: pointer; padding: 0 0 0 6px; }
.toast.leaving { opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* --- Progression d'envoi -------------------------------------------------- */
.dropzone { border: 1px dashed var(--border-strong); border-radius: var(--r); padding: 18px; display: flex; gap: 14px; align-items: center; background: var(--surface-2); }
.dropzone.drag { border-color: var(--primary); background: var(--success-bg); }
.dropzone .grow { flex: 1; min-width: 0; }
.dropzone b { font-weight: 500; }
progress { width: 100%; height: 6px; appearance: none; border: 0; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--surface-3); border-radius: 3px; }
progress::-webkit-progress-value { background: var(--leaf-500); border-radius: 3px; }
progress::-moz-progress-bar { background: var(--leaf-500); border-radius: 3px; }
.upload-status { font-size: 12.5px; color: var(--text-2); margin-top: 6px; font-variant-numeric: tabular-nums; }

/* --- QR ------------------------------------------------------------------- */
.qr-wrap { display: flex; gap: 20px; align-items: flex-start; }
.qr-wrap svg.qr { width: 176px; height: 176px; border-radius: var(--r); border: 1px solid var(--border); flex: none; }

/* --- Pages d'authentification -------------------------------------------- */
.auth { display: grid; grid-template-columns: minmax(380px, 44%) minmax(0, 1fr); min-height: 100vh; }
.auth-art {
  position: relative; background: var(--ink-900); color: var(--snow-50); display: flex; flex-direction: column;
  padding: 28px 36px; overflow: hidden; border-right: 1px solid #111316;
}
.auth-art .art { flex: 1; display: grid; place-items: center; padding: 24px 0; }
.auth-art .art img { width: min(420px, 82%); height: auto; display: block; mix-blend-mode: lighten; /* fond du JPEG fondu dans le panneau ink */ }
.auth-art .art-foot { display: flex; justify-content: space-between; font-size: 12px; color: #8C948D; }
.auth-art .wordmark { font-weight: 600; font-size: 15px; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.auth-art .wordmark span { color: #8C948D; font-weight: 400; font-size: 12.5px; }
.auth-art .ribbon { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, var(--forest-700), var(--leaf-500) 55%, var(--sage-300)); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 372px; }
.auth-card h1 { font-size: 21px; margin-bottom: 4px; }
.auth-card .lead { color: var(--text-2); font-size: 13.5px; margin-bottom: 24px; }
.auth-card .alt { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12px; margin: 18px 0; }
.auth-card .alt::before, .auth-card .alt::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.auth-card .foot { margin-top: 28px; font-size: 12.5px; color: var(--text-3); }
.auth-card .foot a { color: var(--text-2); }
.steps { display: flex; gap: 6px; margin-bottom: 22px; }
.steps span { height: 3px; flex: 1; border-radius: 2px; background: var(--border); }
.steps span.on { background: var(--primary); }
.method-switch { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; font-size: 13px; }

.bare { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.bare .box { max-width: 520px; }
.bare .box .code-big { font: 500 13px var(--mono); color: var(--text-3); margin-bottom: 8px; }

/* --- Divers --------------------------------------------------------------- */
.kbd-hint { font-size: 12px; color: var(--text-3); }
.split { display: flex; gap: 8px; align-items: center; }
.split .grow { flex: 1; min-width: 0; }
.diff-up { color: var(--warn); }
.diff-ok { color: var(--success); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.right { margin-left: auto; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.w-auto { width: auto; }

/* --- Adaptatif ------------------------------------------------------------ */
@media (max-width: 1100px) {
  .grid-main, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .search { width: 220px; }
  .table-wrap { overflow-x: auto; }
  table.data th { position: static; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  /* Barre latérale repliée en bandeau : navigation sur une ligne défilante, sans libellés de groupe. */
  .sidebar { position: static; height: auto; overflow: visible; border-right: 0; border-bottom: 1px solid var(--sidebar-border); }
  .brand { padding: 10px 16px 8px; }
  .ctx-switch, .ctx-current { margin: 0 12px 8px; }
  .nav { display: flex; gap: 2px; overflow-x: auto; padding: 0 8px 8px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-group, .nav-group:first-child { display: flex; gap: 2px; margin: 0; }
  .nav-label, .sidebar-foot { display: none; }
  .nav a { white-space: nowrap; flex: none; }
  .page-head { flex-wrap: wrap; }
  .page-head .titles { flex-basis: 100%; }
  .page-head .actions { justify-content: flex-start; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { border-left: 0; border-top: 1px solid var(--border); }
  .metric:nth-child(-n+2) { border-top: 0; }
  .metric:nth-child(even) { border-left: 1px solid var(--border); }
  .log li { grid-template-columns: 10px minmax(0, 1fr); column-gap: 8px; row-gap: 2px; }
  .log time { grid-column: 2; grid-row: 1; }
  .log .lvl { grid-column: 1; grid-row: 2; margin-top: 7px; }
  .log .what { grid-column: 2; grid-row: 2; }
  .usermenu > button > span:not(.avatar) { display: none; } /* avatar seul : le fil d’Ariane garde la place */
  .grid-2, .form-row, .form-row-3 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { min-height: 220px; }
  .search { display: none; }
  table.data th { position: static; }
  .content { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print { .sidebar, .topbar, .toasts, .support-banner { display: none; } .shell { display: block; } }

.upload-status.error { color: var(--danger); }
.form-error { font-size: 12.5px; color: var(--danger); margin: 8px 0 0; }
.grow { flex: 1; min-width: 0; }
.note > .grow { display: block; }
.check .help { display: block; margin-top: 2px; font-weight: 400; }
table.data td.actions .inline-form { flex-wrap: nowrap; justify-content: flex-end; }
table.data td.actions .inline-form select { min-width: 140px; }
/* Contrôles en ligne dans les tableaux denses : hauteur alignée sur les boutons compacts de la ligne. */
table.data td select, table.data td input[type="text"], table.data td input[type="number"] { height: 28px; font-size: 13px; border-radius: var(--r-sm); }
table.data td .btn-sm { height: 28px; }
