:root {
  --bg: #f3f5f7; --card: #fff; --text: #1c2430; --muted: #66707d; --line: #dfe4ea;
  --accent: #0f766e; --accent-2: #115e59; --accent-soft: #d8f0ec;
  --good: #15803d; --good-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7; --bad: #b91c1c; --bad-bg: #fee2e2;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
small, .muted { color: var(--muted); }
code { background: #eef1f4; padding: .05em .35em; border-radius: 4px; font-size: .9em; }

.topbar { display: flex; align-items: center; gap: 1.5rem; padding: 0 1.25rem; height: 56px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.brand .logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 800; }
.nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav a { padding: .4rem .7rem; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav a:hover { background: #eef1f4; text-decoration: none; }
.nav a.primary { background: var(--accent); color: #fff; }
.nav a.primary:hover { background: var(--accent-2); }
.me { display: flex; gap: .75rem; align-items: center; white-space: nowrap; font-size: .9rem; }
.container { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.card h2 { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; }
.tile .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.tile .value { font-size: 1.7rem; font-weight: 700; margin-top: .15rem; }
.tile .value.bad { color: var(--bad); } .tile .value.warn { color: var(--warn); } .tile .value.good { color: var(--good); }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-success { background: var(--good-bg); color: var(--good); }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.flash-info { background: var(--accent-soft); color: var(--accent-2); }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:hover td { background: #f8fafb; }
.table-wrap { overflow-x: auto; }
table.compact td, table.compact th { padding: .35rem .5rem; }

.badge { display: inline-block; padding: .12em .55em; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.muted { background: #eef1f4; color: var(--muted); }
.badge.info { background: var(--accent-soft); color: var(--accent-2); }
.badge.stock { background: var(--good-bg); color: var(--good); }
.badge.location { background: #dbeafe; color: #1d4ed8; }
.badge.sav { background: var(--bad-bg); color: var(--bad); }
.badge.reforme { background: #e5e7eb; color: #374151; }

form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .9rem 1rem; margin-bottom: .9rem; }
label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: .25rem; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
.field-hint { font-size: .78rem; color: var(--muted); margin-top: .2rem; }
.btn { display: inline-block; padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: #f1f3f5; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--bad); border-color: #f3c0c0; }
.btn.sm { padding: .3rem .6rem; font-size: .82rem; white-space: nowrap; }
.actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem 0; margin: 0 0 1rem; }
legend { font-weight: 600; color: var(--accent-2); padding: 0 .4rem; }
.calc { font-size: 1.25rem; font-weight: 700; }
.toolbar { display: flex; gap: .6rem; align-items: end; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar > div { min-width: 160px; }
.login { max-width: 380px; margin: 4rem auto; }
.chart-box { position: relative; height: 300px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 95px 1fr; gap: .8rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.timeline .when { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.pct-bar { height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; margin-top: .25rem; }
.pct-bar span { display: block; height: 100%; background: var(--accent); }
.pct-bar span.bad { background: var(--bad); } .pct-bar span.warn { background: var(--warn); } .pct-bar span.good { background: var(--good); }
.inline-form { display: inline; }
.hidden { display: none !important; }
@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; padding: .6rem 1rem; gap: .5rem; }
  .me { width: 100%; justify-content: space-between; }
  html { font-size: 14px; }
}

/* Catalogue modèles / fiche modèle */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.mcard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; color: var(--text); }
.mcard:hover { text-decoration: none; box-shadow: 0 4px 14px rgba(16,24,40,.12); }
.mcard .photo { height: 150px; background: #eef1f4 center/contain no-repeat; display: grid; place-items: center; color: var(--muted); font-size: .85rem; border-bottom: 1px solid var(--line); }
.mcard .photo.empty { background: repeating-linear-gradient(45deg, #f3f5f7, #f3f5f7 10px, #eceff2 10px, #eceff2 20px); }
.mcard .body { padding: .8rem .95rem 1rem; }
.mcard .brand { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.mcard .name { font-weight: 700; font-size: 1.05rem; }
.mcard .meta { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .5rem; }
.model-head { display: grid; grid-template-columns: 320px 1fr; gap: 1.5rem; align-items: start; }
.model-head .photo { background: #eef1f4 center/contain no-repeat; border-radius: var(--radius); min-height: 240px; display: grid; place-items: center; color: var(--muted); }
.specs { width: 100%; }
.specs td:first-child { color: var(--muted); width: 38%; font-weight: 600; font-size: .85rem; }
@media (max-width: 800px) { .model-head { grid-template-columns: 1fr; } .model-head .photo { min-height: 180px; } }
.quick-id { display: grid; grid-template-columns: 1fr auto; gap: .6rem; align-items: end; }
.quick-id input { font-size: 1.15rem; padding: .6rem .8rem; }
#lookup-result { margin-top: .6rem; }
#lookup-result .choice { display: inline-block; margin: .2rem .3rem .2rem 0; }
.topsearch { display: flex; gap: .3rem; }
.topsearch input { width: 170px; padding: .35rem .55rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
