/* =========================================================
   HAUTO — espace administrateur
   ========================================================= */
:root {
  --bg: #f1f5f9; --panel: #fff; --line: #e2e8f0; --text: #0f172a; --muted: #64748b;
  --side: #06121f; --cyan: #0891b2; --cyan-l: #22d3ee; --green: #059669; --warn: #d97706; --bad: #dc2626;
  --radius: 14px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .7em; }
h2 { font-size: 1.1rem; }
code { background: #f1f5f9; padding: .1em .4em; border-radius: 5px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.right { text-align: right; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; padding: .7em 1.3em; border-radius: 10px; border: 0; background: linear-gradient(135deg, #0891b2, #059669); color: #fff; font: 600 .95rem inherit; font-family: inherit; cursor: pointer; text-decoration: none !important; transition: filter .2s, transform .2s; }
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: wait; transform: none; }
.btn-sm { padding: .5em 1em; font-size: .85rem; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: var(--bad); }
.btn-block { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--cyan); font: inherit; cursor: pointer; font-size: .88rem; }
.link:hover { text-decoration: underline; }
.link:disabled { color: #cbd5e1; cursor: default; text-decoration: none; }
.link.danger { color: var(--bad); }

/* Formulaires */
label { display: block; font-size: .85rem; font-weight: 600; color: #334155; margin-bottom: .9rem; }
input, select, textarea { display: block; width: 100%; margin-top: .35rem; padding: .65em .85em; border: 1px solid #cbd5e1; border-radius: 9px; font: 400 .95rem inherit; font-family: inherit; color: var(--text); background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(8, 145, 178, .15); }
textarea { resize: vertical; }
label.check { display: flex; align-items: center; gap: .6rem; font-weight: 500; }
label.check input { width: auto; margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

/* Alertes */
.alert { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .92rem; border: 1px solid; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-info { background: #ecfeff; border-color: #a5f3fc; color: #155e75; }

/* Pages de connexion / installation */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; background: radial-gradient(700px 400px at 50% 0%, rgba(34, 211, 238, .25), transparent 70%), #06121f; }
.auth-card { width: min(420px, 100%); background: #fff; border-radius: 20px; padding: 2.2rem; box-shadow: 0 30px 80px rgba(0, 0, 0, .4); }
.auth-card.wide { width: min(640px, 100%); }
.auth-card h1 { font-size: 1.4rem; }
.auth-card h2 { font-size: 1rem; margin-top: 1.4rem; color: var(--cyan); }
.auth-card .btn { margin-top: .4rem; }
.auth-logo { font: 800 1.6rem inherit; font-family: inherit; letter-spacing: .14em; margin-bottom: 1.2rem; }
.auth-logo span { color: var(--cyan-l); }

/* Mise en page admin */
.admin { display: flex; min-height: 100vh; }
.sidebar { width: 250px; flex: 0 0 250px; background: var(--side); color: #cbd5e1; display: flex; flex-direction: column; padding: 1.4rem 1rem; position: sticky; top: 0; height: 100vh; }
.sidebar .side-logo { display: block; color: #fff !important; font-weight: 800; font-size: 1.35rem; letter-spacing: .14em; padding: 0 .6rem 1.6rem; text-decoration: none !important; }
.side-logo span { color: var(--cyan-l); }
.side-logo small { font-size: .65rem; letter-spacing: .1em; color: #64748b; text-transform: uppercase; margin-left: .3rem; }
.sidebar nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.sidebar a { display: flex; align-items: center; gap: .75rem; padding: .7rem .8rem; border-radius: 10px; color: #cbd5e1; text-decoration: none !important; font-weight: 500; }
.sidebar a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar a.active { background: rgba(34, 211, 238, .14); color: var(--cyan-l); }
.sidebar svg { width: 20px; height: 20px; flex: 0 0 20px; }
.pill { margin-left: auto; background: var(--cyan-l); color: #06121f; border-radius: 999px; font-size: .75rem; padding: .05em .55em; }
.side-bottom { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: .8rem; }
.main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 2rem; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 1.25rem; margin: 0; flex: 1; }
.who { color: var(--muted); font-size: .9rem; }
.side-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; font-size: 1.2rem; padding: .2rem .6rem; cursor: pointer; }
.content { padding: 1.8rem 2rem 3rem; max-width: 1300px; }

/* Panneaux */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem 1.5rem; margin-bottom: 1.4rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.panel-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
.grid-2 > .panel { margin-bottom: 0; }
.grid-2 + .grid-2, .grid-2 + .panel, .stat-grid + .grid-2 { margin-top: 1.4rem; }
.grid-wide { align-items: start; }

/* Statistiques */
.stat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.stat span { display: block; font-size: .8rem; color: var(--muted); }
.stat strong { font-size: 1.7rem; }
.stat-ok strong { color: var(--green); }
.stat-warn strong { color: var(--warn); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.bar i { display: block; width: 100%; min-height: 3px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #22d3ee, #059669); }
.bar small { font-size: .7rem; color: var(--muted); margin-top: 4px; }

/* Étiquettes */
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: .2em .65em; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; margin: 0; }
.tag-ok { background: #d1fae5; color: #065f46; }
.tag-warn { background: #fef3c7; color: #92400e; }
.tag-info { background: #cffafe; color: #155e75; }
.tag-muted { background: #f1f5f9; color: #475569; }

/* Tableaux */
.table-wrap { overflow-x: auto; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .92rem; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
tr.unread td { font-weight: 600; background: #f0fdfa; }
.actions { white-space: nowrap; }
.actions form { display: inline; margin-left: .6rem; }
.actions a { margin-left: .6rem; font-size: .88rem; }
.actions select { display: inline-block; width: auto; margin: 0; padding: .3em .5em; font-size: .82rem; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: .6rem; }
.filters input { flex: 1 1 260px; margin: 0; }
.filters select { width: auto; margin: 0; }
.pager { display: flex; flex-wrap: wrap; gap: .35rem; }
.pager a { padding: .35em .75em; border: 1px solid var(--line); border-radius: 8px; color: var(--text); }
.pager a.active { background: var(--cyan); border-color: var(--cyan); color: #fff; }

/* Frise (admin) */
.tl-admin { list-style: none; padding: 0; margin: 0; }
.tl-admin li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tl-a-main { flex: 1 1 260px; }
.tl-a-main .tag { margin-right: .4rem; }
.tl-a-current { background: linear-gradient(90deg, #ecfeff, transparent); }
.tl-admin .actions form, .tl-admin .actions a { margin-left: .5rem; }

/* Messages & envoi */
.message-body { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.2rem; margin: 1rem 0; white-space: normal; }
.row-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.row-actions form { margin: 0; }
.progress { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: 1.2rem 0 .6rem; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #22d3ee, #059669); transition: width .3s; }
.nl-msg { margin-top: 1rem; }
.nl-msg:empty { display: none; }

/* Responsive */
@media (max-width: 1200px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .side-toggle { display: block; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 > .panel + .panel { margin-top: 0; }
  .content { padding: 1.2rem 1rem 3rem; }
  .topbar { padding: .9rem 1rem; }
}
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .who { display: none; }
  .actions { white-space: normal; }
}
