/* ================================================================
   CAMALARM CRM — Components v2
   Buttons · Inputs · Cards · Tables · Modals · Forms
   ================================================================ */

/* ══════════════════════════════════════════════════════════════
   BOUTONS
   ══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 0 var(--s4);
  height: 36px;
  font: var(--fw-semibold) var(--text-sm)/1 var(--font);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: -.01em;
  transition: all var(--tr-fast);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  outline: none;
}
.btn:focus-visible { box-shadow: var(--shadow-focus); }
.btn:active { transform: scale(.97); }
.btn .material-symbols-rounded { font-size: 16px; }

/* Primary */
.bp {
  background: var(--brand);
  color: var(--text-inverse);
  box-shadow: 0 1px 2px rgba(29,78,216,.2);
}
.bp:hover { background: var(--brand-hover); box-shadow: 0 3px 8px rgba(29,78,216,.25); }

/* Outline brand */
.bo {
  background: transparent;
  color: var(--brand);
  border: 1.5px solid var(--brand);
}
.bo:hover { background: var(--brand-light); }

/* Ghost neutral */
.bg {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.bg:hover { background: var(--neutral-100); color: var(--text-primary); border-color: var(--border-strong); }

/* Accent orange */
.bor {
  background: var(--gradient-accent);
  color: var(--text-inverse);
  box-shadow: 0 1px 2px rgba(234,88,12,.2);
}
.bor:hover { box-shadow: 0 3px 8px rgba(234,88,12,.28); filter: brightness(1.04); }

/* Danger */
.br {
  background: var(--danger);
  color: var(--text-inverse);
}
.br:hover { background: var(--red-700); box-shadow: 0 2px 6px rgba(239,68,68,.25); }

/* Button group */
.bgrp { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }

/* ══════════════════════════════════════════════════════════════
   INPUTS / SELECTS / TEXTAREAS
   ══════════════════════════════════════════════════════════════ */
.fi, .fs, .ft {
  width: 100%;
  height: 36px;
  padding: 0 var(--s3);
  font: var(--fw-normal) var(--text-base)/1 var(--font);
  color: var(--text-primary);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
  -webkit-appearance: none;
}
.fi:focus, .fs:focus, .ft:focus {
  border-color: var(--brand);
  box-shadow: var(--shadow-focus);
}
.fi::placeholder, .ft::placeholder { color: var(--text-tertiary); }
.ft {
  height: auto;
  min-height: 80px;
  padding: var(--s3);
  resize: vertical;
  line-height: var(--lh-relaxed);
}

/* Form group */
.fg  { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: var(--s3); }
.fg.c2 { grid-template-columns: 1fr 1fr; }
.fg.c3 { grid-template-columns: 1fr 1fr 1fr; }
.fgp { display: flex; flex-direction: column; gap: var(--s1); }
.fgp.fl { grid-column: 1/-1; }
.fl-l {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ══════════════════════════════════════════════════════════════
   PAPER / DEVIS — Card document
   ══════════════════════════════════════════════════════════════ */
.paper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  max-width: 720px;
  margin: 0 auto;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.paper-head {
  background: var(--gradient-brand);
  padding: var(--s5) var(--s6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.paper-logo { height: 38px; filter: brightness(0) invert(1); }
.paper-label {
  color: var(--text-inverse);
  font-size: 22px;
  font-weight: var(--fw-black);
  text-align: right;
  line-height: 1.1;
  letter-spacing: -.4px;
}
.paper-label small {
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  opacity: .55;
  display: block;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.paper-client {
  background: var(--neutral-50);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
}
.pc-info { font-size: var(--text-base); font-weight: var(--fw-bold); color: var(--nv); }
.pc-info span { color: var(--text-secondary); font-weight: var(--fw-medium); font-size: var(--text-sm); }

.paper-foot {
  background: var(--gradient-brand);
  padding: var(--s3) var(--s5);
  font-size: var(--text-xs);
  color: rgba(255,255,255,.45);
  text-align: center;
  letter-spacing: .2px;
}

/* ── Section headers dans paper ── */
.sec-hdr {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) var(--s5);
  background: var(--neutral-50);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-top: var(--s2);
}
.sec-hdr span { font-size: 16px; color: var(--brand); }

/* ── Calc rows ── */
.calc-section { padding: var(--s3) var(--s5); }
.calc-row {
  display: grid;
  grid-template-columns: 1fr auto 60px 80px 52px 80px;
  gap: var(--s2);
  align-items: center;
  padding: var(--s2) var(--s3);
  border-radius: var(--radius-md);
  margin-bottom: var(--s1);
  transition: background var(--tr-fast);
  background: var(--neutral-50);
  border: 1px solid transparent;
}
.calc-row:hover { background: var(--neutral-100); border-color: var(--border); }
.calc-label { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-primary); line-height: 1.4; }
.sub-label { font-size: var(--text-xs); color: var(--text-tertiary); font-weight: var(--fw-normal); line-height: 1.4; margin-top: 2px; }

.calc-opt {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  cursor: pointer;
  padding: var(--s1) var(--s2);
  border-radius: var(--radius-sm);
  transition: background var(--tr-fast);
}
.calc-opt:hover { background: var(--brand-light); color: var(--brand); }
.calc-opt input[type="radio"],
.calc-opt input[type="checkbox"] {
  margin: 0;
  accent-color: var(--brand);
  width: 15px; height: 15px;
  cursor: pointer;
  flex-shrink: 0;
}
.calc-opt-inline { display: flex; gap: var(--s2); flex-wrap: wrap; }

.qty-input {
  width: 56px;
  height: 34px;
  text-align: center;
  font: var(--fw-bold) var(--text-sm)/1 var(--mono);
  padding: var(--s1) var(--s1);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
}
.qty-input:focus { border-color: var(--brand); box-shadow: var(--shadow-focus); }

.price-input {
  width: 76px;
  height: 34px;
  text-align: right;
  font: var(--fw-semibold) var(--text-sm)/1 var(--mono);
  padding: var(--s1) var(--s2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
}
.price-input:focus { border-color: var(--brand); box-shadow: var(--shadow-focus); }

.calc-total-cell {
  font: var(--fw-bold) var(--text-sm)/1 var(--mono);
  text-align: right;
  color: var(--brand);
  min-width: 70px;
}

/* ── Extra table ── */
.xtbl { width: 100%; border-collapse: collapse; }
.xtbl th {
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: var(--s2) var(--s2);
  text-align: left;
  border-bottom: 2px solid var(--border);
  background: var(--neutral-50);
}
.xtbl td { padding: var(--s1) var(--s2); border-bottom: 1px solid var(--neutral-100); vertical-align: middle; }
.xtbl input, .xtbl select {
  font: var(--text-sm) var(--font);
  padding: var(--s1) var(--s2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color var(--tr-fast);
  height: 32px;
}
.xtbl input:focus { border-color: var(--brand); }

/* ── Img table ── */
.img-table { width: 100%; border-collapse: collapse; }
.img-table th { background: var(--neutral-50); font-size: var(--text-xs); font-weight: var(--fw-bold); color: var(--text-secondary); text-transform: uppercase; padding: var(--s2); border: 1px solid var(--border); text-align: center; }
.img-table td { padding: var(--s2); border: 1px solid var(--border); text-align: center; vertical-align: middle; }
.img-table img { max-height: 80px; max-width: 130px; object-fit: contain; border-radius: var(--radius-sm); }
.img-table .desc-cell { text-align: left; font-size: var(--text-sm); }
.add-img-row {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: var(--s3);
  text-align: center;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  transition: all var(--tr-fast);
  flex: 1;
}
.add-img-row:hover { border-color: var(--brand); background: var(--brand-light); color: var(--brand); }

/* ── Totals box ── */
.totals-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 340px;
  margin: var(--s5) var(--s5) var(--s5) auto;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.tl {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--s3) var(--s4);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}
.tl:last-child { border-bottom: none; }
.tl.grand {
  background: var(--gradient-brand);
  color: var(--text-inverse);
  font-weight: var(--fw-black);
  font-size: var(--text-md);
  padding: var(--s4);
  border-bottom: none;
}
.tl.accent { color: var(--accent); font-weight: var(--fw-bold); background: var(--accent-light); }

/* ══════════════════════════════════════════════════════════════
   PANELS / CARDS
   ══════════════════════════════════════════════════════════════ */
.crd {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: var(--s4);
  transition: box-shadow var(--tr-base);
}
.crd:hover { box-shadow: var(--shadow-md); }
.crh {
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--neutral-50);
  gap: var(--s3);
}
.crt {
  font-size: var(--text-base);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  letter-spacing: -.02em;
}
.crb { padding: var(--s4) var(--s5); }

/* ── Data table ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: var(--s2) var(--s3);
  border-bottom: 2px solid var(--border);
  background: var(--neutral-50);
  white-space: nowrap;
}
.data-table td {
  padding: var(--s3);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--neutral-100);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--tr-fast); cursor: pointer; }
.data-table tbody tr:hover td { background: var(--brand-light); }

/* ── Stat cards ── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--s4) var(--s5);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
  transition: all var(--tr-base);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gradient-brand);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-v {
  font-size: var(--text-xl);
  font-weight: var(--fw-black);
  color: var(--brand);
  font-family: var(--mono);
  letter-spacing: -.04em;
  line-height: 1;
}
.stat-l { font-size: var(--text-xs); color: var(--text-secondary); margin-top: var(--s2); font-weight: var(--fw-semibold); letter-spacing: .2px; }
.stat-card.gn .stat-v { color: var(--success); }
.stat-card.gn::before { background: var(--success); }
.stat-card.or .stat-v { color: var(--accent); }
.stat-card.or::before { background: var(--gradient-accent); }

/* ── Client grid ── */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s3); }
.cl-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: var(--s4);
  cursor: pointer;
  transition: all var(--tr-base);
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}
.cl-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: var(--gradient-brand);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform var(--tr-base);
}
.cl-card:hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.cl-card:hover::before { transform: scaleY(1); }
.cl-nm { font-size: var(--text-base); font-weight: var(--fw-bold); color: var(--text-primary); letter-spacing: -.02em; }
.cl-mt { font-size: var(--text-xs); color: var(--text-secondary); margin-top: var(--s1); }
.cl-sys { display: flex; gap: var(--s1); flex-wrap: wrap; margin-top: var(--s2); }

