/* ===========================================================
   PandaTag Desktop — Stylesheet
   =========================================================== */

:root {
  --bg:        #384454;
  --bg-deep:   #2b3543;
  --fg:        #eaf2ff;
  --muted:     #c8d2e3;
  --dim:       #8895a8;
  --card:      #2f3a48;
  --card-hi:   #38465a;
  --line:      #223043;
  --line-soft: #3a4759;
  --interact:  #233041;
  --accent:    #0086d6;
  --accent-h:  #1aa0f0;
  --brand:     #b6d8f2;
  --note:      #E1A624;
  --white:     #ffffff;
  --ok:        #2ecc71;
  --warn:      #f59e0b;
  --err:       #ef4444;
  --shadow-md: 0 10px 30px rgba(0,0,0,.35);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.25);
  --radius:    12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --topbar-h:  60px;
  --content-max: 1680px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-width: 1100px;
  min-height: 100vh;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--accent-h); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.16); }

/* ============== App layout ============== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
  transition: grid-template-columns .25s ease;
}
.app.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ============== Topbar ============== */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px 0 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 30;
}
.tb-brand {
  display: flex; align-items: center; gap: 10px;
  width: var(--sidebar-w);
  padding-right: 12px;
  margin-right: 4px;
  flex-shrink: 0;
  transition: width .25s ease;
}
.app.sidebar-collapsed .tb-brand { width: var(--sidebar-w-collapsed); }
.tb-brand img { width: 30px; height: 30px; }
.tb-brand .name {
  font-weight: 800; letter-spacing: -0.01em; font-size: 16px;
  display: flex; flex-direction: column;
}
.tb-brand .name b { color: var(--white); }
.tb-brand .name small {
  font-size: 10px; color: var(--dim); font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; line-height: 1;
}
.app.sidebar-collapsed .tb-brand .name { display: none; }

.tb-search {
  flex: 1;
  max-width: 460px;
  display: flex; align-items: center; gap: 8px;
  background: var(--interact);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--muted);
  transition: border-color .15s, background .15s;
}
.tb-search:focus-within { border-color: var(--accent); background: var(--bg-deep); }
.tb-search input {
  background: transparent; border: 0; outline: 0; flex: 1; font-size: 13.5px; font-weight: 500;
}
.tb-search input::placeholder { color: var(--dim); }
.tb-search .kbd {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  padding: 2px 6px; background: rgba(255,255,255,.08); border-radius: 5px; color: var(--muted);
}

.tb-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.tb-icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 8px;
  color: var(--muted); font-size: 18px;
  transition: background .12s, color .12s;
}
.tb-icon-btn:hover { background: rgba(255,255,255,.06); color: var(--white); }
.tb-user {
  display: flex; align-items: center; gap: 10px;
  background: var(--interact); border: 1px solid var(--line);
  padding: 5px 12px 5px 5px; border-radius: 999px;
  color: var(--fg); font-weight: 600; font-size: 13px;
}
.tb-user:hover { border-color: var(--accent); }
.tb-avatar {
  width: 28px; height: 28px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #5ec5ff);
  display: grid; place-items: center; color: white; font-weight: 800; font-size: 12px;
}

/* ============== Sidebar ============== */
.sidebar {
  background: var(--bg-deep);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 20;
}
.sb-section-title {
  padding: 16px 20px 8px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--dim);
}
.app.sidebar-collapsed .sb-section-title { padding: 16px 0 8px; text-align: center; }
.app.sidebar-collapsed .sb-section-title span { display: none; }
.app.sidebar-collapsed .sb-section-title::before {
  content: ''; display: block; height: 1px; background: var(--line); margin: 6px 14px 0;
}

.sb-nav { padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; }
.sb-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600; font-size: 13.5px;
  border: 0; background: transparent;
  text-align: left; width: 100%;
  position: relative;
  transition: background .12s, color .12s;
}
.sb-item .mdi { font-size: 20px; width: 22px; text-align: center; flex-shrink: 0; color: var(--dim); }
.sb-item:hover { background: rgba(0, 134, 214, .14); color: var(--white); }
.sb-item:hover .mdi { color: var(--brand); }
.sb-item.active {
  background: var(--accent); color: var(--white);
  box-shadow: 0 4px 14px rgba(0, 134, 214, .35);
}
.sb-item.active .mdi { color: var(--white); }
.sb-item .badge {
  margin-left: auto;
  background: rgba(255,255,255,.12); color: var(--fg);
  padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
}
.sb-item.active .badge { background: rgba(255,255,255,.22); color: var(--white); }
.app.sidebar-collapsed .sb-item { justify-content: center; padding: 11px 0; }
.app.sidebar-collapsed .sb-item .label,
.app.sidebar-collapsed .sb-item .badge { display: none; }
.app.sidebar-collapsed .sb-item .mdi { font-size: 22px; width: auto; }

.sb-spacer { flex: 1; }
.sb-bottom { padding: 10px 12px 14px; border-top: 1px solid var(--line); }
.sb-user-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: flex; align-items: center; gap: 10px;
}
.sb-user-card .name { font-weight: 700; font-size: 13px; color: var(--white); line-height: 1.1; }
.sb-user-card .email { font-size: 11px; color: var(--dim); }
.sb-user-card .logout-btn {
  margin-left: auto;
  background: transparent; border: 0; color: var(--dim);
  width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center;
}
.sb-user-card .logout-btn:hover { background: rgba(239,68,68,.12); color: var(--err); }
.app.sidebar-collapsed .sb-user-card { padding: 6px; justify-content: center; }
.app.sidebar-collapsed .sb-user-card .name,
.app.sidebar-collapsed .sb-user-card .email,
.app.sidebar-collapsed .sb-user-card .logout-btn { display: none; }

/* Numéro de version, sous la carte du compte. Discret : il se lit quand on le cherche,
   il ne tire pas l'œil le reste du temps. */
.sb-version {
  margin-top: 8px;
  text-align: center;
  font-size: 11px;
  color: var(--dim);
  letter-spacing: .02em;
  user-select: text;
}
.app.sidebar-collapsed .sb-version { font-size: 10px; margin-top: 6px; }

.sb-toggle {
  background: transparent; border: 1px solid var(--line);
  border-radius: 8px; height: 32px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted); font-weight: 600; font-size: 12px;
  margin: 8px 12px 0;
  transition: background .12s, color .12s;
}
.sb-toggle:hover { background: var(--interact); color: var(--white); }
.app.sidebar-collapsed .sb-toggle .label { display: none; }

/* ============== Content area ============== */
.content {
  background: var(--bg);
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}
.view {
  /* padding: 28px clamp(28px, 3vw, 56px) 60px; */
      padding: 20px;
      /* padding: 10px 0px 10px 0px; */
  /* max-width: var(--content-max); */
  margin: 0 auto;
}

/* En plein écran on laisse le contenu respirer (max-width plus large) */
@media (display-mode: fullscreen) {
  .view { max-width: 1880px; }
}
:fullscreen .view,
:-webkit-full-screen .view,
.is-fullscreen .view { max-width: 1880px; }

