/* Demo DUERP — Material Design ciblant la vraie plateforme ALEA Prevention */
:root {
  --primary: #1976d2;
  --primary-dark: #0d47a1;
  --primary-light: #64b5f6;
  --primary-bg: #e3f2fd;
  --accent-orange: #f57c00;
  --accent-orange-bg: #fff3e0;
  --status-todo-bg: #fff3e0;
  --status-todo-text: #e65100;
  --status-todo-border: #ffb74d;
  --status-init-bg: #e3f2fd;
  --status-init-text: #1565c0;
  --status-init-border: #90caf9;
  --status-ok-bg: #e8f5e9;
  --status-ok-text: #2e7d32;
  --status-ok-border: #a5d6a7;
  --bg: #f5f5f5;
  --bg-subtle: #fafafa;
  --border: #e0e0e0;
  --border-strong: #bdbdbd;
  --text: #212121;
  --text-muted: #616161;
  --text-faint: #9e9e9e;
  --sidebar-bg: #ffffff;
  --sidebar-text: #546e7a;
  --sidebar-active-border: #f57c00;
  --red: #d32f2f;
  --amber: #f57c00;
  --green: #388e3c;
  --font: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: var(--font); color: var(--text); }
body { background: var(--bg); font-size: 14px; line-height: 1.45; }

/* ===== Login ===== */
.screen-login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #e8f0fe 0%, #d0e2f7 60%, #b4d0ec 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: white; border-radius: 8px;
  box-shadow: 0 24px 38px rgba(0, 0, 0, 0.06), 0 9px 46px rgba(0, 0, 0, 0.08);
  padding: 40px 32px 28px;
  text-align: center;
}
.login-logo img { max-height: 72px; margin-bottom: 8px; }
.login-title { font-size: 14px; color: var(--text-muted); margin: 8px 0 28px; }
.login-field { margin-bottom: 16px; text-align: left; }
.login-field input {
  width: 100%; padding: 13px 14px;
  border: 1px solid var(--border-strong); border-radius: 4px;
  font-size: 14px; font-family: inherit; outline: none;
  background: white;
  transition: border-color 0.15s;
}
.login-field input:focus { border-color: var(--primary); border-width: 2px; padding: 12px 13px; }
.login-btn {
  width: 100%; padding: 12px; background: var(--primary); color: white;
  border: none; border-radius: 4px; font-size: 14px; font-weight: 500;
  letter-spacing: 0.02em; cursor: pointer; margin-top: 12px;
  text-transform: uppercase; font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.12);
}
.login-btn:hover { background: var(--primary-dark); box-shadow: 0 4px 8px rgba(0,0,0,0.16); }
.login-help { margin-top: 20px; font-size: 11px; color: var(--text-faint); }
.login-error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ===== App shell ===== */
.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.app-sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.app-sidebar-logo {
  padding: 18px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.app-sidebar-logo img { max-height: 44px; max-width: 100%; }
.app-sidebar-section {
  padding: 18px 20px 8px; font-size: 12px; font-weight: 600;
  color: var(--text); letter-spacing: 0.05em;
  display: flex; align-items: center; gap: 8px;
}
.app-sidebar-section::before {
  content: ""; width: 4px; height: 14px; background: var(--primary);
  border-radius: 2px;
}
.app-sidebar-nav { flex: 1; padding: 0 0 20px; }
.app-sidebar-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 12px; font-weight: 500; letter-spacing: 0.04em;
  cursor: pointer; text-transform: uppercase;
  border-left: 3px solid transparent;
  transition: background 0.1s, color 0.1s;
  position: relative;
}
.app-sidebar-item:hover { background: #f5f7fa; color: var(--primary); }
.app-sidebar-item.active {
  background: var(--primary-bg); color: var(--primary);
  border-left-color: var(--accent-orange); font-weight: 600;
}
.app-sidebar-item .material-icons { font-size: 20px; }
.app-sidebar-item .chev { margin-left: auto; font-size: 18px; opacity: 0.5; }

/* Main area */
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-header {
  height: 64px; background: white;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
}
.app-header-perimetre {
  display: flex; align-items: center; gap: 14px; flex: 1;
  font-size: 14px; color: var(--text);
}
.app-header-perimetre .label { color: var(--text-muted); white-space: nowrap; }
.app-header-perimetre .select-wrap {
  flex: 1; max-width: 520px;
  display: flex; align-items: center;
  border: 1px solid var(--border-strong); border-radius: 4px;
  background: white; padding: 0 10px;
  height: 40px;
}
.app-header-perimetre .select-wrap input {
  flex: 1; border: none; outline: none; font-size: 14px; font-family: inherit;
  background: transparent; color: var(--text);
}
.app-header-perimetre .select-wrap .material-icons { color: var(--text-faint); font-size: 20px; }
.app-header-cloud { color: var(--text-faint); cursor: pointer; }
.app-header-lang {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-muted); cursor: pointer;
}
.app-header-user {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); padding-left: 10px; border-left: 1px solid var(--border);
}
.app-header-user .u-name { font-size: 13px; font-weight: 500; line-height: 1.2; }
.app-header-user .u-role { font-size: 11px; color: var(--text-muted); line-height: 1.2; }
.app-header-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-bg); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 500;
}