/* Client card v2 */
.client-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--s4);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--tr-base);
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}
.client-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  opacity: 0;
  transition: opacity var(--tr-base);
}
.client-card:hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.client-card:hover::before { opacity: 1; }
.client-name { font-weight: var(--fw-bold); font-size: var(--text-base); color: var(--text-primary); margin-bottom: var(--s2); }
.client-info { font-size: var(--text-xs); color: var(--text-secondary); display: flex; align-items: center; gap: var(--s1); margin-bottom: 2px; }
.client-badge { display: inline-block; font-size: 9px; padding: 2px var(--s2); border-radius: var(--radius-full); font-weight: var(--fw-bold); letter-spacing: .3px; }
.client-badge.pro { background: var(--brand-mid); color: var(--brand); }
.client-badge.part { background: var(--neutral-100); color: var(--neutral-600); }

/* ── Catalogue grid ── */
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: var(--s3); }
.cat-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--tr-base);
  box-shadow: var(--shadow-xs);
}
.cat-item:hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.cat-img { width: 100%; height: 90px; object-fit: contain; background: var(--neutral-50); padding: var(--s2); }
.cat-inf { padding: var(--s2) var(--s3); }
.cat-nm { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-primary); line-height: 1.35; }
.cat-pr { font-size: var(--text-sm); font-weight: var(--fw-black); color: var(--brand); margin-top: 2px; font-family: var(--mono); }
.cat-pa { font-size: var(--text-xs); color: var(--success); }

