* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; color: #222; background: #f5f6f8; }
a { color: #2563eb; }
.app { display: flex; height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar { width: 240px; background: #1f2937; color: #fff; padding: 20px 0; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; margin: 0 20px 8px; border-bottom: 1px solid #374151; padding-bottom: 12px; }
.sidebar-header h1 { margin: 0; font-size: 18px; letter-spacing: .5px; }
.sync-form { margin: 0; }
.sync-btn { display: flex; align-items: center; gap: 5px; background: #374151; border: none; color: #d1d5db; padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; transition: background .15s; }
.sync-btn:hover { background: #4b5563; color: #fff; }
.sync-status { margin: 0 20px 10px; font-size: 11px; color: #9ca3af; display: flex; align-items: center; gap: 5px; }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: #10b981; display: inline-block; flex-shrink: 0; }
.sync-dot-err { background: #ef4444; }
.sidebar nav { flex: 1; overflow-y: auto; }
.sidebar nav a { display: block; padding: 12px 20px; color: #d1d5db; text-decoration: none; border-left: 3px solid transparent; }
.sidebar nav a:hover { background: #374151; color: #fff; }
.sidebar nav a.active { background: #111827; color: #fff; border-left-color: #3b82f6; }
.sidebar nav a .label { display: flex; align-items: center; }
.nav-icon { vertical-align: -3px; margin-right: 8px; }
.nav-badge { margin-left: auto; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 7px; }
.sidebar-user { border-top: 1px solid #374151; padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: #3b82f6; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { color: #fff; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { color: #9ca3af; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-logout { color: #9ca3af; text-decoration: none; padding: 4px 8px; border-radius: 4px; }
.user-logout:hover { background: #374151; color: #ef4444; }
.user-logout svg { display: block; }

/* ---------- Main ---------- */
.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 18px 24px; background: #fff; border-bottom: 1px solid #e5e7eb; }
.topbar-info { flex: 1; }
.topbar h2 { margin: 0; font-size: 18px; }
.topbar h2 .back { text-decoration: none; color: #6b7280; margin-right: 6px; }
.addr-top { color: #6b7280; font-size: 13px; margin-top: 2px; }
.search { display: flex; align-items: center; gap: 6px; }
.search input[type=search] { padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; width: 320px; max-width: 40vw; }
.search button { padding: 8px 14px; border: none; background: #3b82f6; color: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; }
.search .clear { text-decoration: none; color: #9ca3af; padding: 0 6px; }

.btn-primary { padding: 9px 16px; border: none; background: #3b82f6; color: #fff; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600; }
.btn-primary:hover { background: #2563eb; }
.btn-secondary { padding: 8px 14px; border: 1px solid #d1d5db; background: #fff; color: #374151; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn-secondary:hover { background: #f3f4f6; }

/* ---------- Content ---------- */
.content-single { padding: 20px 24px; }
.content-two { padding: 20px 24px; display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
@media (max-width: 900px) { .content-two { grid-template-columns: 1fr; } }
.panel { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 18px 20px; margin-bottom: 20px; }
.panel h3 { margin: 0 0 14px; font-size: 15px; }
.empty { padding: 30px; text-align: center; color: #9ca3af; }
.muted { color: #6b7280; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
@media (max-width: 700px) { .cards { grid-template-columns: repeat(2, 1fr); } }
.card { display: block; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 18px 20px; text-decoration: none; color: inherit; border-left: 4px solid #9ca3af; transition: box-shadow .15s; }
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.card-num { font-size: 28px; font-weight: 700; }
.card-label { color: #6b7280; font-size: 13px; margin-top: 2px; }
.card-nouveau { border-left-color: #3b82f6; }
.card-en_cours { border-left-color: #f59e0b; }
.card-traite { border-left-color: #10b981; }
.card-rejete { border-left-color: #ef4444; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; color: #6b7280; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; padding: 10px 12px; border-bottom: 2px solid #eef0f3; }
.table td { padding: 11px 12px; border-bottom: 1px solid #f1f2f4; vertical-align: top; }
.table tbody tr:hover { background: #f9fafb; }

.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv th { text-align: left; color: #6b7280; font-weight: 500; padding: 7px 12px 7px 0; width: 160px; vertical-align: top; }
.kv td { padding: 7px 0; }

/* ---------- Filters / chips ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 24px 0; }
.chip { padding: 6px 12px; border-radius: 20px; background: #fff; border: 1px solid #e5e7eb; color: #374151; text-decoration: none; font-size: 13px; }
.chip:hover { background: #f3f4f6; }
.chip.active { background: #1f2937; color: #fff; border-color: #1f2937; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-lg { padding: 6px 14px; font-size: 13px; }
.status-nouveau { background: #dbeafe; color: #1d4ed8; }
.status-en_cours { background: #fef3c7; color: #b45309; }
.status-traite { background: #d1fae5; color: #047857; }
.status-rejete { background: #fee2e2; color: #b91c1c; }
.log-info { background: #e0f2fe; color: #0369a1; }
.log-warning { background: #fef3c7; color: #b45309; }
.log-error { background: #fee2e2; color: #b91c1c; }
.log-debug { background: #f3f4f6; color: #6b7280; }

/* ---------- Flash ---------- */
.flash { margin: 16px 24px 0; padding: 12px 16px; border-radius: 8px; font-size: 14px; }
.flash-ok { background: #d1fae5; color: #065f46; }
.flash-err { background: #fee2e2; color: #991b1b; }

/* ---------- Status form / timeline ---------- */
.status-form .radio { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid #f1f2f4; }
.timeline li:last-child { border-bottom: none; }

/* ---------- JSON tree ---------- */
.json-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.json-table th { text-align: left; color: #6b7280; font-weight: 600; padding: 4px 10px 4px 0; vertical-align: top; white-space: nowrap; }
.json-table td { padding: 4px 0; vertical-align: top; }
.json-table .json-table { margin-left: 4px; border-left: 2px solid #eef0f3; padding-left: 10px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.pagination a { text-decoration: none; padding: 6px 12px; border: 1px solid #d1d5db; border-radius: 6px; color: #374151; }

/* ---------- Login ---------- */
.login-page { background: linear-gradient(135deg, #1f2937 0%, #111827 100%); min-height: 100vh; margin: 0; display: flex; align-items: center; justify-content: center; }
.login-box { background: #fff; padding: 40px; border-radius: 12px; width: 100%; max-width: 400px; box-shadow: 0 20px 40px rgba(0,0,0,.3); }
.login-box h1 { margin: 0 0 8px; font-size: 24px; color: #111827; letter-spacing: 1px; }
.login-box .muted { margin: 0 0 24px; color: #6b7280; font-size: 14px; }
.login-box label { display: block; margin-bottom: 14px; }
.login-box label span { display: block; font-size: 12px; color: #374151; font-weight: 600; margin-bottom: 4px; }
.login-box input { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
.login-box .btn-primary { width: 100%; margin-top: 6px; }
