@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

:root {
  --ink: #1C2024;
  --ink-muted: #6B7178;
  --bg-page: #EDEDE7;
  --panel: #FFFFFF;
  --line: #DCDACF;
  --c-steel: #2F5D8A;
  --c-steel-bg: #E5EDF4;
  --c-green: #3F7D52;
  --c-green-bg: #E6F0E8;
  --c-amber: #B5791F;
  --c-amber-bg: #FBEEDA;
  --c-rust: #A83A2E;
  --c-rust-bg: #F7E4E1;
  --font-display: 'Oswald', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

body { font-family: var(--font-body); color: var(--ink); background: var(--bg-page); }

.app { display: flex; min-height: 100vh; width: 100%; position: relative; }

.loading-screen {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--ink-muted); padding: 60px; width: 100%; font-size: 13px;
}
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.sidebar {
  width: 220px; flex-shrink: 0; background: #1B1F23; color: #E8E7E1;
  display: flex; flex-direction: column; padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 20px; }
.brand-mark { width: 30px; height: 30px; border-radius: 4px; overflow: hidden; position: relative; background: var(--c-amber); flex-shrink: 0; }
.hazard-strip { position: absolute; inset: 0; background-image: repeating-linear-gradient(45deg, #1B1F23 0 4px, var(--c-amber) 4px 9px); }
.brand-title { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.06em; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 10.5px; color: #A6A79C; letter-spacing: 0.03em; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px;
  background: transparent; border: none; color: #C7C6BE; font-family: var(--font-body);
  font-size: 13px; font-weight: 500; cursor: pointer; text-align: left; width: 100%;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: #262B30; color: #fff; }
.nav-item.active { background: var(--c-steel); color: #fff; }
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; }
.nav-count { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; background: rgba(255,255,255,0.14); padding: 1px 6px; border-radius: 10px; }
.nav-item.active .nav-count { background: rgba(255,255,255,0.22); }

.sidebar-foot { margin-top: auto; padding-top: 16px; }
.foot-line { height: 1px; background: #33383D; margin-bottom: 10px; }
.sidebar-foot p { font-size: 10.5px; color: #7C7D74; letter-spacing: 0.05em; text-transform: uppercase; margin: 0; }

.content { flex: 1; min-width: 0; padding: 22px 26px 40px; overflow-y: auto; }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.topbar h1 { font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: 0.01em; margin: 0 0 4px; }
.topbar-sub { font-size: 12px; color: var(--ink-muted); margin: 0; }
.saving-pill { color: var(--c-steel); }

.error-banner { background: var(--c-rust-bg); color: var(--c-rust); padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }

.view { display: flex; flex-direction: column; gap: 18px; }

.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(140px,1fr)); gap: 12px; }
.kpi-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; position: relative; overflow: hidden; }
.kpi-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--ink-muted); }
.kpi-card.tone-steel::before { background: var(--c-steel); }
.kpi-card.tone-green::before { background: var(--c-green); }
.kpi-card.tone-amber::before { background: var(--c-amber); }
.kpi-card.tone-rust::before { background: var(--c-rust); }
.kpi-icon { color: var(--ink-muted); margin-bottom: 8px; }
.kpi-value { font-family: var(--font-display); font-size: 22px; font-weight: 600; line-height: 1; }
.kpi-label { font-size: 11.5px; color: var(--ink-muted); margin-top: 6px; }