/* ── Status tag ── */
.st {
  font-size: 9px;
  font-weight: var(--fw-bold);
  padding: 2px var(--s2);
  border-radius: var(--radius-full);
  background: var(--brand-light);
  color: var(--brand);
  letter-spacing: .2px;
}

/* ══════════════════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════════════════ */
.mo {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: var(--s5) var(--s3);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.mo.s { display: flex; }
.ml {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px rgba(0,0,0,.14), 0 0 0 1px rgba(0,0,0,.06);
  width: 100%;
  max-width: 720px;
  animation: modalIn .22s var(--ease);
}
@keyframes modalIn {
  from { opacity:0; transform:translateY(12px) scale(.98); }
  to   { opacity:1; transform:none; }
}
.mh {
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--neutral-50);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.mtt { font-size: var(--text-md); font-weight: var(--fw-bold); color: var(--text-primary); letter-spacing: -.02em; }
.mx {
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--neutral-100);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--tr-fast);
  flex-shrink: 0;
}
.mx:hover { background: var(--danger-bg); color: var(--danger); transform: rotate(90deg); }
.mbd { padding: var(--s5); }
.mft {
  padding: var(--s3) var(--s5);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--s2);
  background: var(--neutral-50);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  flex-wrap: wrap;
}

/* ── Tab nav inside modal ── */
.dt {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s4);
  overflow-x: auto;
}
.dtb {
  padding: var(--s2) var(--s3);
  font: var(--fw-semibold) var(--text-xs)/1 var(--font);
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: color var(--tr-fast);
  letter-spacing: .2px;
  text-transform: uppercase;
}
.dtb:hover, .dtb.a { color: var(--brand); }
.dtb.a::after {
  content: '';
  position: absolute;
  bottom: 0; left: var(--s1); right: var(--s1);
  height: 2px;
  background: var(--brand);
  border-radius: 2px 2px 0 0;
}
.dp { display: none; }
.dp.a { display: block; }

