:root {
  --accent: #1f4e79;
  --accent-light: #2e74b5;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #d9e1ea;
  --text: #1c2733;
  --muted: #6b7a89;
  --ok: #1e7e34;
  --warn: #b96a00;
  --danger: #b02a37;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  background: var(--accent); color: #fff; padding: 10px 22px;
}
.topbar .brand { color: #fff; font-weight: 700; font-size: 18px; letter-spacing: .5px; }
.topbar .brand span { font-weight: 300; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: #dbe7f3; padding: 7px 11px; border-radius: 6px; }
.topbar nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.topbar nav a.active { background: rgba(255,255,255,.2); color: #fff; font-weight: 600; }
.userbox { color: #dbe7f3; display: flex; gap: 12px; align-items: center; font-size: 13px; }
.userbox a { color: #fff; text-decoration: underline; }

main { max-width: 1200px; margin: 0 auto; padding: 22px; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 18px; }

h1 { color: var(--accent); font-size: 24px; margin: 8px 0 16px; }
h2 { color: var(--accent-light); font-size: 17px; margin: 18px 0 10px; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pagehead > div { display: flex; gap: 8px; align-items: center; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: #e2f2e6; color: var(--ok); border: 1px solid #bfe3c8; }
.flash.error { background: #fbe4e7; color: var(--danger); border: 1px solid #f2c3ca; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin: 14px 0; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.card .num { font-size: 26px; font-weight: 700; color: var(--accent); }
.cardlink { color: inherit; }
.cardlink:hover { border-color: var(--accent-light); text-decoration: none; }

.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.threecol { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .twocol, .threecol { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
thead th { background: var(--accent); color: #fff; font-size: 13px; }
tbody tr:nth-child(even) { background: #f0f5fa; }
tbody tr:last-child td { border-bottom: none; }
table.kv th { width: 45%; background: none; color: var(--muted); font-weight: 500; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.etat-Bon { background: #e2f2e6; color: var(--ok); }
.etat-Panne { background: #fdeeda; color: var(--warn); }
.etat-Hors-Usage { background: #fbe4e7; color: var(--danger); }
.badge.role { background: #e3ecf5; color: var(--accent); }

.btn {
  display: inline-block; background: var(--accent); color: #fff; border: 1px solid var(--accent);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn:hover { background: var(--accent-light); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: #e3ecf5; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: #fbe4e7; }
.btn.small { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
form.inline { display: inline; }

.form { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px; max-width: 520px; }
.form.wide { max-width: 900px; }
.form label, .login-card label { display: block; margin-bottom: 12px; font-weight: 600; font-size: 13px; color: var(--accent); }
input, select {
  width: 100%; padding: 8px 10px; margin-top: 4px;
  border: 1px solid var(--border); border-radius: 7px; font-size: 14px; background: #fff; color: var(--text);
}
input:disabled { background: #eef1f5; color: var(--muted); }
input:focus, select:focus { outline: 2px solid var(--accent-light); border-color: var(--accent-light); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 700px) { .grid3 { grid-template-columns: 1fr; } }
.formactions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; align-items: center; }
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-width: 160px; margin-top: 0; }
.addrow { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.addrow input, .addrow select { width: auto; min-width: 130px; margin-top: 0; flex: 1; }
.inline-check { font-weight: 400; display: flex; align-items: center; gap: 6px; }
.inline-check input { width: auto; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--accent); }
.login-card { background: #fff; border-radius: 14px; padding: 34px 38px; width: 360px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.login-card h1 { text-align: center; margin: 0; }
.login-card h1 span { font-weight: 300; }
.login-card .sub { text-align: center; color: var(--muted); margin: 6px 0 20px; font-size: 13px; }
.login-card button { width: 100%; margin-top: 6px; background: var(--accent); color: #fff; border: none; padding: 11px; border-radius: 8px; font-size: 15px; cursor: pointer; }
.login-card button:hover { background: var(--accent-light); }

.barcode svg { max-width: 260px; height: auto; }

/* Étiquettes : plusieurs par page, planche autocollante */
.labels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6mm; }
.label {
  border: 1px dashed #aab; border-radius: 4px; padding: 4mm; text-align: center;
  background: #fff; break-inside: avoid; page-break-inside: avoid;
}
.label svg { max-width: 100%; height: auto; }
.label-desig { font-size: 11px; font-weight: 600; margin-bottom: 2mm; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.print-only { display: none; }
@media print {
  .no-print, footer { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; font-size: 12px; }
  main { max-width: none; padding: 0; }
  table, .label { border-color: #999; }
  thead th { background: #eee !important; color: #000; }
  .labels { grid-template-columns: repeat(3, 1fr); }
}
