/* =========================================================
   TAILOR DESIGN SYSTEM — UI Kit logiciels de gestion
   Mode clair par défaut · mode sombre via [data-theme="dark"]
   Font unique : Helvetica
   ========================================================= */

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body, h1, h2, h3, h4, h5, h6, p, ul, ol, figure, blockquote, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }

/* =========================================================
   TOKENS
   ========================================================= */
:root {
  --font-sans: Helvetica, "Helvetica Neue", Arial, sans-serif;

  --fs-xs: 9px;
  --fs-sm: 10px;
  --fs-base: 10px;
  --fs-md: 11px;
  --fs-lg: 13px;
  --fs-xl: 14px;
  --fs-2xl: 18px;
  --fs-3xl: 22px;
  --fs-4xl: 27px;

  --sp-1: 3px; --sp-2: 6px; --sp-3: 10px; --sp-4: 13px; --sp-5: 16px;
  --sp-6: 19px; --sp-7: 26px; --sp-8: 32px; --sp-9: 38px; --sp-10: 51px;

  --r-xs: 2px; --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 11px; --r-2xl: 16px; --r-full: 999px;

  --t-fast: 120ms ease; --t-base: 180ms ease; --t-slow: 280ms ease;

  /* MODE CLAIR — teinté jaune-gris, doux pour les yeux */
  --bg: #f5f4f0;
  --bg-alt: #efeee9;
  --surface: #fdfcf8;
  --surface-2: #f8f7f3;
  --surface-3: #f2f1ec;
  --surface-hover: #f2f1ec;
  --overlay: rgba(11, 30, 52, 0.45);

  --text: #1a1a17;
  --text-secondary: #5a5847;
  --text-tertiary: #8a8878;
  --text-disabled: #b8b6a8;
  --text-inverse: #fdfcf8;

  --border: #e4e2d8;
  --border-strong: #cbc9be;
  --border-focus: #2563eb;
  --divider: #edebe3;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-active: #1e40af;
  --primary-soft: #dde5f5;
  --primary-soft-text: #1e40af;

  --success: #16a34a; --success-hover: #15803d; --success-soft: #ddf5e4; --success-soft-text: #15803d;
  --warning: #ea580c; --warning-hover: #c2410c; --warning-soft: #fdecd6; --warning-soft-text: #9a3412;
  --danger:  #dc2626; --danger-hover:  #b91c1c; --danger-soft:  #fce4e4; --danger-soft-text:  #991b1b;
  --info:    #0891b2; --info-hover:    #0e7490; --info-soft:    #d4f5fa; --info-soft-text:    #155e75;
  --neutral-soft: #e4e2d8; --neutral-soft-text: #3a3930;

  --shadow-xs: 0 1px 2px rgba(15, 29, 46, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 29, 46, 0.08), 0 1px 2px rgba(15, 29, 46, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 29, 46, 0.08), 0 2px 4px -2px rgba(15, 29, 46, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 29, 46, 0.10), 0 4px 6px -4px rgba(15, 29, 46, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(15, 29, 46, 0.12), 0 8px 10px -6px rgba(15, 29, 46, 0.06);
  --shadow-focus: 0 0 0 3px rgba(37, 99, 235, 0.25);

  --sidebar-bg: #faf9f5;
  --sidebar-text: #5a5847;
  --sidebar-text-active: #2563eb;
  --sidebar-active-bg: #e8e6da;
  --sidebar-hover-bg: #f2f1ec;
  --topbar-bg: #faf9f5;
}

/* MODE SOMBRE — bleu marine sobre */
[data-theme="dark"] {
  --bg: #0b1e34;
  --bg-alt: #08182a;
  --surface: #122b47;
  --surface-2: #173354;
  --surface-3: #1d3c62;
  --surface-hover: #1d3c62;
  --overlay: rgba(0, 0, 0, 0.6);

  --text: #e6edf5;
  --text-secondary: #9aabc1;
  --text-tertiary: #6c8099;
  --text-disabled: #4a5d76;
  --text-inverse: #0b1e34;

  --border: #1e3a5f;
  --border-strong: #2a4f7a;
  --border-focus: #3b82f6;
  --divider: #173354;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-active: #2563eb;
  --primary-soft: #1e3a5f;
  --primary-soft-text: #93c5fd;

  --success: #22c55e; --success-hover: #4ade80; --success-soft: #14361f; --success-soft-text: #86efac;
  --warning: #f97316; --warning-hover: #fb923c; --warning-soft: #3a1d0a; --warning-soft-text: #fdba74;
  --danger:  #ef4444; --danger-hover:  #f87171; --danger-soft:  #3b1414; --danger-soft-text:  #fca5a5;
  --info:    #06b6d4; --info-hover:    #22d3ee; --info-soft:    #0a3540; --info-soft-text:    #67e8f9;
  --neutral-soft: #1e3a5f; --neutral-soft-text: #cbd5e1;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.7), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-focus: 0 0 0 3px rgba(59, 130, 246, 0.35);

  --sidebar-bg: #122b47;
  --sidebar-text: #9aabc1;
  --sidebar-text-active: #93c5fd;
  --sidebar-active-bg: #1e3a5f;
  --sidebar-hover-bg: #173354;
  --topbar-bg: #122b47;
}

/* =========================================================
   BASE
   ========================================================= */
body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--t-base), color var(--t-base);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

