/* Mise en page et composants de DBHL Pro (jetons de couleur : tokens.css, communs avec Organisateur). */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); min-height: 100vh; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
a { color: var(--brand); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* --- Structure : barre latérale + contenu --- */
.layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 0.25rem;
  padding: 1rem 0.75rem; background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.55rem; font-weight: 700; font-size: 1.05rem; padding: 0.25rem 0.5rem 1rem; color: var(--text); text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: linear-gradient(135deg, var(--hero-from), var(--hero-to)); color: #fff; font-size: 0.8rem; font-weight: 800; }
.nav-link {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.65rem; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 0.93rem;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link.is-active { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }
.nav-icon { width: 1.25rem; text-align: center; }
.nav-count { margin-left: auto; font-size: 0.72rem; font-weight: 700; padding: 0 0.45rem; border-radius: 999px; background: var(--danger); color: #fff; }
.sidebar-foot { margin-top: auto; display: grid; gap: 0.25rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.sidebar-user { font-size: 0.8rem; color: var(--subtle); padding: 0 0.65rem; }
.main { padding: 1.5rem 2rem 3rem; min-width: 0; max-width: 1200px; width: 100%; }
.topbar-mobile { display: none; }
.scrim { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%);
    transition: transform 0.2s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; }
  .scrim { display: none; position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / 0.35); }
  .topbar-mobile {
    display: flex; align-items: center; gap: 0.6rem; position: sticky; top: 0; z-index: 30;
    padding: 0.5rem 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .topbar-mobile .brand { padding: 0; }
  .main { padding: 1rem 16px 3rem; }
}

/* --- En-tête de page --- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; }
.page-head h1 { margin-right: auto; overflow-wrap: anywhere; }
.page-sub { color: var(--muted); font-size: 0.9rem; margin-top: 0.2rem; }
.breadcrumb { font-size: 0.85rem; margin-bottom: 0.4rem; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--brand); }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 1rem; }
.toolbar .search { flex: 1 1 14rem; max-width: 24rem; }

/* --- Boutons --- */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem; font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 0.4rem 0.9rem; min-height: 38px; box-shadow: var(--shadow-sm); white-space: nowrap; text-decoration: none;
  transition: background var(--ease), border-color var(--ease);
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-small { min-height: 30px; padding: 0.15rem 0.6rem; font-size: 0.82rem; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { color: var(--danger-text); }
.btn-danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: var(--on-brand); }
.icon-btn { width: 38px; padding: 0; justify-content: center; }

/* --- Cartes --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow-sm); min-width: 0; }
.card + .card { margin-top: 1rem; }
.card-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.85rem; }
.card-head h2 { margin-right: auto; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.grid-2 > .card + .card { margin-top: 0; }
.stack { display: grid; gap: 1rem; align-content: start; }
.stack > .card + .card { margin-top: 0; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } }

/* Indicateurs du tableau de bord */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.85rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1rem; box-shadow: var(--shadow-sm); text-decoration: none; color: inherit; display: block; }
a.stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.stat-label { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 0.15rem; }
.stat-sub { font-size: 0.8rem; color: var(--subtle); }
.stat.is-alert { border-color: color-mix(in srgb, var(--danger) 50%, transparent); background: var(--danger-soft); }
.stat.is-alert .stat-value { color: var(--danger-text); }

/* --- Tableaux --- */
.table-wrap { overflow-x: auto; margin: 0 -0.2rem; }
table.list { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.list th { text-align: left; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--subtle); padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.list td { padding: 0.6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr.is-link { cursor: pointer; }
table.list tbody tr.is-link:hover td { background: var(--surface-2); }
table.list th.num, table.list td.num { text-align: right; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 0.8rem; color: var(--muted); }
.empty { color: var(--muted); padding: 1.25rem 0.5rem; text-align: center; font-size: 0.9rem; }

/* Listes simples (relances, alertes) */
.rows { list-style: none; margin: 0; padding: 0; display: grid; }
.rows li { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0; border-bottom: 1px solid var(--border); min-width: 0; }
.rows li:last-child { border-bottom: 0; }
.rows .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* --- Pastilles --- */
.badge { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.74rem; font-weight: 600; line-height: 1.5; padding: 0.05rem 0.55rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.badge-brand { background: var(--brand-soft); color: var(--brand-text); }
.badge-ok { background: var(--ok-soft); color: var(--ok-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-warn { background: var(--accent-soft); color: var(--accent-text); }
.badge-violet { background: var(--violet-soft); color: var(--violet-text); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--subtle); flex: none; display: inline-block; }
.dot-up { background: var(--ok); }
.dot-down { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

/* --- Formulaires --- */
.field { display: grid; gap: 0.3rem; min-width: 0; }
.field > span { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.field-hint { font-size: 0.78rem; color: var(--subtle); }
.check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
input, select, textarea {
  font: inherit; font-size: 0.92rem; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0.45rem 0.6rem; min-height: 38px;
}
input[type='checkbox'] { width: auto; min-height: 0; accent-color: var(--brand); }
textarea { resize: vertical; min-height: 5rem; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.form-error { background: var(--danger-soft); color: var(--danger-text); border-radius: var(--radius-sm); padding: 0.55rem 0.75rem; font-size: 0.88rem; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }

/* --- Fenêtres (formulaires) --- */
dialog.modal {
  width: min(100% - 32px, 40rem); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgb(15 17 21 / 0.45); }
.modal form { display: grid; gap: 1rem; padding: 1.25rem; }
.modal-head { display: flex; align-items: center; gap: 0.5rem; }
.modal-head h2 { margin-right: auto; font-size: 1.1rem; }

/* --- Fiche (client, site) --- */
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.4rem 1rem; margin: 0; font-size: 0.9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.65rem; }
.timeline li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.6rem; padding: 0.65rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.timeline-icon { font-size: 1.05rem; }
.timeline-meta { font-size: 0.78rem; color: var(--muted); }
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tab { font: inherit; font-size: 0.9rem; font-weight: 600; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 0.5rem 0.75rem; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }

/* --- Éditeur de devis --- */
.quote-lines { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.quote-lines th { text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--subtle); text-transform: uppercase; padding: 0.35rem 0.3rem; border-bottom: 1px solid var(--border); }
.quote-lines td { padding: 0.3rem; vertical-align: top; }
.quote-lines textarea { min-height: 38px; height: 38px; }
.quote-lines .c-qty { width: 6rem; }
.quote-lines .c-unit { width: 6rem; }
.quote-lines .c-price { width: 8rem; }
.quote-lines .c-vat { width: 6.5rem; }
.quote-lines .c-total { width: 7.5rem; text-align: right; padding-top: 0.75rem; font-variant-numeric: tabular-nums; font-weight: 600; }
.quote-lines .c-del { width: 2.5rem; }
.quote-lines input { text-align: right; }
.quote-lines input.c-unit-input { text-align: left; }
@media (max-width: 760px) {
  .quote-lines thead { display: none; }
  .quote-lines tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.35rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
  .quote-lines td { padding: 0; width: auto !important; }
  .quote-lines td.c-desc { grid-column: 1 / -1; }
  .quote-lines td.c-total { padding-top: 0.5rem; }
}
.totals { margin-left: auto; width: min(100%, 20rem); display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 1rem; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.totals .grand { font-weight: 700; font-size: 1.05rem; border-top: 1px solid var(--border); padding-top: 0.4rem; }
.totals dd { margin: 0; text-align: right; }
.totals dt.grand + dd { font-weight: 700; font-size: 1.05rem; border-top: 1px solid var(--border); padding-top: 0.4rem; }
.notice { padding: 0.65rem 0.85rem; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--text); font-size: 0.88rem; margin-bottom: 1rem; }
.notice-warn { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text); }

/* --- Supervision : barres des tests des 24 dernières heures --- */
.uptime-bars { display: flex; align-items: flex-end; gap: 1px; height: 46px; }
.uptime-bars span { flex: 1; min-width: 1px; border-radius: 1px; background: var(--ok); opacity: 0.85; }
.uptime-bars span.is-down { background: var(--danger); opacity: 1; }
.uptime-axis { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--subtle); margin-top: 0.25rem; }

/* --- Messages éphémères --- */
.toast-zone { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 0.5rem; width: min(100% - 32px, 26rem); }
.toast { padding: 0.65rem 0.9rem; border-radius: var(--radius-sm); background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); font-size: 0.9rem; }
.toast.is-error { background: var(--danger); color: #fff; }
.loading { color: var(--muted); padding: 2rem 0; }
button.nav-link { border: 0; background: none; font: inherit; cursor: pointer; text-align: left; width: 100%; }