.view-header {
  display: flex; align-items: end; justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}
.view-title {
  font-size: 24px; font-weight: 800; letter-spacing: -0.02em;
  color: var(--white); margin: 0 0 2px;
}
.view-sub { color: var(--muted); font-size: 14px; margin: 0; }

/* ============== Cards ============== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.card-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 700; color: var(--white);
  margin: 0 0 14px;
}
.card-title .mdi { color: var(--brand); font-size: 20px; }
.card-section + .card-section { margin-top: 18px; }
.card-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.card-row:last-child { border-bottom: 0; }
.card-row .k { color: var(--muted); font-size: 13px; }
.card-row .v { color: var(--white); font-weight: 600; font-size: 13px; }

/* Masterspool info card (détail bobine) */
.spool-info-card {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 14px;
  align-items: center;
}
.sic-left { display: flex; justify-content: center; align-items: center; }
.sic-image {
  width: 80px; height: 80px; object-fit: contain;
  border-radius: 8px;
  padding: 4px;
}
.sic-placeholder {
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
  background: var(--interact, rgba(255,255,255,0.05));
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 38px;
}
.sic-right { display: grid; gap: 4px; min-width: 0; }
.sic-name {
  font-size: 15px; font-weight: 700;
  color: var(--white); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis;
}
.sic-sub { font-size: 12px; color: var(--muted); }
.sic-weight { font-weight: 700; color: var(--white); }

