/* SUNU Workflow — charte inspirée de SUNU Assurances (rouge / gris anthracite) */
:root {
  --sunu-red: #C8102E;
  --sunu-red-dark: #9d0c24;
  --sunu-red-soft: #fdecef;
  --sunu-ink: #23252b;
  --sunu-ink-2: #2e3138;
  --sunu-grey: #6b7280;
  --sunu-line: #e6e8ec;
  --sunu-bg: #f4f5f8;
  --sidebar-w: 264px;
  --radius: 14px;
  --bs-primary: #C8102E;
  --bs-primary-rgb: 200, 16, 46;
  --bs-link-color: #C8102E;
  --bs-link-hover-color: #9d0c24;
  --bs-body-font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --bs-body-bg: var(--sunu-bg);
}
html, body { height: 100%; }
body { background: var(--sunu-bg); color: #1f2430; font-size: 14.5px; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }

/* Boutons marque */
.btn-sunu { background: var(--sunu-red); color: #fff; border: 1px solid var(--sunu-red); font-weight: 500; }
.btn-sunu:hover, .btn-sunu:focus { background: var(--sunu-red-dark); border-color: var(--sunu-red-dark); color: #fff; }
.btn-outline-sunu { color: var(--sunu-red); border: 1px solid var(--sunu-red); background: transparent; }
.btn-outline-sunu:hover { background: var(--sunu-red); color: #fff; }
.btn-icon { border: 0; background: transparent; padding: 6px 10px; border-radius: 10px; color: var(--sunu-ink); }
.btn-icon:hover { background: #eceef2; }
.form-control:focus, .form-select:focus { border-color: var(--sunu-red); box-shadow: 0 0 0 .2rem rgba(200, 16, 46, .14); }
.form-check-input:checked { background-color: var(--sunu-red); border-color: var(--sunu-red); }

/* Logo losange */
.sunu-diamond { width: 42px; height: 42px; position: relative; display: inline-block; flex: 0 0 auto; }
.sunu-diamond::before { content: ""; position: absolute; inset: 4px; background: var(--sunu-red); transform: rotate(45deg); border-radius: 6px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.sunu-diamond span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 10px; letter-spacing: .5px; }
.sunu-diamond.big { width: 84px; height: 84px; margin: 0 auto 8px; }
.sunu-diamond.big span { font-size: 20px; }

/* Structure */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--sunu-ink); color: #cfd3da; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 1040; transition: transform .25s ease; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-text { line-height: 1.1; }
.brand-text b { font-size: 17px; display: block; letter-spacing: .2px; }
.brand-text small { color: #9aa1ad; font-size: 11px; }
.menu { padding: 10px 12px 20px; overflow-y: auto; flex: 1; }
.menu-section { text-transform: uppercase; font-size: 10.5px; letter-spacing: 1px; color: #7d8491; margin: 16px 10px 6px; font-weight: 600; }
.menu-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0; border-radius: 10px; color: #cfd3da; font-weight: 500; position: relative; }
.menu-link i { font-size: 17px; width: 20px; text-align: center; opacity: .9; }
.menu-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.menu-link.active { background: rgba(200,16,46,.18); color: #fff; }
.menu-link.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; background: var(--sunu-red); border-radius: 0 4px 4px 0; }
.sidebar-foot { padding: 12px 20px; font-size: 11.5px; color: #7d8491; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-backdrop { display: none; }
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 64px; background: #fff; border-bottom: 1px solid var(--sunu-line); display: flex; align-items: center; gap: 12px; padding: 0 22px; position: sticky; top: 0; z-index: 1030; }
.content { padding: 24px 26px 40px; flex: 1; }
.app-footer { padding: 14px 26px; color: var(--sunu-grey); font-size: 12px; border-top: 1px solid var(--sunu-line); background: #fff; }

/* Recherche globale */
.global-search { width: min(440px, 46vw); }
.global-search > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--sunu-grey); }
.global-search .form-control { padding-left: 36px; background: #f3f4f7; border-color: transparent; border-radius: 10px; }
.global-search .form-control:focus { background: #fff; }
.search-results { position: absolute; top: 46px; left: 0; right: 0; background: #fff; border: 1px solid var(--sunu-line); border-radius: 12px; box-shadow: 0 12px 30px rgba(20,22,30,.14); max-height: 420px; overflow-y: auto; z-index: 1050; }
.search-results a { display: block; padding: 9px 14px; color: inherit; border-bottom: 1px solid #f0f1f4; }
.search-results a:hover { background: var(--sunu-red-soft); }
.search-results .grp { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--sunu-grey); padding: 8px 14px 2px; font-weight: 600; }

/* Profil, notifications */
.profile-btn { display: flex; align-items: center; gap: 10px; border: 0; padding: 4px 8px; border-radius: 12px; }
.profile-btn:hover { background: #eceef2; }
.avatar { border-radius: 50%; object-fit: cover; display: inline-block; }
.avatar-initials { display: inline-flex; align-items: center; justify-content: center; background: var(--sunu-red-soft); color: var(--sunu-red); font-weight: 700; }
.notif-dot { position: absolute; top: 0; right: 0; font-size: 10px; }
.notif-menu { width: 360px; max-width: 92vw; border-radius: 14px; overflow: hidden; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: block; padding: 10px 16px; border-bottom: 1px solid #f0f1f4; color: inherit; }
.notif-item:hover { background: #fafafb; }
.notif-item.unread { background: var(--sunu-red-soft); }
.notif-item b { display: block; font-size: 13px; }
.notif-item span { font-size: 12.5px; color: var(--sunu-grey); display: block; }
.notif-item small { color: #9aa1ad; font-size: 11px; }

/* Cartes et KPI */
.card { border: 1px solid var(--sunu-line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(20,22,30,.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--sunu-line); font-weight: 600; padding: 14px 18px; }
.card-body { padding: 18px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.2px; }
.page-head p { margin: 2px 0 0; color: var(--sunu-grey); }
.kpi { display: flex; gap: 14px; align-items: center; padding: 16px 18px; background: #fff; border: 1px solid var(--sunu-line); border-radius: var(--radius); height: 100%; transition: box-shadow .15s, transform .15s; }
a.kpi:hover { box-shadow: 0 8px 20px rgba(20,22,30,.08); transform: translateY(-1px); }
.kpi .ico { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; background: var(--k-bg, var(--sunu-red-soft)); color: var(--k-fg, var(--sunu-red)); flex: 0 0 auto; }
.kpi .val { font-size: 24px; font-weight: 700; line-height: 1.1; color: #1f2430; }
.kpi .lbl { color: var(--sunu-grey); font-size: 12.5px; margin-top: 2px; }
.kpi.k-blue { --k-bg: #e8f0fe; --k-fg: #0d6efd; }
.kpi.k-amber { --k-bg: #fff4e0; --k-fg: #d98200; }
.kpi.k-green { --k-bg: #e6f6ee; --k-fg: #198754; }
.kpi.k-red { --k-bg: var(--sunu-red-soft); --k-fg: var(--sunu-red); }
.kpi.k-purple { --k-bg: #f0e9fb; --k-fg: #6f42c1; }
.kpi.k-teal { --k-bg: #e0f5f3; --k-fg: #0f766e; }
.kpi.k-grey { --k-bg: #eceef2; --k-fg: #495057; }
.chart-box { position: relative; height: 280px; }

/* Tables */
.table { --bs-table-bg: transparent; }
.data-table thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--sunu-grey); font-weight: 600; background: #fafbfc; border-bottom: 1px solid var(--sunu-line); white-space: nowrap; }
.data-table td { vertical-align: middle; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.filter-bar { background: #fff; border: 1px solid var(--sunu-line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px; }

/* Statuts */
.status-badge { --st: #6c757d; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--st); background: color-mix(in srgb, var(--st) 12%, #fff); border: 1px solid color-mix(in srgb, var(--st) 30%, #fff); white-space: nowrap; }
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--st); }

/* Frise chronologique */
.timeline { position: relative; margin: 0; padding: 0 0 0 26px; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--sunu-line); }
.timeline li { position: relative; padding: 0 0 18px; }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--tl, #9aa1ad); }
.timeline .tl-title { font-weight: 600; }
.timeline .tl-meta { color: var(--sunu-grey); font-size: 12px; }
.timeline .tl-comment { background: #f6f7f9; border-left: 3px solid var(--tl, #9aa1ad); padding: 6px 10px; border-radius: 6px; margin-top: 6px; font-size: 13px; white-space: pre-wrap; }

/* Étapes du circuit */
.steps { display: flex; flex-wrap: wrap; gap: 10px; }
.step-pill { border: 1px solid var(--sunu-line); border-radius: 12px; padding: 8px 12px; background: #fff; min-width: 170px; }
.step-pill small { color: var(--sunu-grey); display: block; }
.step-pill.s-APPROVED { border-color: #b7e0c8; background: #f1faf5; }
.step-pill.s-PENDING { border-color: #f1d28f; background: #fff9ec; }
.step-pill.s-REJECTED, .step-pill.s-RETURNED { border-color: #f3b4be; background: var(--sunu-red-soft); }
.step-pill.s-CANCELLED, .step-pill.s-WAITING, .step-pill.s-SKIPPED { opacity: .65; }

/* États vides, formulaires */
.empty-state { text-align: center; padding: 38px 16px; color: var(--sunu-grey); }
.empty-state i { font-size: 38px; color: #c4c8d0; }
.empty-state h6 { margin: 10px 0 4px; color: #4b5260; }
.empty-state p { margin: 0; font-size: 13px; }
.form-section { border: 1px solid var(--sunu-line); border-radius: var(--radius); background: #fff; margin-bottom: 18px; }
.form-section > h6 { margin: 0; padding: 13px 18px; border-bottom: 1px solid var(--sunu-line); font-weight: 600; display: flex; gap: 8px; align-items: center; }
.form-section > h6 i { color: var(--sunu-red); }
.form-section .inner { padding: 18px; }
.req::after { content: " *"; color: var(--sunu-red); }
.type-card { display: block; border: 2px solid var(--sunu-line); border-radius: var(--radius); padding: 16px; background: #fff; color: inherit; height: 100%; transition: all .15s; }
.type-card:hover { border-color: var(--sunu-red); box-shadow: 0 8px 22px rgba(200,16,46,.10); color: inherit; }
.type-card i { font-size: 26px; color: var(--sunu-red); }
.type-card h6 { margin: 8px 0 2px; font-weight: 600; }
.type-card p { margin: 0; color: var(--sunu-grey); font-size: 12.5px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 22px; }
.detail-grid dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--sunu-grey); font-weight: 600; }
.detail-grid dd { margin: 2px 0 0; font-weight: 500; }
.doc-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--sunu-line); border-radius: 10px; background: #fff; }
.doc-item i.bi { font-size: 22px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px 18px; }
.badge-prov { background: #fff4e0; color: #b26b00; border: 1px solid #f1d28f; font-weight: 600; }

/* Page de connexion */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: linear-gradient(135deg, var(--sunu-red) 0%, #7d0a1d 100%); color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 60px; position: relative; overflow: hidden; }
.login-art::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; background: rgba(255,255,255,.07); transform: rotate(45deg); border-radius: 40px; }
.login-art h1 { font-weight: 700; font-size: 36px; margin: 18px 0 10px; }
.login-art p { opacity: .9; max-width: 440px; }
.login-art ul { list-style: none; padding: 0; margin: 26px 0 0; }
.login-art li { margin: 8px 0; display: flex; gap: 10px; align-items: center; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: #fff; }
.login-card { width: 100%; max-width: 400px; }
.error-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--sunu-bg); font-family: 'Inter', 'Segoe UI', sans-serif; }
.error-card { background: #fff; border: 1px solid var(--sunu-line); border-radius: 16px; padding: 40px; text-align: center; max-width: 480px; box-shadow: 0 10px 30px rgba(20,22,30,.06); }
.error-card h1 { font-size: 22px; margin: 6px 0 10px; }
.error-card .btn-sunu { display: inline-block; padding: 8px 18px; border-radius: 8px; }

/* Chargement */
.page-loader { position: fixed; inset: 0; background: rgba(255,255,255,.7); backdrop-filter: blur(2px); display: none; align-items: center; justify-content: center; z-index: 2000; }
.page-loader.show { display: flex; }
.skeleton { background: linear-gradient(90deg, #eee 25%, #f6f6f6 37%, #eee 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 6px; min-height: 14px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* Responsive */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035; }
  .main { margin-left: 0; }
  .content { padding: 18px 14px 30px; }
  .topbar { padding: 0 12px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
@media print { .sidebar, .topbar, .filter-bar, .btn, .app-footer { display: none !important; } .main { margin: 0; } }