/* ── Filters bar ── */
.flt { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; margin-bottom: var(--s3); }
.sb { flex: 1; min-width: 130px; position: relative; }
.sb input {
  width: 100%;
  padding: 0 var(--s3) 0 var(--s7);
  height: 36px;
  font: var(--text-sm) var(--font);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
}
.sb input:focus { border-color: var(--brand); box-shadow: var(--shadow-focus); }
.sb::before {
  content: '🔍';
  position: absolute;
  left: var(--s3);
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════
   LOGIN
   ══════════════════════════════════════════════════════════════ */
.po {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--s4);
  background: var(--gradient-brand);
  position: relative;
  overflow: hidden;
}
.po::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(59,130,246,.2) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(234,88,12,.12) 0%, transparent 50%);
}
.pbox {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: var(--s7) var(--s6);
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.2);
  border: 1px solid rgba(255,255,255,.1);
  max-width: 340px;
  width: 100%;
  position: relative;
  z-index: 1;
}
.ptt { font-size: var(--text-lg); font-weight: var(--fw-black); color: var(--text-primary); margin-bottom: var(--s1); letter-spacing: -.03em; }
.psb { font-size: var(--text-xs); color: var(--text-secondary); margin-bottom: var(--s5); }
.pin {
  font: var(--fw-bold) 26px/1 var(--mono);
  letter-spacing: 10px;
  text-align: center;
  width: 150px;
  padding: var(--s3);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  outline: none;
  color: var(--text-primary);
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
}
.pin:focus { border-color: var(--brand); box-shadow: var(--shadow-focus); }
.pe { color: var(--danger); font-size: var(--text-xs); margin-top: var(--s2); display: none; }

/* ══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════════════════════════ */
.toast-c {
  position: fixed;
  bottom: var(--s5);
  right: var(--s5);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  pointer-events: none;
}
.tst {
  display: flex;
  align-items: center;
  gap: var(--s2);
  background: var(--neutral-900);
  color: var(--text-inverse);
  padding: var(--s3) var(--s4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  animation: toastIn .22s var(--ease), toastOut .22s var(--ease) 2.5s forwards;
  pointer-events: auto;
  max-width: 320px;
  border: 1px solid rgba(255,255,255,.08);
}
.tst.ok { background: var(--green-700); }
.tst.er { background: var(--red-700); }

/* ══════════════════════════════════════════════════════════════
   REMOVE BUTTON
   ══════════════════════════════════════════════════════════════ */
.rm-btn {
  width: 24px; height: 24px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--neutral-100);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--tr-fast);
}
.rm-btn:hover { background: var(--danger-bg); color: var(--danger); transform: scale(1.1); }