/* ============== Buttons ============== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  background: var(--interact);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 600; font-size: 13px;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn .mdi { font-size: 18px; }
.btn:hover { background: var(--card-hi); border-color: var(--line-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(255,255,255,.06); }
.btn.danger { background: rgba(239,68,68,.12); color: var(--err); border-color: rgba(239,68,68,.3); }
.btn.danger:hover { background: rgba(239,68,68,.2); }
.btn.note { background: rgba(225,166,36,.14); color: var(--note); border-color: rgba(225,166,36,.35); }
.btn.full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-group { display: inline-flex; background: var(--interact); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.btn-group button {
  background: transparent; border: 0; color: var(--muted);
  padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 12.5px;
  display: flex; align-items: center; gap: 6px;
}
.btn-group button .mdi { font-size: 16px; }
.btn-group button.active { background: var(--card-hi); color: var(--white); }
.btn-group button:not(.active):hover { color: var(--white); }

/* ============== Inputs / Forms ============== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field-label {
  font-size: 12px; font-weight: 600; color: var(--muted);
  letter-spacing: 0.02em;
}
.input, .select, textarea.input {
  background: var(--interact);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--fg);
  font-size: 13.5px;
  outline: none;
  transition: border-color .12s, background .12s;
  width: 100%;
}
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--accent);
  background: var(--bg-deep);
}
.input::placeholder { color: var(--dim); }

.field-grid { display: grid; gap: 14px; }
.field-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.field-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px;
  background: var(--line); border-radius: 999px;
  outline: none;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 999px;
  background: var(--accent); border: 2px solid var(--white);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 999px; background: var(--accent); border: 2px solid white; cursor: pointer;
}

/* ============== Tags / badges ============== */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  background: rgba(255,255,255,.08);
  color: var(--muted);
  letter-spacing: 0.02em;
}
.tag .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.tag.ok    { background: rgba(46,204,113,.15); color: var(--ok); }
.tag.warn  { background: rgba(245,158,11,.15); color: var(--warn); }
.tag.err   { background: rgba(239,68,68,.15);  color: var(--err); }
.tag.info  { background: rgba(0,134,214,.18);  color: #5fb7eb; }
.tag.note  { background: rgba(225,166,36,.15); color: var(--note); }

/* status pills with icon */
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 700;
}
.status-pill.commande { background: rgba(0,134,214,.15);  color: #5fb7eb; }
.status-pill.neuf     { background: rgba(46,204,113,.15); color: var(--ok); }
.status-pill.ouvert   { background: rgba(245,158,11,.15); color: var(--warn); }
.status-pill.vide     { background: rgba(239,68,68,.15);  color: var(--err); }

/* ============== Spool component ============== */
.spool {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}
.spool svg { width: 100%; height: 100%; display: block; }

/* ============== Color swatches ============== */
.swatch {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 999px;
  border: 1.5px solid rgba(255,255,255,.25);
  vertical-align: middle;
  flex-shrink: 0;
}
.swatch-stack { display: inline-flex; gap: -4px; }
.swatch-stack .swatch + .swatch { margin-left: -5px; }

/* ============== Filament gauge ============== */
.gauge {
  position: relative;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.gauge .fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width .4s ease;
}
.gauge.ok   .fill { background: linear-gradient(90deg, var(--ok), #50e58c); }
.gauge.warn .fill { background: linear-gradient(90deg, var(--warn), #fbbf41); }
.gauge.err  .fill { background: linear-gradient(90deg, var(--err), #f97070); }

.gauge-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; font-weight: 600;
  color: var(--muted); margin-bottom: 5px;
}
.gauge-row .pct { color: var(--white); font-variant-numeric: tabular-nums; }

/* ============== Inventory ============== */
.inv-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px;
  margin-bottom: 18px;
}
.inv-toolbar .search {
  flex: 1; min-width: 240px; max-width: 460px;
  display: flex; align-items: center; gap: 8px;
  background: var(--interact); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px;
}
.inv-toolbar .search input { background: transparent; border: 0; outline: 0; flex: 1; color: var(--fg); font-size: 13.5px; }

.inv-stats { display: flex; gap: 14px; padding: 0 8px; }
.inv-stat .k { font-size: 10.5px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }
.inv-stat .v { font-size: 16px; font-weight: 800; color: var(--white); }
.inv-stat .v small { font-weight: 600; color: var(--muted); font-size: 11px; }

.inv-layout {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 20px;
  align-items: start;
}
.inv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.inv-grid.dense { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }

.inv-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
  display: flex; flex-direction: column; gap: 10px;
  position: relative;
}
.inv-card:hover { transform: translateY(-2px); border-color: var(--line-soft); box-shadow: var(--shadow-sm); }
.inv-card .head { display: flex; align-items: flex-start; gap: 12px; }
.inv-card .spool { width: 60px; height: 60px; }
.inv-card .meta { flex: 1; min-width: 0; }
.inv-card .brand-row { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--white); font-size: 13px; }
.inv-card .brand-row .brand-mark {
  width: 18px; height: 18px; border-radius: 4px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: 9px; color: white;
}
.inv-card .material { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.inv-card .color-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 11.5px; color: var(--muted); }
.inv-card .note-badge {
  position: absolute; top: 10px; right: 10px;
  width: 22px; height: 22px; border-radius: 8px;
  background: rgba(225,166,36,.18); color: var(--note);
  display: grid; place-items: center; font-size: 13px;
}
.inv-card .footer { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--dim); margin-top: 4px; }
.inv-card .tagid { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; }

/* Stock view (dense table) */
.inv-table { width: 100%; border-collapse: collapse; }
.inv-table thead { background: var(--bg-deep); }
.inv-table th {
  text-align: left; font-size: 11px; font-weight: 700; color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.inv-table tbody tr {
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background .12s;
}
.inv-table tbody tr:hover { background: rgba(255,255,255,.025); }
.inv-table td { padding: 10px 12px; font-size: 13px; }
.inv-table .spool-cell { display: flex; align-items: center; gap: 10px; }
.inv-table .spool-cell .spool { width: 36px; height: 36px; }
.inv-table .gauge-cell { display: flex; align-items: center; gap: 8px; }
.inv-table .gauge-cell .gauge { width: 80px; }
.inv-table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }

/* Filter panel */
.filter-panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px;
  position: sticky; top: 12px;
  display: flex; flex-direction: column; gap: 16px;
}
.filter-group { display: flex; flex-direction: column; gap: 8px; }
.filter-group .title {
  font-size: 11px; font-weight: 700; color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.1em;
}
.filter-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-pill {
  padding: 6px 11px; font-size: 12px; font-weight: 600;
  background: var(--interact); border: 1px solid var(--line);
  border-radius: 999px; color: var(--muted);
}
.filter-pill:hover { background: var(--card-hi); color: var(--white); }
.filter-pill.active { background: var(--accent); color: var(--white); border-color: var(--accent); }

/* ============== Home dashboard ============== */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 22px;
  margin-bottom: 22px;
}
.hero-main {
  background:
    radial-gradient(circle at 88% 12%, rgba(0,134,214,0.4), transparent 55%),
    radial-gradient(circle at 12% 92%, rgba(182,216,242,0.18), transparent 55%),
    linear-gradient(140deg, #1a2433, #2f3a48);
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  padding: 32px 34px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.hero-main::after {
  content: ''; position: absolute;
  width: 380px; height: 380px;
  right: -120px; top: -120px;
  background: radial-gradient(circle, rgba(0,134,214,.18), transparent 70%);
  pointer-events: none;
}
.hero-main h1 {
  font-size: 30px; line-height: 1.15; font-weight: 800;
  letter-spacing: -0.025em; margin: 0 0 8px;
  color: var(--white);
}
.hero-main h1 b { color: var(--brand); }
.hero-main p { color: var(--muted); margin: 0 0 20px; max-width: 540px; }
.hero-main .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-main .actions .btn { padding: 11px 18px; }
.hero-main .actions .btn .mdi { font-size: 20px; }

.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
}
.kpi .icon {
  position: absolute; top: 12px; right: 12px;
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(0,134,214,.15); color: var(--brand);
  display: grid; place-items: center; font-size: 16px;
}
.kpi .label { font-size: 11px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; }
.kpi .value { font-size: 24px; font-weight: 800; color: var(--white); letter-spacing: -0.01em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .value small { font-weight: 600; font-size: 13px; color: var(--muted); margin-left: 4px; }
.kpi .delta { font-size: 11.5px; color: var(--ok); font-weight: 700; }
.kpi .delta.down { color: var(--err); }

/* spools mini stat */
.dashboard-grid {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px;
}
.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
}
.recent-item:hover { background: var(--interact); }
.recent-item .spool { width: 38px; height: 38px; flex-shrink: 0; }
.recent-item .info { flex: 1; min-width: 0; }
.recent-item .info .t { font-weight: 700; font-size: 13px; color: var(--white); }
.recent-item .info .s { font-size: 11px; color: var(--dim); }
.recent-item .when { font-size: 11px; color: var(--dim); }

/* Sparkline */
.sparkline { width: 100%; height: 50px; }
.sparkline .area { fill: rgba(0,134,214,.18); }
.sparkline .stroke { stroke: var(--accent); stroke-width: 2; fill: none; }

/* ============== Detail view ============== */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.detail-summary {
  display: flex; align-items: flex-start; gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.detail-summary .spool { width: 110px; height: 110px; flex-shrink: 0; }
.detail-summary .meta { flex: 1; min-width: 0; }
.detail-summary .brand { font-size: 18px; font-weight: 800; color: var(--white); display: flex; align-items: center; gap: 8px; }
.detail-summary .material { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.detail-summary .color { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.detail-summary .note {
  margin-top: 10px;
  background: rgba(225,166,36,.1); border: 1px solid rgba(225,166,36,.3);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; color: var(--note);
}

.specs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border-radius: 10px; overflow: hidden; }
.specs-grid .cell {
  background: var(--card-hi); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.specs-grid .cell .k { font-size: 10.5px; color: var(--dim); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.specs-grid .cell .v { font-size: 13.5px; color: var(--white); font-weight: 700; font-variant-numeric: tabular-nums; }

.tag-id-display {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  padding: 8px 10px; border-radius: 8px;
  font-size: 12.5px; color: var(--brand);
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}

/* QR card */
.qr-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.qr-card {
  background: var(--bg-deep); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.qr-card .preview {
  background: white; border-radius: 8px; padding: 12px;
  display: grid; place-items: center;
  aspect-ratio: 16 / 9;
}
.qr-card.vertical .preview { aspect-ratio: 9 / 16; max-height: 220px; margin: 0 auto; width: 60%; }
.qr-card .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.qr-card .actions .btn { padding: 6px 8px; font-size: 11.5px; justify-content: center; }
.qr-card .actions .btn .mdi { font-size: 15px; }
.qr-card h4 { margin: 0; font-size: 13px; color: var(--white); display: flex; align-items: center; gap: 6px; }

/* ============== Balance view ============== */
.balance-layout {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; align-items: start;
}
.weight-display {
  text-align: center;
  padding: 28px 14px 18px;
  background: var(--bg-deep);
  border-radius: 14px;
  margin-bottom: 14px;
}
.weight-display .number {
  font-size: 56px; font-weight: 800; letter-spacing: -0.04em;
  color: var(--white); font-variant-numeric: tabular-nums;
  line-height: 1;
}
.weight-display .number .unit { font-size: 22px; color: var(--muted); margin-left: 6px; font-weight: 700; }
.weight-display .label { color: var(--muted); font-size: 12.5px; margin-top: 6px; font-weight: 600; }

.big-gauge { height: 14px; border-radius: 999px; }
.big-gauge .fill { transition: width .25s ease; }

.detected-spool {
  display: flex; align-items: center; gap: 14px;
  padding: 12px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s;
}
.detected-spool:hover { border-color: var(--accent); }
.detected-spool .spool { width: 56px; height: 56px; }
.detected-spool .empty {
  color: var(--dim);
  font-size: 13px; font-style: italic;
}

.led {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 999px; background: var(--ok);
  box-shadow: 0 0 0 3px rgba(46,204,113,0.18);
  position: relative;
}
.led.offline { background: var(--err); box-shadow: 0 0 0 3px rgba(239,68,68,0.18); }
.led.pulse::after {
  content: ''; position: absolute; inset: -4px; border-radius: 999px;
  background: currentColor; opacity: 0.4;
  animation: pulse 1.5s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(1); opacity: .4; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* ============== Toast ============== */
.toast-stack {
  position: fixed; top: 76px; right: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200; pointer-events: none;
  width: 340px;
}
.toast {
  pointer-events: all;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex; align-items: flex-start; gap: 10px;
  box-shadow: var(--shadow-md);
  animation: toast-in .25s ease;
}
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.toast.success { border-left-color: var(--ok); }
.toast.error   { border-left-color: var(--err); }
.toast.warning { border-left-color: var(--warn); }
.toast.info    { border-left-color: var(--accent); }
.toast .mdi { font-size: 20px; flex-shrink: 0; padding-top: 1px; }
.toast.success .mdi { color: var(--ok); }
.toast.error .mdi { color: var(--err); }
.toast.warning .mdi { color: var(--warn); }
.toast.info .mdi { color: var(--accent); }
.toast .body { flex: 1; min-width: 0; }
.toast .title { font-weight: 700; color: var(--white); font-size: 13px; }
.toast .msg { color: var(--muted); font-size: 12px; }
.toast .close { background: 0; border: 0; color: var(--dim); padding: 0; font-size: 16px; cursor: pointer; }
.toast .close:hover { color: var(--white); }

/* ============== Modal ============== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 25, 33, .72);
  backdrop-filter: blur(4px);
  /* Le fond défile, pas la boîte : une modale plus haute que l'écran (zoom Windows,
     zoom navigateur, petit portable) reste atteignable jusqu'à son dernier bouton.
     C'est volontairement `flex-start` + `margin: auto` sur l'enfant, et non un centrage
     par `place-items` : centrer un enfant plus grand que son conteneur défile le fait
     déborder PAR LE HAUT, hors d'atteinte du défilement. */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 16px;
  z-index: 100;
  animation: fade-in .15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 22px;
  width: min(440px, 100%);   /* les marges viennent du padding du fond */
  box-shadow: var(--shadow-md);
  animation: pop-in .18s ease;
  /* Centre tant que la place le permet, se cale en haut dès qu'elle manque. */
  margin: auto;
  flex: 0 0 auto;
}
@keyframes pop-in { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { margin: 0 0 8px; font-size: 18px; font-weight: 800; color: var(--white); display: flex; align-items: center; gap: 10px; }
.modal h3 .mdi { color: var(--warn); font-size: 22px; }
.modal p { color: var(--muted); margin: 0 0 18px; font-size: 13.5px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Modal large for scanner */
.modal.lg { width: min(640px, 100%); }
.modal.scanner-modal { padding: 0; overflow: hidden; }
.scanner-stream {
  position: relative;
  background: black;
  aspect-ratio: 16 / 10;
}
.scanner-frame {
  position: absolute; inset: 50% auto auto 50%;
  width: 60%; aspect-ratio: 1; transform: translate(-50%, -50%);
  border: 2px solid var(--accent);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.55);
}
.scanner-frame::before, .scanner-frame::after,
.scanner-frame > i:nth-child(1), .scanner-frame > i:nth-child(2) {
  content: ''; position: absolute; width: 22px; height: 22px;
  border: 3px solid var(--white);
}
.scanner-frame::before { top: -3px; left: -3px; border-right: 0; border-bottom: 0; border-radius: 6px 0 0 0; }
.scanner-frame::after { bottom: -3px; right: -3px; border-left: 0; border-top: 0; border-radius: 0 0 6px 0; }
.scanner-frame > i:nth-child(1) { top: -3px; right: -3px; border-left: 0; border-bottom: 0; border-radius: 0 6px 0 0; }
.scanner-frame > i:nth-child(2) { bottom: -3px; left: -3px; border-right: 0; border-top: 0; border-radius: 0 0 0 6px; }
.scanner-laser {
  position: absolute;
  left: 8%; right: 8%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 12px var(--accent);
  animation: laser 2.4s ease-in-out infinite;
  top: 30%;
}
@keyframes laser {
  0%, 100% { top: 30%; opacity: 1; }
  50% { top: 68%; opacity: 1; }
}
.scanner-modal .head {
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
}
.scanner-modal .head h3 { margin: 0; }
.scanner-modal .foot { padding: 14px 18px; display: flex; gap: 10px; align-items: center; }

/* NFC pulse */
.nfc-pulse {
  position: relative; width: 200px; height: 200px;
  display: grid; place-items: center; margin: 24px auto;
}
.nfc-pulse i {
  position: absolute; inset: 0;
  border-radius: 50%; border: 2px solid var(--accent);
  animation: nfcWave 2s ease-out infinite;
  opacity: 0;
}
.nfc-pulse i:nth-child(2) { animation-delay: .5s; }
.nfc-pulse i:nth-child(3) { animation-delay: 1s; }
@keyframes nfcWave {
  0% { transform: scale(.4); opacity: .8; }
  100% { transform: scale(1.4); opacity: 0; }
}
.nfc-pulse .center {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--accent);
  display: grid; place-items: center;
  color: white; font-size: 38px;
  box-shadow: 0 8px 30px rgba(0,134,214,.5);
}

/* ============== Searchable select ============== */
.smart-select {
  position: relative;
}
.ss-trigger {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  background: var(--interact);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px; font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  transition: border-color .12s;
  text-align: left;
}
.ss-trigger:hover { border-color: var(--line-soft); }
.ss-trigger.open { border-color: var(--accent); }
.ss-trigger .mdi.chevron { margin-left: auto; color: var(--dim); }
.ss-trigger.placeholder { color: var(--dim); font-weight: 500; }

/* Logo de marque : même taille dans la liste et dans le champ refermé, pour que
   la ligne ne saute pas au moment du choix. */
.ss-logo {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  object-fit: contain;
  border-radius: 3px;
  background: rgba(255,255,255,.06);
}
.ss-pop {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  z-index: 50;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  max-height: 280px;
  display: flex; flex-direction: column;
}
.ss-search {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: var(--bg-deep);
  border-radius: 8px;
  margin-bottom: 4px;
}
.ss-search input { background: transparent; border: 0; outline: 0; flex: 1; color: var(--fg); font-size: 13px; }
.ss-list { overflow-y: auto; max-height: 220px; }
.ss-option {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--fg);
}
.ss-option:hover { background: var(--interact); }
.ss-option.active { background: var(--accent); color: var(--white); }
.ss-option .lead { width: 18px; flex-shrink: 0; display: grid; place-items: center; }
.ss-group {
  padding: 6px 10px 4px;
  font-size: 10.5px; font-weight: 700; color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.08em;
}

/* ============== Helper utility ============== */
.row { display: flex; align-items: center; gap: 8px; }
.row.gap-12 { gap: 12px; }
.row.gap-16 { gap: 16px; }
.row.gap-24 { gap: 24px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.center-text { text-align: center; }
.mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

.divider { height: 1px; background: var(--line); margin: 12px 0; }

/* fade transition for views */
.view-enter { animation: viewFade .22s ease; }
@keyframes viewFade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Auth view */
.auth-wrap {
  display: grid; place-items: center;
  min-height: calc(100vh - var(--topbar-h));
  padding: 24px;
  background:
    radial-gradient(circle at 20% 80%, rgba(0,134,214,.15), transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(182,216,242,.08), transparent 50%);
}
.auth-card {
  width: min(420px, 92vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 28px 22px;
  box-shadow: var(--shadow-md);
}
.auth-tabs { display: flex; background: var(--interact); padding: 4px; border-radius: 10px; margin-bottom: 22px; }
.auth-tabs button { flex: 1; background: transparent; border: 0; padding: 8px; color: var(--muted); font-weight: 700; border-radius: 8px; }
.auth-tabs button.active { background: var(--accent); color: var(--white); }

/* Help / shortcuts modal */
.shortcut-list { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.shortcut-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg-deep); border-radius: 8px; }
.shortcut-item .desc { color: var(--muted); font-size: 13px; }
.shortcut-item .keys { display: flex; gap: 4px; }
.kbd-key {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  padding: 3px 7px; background: var(--card-hi); border: 1px solid var(--line); border-radius: 5px;
  color: var(--white); font-weight: 600;
}

/* Login footer */
.auth-card h2 { margin: 0 0 6px; font-size: 22px; color: var(--white); font-weight: 800; letter-spacing: -0.02em; }
.auth-card .hint { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.auth-card .form { display: flex; flex-direction: column; gap: 12px; }
.auth-card .form .actions { margin-top: 6px; }

/* responsive */
@media (max-width: 1280px) {
  .inv-layout { grid-template-columns: 1fr; }
  .filter-panel { position: static; flex-direction: row; flex-wrap: wrap; }
  .filter-panel .filter-group { min-width: 200px; }
}
@media (max-width: 1100px) {
  body { min-width: 1000px; }
  .hero { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .balance-layout { grid-template-columns: 1fr; }
  .detail-layout { grid-template-columns: 1fr; }
}

/* ============== Balance view ============== */
.status-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--dim);
  box-shadow: 0 0 0 2px rgba(255,255,255,.06);
}
.status-dot.green { background: var(--ok); box-shadow: 0 0 0 2px rgba(46,204,113,.18); }
.status-dot.red   { background: var(--err); box-shadow: 0 0 0 2px rgba(239,68,68,.18); }

.bal-meter {
  display: flex; align-items: center; gap: 10px;
  margin-top: 4px;
}
.bal-meter-bar {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: #1f2a38;
  border: 1px solid var(--line);
  overflow: hidden;
}
.bal-meter-pct {
  font-size: 13px; font-weight: 800;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  min-width: 44px; text-align: right;
}

.bal-bobine {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 14px; align-items: center;
}
.bal-bobine-left { display: flex; align-items: center; justify-content: center; }
.bal-bobine-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

/* ============== Spool vertical (filament_v + core_v) ============== */
.spool-v {
  position: relative;
  display: block;
  --filament: #666;
}
.spool-v-filament-empty,
.spool-v-filament {
  position: absolute; inset: 0;
  pointer-events: none;
  -webkit-mask-image: url("assets/spool/filament_v.svg");
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
          mask-image: url("assets/spool/filament_v.svg");
          mask-repeat: no-repeat;
          mask-position: center;
          mask-size: contain;
}
/* Default: filament fully colored, no empty layer visible */
.spool-v-filament-empty { background: rgba(255,255,255,.06); display: none; }
.spool-v-filament { background: var(--filament); }

/* has-fill: show empty layer (full) + colored layer clipped symmetrically toward
   the center, mimicking a real spool emptying from both flanges toward the hub. */
.spool-v.has-fill .spool-v-filament-empty { display: block; }
.spool-v.has-fill .spool-v-filament {
  clip-path: inset(calc((100% - var(--fill-pct, 0%)) / 2) 0 calc((100% - var(--fill-pct, 0%)) / 2) 0);
  -webkit-clip-path: inset(calc((100% - var(--fill-pct, 0%)) / 2) 0 calc((100% - var(--fill-pct, 0%)) / 2) 0);
  transition: clip-path .3s ease;
}
.spool-v-core {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.spool-v .brand-logo {
  position: absolute;
  bottom: 4%; right: 4%;
  width: 28%; height: 28%;
  object-fit: contain;
  pointer-events: none;
  border-radius: 5px;
  padding: 2px;
}

/* ============== Spool avatar (style mobile) ============== */
.spool-avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  --filament: var(--interact);
}
.spool-avatar img.base {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.spool-avatar .filament {
  position: absolute; inset: 0;
  background: var(--filament);
  pointer-events: none;
  -webkit-mask-image: url("assets/spool/filament.svg");
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
          mask-image: url("assets/spool/filament.svg");
          mask-repeat: no-repeat;
          mask-position: center;
          mask-size: contain;
}
.spool-avatar .brand-logo {
  position: absolute;
  bottom: 0; right: 0;
  width: 35%; height: 35%;
  object-fit: contain;
  pointer-events: none;
  border-radius: 5px;
  padding: 2px;
}

/* ============== Inventory list — style mobile, 2 colonnes desktop ============== */
.mobile-inv-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.mi-item {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .08s;
}
.mi-item:hover { background-color: var(--card-hi); border-color: var(--line-soft); transform: translateY(-1px); }
@media (max-width: 1280px) { .mobile-inv-list { grid-template-columns: 1fr; } }
.mi-left { display: flex; align-items: center; justify-content: center; }
.mi-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mi-material { color: var(--white); font-size: 15px; line-height: 1.25; }
.mi-material b { font-weight: 800; }
.mi-brand {
  /* color: var(--accent); */
  font-size: 13px;
  margin: 2px 0 4px;
  display: flex; align-items: center; gap: 4px;
}
.mi-brand .mdi { font-size: 14px; }
.mi-row { font-size: 13px; color: var(--white); display: flex; align-items: center; gap: 4px; }
.mi-row .mdi { font-size: 14px; }
.mi-row b { font-weight: 700; }
.mi-row.mi-strong { font-size: 14px; font-weight: 600; }
.mi-note {
  font-size: 12.5px;
  color: var(--note);
  margin-top: 2px;
  word-break: break-word;
}
.mi-note .mdi { font-size: 14px; }
.mi-note b { font-weight: 700; }
.mi-meter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.mi-meter {
  flex: 1;
  height: 7px;
  border-radius: 8px;
  background: #1f2a38;
  border: 1px solid var(--line);
  overflow: hidden;
}
.mi-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width .25s ease;
}
.mi-fill.ok   { background: var(--ok); }
.mi-fill.warn { background: var(--warn); }
.mi-fill.err  { background: var(--err); }
.mi-meter-label {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--white);
  min-width: 36px;
  text-align: right;
}

/* ============== Treemap des matières (tableau de bord) ============== */
.treemap {
  position: relative;
  width: 100%;
  height: 380px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-deep);
}
.tm-tile {
  position: absolute;
  border-radius: 6px;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  color: #fff;
  cursor: pointer;
  transition: filter .12s, transform .08s;
}
.tm-tile:hover { filter: brightness(1.18); }
.tm-tile:active { transform: scale(.985); }
.tm-tile[data-material=""] { cursor: default; }
.tm-tile[data-material=""]:hover { filter: none; }
.tm-name {
  font-size: 12.5px; font-weight: 700; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.tm-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.tm-tile.is-small { padding: 4px 6px; }
.tm-tile.is-small .tm-name { font-size: 10.5px; font-weight: 600; }
.tm-tile.is-small .tm-val { font-size: 11.5px; }

@media (max-width: 1100px) {
  .treemap { height: 260px; }
}


/* =========================================================
   STOCKAGE (bureau) — tous les racks visibles, cases réglables
   Les cases portent --c (couleur de la bobine), les racks --rc
   (couleur du rack) ; les tailles passent par --cell / --gap / --h.
   ========================================================= */

/* Hauteur fixe de l'en-tête de page : les en-têtes de rack et le panneau
   « à ranger » viennent se coller juste en dessous. */
.stg { --stg-head-h: 84px; }

/* En-tête figé pendant le défilement. Les marges négatives annulent le padding
   de .view pour qu'il couvre toute la largeur et masque ce qui passe dessous. */
.stg .view-header {
  position: sticky; top: 0; z-index: 20;
  box-sizing: border-box;
  height: var(--stg-head-h);
  margin: -20px -20px 16px;
  padding: 0 20px;
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.stg-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

/* ---------- Sélecteur de taille de case ---------- */
.stg-sizer {
  display: flex; gap: 2px; padding: 2px;
  background: var(--card-hi);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.stg-sizer button {
  width: 30px; height: 28px; border: none; border-radius: 7px;
  background: transparent; color: var(--dim);
  cursor: pointer; display: grid; place-items: center;
  transition: background .12s, color .12s;
}
.stg-sizer button:hover { color: var(--white); background: rgba(255,255,255,.06); }
.stg-sizer button.active { background: var(--accent); color: #fff; }
.stg-sizer .mdi { font-size: 16px; }

/* ---------- Colonne des racks ---------- */
.stg-racks { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.stg-rack {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--rc);
  border-radius: 16px;
}

/* L'en-tête reste visible pendant le défilement d'un grand rack, calé juste
   sous l'en-tête de page (1px de recouvrement pour ne laisser aucun interstice). */
.stg-rack__head {
  position: sticky; top: calc(var(--stg-head-h) - 1px); z-index: 3;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  border-radius: 13px 13px 0 0;
  background: var(--card);
}
.stg-rack.is-folded .stg-rack__head { border-bottom: none; border-radius: 13px; }

.stg-rack__fold {
  flex-shrink: 0; width: 28px; height: 28px;
  border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--muted);
  cursor: pointer; display: grid; place-items: center;
}
.stg-rack__fold:hover { color: var(--white); border-color: var(--line-soft); background: rgba(255,255,255,.05); }
.stg-rack__fold .mdi { font-size: 18px; }

.stg-rack__icon {
  flex-shrink: 0; width: 34px; height: 34px;
  border-radius: 10px; display: grid; place-items: center;
  font-size: 18px;
  background: var(--card-hi); color: var(--rc);
  background: color-mix(in srgb, var(--rc) 18%, transparent);
}

.stg-rack__id { flex: 1; min-width: 0; }
.stg-rack__name {
  margin: 0; font-size: 15px; font-weight: 800; color: var(--white);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stg-rack__loc {
  display: flex; align-items: center; gap: 4px;
  font-size: 11.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stg-rack__loc .mdi { font-size: 12px; }

.stg-rack__meter { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.stg-rack__gauge { width: 104px; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.stg-rack__gauge > span { display: block; height: 100%; border-radius: 99px; background: var(--rc); transition: width .25s; }
.stg-rack__num { font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.stg-rack__num b { color: var(--white); font-weight: 800; }

.stg-rack__fmt, .stg-rack__free {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 7px;
  font-size: 11px; font-weight: 700;
  background: var(--card-hi); border: 1px solid var(--line); color: var(--muted);
}
.stg-rack__fmt .mdi { font-size: 13px; }
.stg-rack__free { color: var(--ok); background: rgba(16,185,129,.1); border-color: rgba(16,185,129,.3); }
.stg-rack__free.is-full { color: var(--warn); background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); }

.stg-rack__tools { flex-shrink: 0; display: flex; gap: 3px; }
.stg-tool {
  width: 30px; height: 30px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--dim);
  cursor: pointer; display: grid; place-items: center;
}
.stg-tool:hover { color: var(--white); background: rgba(255,255,255,.07); border-color: var(--line); }
.stg-tool .mdi { font-size: 16px; }

/* ---------- Grilles ---------- */
/* La grille respecte le nombre de colonnes du rack ; sous la largeur
   minimale de case, elle défile horizontalement plutôt que de se tasser. */
/* overflow-y figé : sans cela l'axe libre passe aussi en « auto » et le survol
   d'une case fait apparaître une barre de défilement verticale parasite. */
.stg-scroll { overflow-x: auto; overflow-y: hidden; padding: 14px; }
.stg-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(var(--cell), 1fr)); }
.stg-queue__list { grid-template-columns: repeat(auto-fill, minmax(var(--cell), 1fr)); }
.stg-grid, .stg-queue__list { gap: var(--gap); }

/* --cell et --h sont accordés pour garder une case d'environ 3 largeurs pour
   4 hauteurs ; --h cale aussi la hauteur d'une rangée vide sur une rangée remplie. */
.stg-grid.size-s, .stg-queue__list.size-s { --cell: 100px; --gap: 8px;  --h: 138px; }
.stg-grid.size-m, .stg-queue__list.size-m { --cell: 150px; --gap: 10px; --h: 204px; }
.stg-grid.size-l, .stg-queue__list.size-l { --cell: 200px; --gap: 12px; --h: 268px; }

/* ---------- Case ---------- */
.stg-slot {
  position: relative;
  min-width: 0; min-height: var(--h);
  padding: 8px;
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card-hi);
  transition: border-color .12s, transform .08s, box-shadow .12s;
}
.stg-slot.is-filled {
  cursor: grab;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 17%, transparent), transparent 56%), var(--card-hi);
  border-color: color-mix(in srgb, var(--c) 38%, var(--line));
}
/* Soulèvement contenu dans la marge de la grille (14px), sinon l'ombre est rognée. */
.stg-slot.is-filled:hover {
  z-index: 2;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.32);
  border-color: color-mix(in srgb, var(--c) 72%, var(--line));
}
.stg-slot.is-filled:active { cursor: grabbing; }
.stg-slot.is-dragging { opacity: .32; }

.stg-slot.is-empty {
  align-items: center; justify-content: center;
  border-style: dashed;
  background: rgba(255,255,255,.015);
}
.stg-slot.is-empty:hover { border-color: var(--accent); background: rgba(0,134,214,.05); }
.stg-slot__plus {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--dim); border: 1px dashed var(--line-soft);
}
.stg-slot__plus .mdi { font-size: 18px; }
/* Pendant un glissement, les cases libres se signalent. */
.is-dnd .stg-slot.is-empty { border-color: var(--line-soft); background: rgba(0,134,214,.05); }

.stg-slot.is-over {
  transform: none;
  border-style: solid;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent), 0 0 20px rgba(0,134,214,.35);
}

.stg-slot__num {
  position: absolute; top: 6px; left: 8px; z-index: 2;
  pointer-events: none;
  font-size: 9.5px; font-weight: 800; letter-spacing: .06em;
  color: var(--dim); font-variant-numeric: tabular-nums;
}
.stg-slot__grip {
  position: absolute; top: 4px; right: 4px; z-index: 2;
  width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center;
  color: var(--dim); opacity: 0; transition: opacity .12s;
}
.stg-slot:hover .stg-slot__grip { opacity: 1; }
.stg-slot__grip .mdi { font-size: 14px; }

/* ---------- Contenu d'une case ---------- */
.stg-slot__spool {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding-top: 10px;
}
.stg-pct { font-size: 11.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stg-pct.ok   { color: var(--ok); }
.stg-pct.warn { color: var(--warn); }
.stg-pct.err  { color: var(--err); }

.stg-slot__info { min-width: 0; margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.stg-line {
  min-width: 0;
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--muted);
}
.stg-line .mdi { flex-shrink: 0; font-size: 13px; color: var(--dim); }
.stg-line .truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stg-line--color { font-size: 12.5px; font-weight: 800; color: var(--white); }
.stg-dot { flex-shrink: 0; width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(255,255,255,.22); }
.stg-line--mat { font-weight: 700; color: var(--white); }
.stg-line--status .mdi { color: var(--brand); }
.stg-line--note { color: var(--dim); font-style: italic; }
.stg-line--weight { font-weight: 700; font-variant-numeric: tabular-nums; }
.stg-line--weight b { color: var(--white); font-weight: 800; }

/* Contenu adapté à la taille : rien n'est jamais tronqué verticalement.
   Petites cases : bobine, pourcentage, couleur.
   Cases moyennes : + matière et poids.  Grandes cases : tout. */
.stg-grid.size-s .stg-line--mat,
.stg-grid.size-s .stg-line--brand,
.stg-grid.size-s .stg-line--status,
.stg-grid.size-s .stg-line--note,
.stg-grid.size-s .stg-line--weight,
.stg-queue__list.size-s .stg-line--mat,
.stg-queue__list.size-s .stg-line--brand,
.stg-queue__list.size-s .stg-line--note,
.stg-queue__list.size-s .stg-line--weight { display: none; }

.stg-grid.size-m .stg-line--brand,
.stg-grid.size-m .stg-line--status,
.stg-grid.size-m .stg-line--note,
.stg-queue__list.size-m .stg-line--brand,
.stg-queue__list.size-m .stg-line--note { display: none; }

.stg-grid.size-s .stg-line--color,
.stg-queue__list.size-s .stg-line--color { font-size: 11px; }

/* Bobine ciblée depuis la fiche détail */
@keyframes stgFlash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,134,214,0); }
  50%      { box-shadow: 0 0 0 3px var(--accent), 0 0 24px rgba(0,134,214,.7); }
}
.stg-slot.is-flash { z-index: 4; border-color: var(--accent); animation: stgFlash .7s ease-in-out 0s 5; }