/* Content */
.app-content { flex: 1; padding: 20px 24px; overflow-y: auto; background: white; }

/* Page head */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
  padding-bottom: 4px;
}
.page-head h1 {
  margin: 0;
  color: var(--primary);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.page-head h1 .back-arrow {
  font-size: 22px; vertical-align: middle; margin-right: 6px;
  color: var(--primary); cursor: pointer;
}
.page-head .head-actions { display: flex; align-items: center; gap: 8px; }
.page-head .subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* Toolbar (search + view toggles + filter) */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--border);
  margin-top: 4px;
}
.toolbar .search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 4px;
  padding: 6px 12px; background: white;
}
.toolbar .search input {
  flex: 1; border: none; outline: none; font-size: 14px; font-family: inherit;
}
.toolbar .search .material-icons { color: var(--text-faint); font-size: 20px; }
.toolbar .view-btn, .toolbar .filter-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: 4px;
  color: var(--text-muted); cursor: pointer;
}
.toolbar .view-btn.active { color: var(--primary); background: var(--primary-bg); }
.toolbar .view-btn:hover, .toolbar .filter-btn:hover { background: #f5f7fa; }
.toolbar .total-actions {
  display: flex; align-items: center; gap: 4px;
  color: var(--text); font-size: 13px; font-weight: 500;
  padding: 8px 12px; cursor: pointer;
}

/* Buttons */
.btn-primary {
  padding: 10px 18px; background: var(--primary); color: white;
  border: none; border-radius: 4px; font-size: 13px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.12);
  font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 8px rgba(0,0,0,0.16); }
.btn-primary:disabled { background: #bdbdbd; cursor: not-allowed; box-shadow: none; }
.btn-secondary {
  padding: 10px 18px; background: white; color: var(--primary);
  border: 1px solid var(--border-strong); border-radius: 4px;
  font-size: 13px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em;
  cursor: pointer; font-family: inherit;
}
.btn-secondary:hover { background: var(--primary-bg); }
.btn-icon {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 50%;
  color: var(--primary); cursor: pointer;
  transition: background 0.1s;
}
.btn-icon:hover { background: var(--primary-bg); }
.btn-icon .material-icons { font-size: 20px; }

/* Data table */
.data-table {
  width: 100%; background: white;
  border: 1px solid var(--border); border-collapse: collapse;
  border-radius: 4px; overflow: hidden;
}
.data-table thead tr { background: var(--bg-subtle); border-bottom: 2px solid var(--border); }
.data-table th {
  text-align: left; padding: 12px 16px;
  color: var(--text); font-size: 13px; font-weight: 500;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  border-left: 4px solid transparent;
  transition: background 0.1s;
  position: relative;
}
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr:hover { background: #fafcff; }
.data-table tbody tr.clickable:hover { border-left-color: var(--primary); }
.data-table td { padding: 14px 16px; font-size: 13px; color: var(--text); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table .etab-cell { display: flex; align-items: center; gap: 12px; }
.data-table .etab-thumb {
  width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text-faint); flex-shrink: 0;
}
.data-table .etab-thumb .material-icons { font-size: 24px; }
.data-table .actions-cell { display: flex; align-items: center; gap: 4px; }

/* Tags */
.tag {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
}
.tag-todo { background: var(--status-todo-bg); color: var(--status-todo-text); border-color: var(--status-todo-border); }
.tag-init { background: var(--status-init-bg); color: var(--status-init-text); border-color: var(--status-init-border); }
.tag-ok   { background: var(--status-ok-bg); color: var(--status-ok-text); border-color: var(--status-ok-border); }

/* Risk badge */
.risk-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; height: 28px;
  padding: 0 8px;
  border-radius: 4px; font-size: 12px; font-weight: 700;
  color: white;
}
.risk-badge.green  { background: var(--green); }
.risk-badge.orange { background: var(--amber); }
.risk-badge.red    { background: var(--red); }

/* Stat cards */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin: 16px 0;
}
.stat-card {
  background: white; border: 1px solid var(--border);
  border-radius: 4px; padding: 16px 18px;
  border-left: 4px solid var(--primary);
}
.stat-card.accent-red { border-left-color: var(--red); }
.stat-card.accent-amber { border-left-color: var(--amber); }
.stat-card.accent-green { border-left-color: var(--green); }
.stat-card-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card-value { font-size: 28px; font-weight: 500; color: var(--text); margin-top: 6px; line-height: 1.1; }
.stat-card-sub { font-size: 11px; color: var(--text-faint); margin-top: 4px; }