/* ══════════════════════════════════════════════════════════════
   MENU CONTEXTUEL
   ══════════════════════════════════════════════════════════════ */
.act-menu { display: none; }
.act-menu.s { display: block !important; animation: menuIn .15s var(--ease); }

.act-pop {
  position: fixed;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,.14), 0 0 0 1px rgba(0,0,0,.06);
  padding: var(--s1) 0;
  min-width: 220px;
  z-index: 9999;
  max-height: 80vh;
  overflow-y: auto;
}
.nm-item {
  padding: var(--s2) var(--s4);
  font-size: var(--text-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--s3);
  transition: background var(--tr-fast);
  color: var(--text-primary);
}
.nm-item:hover { background: var(--neutral-50); }

/* ══════════════════════════════════════════════════════════════
   MOBILE NAV
   ══════════════════════════════════════════════════════════════ */
.mob-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0,0,0,.06);
  display: none;
}
.mob-nav-inner { display: flex; justify-content: space-around; align-items: center; padding: var(--s2) 0; max-width: 600px; margin: 0 auto; }
.mob-nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--text-secondary); padding: var(--s1) var(--s2); cursor: pointer; text-decoration: none; min-width: 56px; transition: color var(--tr-fast); }
.mob-nav-item.active { color: var(--brand); }
.mob-nav-item .material-symbols-rounded { font-size: 22px; }
.mob-more-menu { position: fixed; bottom: 60px; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 24px rgba(0,0,0,.1); z-index: 199; display: none; padding: var(--s4); max-height: 50vh; overflow-y: auto; }
.mob-more-menu.s { display: block; }
.mob-more-item { display: flex; align-items: center; gap: var(--s3); padding: var(--s3); border-radius: var(--radius-lg); font-size: var(--text-base); font-weight: var(--fw-medium); cursor: pointer; transition: background var(--tr-fast); }
.mob-more-item:hover { background: var(--neutral-50); }
.mob-more-item .material-symbols-rounded { font-size: 20px; color: var(--brand); }

/* ══════════════════════════════════════════════════════════════
   RICH TEXT EDITOR
   ══════════════════════════════════════════════════════════════ */
.rte-box { border: 1.5px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); transition: border-color var(--tr-fast); margin-bottom: var(--s4); }
.rte-box:focus-within { border-color: var(--brand); box-shadow: var(--shadow-focus); }
.rte-bar { display: flex; gap: 2px; padding: var(--s2) var(--s3); background: var(--neutral-50); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.rte-bar button { width: 28px; height: 26px; border: none; border-radius: var(--radius-sm); background: transparent; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center; transition: all var(--tr-fast); color: var(--text-secondary); }
.rte-bar button:hover { background: var(--brand-light); color: var(--brand); }
.rte-bar .sep { width: 1px; height: 18px; background: var(--border); margin: 4px 2px; align-self: center; }
.rte-ed { min-height: 80px; padding: var(--s3) var(--s4); font: var(--text-base)/var(--lh-relaxed) var(--font); color: var(--text-primary); outline: none; }
.rte-ed:empty::before { content: attr(data-placeholder); color: var(--text-tertiary); font-style: italic; pointer-events: none; }

/* ══════════════════════════════════════════════════════════════
   T170aa — Zone Notes techniques agrandie (Devis Classique + Express)
   ══════════════════════════════════════════════════════════════ */
#dvc_notes,
#d_notes {
  min-height: 280px !important;
  resize: vertical;
  overflow-y: auto;
  font-family: 'Inter', 'Segoe UI', Arial, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  padding: 14px 16px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #1e293b;
  white-space: pre-wrap;       /* préserve les sauts de ligne et espaces */
  word-wrap: break-word;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#dvc_notes:focus,
#d_notes:focus {
  border-color: #0F3D67;
  box-shadow: 0 0 0 3px rgba(15, 61, 103, 0.10);
}
/* Zone Info techniques aussi un peu plus haute pour cohérence */
#dvc_info,
#d_info {
  min-height: 140px !important;
  font-family: 'Inter', 'Segoe UI', Arial, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  padding: 12px 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ── Contenteditable ── */