.dash-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; }
@media (max-width: 880px) { .dash-grid { grid-template-columns: 1fr; } .kpi-row { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 640px) { .sidebar { width: 72px; } .brand-title, .brand-sub, .nav-item span, .sidebar-foot p { display: none; } .nav-item { justify-content: center; } .content { padding: 16px; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px 18px; }
.panel-head { margin-bottom: 12px; display: flex; flex-direction: column; gap: 2px; }
.panel-head.with-actions { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.panel-head h3 { font-family: var(--font-display); font-size: 15px; font-weight: 600; margin: 0; }
.panel-sub { font-size: 11.5px; color: var(--ink-muted); }

.head-actions { display: flex; align-items: center; gap: 10px; }
.search-box { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; color: var(--ink-muted); background: #FAFAF7; }
.search-box input { border: none; background: transparent; outline: none; font-size: 12.5px; font-family: var(--font-body); width: 160px; color: var(--ink); }

.mini-table, .data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.mini-table th, .data-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-muted); font-weight: 600; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.mini-table td, .data-table td { padding: 8px 10px; border-bottom: 1px solid #EFEEE6; color: var(--ink); }
.mini-table tr:last-child td, .data-table tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; }
.data-table { min-width: 640px; }
.cell-strong { font-weight: 600; }
.mono { font-family: var(--font-mono); font-size: 12px; color: var(--ink); white-space: nowrap; }

.statut-badge { font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 20px; white-space: nowrap; display: inline-block; }

.gauge-track { width: 100%; height: 6px; background: #EEEDE5; border-radius: 4px; overflow: hidden; }
.gauge-fill { height: 100%; border-radius: 4px; transition: width 0.2s ease; }

.move-badge { font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 5px; display: inline-block; }
.move-badge.in { color: var(--c-green); background: var(--c-green-bg); }
.move-badge.out { color: var(--c-steel); background: var(--c-steel-bg); }

.empty { padding: 22px 8px; text-align: center; color: var(--ink-muted); font-size: 12.5px; }

.btn { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-body); font-size: 12.5px; font-weight: 600; padding: 8px 13px; border-radius: 7px; border: 1px solid transparent; cursor: pointer; }
.btn.primary { background: var(--c-steel); color: #fff; }
.btn.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.small { font-size: 11.5px; padding: 6px 10px; }

.icon-btn { background: transparent; border: none; color: var(--ink-muted); cursor: pointer; padding: 4px; border-radius: 5px; display: inline-flex; }
.icon-btn svg { width: 15px; height: 15px; display: block; flex-shrink: 0; }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.icon-btn:hover { background: #F0EFE7; }
.icon-btn.danger:hover { color: var(--c-rust); background: var(--c-rust-bg); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(20,20,18,0.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border-radius: 12px; width: 460px; max-width: 100%; max-height: 88vh; overflow-y: auto; }
.modal.modal-wide { width: 640px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-family: var(--font-display); font-size: 16px; margin: 0; }
.modal-body { padding: 18px; }

.form-grid { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-muted); font-weight: 600; }
.field input { font-family: var(--font-body); font-size: 13px; color: var(--ink); font-weight: 400; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; outline: none; background: #FAFAF7; width: 100%; }
.field input:focus { border-color: var(--c-steel); }
.produit-preview { font-size: 12px; color: var(--ink-muted); background: #F5F4EE; padding: 8px 10px; border-radius: 7px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.bar-label { width: 140px; font-size: 11px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 14px; background: #F0EFE7; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--c-steel); border-radius: 4px; }
.bar-value { width: 90px; text-align: right; font-family: var(--font-mono); font-size: 11px; color: var(--ink-muted); }

.role-select { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-muted); font-weight: 600; }
.role-select select {
  font-family: var(--font-body); font-size: 12.5px; font-weight: 600; color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; background: #FAFAF7; outline: none;
}

.stepper { display: flex; flex-direction: column; gap: 0; margin: 4px 0; }
.step { display: flex; gap: 12px; position: relative; padding-bottom: 18px; }
.step:last-child { padding-bottom: 0; }
.step:not(:last-child)::before {
  content: ""; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--line);
}
.step-dot {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; background: #EEEDE5; color: var(--ink-muted); z-index: 1;
}
.step.done .step-dot { background: var(--c-green); color: #fff; }
.step.rejected .step-dot { background: var(--c-rust); color: #fff; }
.step.current .step-dot { background: var(--c-amber); color: #fff; }
.step.skipped .step-dot { opacity: 0.4; }
.step-label { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.step-meta { font-size: 11px; color: var(--ink-muted); margin-top: 2px; }
.step.skipped .step-label, .step.skipped .step-meta { opacity: 0.4; }

.action-box { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 14px; display: flex; flex-direction: column; gap: 12px; }

.sub-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.sub-tab { font-family: var(--font-body); font-size: 12.5px; font-weight: 600; padding: 8px 14px; border: none; background: transparent; color: var(--ink-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sub-tab:hover { color: var(--ink); }
.sub-tab.active { color: var(--c-steel); border-bottom-color: var(--c-steel); }
tfoot td { border-top: 2px solid var(--line); padding: 8px 10px; }

@media print {
  .sidebar, .topbar, .sub-tabs, .head-actions, .modal-backdrop, .kpi-row { display: none !important; }
  .content { padding: 0 !important; overflow: visible !important; }
  .panel { border: none !important; box-shadow: none !important; }
  body, .app { background: #fff !important; }
  table { font-size: 10px; }
}

.auth-shell { align-items: center; justify-content: center; background: var(--bg-page); padding: 20px; }
.auth-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px 26px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.auth-tab { flex: 1; font-family: var(--font-body); font-size: 12.5px; font-weight: 600; padding: 9px 10px; border: none; background: transparent; color: var(--ink-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.auth-tab:hover { color: var(--ink); }
.auth-tab.active { color: var(--c-steel); border-bottom-color: var(--c-steel); }

.user-badge { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.user-badge-name { font-weight: 600; color: var(--ink); }
.user-badge-role { color: var(--ink-muted); }