::selection { background: var(--primary); color: #fff; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-alt); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); border: 2px solid var(--bg-alt); }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

h1, .h1 { font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
h2, .h2 { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
h3, .h3 { font-size: var(--fs-xl); font-weight: 600; color: var(--text); }
h4 { font-size: var(--fs-lg); font-weight: 600; color: var(--text); }

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

code { font-family: var(--font-sans); background: var(--surface-3); padding: 1px 5px; border-radius: var(--r-xs); font-size: 0.9em; border: 1px solid var(--border); color: var(--primary); }

/* =========================================================
   TOPBAR · SIDEBAR · MAIN (mapping classes existantes t-*)
   ========================================================= */
.t-topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-3) var(--sp-6);
  display: flex; align-items: center; gap: var(--sp-4);
  position: sticky; top: 0; z-index: 50;
  height: 48px;
  --bsf-topbar-h: 48px;
}
.t-brand { font-size: var(--fs-lg); font-weight: 700; color: var(--text); text-decoration: none; }
.t-brand-sub { color: var(--primary); font-weight: 600; }
.t-app-pill {
  background: var(--primary-soft); color: var(--primary-soft-text);
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: 500;
}
.t-app-juris {
  background: var(--primary); color: #fff;
  padding: 1px 5px; border-radius: var(--r-xs);
  font-size: var(--fs-xs); margin-left: 4px;
}
.t-nav { margin-left: auto; display: flex; gap: var(--sp-3); align-items: center; }
.t-nav a { color: var(--text-secondary); font-weight: 500; }
.t-nav a:hover { color: var(--primary); }
.t-user { color: var(--text-tertiary); font-size: var(--fs-sm); }

.t-main {
  flex: 1;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  padding: var(--sp-6) var(--sp-7);
  display: grid;
  gap: var(--sp-6);
}
.t-main.t-with-sidebar,
.t-main:has(> [style*="display: contents"]) {
  grid-template-columns: 208px 1fr;
}

.t-footer {
  padding: var(--sp-4) var(--sp-6);
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--fs-sm);
  text-align: center;
}

.t-sidebar {
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-2);
  position: sticky;
  top: 64px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  align-self: start;
  display: flex;
  flex-direction: column;
}
.t-side-section {
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary); font-weight: 600;
}
.t-side-item {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--sidebar-text);
  font-size: var(--fs-md);
  margin-bottom: 2px;
  border-left: 0;
  transition: background var(--t-fast), color var(--t-fast);
}
.t-side-item:hover { background: var(--sidebar-hover-bg); color: var(--text); }
.t-side-item.t-side-item-active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  font-weight: 600;
}

/* =========================================================
   CARDS
   ========================================================= */