/* Stepper (Material) */
.stepper {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0; margin-bottom: 20px;
  overflow-x: auto;
}
.stepper-step {
  display: flex; flex-direction: column; align-items: center;
  flex: 1; min-width: 100px; position: relative;
}
.stepper-step::after {
  content: ""; position: absolute; top: 14px; left: 60%; right: -40%;
  height: 1px; background: var(--border);
}
.stepper-step:last-child::after { display: none; }
.stepper-circle {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 500;
  margin-bottom: 8px; z-index: 1;
}
.stepper-step.inactive .stepper-circle { background: #b0bec5; }
.stepper-step .stepper-label {
  font-size: 12px; color: var(--text); text-align: center;
  font-weight: 500; max-width: 140px;
}

/* Accordion / expansion panel */
.accordion { margin-bottom: 16px; border-radius: 4px; overflow: hidden; }
.accordion-panel {
  background: white;
  border: 1px solid var(--border);
  margin-bottom: 8px; border-radius: 4px;
  overflow: hidden;
}
.accordion-header {
  padding: 16px 20px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
  background: white; font-weight: 500; color: var(--text);
  border-bottom: 1px solid transparent;
  transition: background 0.1s;
}
.accordion-header:hover { background: var(--bg-subtle); }
.accordion-panel.open .accordion-header { border-bottom-color: var(--border); }
.accordion-panel.open .accordion-chev { transform: rotate(180deg); }
.accordion-chev { transition: transform 0.2s; color: var(--text-muted); }
.accordion-body { padding: 20px; display: none; }
.accordion-panel.open .accordion-body { display: block; }

/* Form (Material outlined) */
.form-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 18px 16px; margin-top: 8px;
}
.form-grid.full { grid-template-columns: 1fr; }
.form-field { position: relative; }
.form-field label.flabel {
  position: absolute; top: -7px; left: 10px; padding: 0 6px;
  font-size: 11px; color: var(--text-muted); background: white;
  z-index: 1; pointer-events: none;
}
.form-field.required label.flabel::after { content: " *"; color: var(--red); }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 13px 14px;
  border: 1px solid var(--border-strong); border-radius: 4px;
  font-size: 14px; font-family: inherit; outline: none;
  background: white; color: var(--text);
  transition: border-color 0.15s, border-width 0.15s;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--primary); border-width: 2px; padding: 12px 13px;
}
.form-field input:disabled { background: #fafafa; color: var(--text-faint); }
.form-section-title {
  font-size: 13px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.05em; margin: 22px 0 10px; font-weight: 500;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.form-section-title:first-child { margin-top: 0; }

/* Empty state */
.empty {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
  font-size: 14px; background: var(--bg-subtle);
  border: 1px dashed var(--border-strong); border-radius: 4px;
}

/* Detail section (card) */
.detail-card {
  background: white; border: 1px solid var(--border);
  border-radius: 4px; padding: 20px; margin-bottom: 16px;
}
.detail-card h3 {
  margin: 0 0 14px; font-size: 15px; color: var(--text); font-weight: 500;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.detail-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .detail-grid2 { grid-template-columns: 1fr; } }
.kv { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.kv .k { color: var(--text-muted); }
.kv .v { color: var(--text); font-weight: 500; text-align: right; }

/* ===== Drawer (side panel) ===== */
.drawer-overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(0,0,0,0.35);
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
  z-index: 999;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 520px; max-width: 90vw; background: var(--bg);
  transform: translateX(100%); transition: transform 0.25s;
  display: flex; flex-direction: column;
  z-index: 1000; box-shadow: -6px 0 30px rgba(0,0,0,0.15);
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  padding: 22px 24px 14px; background: white;
  border-bottom: 1px solid var(--border);
}
.drawer-header h2 {
  margin: 0; color: var(--primary); font-size: 18px; font-weight: 500;
}
.drawer-body {
  flex: 1; overflow-y: auto; padding: 22px 24px;
}
.drawer-footer {
  padding: 14px 24px; background: white;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* Footer */
.app-footer {
  padding: 10px 20px; font-size: 11px; color: var(--text-faint);
  border-top: 1px solid var(--border); background: white; text-align: center;
}

/* Demo watermark */
.demo-watermark {
  position: fixed; bottom: 6px; left: 6px;
  background: rgba(0, 0, 0, 0.7); color: white;
  padding: 3px 8px; border-radius: 3px;
  font-size: 10px; z-index: 100;
  letter-spacing: 0.05em; pointer-events: none;
}

/* Status bande verticale à gauche de la ligne table */
.data-table tbody tr.status-todo::before,
.data-table tbody tr.status-init::before,
.data-table tbody tr.status-ok::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}
.data-table tbody tr.status-todo::before { background: var(--amber); }
.data-table tbody tr.status-init::before { background: var(--primary); }
.data-table tbody tr.status-ok::before { background: var(--green); }

/* Snackbar */
.snackbar {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #323232; color: white; padding: 14px 22px; border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25); font-size: 14px;
  z-index: 2000; opacity: 0; transition: opacity 0.2s, transform 0.2s;
}
.snackbar.show { opacity: 1; transform: translateX(-50%) translateY(0); }
