/* Maquette artisan électricien — style sobre, tons bleu/gris. */
:root {
  --blue: #2563eb;
  --blue-dark: #1e3a5f;
  --blue-600: #1d4ed8;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #fff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--slate-800);
  background: var(--slate-100);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 258px;
  background: var(--blue-dark);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand h1 { font-size: 18px; color: #fff; display: flex; align-items: center; gap: 8px; }
.brand span { font-size: 12px; color: var(--slate-400); }

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px; border-radius: 9px;
  color: #cbd5e1; text-decoration: none; font-size: 14.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-icon { font-size: 16px; }

.demo-banner {
  margin: 12px; padding: 11px 13px; font-size: 12px; line-height: 1.45;
  background: rgba(37, 99, 235, .18); border: 1px solid rgba(96, 165, 250, .35);
  border-radius: 9px; color: #dbeafe;
}

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

.topbar {
  display: none;
  align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--blue-dark); color: #fff;
  position: sticky; top: 0; z-index: 20;
}
.topbar strong { font-size: 15px; }
#menu-toggle {
  background: rgba(255, 255, 255, .12); border: 0; color: #fff;
  width: 40px; height: 40px; border-radius: 8px; font-size: 20px; cursor: pointer;
}

.main { padding: 28px 32px 56px; max-width: 1180px; width: 100%; }

/* ---------- Page header ---------- */
.page-header { margin-bottom: 22px; }
.page-header h1 { font-size: 24px; color: var(--slate-900); }
.page-header p { color: var(--slate-500); margin-top: 4px; font-size: 14px; }
.section-title { margin: 30px 0 12px; font-size: 17px; color: var(--slate-800); }

/* ---------- Cards / KPI ---------- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--white); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
  border-left: 4px solid var(--blue);
}
.card-label { font-size: 12.5px; color: var(--slate-500); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.card-value { font-size: 27px; font-weight: 700; color: var(--slate-900); }
.card-hint { font-size: 12.5px; color: var(--slate-400); }

/* ---------- Charts ---------- */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card { background: var(--white); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.chart-card h3 { font-size: 15px; color: var(--slate-700); margin-bottom: 10px; }
.bar-chart { width: 100%; height: auto; }
.bar-chart .grid { stroke: var(--slate-200); stroke-width: 1; }
.bar-chart .axis-label { fill: var(--slate-500); font-size: 11px; }
.bar-chart .bar-value { fill: var(--slate-700); font-size: 11px; font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 13px 16px; background: var(--slate-50);
  color: var(--slate-500); font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--slate-200); white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--slate-100); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--slate-50); }
.num { text-align: right; white-space: nowrap; }
.strong { font-weight: 700; color: var(--slate-900); }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px; color: var(--slate-600); }
.muted { color: var(--slate-500); font-size: 13px; }
.stock-low { color: #dc2626; font-weight: 700; }
.empty { text-align: center; color: var(--slate-400); padding: 26px; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.input {
  padding: 9px 12px; border: 1px solid var(--slate-200); border-radius: 9px;
  font-size: 14px; background: #fff; color: var(--slate-800); font-family: inherit;
}
.input:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
.toolbar .input[type="search"] { flex: 1; min-width: 200px; }

/* ---------- Postes ---------- */
.poste-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.poste-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.poste-head h3 { font-size: 16px; color: var(--slate-900); }
.poste-total { text-align: right; font-size: 22px; font-weight: 700; color: var(--blue); display: flex; flex-direction: column; }
.poste-total span { font-size: 11px; color: var(--slate-400); font-weight: 500; text-transform: uppercase; }
.sub-table thead th { background: transparent; }
.row-sum td { font-weight: 600; color: var(--slate-700); background: var(--slate-50); }

/* ---------- Devis ---------- */
.devis-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.devis-header { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.devis-header label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--slate-500); }
.devis-header .input { width: 100%; }
.input-qty { width: 74px; text-align: right; }
.btn-icon { border: 0; background: var(--slate-100); color: var(--slate-500); width: 28px; height: 28px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.btn-icon:hover { background: #fee2e2; color: #dc2626; }

.devis-totals { margin-top: 18px; margin-left: auto; width: 300px; max-width: 100%; }
.tot-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--slate-100); font-size: 14px; }
.tot-line span { color: var(--slate-500); }
.tot-ttc { border-bottom: 0; border-top: 2px solid var(--slate-200); margin-top: 4px; padding-top: 12px; font-size: 18px; }
.tot-ttc strong { color: var(--blue); }

.devis-actions { display: flex; gap: 12px; margin-top: 20px; }
.btn { padding: 10px 18px; border: 0; border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-600); }
.btn-secondary { background: var(--slate-100); color: var(--slate-700); }
.btn-secondary:hover { background: var(--slate-200); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-envoye { background: #dbeafe; color: #1d4ed8; }
.badge-refuse { background: #fee2e2; color: #b91c1c; }
.badge-paye { background: #d1fae5; color: #047857; }
.badge-impaye { background: #fef3c7; color: #b45309; }

/* ---------- Modal PDF ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); max-width: 640px; width: 100%; max-height: 92vh; overflow: auto; }
.pdf-doc { padding: 32px; }
.pdf-brand { display: flex; justify-content: space-between; border-bottom: 3px solid var(--blue); padding-bottom: 14px; }
.pdf-brand strong { font-size: 18px; color: var(--blue-dark); }
.pdf-num { text-align: right; font-weight: 700; color: var(--slate-700); }
.pdf-client { margin: 16px 0; font-size: 14px; }
.pdf-table { margin: 8px 0; }
.pdf-table th { background: var(--slate-50); }
.pdf-totals { margin: 16px 0 8px auto; width: 260px; }
.pdf-totals div { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.pdf-totals span { color: var(--slate-500); }
.pdf-ttc { border-top: 2px solid var(--slate-200); font-size: 17px; }
.pdf-ttc strong { color: var(--blue); }
.pdf-note { font-size: 12px; color: var(--slate-400); font-style: italic; margin-top: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; background: var(--slate-50); border-top: 1px solid var(--slate-200); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .devis-header { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { display: flex; }
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; height: 100vh;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 18px 16px 48px; }
  .cards { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 20px; }
}

@media print {
  .sidebar, .topbar, .modal-actions { display: none !important; }
  .modal-overlay { position: static; background: none; padding: 0; }
  body { background: #fff; }
}