.t-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-6);
  box-shadow: var(--shadow-xs);
}
.t-card h1, .t-card h2 { margin-bottom: var(--sp-4); }
.t-card h3 { margin-bottom: var(--sp-2); margin-top: 0; color: var(--text); font-size: var(--fs-lg); font-weight: 600; }
.t-card p { color: var(--text-secondary); font-size: var(--fs-md); }
.t-grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--sp-4);
}

.t-page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: var(--sp-5);
  flex-wrap: wrap; gap: var(--sp-3);
}
.t-page-header h1 { font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -0.02em; }

.t-meta { color: var(--text-secondary); font-size: var(--fs-sm); }
.t-help { color: var(--text-tertiary); font-size: var(--fs-sm); }

/* =========================================================
   BUTTONS
   ========================================================= */
.t-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 0 var(--sp-4);
  height: 29px;
  font-size: var(--fs-md); font-weight: 500;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
  transition: all var(--t-fast);
  white-space: nowrap; user-select: none;
  cursor: pointer;
}
.t-btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.t-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.t-btn:disabled, .t-btn[disabled] { opacity: 0.5; pointer-events: none; }

.t-btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.t-btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.t-btn-primary:active { background: var(--primary-active); }

.t-btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.t-btn-success:hover { background: var(--success-hover); border-color: var(--success-hover); color: #fff; }
.t-btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.t-btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }
.t-btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.t-btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.t-btn-sm { height: 24px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }

/* =========================================================
   FORMS
   ========================================================= */
.t-form {
  display: flex; flex-direction: column;
  gap: var(--sp-4);
  max-width: 480px;
}
.t-card > form, .t-card .t-form { max-width: 100%; }

.t-form label,
.t-form-aside label {
  display: flex; flex-direction: column; gap: var(--sp-2);
  font-size: var(--fs-sm); font-weight: 600; color: var(--text);
}
.t-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.t-form-aside .t-form-row,
.t-dialog .t-form-row { grid-template-columns: 1fr; }

.t-form-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; }

.t-form-check {
  display: flex !important;
  flex-direction: row !important;
  align-items: center; gap: var(--sp-2);
  font-weight: 500; color: var(--text-secondary);
}
.t-form-check input { width: auto !important; height: auto !important; padding: 0 !important; }

.t-form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-6);
  margin-bottom: var(--sp-4);
}
.t-form-section h3 { margin-bottom: var(--sp-4); color: var(--text); font-size: var(--fs-lg); font-weight: 600; }

/* Inputs / Select / Textarea — règle globale dark-safe pour TOUT le main */
.t-main :where(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="file"]):not([type="color"]):not([type="range"]) {
  width: 100%;
  height: 30px;
  padding: 0 var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: var(--fs-md);
  outline: none;
  transition: all var(--t-fast);
}
.t-main textarea {
  height: auto;
  min-height: 72px;
  padding: var(--sp-3);
  resize: vertical;
}
.t-main :where(input, select, textarea):hover { border-color: var(--border-strong); }
.t-main :where(input, select, textarea):focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}
.t-main :where(input, textarea)::placeholder { color: var(--text-tertiary); }

.t-main select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23808078' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 29px;
}
[data-theme="dark"] .t-main select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aabc1' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}

/* PDF preview garde son fond blanc volontaire */
.t-brand-mockup :where(input, textarea) { background: #fff; color: #1a1a1a; }

/* =========================================================
   TABLES
   ========================================================= */
.t-table { width: 100%; font-size: var(--fs-md); }
.t-table th {
  text-align: left; padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2); color: var(--text-secondary);
  font-weight: 600; font-size: var(--fs-xs);
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.t-table td { padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--divider); color: var(--text); }
.t-table tr:hover td { background: var(--surface-2); }
.t-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* =========================================================
   STATUS BADGES / PILLS
   ========================================================= */