/* ---------- Panneau « à ranger » ---------- */
.stg-queue {
  position: sticky; top: calc(var(--stg-head-h) + 12px);
  min-width: 0; max-height: calc(100vh - 168px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
}
.stg-queue.is-over { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }

.stg-queue__head {
  flex-shrink: 0;
  padding: 12px; border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 9px;
}
.stg-queue__title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 800; color: var(--white); }
.stg-queue__title .mdi { font-size: 18px; color: var(--brand); }
.stg-count {
  margin-left: auto;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums;
  background: var(--card-hi); border: 1px solid var(--line); color: var(--muted);
}

.stg-search {
  display: flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 9px;
  background: var(--card-hi); border: 1px solid var(--line); border-radius: 9px;
}
.stg-search:focus-within { border-color: var(--accent); }
.stg-search input {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  color: var(--white); font-size: 12.5px; font-family: inherit;
}
.stg-search button { padding: 0; border: none; background: none; color: var(--dim); cursor: pointer; display: grid; place-items: center; }
.stg-search button:hover { color: var(--white); }

.stg-chips { display: flex; flex-wrap: wrap; gap: 5px; max-height: 94px; overflow-y: auto; }
.stg-chip {
  max-width: 100%;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 99px;
  font-size: 10.5px; font-weight: 700; font-family: inherit;
  color: var(--muted); background: var(--card-hi);
  border: 1px solid var(--line); cursor: pointer;
}
.stg-chip .mdi { font-size: 12px; color: var(--dim); }
.stg-chip b { font-weight: 800; color: var(--dim); font-variant-numeric: tabular-nums; }
.stg-chip:hover { color: var(--white); border-color: var(--line-soft); }
.stg-chip.active { color: var(--white); background: rgba(0,134,214,.16); border-color: var(--accent); }
.stg-chip.active .mdi, .stg-chip.active b { color: var(--accent); }
.stg-chip.is-reset { border-style: dashed; }

