:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #667085;
  --border: #e3e6eb;
  --accent: #2f6fde;
  --accent-dark: #2459b5;
  --danger: #c0352b;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --card: #1d2128; --text: #e7e9ee; --muted: #9aa3b2;
    --border: #2c323c; --accent: #5b8ff0; --accent-dark: #4a7ad6;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 1.2rem 0 .6rem; }
code { background: var(--border); padding: .05rem .35rem; border-radius: 4px; font-size: .9em; }
small, .muted { color: var(--muted); }

/* Barre du haut */
.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  padding: .75rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.topbar nav { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; font: inherit; cursor: pointer; }

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

/* Cartes */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; margin-bottom: 1rem;
}
.card.narrow { max-width: 480px; }
.card.empty { text-align: center; color: var(--muted); padding: 2.5rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.site-card { display: flex; flex-direction: column; gap: .35rem; color: var(--text); transition: transform .12s, border-color .12s; }
.site-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); }
.site-card .icon { font-size: 2rem; line-height: 1; }
.site-card .name { font-weight: 600; font-size: 1.05rem; }
.site-card .desc { color: var(--muted); font-size: .9rem; }

/* Connexion */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }
.login-wrap .flash { width: 100%; max-width: 380px; }

/* Formulaires */
label { display: block; margin-bottom: .9rem; font-weight: 500; }
input[type=text], input:not([type]), input[type=email], input[type=password], input[type=number], textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; }
.checks { margin: .5rem 0 1rem; }
label.check { display: flex; align-items: baseline; gap: .5rem; font-weight: 400; margin-bottom: .4rem; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .8rem 1rem .4rem; margin: 0 0 1rem; }
legend { font-weight: 600; padding: 0 .4rem; }
.actions { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-top: .5rem; }
.actions form { margin: 0; }

button, .button {
  display: inline-block; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font: inherit; font-weight: 500; cursor: pointer;
}
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .button.primary:hover { background: var(--accent-dark); text-decoration: none; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.wide { width: 100%; }

/* Messages */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash-error { background: #fdecea; border-color: #f5c2bd; color: #8a1f17; }
.flash-info { background: #e8f1fd; border-color: #bcd4f7; color: #1c4587; }

/* Onglets admin */
.tabs { display: flex; gap: .3rem; margin-bottom: 1.2rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs a { padding: .5rem 1rem; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* Tableaux */
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.ua { font-size: .8rem; color: var(--muted); max-width: 320px; }

.tag { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--border); margin-right: .25rem; }
.tag-admin { background: #e8f1fd; color: #1c4587; }
.tag-ok { background: #e4f5ea; color: var(--ok); }
.tag-off { background: #fdecea; color: var(--danger); }
.tag-warn { background: #fdf3e1; color: var(--warn); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.2rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* Accueil public */
.home-wrap { max-width: 960px; margin: 0 auto; padding: 4rem 1.5rem 2rem; }
.home-features { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.home-features .card { margin-bottom: 0; }
.home-features .icon { font-size: 1.8rem; line-height: 1; }
.home-features h2 { margin: .6rem 0 .3rem; font-size: 1.05rem; }
.home-features p { margin: 0; color: var(--muted); font-size: .92rem; }
.home-footer { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 2.5rem; }
.home-features .site-card { gap: 0; }

/* Choix d'icône (administration > sites) */
.icon-picker { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem .8rem; margin: 0 0 1rem; }
.icon-picker legend { padding: 0 .3rem; font-size: .95rem; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.9rem, 1fr)); gap: .35rem; margin-bottom: .7rem; }
.icon-option { position: relative; margin: 0; cursor: pointer; }
.icon-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.icon-option span {
  display: flex; align-items: center; justify-content: center; height: 2.9rem;
  font-size: 1.5rem; line-height: 1; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); transition: border-color .1s, background .1s;
}
.icon-option span.none { font-size: .75rem; color: var(--muted); }
.icon-option:hover span { border-color: var(--accent); }
.icon-option input:checked + span { border: 2px solid var(--accent); background: var(--card); box-shadow: 0 0 0 2px var(--accent) inset; }
.icon-option input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-custom { max-width: 380px; margin: 0; }