.t-status, .t-status-pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px;
  font-size: var(--fs-xs); font-weight: 600;
  border-radius: var(--r-full);
  background: var(--neutral-soft); color: var(--neutral-soft-text);
  line-height: 1.4; white-space: nowrap;
}
.t-status-draft { background: var(--neutral-soft); color: var(--neutral-soft-text); }
.t-status-issued, .t-status-active { background: var(--primary-soft); color: var(--primary-soft-text); }
.t-status-paid, .t-status-success { background: var(--success-soft); color: var(--success-soft-text); }
.t-status-cancelled, .t-status-danger { background: var(--danger-soft); color: var(--danger-soft-text); }
.t-status-warning { background: var(--warning-soft); color: var(--warning-soft-text); }

/* =========================================================
   FLASH / ALERTS
   ========================================================= */
.flash {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
  border-left: 4px solid var(--primary);
  background: var(--primary-soft); color: var(--primary-soft-text);
  font-size: var(--fs-md);
}
.flash-success { background: var(--success-soft); color: var(--success-soft-text); border-color: var(--success); }
.flash-warning { background: var(--warning-soft); color: var(--warning-soft-text); border-color: var(--warning); }
.flash-error, .flash-danger { background: var(--danger-soft); color: var(--danger-soft-text); border-color: var(--danger); }

/* =========================================================
   FILTER BAR (orders/deliveries/stock)
   ========================================================= */
.t-filter-bar {
  display: flex; flex-wrap: wrap; gap: var(--sp-3);
  align-items: center;
  margin-bottom: var(--sp-4);
}
.t-filter-input, .t-filter-select {
  min-width: 160px;
  height: 30px;
  padding: 0 var(--sp-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text); font-size: var(--fs-md);
}
.t-filter-input { min-width: 240px; flex: 1; }

/* =========================================================
   MODAL DIALOG (HTML5 <dialog>)
   ========================================================= */
.t-dialog {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-6);
  box-shadow: var(--shadow-xl);
  min-width: 420px; max-width: 560px;
}
.t-dialog::backdrop { background: var(--overlay); }
.t-dialog h3 { margin: 0 0 var(--sp-4) 0; }
.t-dialog .t-form-row { margin-top: var(--sp-3); }
.t-dialog .t-form-actions { margin-top: var(--sp-5); }

/* =========================================================
   STACKED SECTIONS (logistics / mfg setup)
   ========================================================= */
.t-logistics-grid {
  display: flex; flex-direction: column; gap: var(--sp-5);
}
.t-logistics-grid > section { padding: var(--sp-5) var(--sp-6); }
.t-logistics-grid h2 { margin: 0 0 var(--sp-3) 0; font-size: var(--fs-xl); }

/* =========================================================
   KPI / COST / MASTER CARDS
   ========================================================= */
.t-kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.t-kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--shadow-xs);
}
.t-kpi-label { font-size: var(--fs-xs); color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.t-kpi-value { font-size: var(--fs-3xl); font-weight: 700; margin-top: var(--sp-2); color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.t-kpi-card.t-kpi-warn { border-left: 3px solid var(--warning); }
.t-kpi-card.t-kpi-warn .t-kpi-value { color: var(--warning); }

.t-cost-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.t-cost-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5);
  color: var(--text); box-shadow: var(--shadow-xs);
}
.t-cost-card-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.t-cost-card-primary .t-cost-label, .t-cost-card-primary .t-meta { color: rgba(255,255,255,0.85); }
.t-cost-card-success { border-left: 4px solid var(--success); }
.t-cost-card-danger  { border-left: 4px solid var(--danger); }
.t-cost-card .t-cost-label { font-size: var(--fs-xs); color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.t-cost-card .t-cost-value { font-size: var(--fs-3xl); font-weight: 700; margin-top: var(--sp-2); font-variant-numeric: tabular-nums; color: inherit; letter-spacing: -0.02em; }
.t-cost-mini-tbl { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-1) var(--sp-3); margin-top: var(--sp-3); font-size: var(--fs-sm); color: var(--text-secondary); }
.t-cost-mini-tbl .num { font-variant-numeric: tabular-nums; }
.t-cost-breakdown td:first-child { padding-left: var(--sp-3); }

