:root {
  --text: #2A363E;
  --accent: #38a9a2;
  --accent-dark: #2d8a84;
  --terra: #bb6f58;
  --bg: #F9F6F0;
  --line: #dfe6e7;
  --white: #fff;
  --ivoire: #F9F6F0;
  --ko: #cc1915;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.45;
}
a { color: var(--accent-dark); }
h1 { font-size: 1.5rem; margin: 0; font-weight: 600; }
h1 small { font-size: .8rem; font-weight: 400; opacity: .6; margin-left: .5rem; }
h2 { font-size: 1.1rem; margin: 0 0 1rem; }

.topbar {
  background: var(--text); color: var(--white);
  display: flex; justify-content: space-between; align-items: center; padding: .7rem 1.5rem;
  border-bottom: 4px solid var(--accent);
}
.brand { color: var(--white); text-decoration: none; font-size: 1.25rem; font-weight: 700; letter-spacing: .04em; }
.brand span { font-weight: 300; opacity: .75; font-size: .95rem; margin-left: .4rem; }
.who { display: flex; align-items: center; gap: 1rem; font-size: .9rem; }

.container { max-width: 1400px; margin: 1.5rem auto; padding: 0 1.5rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }

.btn {
  display: inline-block; background: var(--accent); color: var(--white); border: 1px solid var(--accent);
  padding: .55rem 1.1rem; border-radius: 6px; font-size: .95rem; cursor: pointer; text-decoration: none; font-weight: 500;
}
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--accent-dark); }
.topbar .btn-ghost { color: var(--white); border-color: rgba(255,255,255,.4); padding: .35rem .8rem; }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-ghost:hover { background: rgba(56,169,162,.1); color: var(--accent-dark); }
.btn-small { padding: .3rem .75rem; font-size: .85rem; line-height: 1.4; vertical-align: middle;}

.btn-bis {
  background: var(--terra);
  display: inline-block; color: var(--white); border: 2px solid var(--terra);
  padding: .55rem 1.1rem; border-radius: 6px; font-size: .95rem; cursor: pointer; text-decoration: none; font-weight: 500;
}
.btn-bis:hover { background: var(--ivoire); border: 2px solid var(--terra); color: var(--terra) }

.btn-danger { background: transparent; color: var(--ko); border-color: var(--ko); }
.btn-danger:hover { background: var(--ko); border-color: var(--ko); color: var(--white); }

.alert { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-ok { background: #e3f4f3; border: 1px solid var(--accent); }
.alert-ko { background: #fbeceb; border: 1px solid var(--ko); color: var(--ko); }

.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1 1 260px; }

input, select, textarea {
  font: inherit; color: var(--text); padding: .5rem .65rem; border: 1px solid var(--line);
  border-radius: 6px; background: var(--white); width: 100%;
}
.filters input, .filters select { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.table-wrap { overflow-x: auto; background: var(--white); border-radius: 8px; border: 1px solid var(--line); }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  background: var(--accent); color: var(--white); text-align: left; padding: .65rem .75rem;
  font-weight: 600; font-size: .85rem; white-space: nowrap;
}
table.data td { padding: .6rem .75rem; border-top: 1px solid var(--line); vertical-align: top; }
table.data tbody tr:hover { background: #f1f9f9; }
table.data .num { text-align: right; white-space: nowrap; }
table.data small, .muted { opacity: .65; }
table.data .empty { text-align: center; padding: 2rem; opacity: .6; }
table.data td.old { text-decoration: line-through; opacity: .65; }
.note { color: var(--accent-dark); cursor: help; }

.tag, .badge {
  display: inline-block; padding: .15rem .6rem; border-radius: 99px; font-size: .8rem; font-weight: 600; white-space: nowrap;
}
.tag-altitude { background: var(--text); color: var(--white); }
.tag-plenitude { background: var(--accent); color: var(--white); }
.badge-ok { background: var(--accent); color: var(--white); }
.badge-mid { background: #e3f4f3; color: var(--text); border: 1px solid var(--accent); }
.badge-new { background: var(--white); color: var(--text); border: 1px solid var(--line); }
.badge-ko { background: #f3d7d5; color: var(--ko); }

.pager { display: flex; gap: 1rem; justify-content: center; align-items: center; margin: 1rem 0; }

.card { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; }
fieldset { border: 0; padding: 0; margin: 0 0 1.5rem; }
legend { font-weight: 600; color: var(--accent-dark); padding: 0 0 .6rem; border-bottom: 2px solid var(--accent); width: 100%; margin-bottom: 1rem; }
legend small { font-weight: 400; color: var(--text); opacity: .65; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 500; }
.field input, .field select, .field textarea { font-weight: 400; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--ko); }
.err { color: var(--ko); font-weight: 400; }
.req { color: var(--ko); }
.actions { display: flex; gap: .75rem; }

.login-card { max-width: 380px; margin: 4rem auto; background: var(--white); padding: 2rem; border-radius: 10px; border: 1px solid var(--line); border-top: 4px solid var(--accent); }
.login-card h1 { margin-bottom: 1.2rem; }
.login-card label { display: block; margin-bottom: 1rem; font-weight: 500; font-size: .9rem; }
.login-card input { margin-top: .3rem; }
.login-card .btn { width: 100%; }

@media (max-width: 700px) {
  .container { padding: 0 .75rem; }
  .topbar { padding: .6rem .75rem; }
}

/* Gestion des utilisateurs */
details.edit-user summary { list-style: none; display: inline-block; }
details.edit-user summary::-webkit-details-marker { display: none; }
.edit-form { display: grid; gap: .7rem; margin-top: .7rem; padding: .9rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; min-width: 260px; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.check input { width: auto; }

/* Suppression douce (vue admin) */
tr.deleted td { background: #f6f1f0; opacity: .7; }
tr.deleted td:first-child strong { text-decoration: line-through; }
.inline { display: inline; margin: 0; }
.row-actions { white-space: nowrap; }

.banner-deleted { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea { background: #f1f4f4; color: var(--text); opacity: .85; }

/* Indicateurs clés (admin) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: var(--white); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 8px; padding: .9rem 1.1rem; display: flex; flex-direction: column; gap: .2rem; }
.kpi-label { font-size: .82rem; font-weight: 600; opacity: .75; text-transform: uppercase; letter-spacing: .03em; }
.kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.kpi-pct { font-size: 1rem; font-weight: 600; color: var(--accent-dark); margin-left: .4rem; }
.kpi-sub { font-size: .85rem; opacity: .7; }
.kpi-bar { display: block; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: .35rem; }
.kpi-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* Indicateurs : répartition par type et échéances */
.kpi-line { display: flex; align-items: center; gap: .45rem; font-size: 1rem; margin-top: .15rem; }
.kpi-indent { padding-left: 1.05rem; }
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; }
.dot-altitude, .seg-altitude { background: var(--text); }
.dot-plenitude, .seg-plenitude { background: var(--accent); }
.kpi-bar-split { display: flex; }
.kpi-bar-split i { height: 100%; border-radius: 0; }
.kpi-link { color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.kpi-link:hover { box-shadow: 0 2px 8px rgba(42, 54, 62, .15); border-color: var(--accent-dark); }

/* Correctif : la barre de répartition était entièrement turquoise (priorité CSS de « .kpi-bar i ») */
.kpi-bar .seg-altitude { background: var(--text); }
.kpi-bar .seg-plenitude { background: var(--accent); }
/* Bloc « Bons émis » : total + mois courant */
.kpi-sep { border-top: 1px solid var(--line); margin: .55rem 0 .4rem; }
.kpi-value-sm { font-size: 1.3rem; }
