:root {
  --bg: #f6f7fa;
  --card: #fff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --green: #10b981;
  --red: #ef4444;
  --orange: #f59e0b;
}

* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  background: var(--bg); color: var(--text); margin: 0; font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: white; padding: 36px 32px; border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 8px 30px rgba(0,0,0,.05); width: 320px; }
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card p { margin: 0 0 18px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.login-card button { width: 100%; padding: 10px 12px; background: var(--accent); color: white; border: 0; border-radius: 8px; font-weight: 600; cursor: pointer; }
.login-card button:hover { background: var(--accent-dark); }

/* Layout */
.topbar {
  display: flex; align-items: center; gap: 24px; padding: 12px 24px;
  background: white; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; color: var(--accent); }
.tabs { display: flex; gap: 6px; flex: 1; }
.tab { padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.tab:hover { background: #f3f4f6; text-decoration: none; }
.tab.active { background: var(--accent); color: white; }
.logout { color: var(--muted); font-size: 13px; }

.container { max-width: 1100px; margin: 24px auto; padding: 0 24px; }
.flashes { max-width: 1100px; margin: 12px auto 0; padding: 0 24px; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 13px; }
.alert.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.panel.hidden { display: none; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-header h2 { margin: 0; font-size: 18px; }

.empty { color: var(--muted); padding: 28px; text-align: center; background: white; border: 1px dashed var(--border); border-radius: 12px; }

/* Card */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.item-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.item-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.item-body { margin-top: 8px; font-size: 13px; }

.muted { color: var(--muted); }

/* Forms */
.form { margin-top: 12px; padding: 16px; background: #fafbfc; border: 1px solid var(--border); border-radius: 10px; }
.form.hidden { display: none; }
.form h3, .form h4 { margin: 0 0 12px; }
.form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.form label.col-2 { grid-column: span 2; }
.form label.check { display: flex; align-items: center; gap: 8px; }
.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form input[type="number"],
.form input:not([type]),
.form select,
.form textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: white;
}
.form textarea { font-family: inherit; resize: vertical; }
.row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 4px; }

/* Lignes table */
.lignes-wrap { margin: 14px 0; }
.lignes-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lignes-table th { text-align: left; padding: 6px 8px; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--border); }
.lignes-table td { padding: 4px; }
.lignes-table input { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 5px; font-size: 13px; }

/* Buttons */
button, .btn-primary, .btn-ghost, .btn-danger, .btn-warn {
  font-family: inherit; cursor: pointer; padding: 7px 12px; border-radius: 7px; font-size: 13px;
  border: 1px solid transparent; transition: all .15s;
}
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: white; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #f3f4f6; }
.btn-danger { background: white; color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-warn { background: var(--orange); color: white; border-color: var(--orange); }
.btn-warn:hover { filter: brightness(0.95); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.actions { display: flex; gap: 8px; margin-top: 12px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; font-size: 11px; font-weight: 600; border-radius: 10px; background: #f3f4f6; color: var(--muted); }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-grey { background: #f3f4f6; color: var(--muted); }
.badge-red { background: #fee2e2; color: #991b1b; }

/* Historique */
.history-table { width: 100%; background: white; border-radius: 12px; border: 1px solid var(--border); border-collapse: collapse; overflow: hidden; }
.history-table th, .history-table td { padding: 10px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
.history-table th { background: #fafbfc; color: var(--muted); font-weight: 500; font-size: 12px; }
.history-table tr:last-child td { border-bottom: 0; }

@media (max-width: 768px) {
  .row { grid-template-columns: 1fr; }
  .form label.col-2 { grid-column: 1; }
  .topbar { gap: 12px; padding: 10px 14px; flex-wrap: wrap; }
  .container { padding: 0 14px; }
}