.t-master-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-4); margin-top: var(--sp-3); }
.t-master-card {
  display: block; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
}
.t-master-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.t-master-card h3 { color: var(--text); }
.t-master-card-header { display: flex; justify-content: space-between; align-items: center; }
.t-master-packs { margin-top: var(--sp-2); display: flex; flex-wrap: wrap; gap: 4px; }
.t-master-pack { background: var(--primary-soft); color: var(--primary-soft-text); padding: 2px 8px; border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 600; text-transform: lowercase; }

/* =========================================================
   COMPOSER WIZARD
   ========================================================= */
.t-compose { max-width: 880px; margin: 0 auto; padding: var(--sp-5); color: var(--text); }
.t-compose-header { text-align: center; margin-bottom: var(--sp-6); }
.t-compose-progress { display: flex; align-items: center; justify-content: center; gap: 0; margin-bottom: var(--sp-7); flex-wrap: wrap; }
.t-compose-step { display: flex; flex-direction: column; align-items: center; padding: var(--sp-2); }
.t-compose-step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-tertiary);
  font-weight: 700; font-size: var(--fs-md);
  border: 2px solid var(--border);
}
.t-compose-step-label { font-size: var(--fs-xs); color: var(--text-tertiary); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.t-compose-step-current .t-compose-step-num { background: var(--primary); color: #fff; border-color: var(--primary); }
.t-compose-step-current .t-compose-step-label { color: var(--primary); font-weight: 700; }
.t-compose-step-done .t-compose-step-num { background: var(--success); color: #fff; border-color: var(--success); }
.t-compose-step-sep { width: 40px; height: 2px; background: var(--border); margin: 0 6px; }
.t-compose-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-7) var(--sp-8);
  margin-bottom: var(--sp-4); color: var(--text);
  box-shadow: var(--shadow-sm);
}
.t-compose-options { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-5); }
.t-compose-option {
  display: flex; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--t-fast);
}
.t-compose-option:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-soft-text); }
.t-compose-option input[type=checkbox], .t-compose-option input[type=radio] { margin-top: 3px; flex-shrink: 0; }
.t-compose-option-label { font-weight: 600; color: var(--text); }
.t-compose-fields { display: flex; flex-direction: column; gap: var(--sp-4); margin-top: var(--sp-5); }
.t-compose-fields label { display: flex; flex-direction: column; gap: var(--sp-2); color: var(--text); font-weight: 600; }
.t-compose-recap h3 { margin: var(--sp-5) 0 var(--sp-3) 0; color: var(--primary); }

/* =========================================================
   DOCUMENT GRID (3 cards client/détails/totaux)
   ========================================================= */
.t-doc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-4); }
.t-doc-status-bar {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  margin-bottom: var(--sp-4); padding: var(--sp-3);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
}
.t-meta-tbl { width: 100%; }
.t-meta-tbl th { padding: 4px 0; text-align: left; font-weight: 500; color: var(--text-secondary); width: 45%; font-size: var(--fs-sm); }
.t-meta-tbl td { padding: 4px 0; color: var(--text); font-size: var(--fs-sm); }
.t-meta-tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.t-totals-show-ttc th, .t-totals-show-ttc td {
  background: var(--primary-soft); color: var(--primary-soft-text);
  padding: var(--sp-2) var(--sp-3); font-weight: 700; border-radius: var(--r-sm);
}

/* =========================================================
   DOC LINES TABLE (factures, commandes, BL)
   ========================================================= */
.t-doc-lines { width: 100%; }
.t-doc-lines th { background: var(--surface-2); color: var(--text-secondary); font-weight: 600; padding: var(--sp-2); font-size: var(--fs-xs); text-transform: uppercase; }
.t-doc-lines td { padding: var(--sp-2); border-top: 1px solid var(--divider); }
.t-doc-lines tfoot tr th, .t-doc-lines tfoot tr td { background: var(--surface-2); font-weight: 600; }
.t-tot-ttc th, .t-tot-ttc td { background: var(--primary); color: #fff; padding: var(--sp-3); }
.t-doc-lines-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-3); }
.line-no { color: var(--text-tertiary); font-weight: 600; }

