/* Facturation - admin CSS */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f6f9;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.5;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

code { font-family: "SF Mono", Monaco, "Courier New", monospace; font-size: 12px; background: #eef0f5; padding: 1px 5px; border-radius: 3px; }

/* ============================================== Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0f172a;
  color: #fff;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.topbar .brand {
  display: flex; align-items: center; gap: 12px;
  font-size: 16px;
}
.topbar .brand strong { letter-spacing: 0.5px; }
.company-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.topbar .mainnav { display: flex; gap: 2px; }
.topbar .mainnav a {
  color: #cbd5e1;
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 500;
  text-decoration: none;
}
.topbar .mainnav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.topbar .mainnav a.active { background: rgba(255,255,255,0.15); color: #fff; }
.topbar .user { display: flex; align-items: center; gap: 12px; font-size: 12px; color: #cbd5e1; }
.btn-logout {
  color: #fca5a5;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  font-size: 12px;
}

/* ============================================== Layout */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 32px 60px;
}
.page-title {
  margin: 0 0 20px 0;
  font-size: 22px;
  font-weight: 700;
}
.admin-footer {
  text-align: center;
  color: #94a3b8;
  font-size: 11px;
  padding: 20px;
}

/* ============================================== Flash */
.flash {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
}
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-info { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }

/* ============================================== Cards */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 18px 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid #e5e7eb;
}
.card h2, .card h3 { margin-top: 0; }
.card.card-wide { grid-column: 1 / -1; }
.card.card-danger { border-left: 4px solid #dc2626; background: #fef2f2; }
.card-hint { font-size: 11px; color: #64748b; margin: 6px 0 0; font-style: italic; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.sap-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 20px;
}

/* SAP big display */
.sap-big {
  text-align: center;
  margin: 16px 0;
}
.sap-percent {
  font-size: 54px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -2px;
}
.sap-statut {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 12px;
}
.sap-breakdown {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  font-size: 13px;
}
.sap-breakdown li { padding: 4px 0; border-bottom: 1px dashed #e5e7eb; }

.card dl { margin: 0; }
.card dl dt { color: #64748b; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; margin-top: 6px; }
.card dl dd { margin: 0 0 4px 0; font-size: 14px; }

.center { text-align: center; }

/* ============================================== Stat tables */
.stat-table, .list-table, .mini-table {
  width: 100%;
  border-collapse: collapse;
}
.stat-table th, .list-table th, .mini-table th {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 2px solid #e5e7eb;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  font-weight: 600;
}
.stat-table td, .list-table td, .mini-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}
.stat-table th.right, .stat-table td.right,
.list-table th.right, .list-table td.right,
.mini-table th.right, .mini-table td.right { text-align: right; }
.empty { text-align: center; color: #94a3b8; padding: 20px; font-style: italic; }

.mini-table { margin-top: 10px; font-size: 12px; }

/* ============================================== Pills / Badges */
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #e5e7eb;
  color: #374151;
}
.pill-sap { background: #fef3c7; color: #92400e; }
.pill-warn { background: #fed7aa; color: #9a3412; }
.pill-impaye { background: #fee2e2; color: #991b1b; }
.pill-partiellement_paye { background: #fef3c7; color: #92400e; }
.pill-paye { background: #d1fae5; color: #065f46; }
.pill-annule_par_avoir { background: #e5e7eb; color: #6b7280; text-decoration: line-through; }

/* ============================================== Forms */
.filters-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: flex-end;
  background: #fff;
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  flex-wrap: wrap;
}
.filters-bar label { display: flex; flex-direction: column; font-size: 11px; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.filters-bar input, .filters-bar select { padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 5px; font-size: 13px; min-width: 140px; }

button, .btn, .btn-primary, .btn-danger {
  padding: 8px 16px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  text-decoration: none;
  display: inline-block;
}
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; color: #fff; text-decoration: none; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; color: #fff; }

fieldset {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
  background: #fff;
}
fieldset legend {
  padding: 0 8px;
  font-weight: 700;
  color: #374151;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
fieldset label { display: block; margin-bottom: 10px; font-size: 13px; }
fieldset input, fieldset select, fieldset textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.line-editor { width: 100%; }
.line-editor th { font-size: 10px; }
.line-editor input, .line-editor select { padding: 5px; font-size: 12px; min-width: 70px; }

.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.inline-form input, .inline-form select { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 5px; font-size: 13px; }

.form-actions { margin-top: 16px; display: flex; gap: 10px; }

.catalog-edit { background: #f9fafb; padding: 14px; border-radius: 6px; margin-top: 10px; }
.catalog-edit label { display: block; margin-bottom: 8px; }

/* ============================================== Invoice view */
.invoice-view .invoice-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: #fff;
  padding: 20px 24px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  margin-bottom: 16px;
}
.invoice-view .invoice-head h2 { margin-top: 0; }
.invoice-view .invoice-actions { display: flex; gap: 8px; }
.muted { color: #64748b; font-size: 12px; }

.event-list { list-style: none; padding: 0; margin: 0; }
.event-list li { padding: 6px 0; border-bottom: 1px dashed #e5e7eb; font-size: 12px; }
.event-list li code { font-size: 11px; }
.event-list pre { background: #f1f5f9; padding: 8px; border-radius: 4px; font-size: 11px; overflow-x: auto; }

/* ============================================== Login */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a, #1e293b);
}
.login-box {
  background: #fff;
  padding: 32px 40px;
  border-radius: 12px;
  min-width: 360px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.login-box h1 { margin-top: 0; text-align: center; }
.login-company { text-align: center; font-weight: 700; margin: 0 0 18px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.login-box label { display: block; margin-bottom: 12px; font-size: 12px; color: #64748b; }
.login-box input { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; margin-top: 4px; }
.login-box button { width: 100%; background: #2563eb; color: #fff; border: none; padding: 11px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.login-box button:hover { background: #1d4ed8; }

/* ============================================== Year select */
.year-select { margin-bottom: 16px; }
.year-select form { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; }
.year-select select { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 5px; }

/* Responsive fallback */
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .sap-detail-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; height: auto; padding: 10px; gap: 8px; }
  .topbar .mainnav { flex-wrap: wrap; justify-content: center; }
  .main-content { padding: 16px; }
}