[contenteditable=true]:empty::before { content: attr(data-placeholder); color: var(--text-tertiary); font-style: italic; pointer-events: none; }

/* ══════════════════════════════════════════════════════════════
   SETTINGS NAV
   ══════════════════════════════════════════════════════════════ */
.set-nav-item {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s4);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all var(--tr-fast);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.set-nav-item:hover { background: var(--neutral-100); color: var(--text-primary); }
.set-nav-item.active { background: var(--brand-light); border-left-color: var(--brand); color: var(--brand); font-weight: var(--fw-semibold); }
.set-sec { display: none; }
.set-sec.first { display: block; }

/* ══════════════════════════════════════════════════════════════
   DEVIS EXPRESS — Cards produits
   ══════════════════════════════════════════════════════════════ */
.xp-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s3);
  min-width: 120px;
  flex: 1;
  max-width: 160px;
  text-align: center;
  cursor: pointer;
  transition: all var(--tr-fast);
  user-select: none;
}
.xp-card:hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.xp-card.on { border-color: var(--brand); background: var(--brand-light); box-shadow: 0 0 0 3px rgba(29,78,216,.12); }
.xp-icon { font-size: 26px; margin-bottom: var(--s1); }
.xp-name { font-size: var(--text-xs); font-weight: var(--fw-semibold); color: var(--text-primary); }
.xp-price { font-size: var(--text-sm); font-weight: var(--fw-black); color: var(--brand); margin-top: 2px; font-family: var(--mono); }
.xp-qty { display: flex; align-items: center; justify-content: center; gap: var(--s2); margin-top: var(--s2); }
.xp-qty button { width: 26px; height: 26px; border-radius: var(--radius-full); border: 1.5px solid var(--border); background: var(--surface); font-size: 14px; font-weight: var(--fw-bold); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--tr-fast); }
.xp-qty button:hover { background: var(--brand); color: var(--text-inverse); border-color: var(--brand); }
.xp-qty span { font: var(--fw-bold) var(--text-base)/1 var(--mono); min-width: 22px; text-align: center; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media(max-width:768px) {
  .fg, .fg.c2, .fg.c3 { grid-template-columns: 1fr; }
  .client-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2,1fr); }
  .calc-row { grid-template-columns: 1fr auto 54px 72px 50px 72px; gap: var(--s1); padding: var(--s2); }
  .data-table th, .data-table td { padding: var(--s2); font-size: var(--text-xs); }
  .totals-box { max-width: 100%; margin: var(--s4) 0; }
  .mo { padding: var(--s2); }
  .ml { border-radius: var(--radius-lg); max-height: 96vh; overflow-y: auto; }
  .mbd { padding: var(--s3) var(--s4); }
  .mft { flex-wrap: wrap; gap: var(--s2); }
  .mft .btn { flex: 1; min-width: 80px; justify-content: center; }
  .paper { border-radius: var(--radius-lg); }
  .paper-head { padding: var(--s4); flex-direction: column; gap: var(--s2); text-align: center; }
  .paper-client { padding: var(--s3) var(--s4); flex-direction: column; gap: var(--s2); }
  .calc-section { padding: var(--s3); }
  .sec-hdr { padding: var(--s2) var(--s4); font-size: var(--text-xs); }
  .bgrp { gap: var(--s1); }
  .xp-card { min-width: calc(50% - 8px); max-width: none; }
}
@media(max-width:480px) {
  .stats-row { grid-template-columns: 1fr; }
  .calc-row { grid-template-columns: 1fr 1fr; gap: var(--s1); }
}
@media(min-width:769px) and (max-width:1024px) {
  .stats-row { grid-template-columns: repeat(3,1fr); }
}
@media print {
  .sec-hdr { background: var(--nv) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .btn, .bgrp, .hdr, .mob-nav { display: none !important; }
}