/* =========================================================
   SPLIT LAYOUT (main + aside)
   ========================================================= */
.t-split { display: grid; grid-template-columns: 1fr 360px; gap: var(--sp-5); align-items: start; }
.t-split-main { min-width: 0; }
.t-split-aside { position: sticky; top: 72px; }
.t-form-aside {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-3);
  box-shadow: var(--shadow-xs);
}
@media (max-width: 1024px) {
  .t-split { grid-template-columns: 1fr; }
  .t-split-aside { position: static; }
}

/* =========================================================
   EMPTY STATE
   ========================================================= */
.t-empty { text-align: center; padding: var(--sp-9) var(--sp-5); color: var(--text-secondary); }
.t-empty-icon { font-size: var(--fs-4xl); margin-bottom: var(--sp-3); }

/* =========================================================
   BRAND MOCKUP (PDF preview — fond clair volontaire)
   ========================================================= */
.t-brand-preview { margin-top: var(--sp-4); }
.t-brand-preview-label { font-size: var(--fs-sm); color: var(--text-secondary); margin-bottom: var(--sp-2); font-weight: 600; }
.t-brand-mockup { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; max-width: 540px; box-shadow: var(--shadow-sm); }
.t-brand-mockup-header { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-3) var(--sp-4); transition: background 0.15s, color 0.15s; }
.t-brand-mockup-logo { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 2px solid currentColor; border-radius: var(--r-sm); font-weight: 700; letter-spacing: 1px; font-size: var(--fs-sm); }
.t-brand-mockup-doctype { font-weight: 700; letter-spacing: 2px; font-size: var(--fs-xl); }
.t-brand-mockup-body { padding: var(--sp-4); background: #fff; color: #1a1a1a; }
.t-brand-mockup-line { padding: 3px 0; border-bottom: 1px dashed #e5e5e5; font-variant-numeric: tabular-nums; color: #1a1a1a; }
.t-brand-mockup-line:last-child { border-bottom: 0; }
.t-brand-mockup-totals { padding: var(--sp-3); font-weight: 700; text-align: right; transition: background 0.15s, color 0.15s; }

/* =========================================================
   LINKS / MISC
   ========================================================= */
.t-link { color: var(--primary); font-size: var(--fs-sm); font-weight: 500; }
.t-link:hover { text-decoration: underline; color: var(--primary-hover); }
.t-link-danger { color: var(--danger); }
.t-link-danger:hover { color: var(--danger-hover); }
.t-badge { display: inline-block; padding: 2px 6px; border-radius: var(--r-xs); background: var(--surface-3); color: var(--text-secondary); font-size: var(--fs-xs); }

.t-row-low-stock { background: var(--warning-soft); }
.t-row-low-stock td { color: var(--warning-soft-text); }
.t-section-header { background: var(--surface-2); }
.t-section-header th { color: var(--text); font-weight: 700; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 960px) {
  .t-main.t-with-sidebar,
  .t-main:has(> [style*="display: contents"]) { grid-template-columns: 1fr; }
  .t-sidebar { position: static; max-height: none; }
  .t-main { padding: var(--sp-4); }
}

/* =========================================================
   THEME TOGGLE (topbar)
   ========================================================= */
.t-theme-toggle {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: all var(--t-fast);
  font-size: var(--fs-lg);
  margin-right: var(--sp-2);
}
.t-theme-toggle:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
.t-theme-toggle .t-theme-icon-dark { display: none; }
[data-theme="dark"] .t-theme-toggle .t-theme-icon-light { display: none; }
[data-theme="dark"] .t-theme-toggle .t-theme-icon-dark { display: inline; }

/* =========================================================
   BREADCRUMB (DS Walid)
   ========================================================= */
.t-breadcrumb {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-sm); color: var(--text-secondary);
  margin-bottom: var(--sp-4);
}
.t-breadcrumb a { color: var(--text-secondary); }
.t-breadcrumb a:hover { color: var(--primary); }
.t-breadcrumb-sep { color: var(--text-tertiary); }
.t-breadcrumb-current { color: var(--text); font-weight: 500; }
