:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #d8dbe0;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 { font-size: 18px; margin: 0; }
header nav a {
  color: var(--accent);
  text-decoration: none;
  margin-left: 16px;
  font-weight: 500;
}
header nav a:hover { text-decoration: underline; }

main { max-width: 1100px; margin: 0 auto; padding: 24px; }

.section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.section > h2 {
  font-size: 15px;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.row-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 12px;
  position: relative;
  background: #fcfcfd;
}
.row-card .row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.row-card .row-head strong { font-size: 13px; color: var(--muted); }

button {
  font: inherit;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 500;
}
.btn-add {
  background: #eef2ff;
  color: var(--accent-dark);
  border: 1px dashed var(--accent);
}
.btn-add:hover { background: #e0e7ff; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-remove {
  background: transparent;
  color: var(--danger);
  padding: 4px 8px;
  font-size: 12px;
}
.btn-remove:hover { text-decoration: underline; }

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 14px 0;
}

.msg { font-weight: 500; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }

/* --- Page admin --- */
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: #f9fafb; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge.en_attente { background: #fef3c7; color: #92400e; }
.badge.facture { background: #dcfce7; color: #166534; }
.table-actions button { padding: 5px 10px; font-size: 12px; margin-right: 6px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px; }

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  max-width: 720px;
  width: 90%;
}
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .dlg-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
dialog pre { margin: 0; padding: 18px; max-height: 60vh; overflow: auto; font-size: 12px; background: #0f172a; color: #e2e8f0; }