.stg-selbar, .stg-queue__hint { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.stg-selbar { padding: 6px 9px; border-radius: 9px; background: rgba(0,134,214,.12); border: 1px solid var(--accent); }
.stg-selbar b { color: var(--white); }
.stg .btn.sm { height: 28px; padding: 0 10px; font-size: 11.5px; }
.stg .btn.sm .mdi { font-size: 14px; }

.stg-queue__list {
  flex: 1; overflow-y: auto;
  padding: 10px;
  display: grid; align-content: start;
}
.stg-pick {
  position: absolute; top: 4px; right: 4px; z-index: 3;
  width: 24px; height: 24px; border: none; border-radius: 50%;
  background: rgba(0,0,0,.35); color: var(--dim);
  cursor: pointer; display: grid; place-items: center;
  opacity: 0; transition: opacity .12s;
}
.stg-card:hover .stg-pick, .stg-card.is-picked .stg-pick { opacity: 1; }
.stg-pick .mdi { font-size: 16px; }
.stg-card.is-picked { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.stg-card.is-picked .stg-pick { color: var(--accent); }

.stg-empty { grid-column: 1 / -1; padding: 36px 12px; text-align: center; color: var(--dim); }
.stg-empty .mdi { font-size: 30px; }
.stg-empty p { margin: 8px 0 0; font-size: 12.5px; }
.stg-more { grid-column: 1 / -1; padding: 8px; text-align: center; font-size: 11px; color: var(--dim); }

/* ---------- Choix du rack (placement d'une sélection) ---------- */
.stg-picklist { margin: 14px 0 4px; max-height: 52vh; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; }
.stg-pickrack {
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 11px;
  padding: 10px; border-radius: 11px;
  background: var(--card-hi); border: 1px solid var(--line);
  color: inherit; font-family: inherit; cursor: pointer;
}
.stg-pickrack:hover:not([disabled]) { border-color: var(--accent); background: rgba(0,134,214,.08); }
.stg-pickrack[disabled] { opacity: .45; cursor: not-allowed; }
.stg-pickic { flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; }
.stg-pickmeta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stg-pickmeta b { font-size: 13.5px; font-weight: 800; color: var(--white); }
.stg-pickmeta small { font-size: 11.5px; color: var(--muted); }

/* ---------- Adaptation aux fenêtres étroites ---------- */
@media (max-width: 1500px) {
  .stg-layout { grid-template-columns: minmax(0, 1fr) 316px; }
}
@media (max-width: 1240px) {
  .stg-layout { grid-template-columns: minmax(0, 1fr); }
  .stg-queue { position: static; max-height: none; }
  .stg-queue__list { max-height: 440px; }
  .stg-rack__meter, .stg-rack__fmt { display: none; }
}

/* ============================================================
   BALANCE — historique et courbe de consommation (1.5.0)
   ============================================================ */

/* Interrupteur de sauvegarde automatique : une case, un titre, une explication. */
.bal-switch {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 14px; padding: 10px 12px;
  background: var(--card-hi); border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer;
}
.bal-switch input { margin-top: 3px; flex: 0 0 auto; }
.bal-switch span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bal-switch b { font-size: 13px; color: var(--white); }
.bal-switch small { font-size: 11px; line-height: 1.45; color: var(--muted); }

.bal-lbl {
  font-size: 11px; font-weight: 700; color: var(--dim);
  text-transform: uppercase; letter-spacing: .1em;
  margin-bottom: 6px; display: block;
}

/* --- Courbe de consommation, en SVG natif (fiche filament) ---
   Le SVG garde son rapport (pas de preserveAspectRatio="none") : les textes des axes
   et les marqueurs ne sont donc jamais déformés, et l'indicateur HTML peut se placer
   en pourcentage, puisque le dessin remplit exactement la boîte. */
.cc-plot { position: relative; }
.cc-svg { display: block; width: 100%; height: auto; }
.cc-grid { stroke: var(--line); stroke-width: 1; }
.cc-area { fill: color-mix(in srgb, var(--accent) 16%, transparent); stroke: none; }
.cc-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.cc-axis { fill: var(--dim); font-size: 10px; font-family: inherit; }

/* Les marqueurs dorment ; seul celui que la souris désigne apparaît. */
.cc-pt { fill: var(--accent); stroke: var(--bg); stroke-width: 2; opacity: 0; transition: opacity .1s; }
.cc-pt.on { opacity: 1; }

/* Trait vertical qui suit la souris. */
.cc-rule {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: color-mix(in srgb, var(--accent) 55%, transparent);
  pointer-events: none; transform: translateX(-.5px);
}

/* Bulle de lecture : ancrée sur le point, décalée pour ne pas le masquer. */
.cc-tip {
  position: absolute; z-index: 2;
  transform: translate(12px, -50%);
  display: flex; flex-direction: column; gap: 1px;
  padding: 6px 9px; border-radius: 8px;
  background: var(--card-hi); border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
  pointer-events: none; white-space: nowrap;
}
.cc-tip--left { transform: translate(calc(-100% - 12px), -50%); }
.cc-tip b { font-size: 14px; color: var(--white); line-height: 1.1; }
.cc-tip span { font-size: 11px; color: var(--muted); }
.cc-src { font-size: 10px; font-style: normal; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }

.cc-hint {
  margin-top: 6px; text-align: center;
  font-size: 11px; color: var(--dim);
}
.cc:hover .cc-hint { visibility: hidden; }

/* Carte vide : même bloc pour « pas encore de mesure » et « chargement ». */
.cc-empty {
  display: grid; place-items: center; gap: 8px;
  padding: 28px 16px; text-align: center;
  color: var(--muted); font-size: 13px;
}
.cc-empty .mdi { font-size: 34px; color: var(--dim); }

/* Au doigt, il n'y a pas de survol : l'invite n'a pas lieu d'être. */
@media (hover: none) {
  .cc-hint { display: none; }
}

/* --- Tableau des dernières lectures ---
   Dix lignes visibles, le reste au défilement. La hauteur se déduit de deux variables
   plutôt que d'un nombre magique : changer le nombre de lignes tient en un chiffre. */
.bal-hist-wrap {
  --bal-lignes: 10;
  --bal-ligne-h: 41px;
  max-height: calc(var(--bal-lignes) * var(--bal-ligne-h) + 26px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.bal-hist { width: 100%; border-collapse: collapse; font-size: 12px; }
.bal-hist th {
  text-align: left; font-size: 10px; font-weight: 700; color: var(--dim);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 0 8px 6px; border-bottom: 1px solid var(--line);
  /* L'en-tête reste lisible pendant le défilement. Il lui faut un fond opaque,
     sinon les lignes défilantes transparaîtraient dessous. */
  position: sticky; top: 0; z-index: 1;
  background: var(--card);
}
.bal-hist th.num, .bal-hist td.num { text-align: right; }
.bal-hist td { padding: 6px 8px; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.bal-hist tbody tr:last-child td { border-bottom: 0; }
.bal-hist tbody tr:hover { background: var(--interact); }
.bal-hist__at { color: var(--muted); white-space: nowrap; }

/* Colonne Bobine : pastille de couleur, marque et matière, puis la couleur en second. */
.bal-hist__bob { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bal-dot-color {
  flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%;
  background: var(--c, #555c66);
  border: 1px solid color-mix(in srgb, var(--white) 22%, transparent);
}
.bal-hist__txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.bal-hist__txt b {
  font-size: 12px; color: var(--white); line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bal-hist__txt small {
  font-size: 10.5px; color: var(--muted); line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* La flèche n'apparaît qu'au survol : elle signale que la ligne mène quelque part,
   sans encombrer un tableau où chaque ligne la porterait. */
.bal-hist__arrow { margin-left: auto; color: var(--dim); opacity: 0; transition: opacity .12s; }
.bal-hist__go { cursor: pointer; }
.bal-hist__go:hover .bal-hist__arrow { opacity: 1; }
.bal-hist__go:hover .bal-hist__txt b { color: var(--accent); }

.bal-hist__pct { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }

/* Les deux cartes peuvent être vides : un bloc commun plutôt que deux variantes. */
.bal-empty {
  display: grid; place-items: center; gap: 8px;
  padding: 28px 16px; text-align: center;
  color: var(--muted); font-size: 13px;
}
.bal-empty .mdi { font-size: 34px; color: var(--dim); }


