/* HEXCEOS — Console de supervision.
   Thème sombre moderne, généreux en espace. Accent injecté via --accent. */
:root {
  --bg: #0a101e;
  --sidebar: #0b1120;
  --panel: #131d31;
  --panel-2: #0f1729;
  --hover: #1a2640;
  --border: #25324c;
  --border-soft: #1b2640;
  --text: #eef3fa;
  --text-dim: #b2bdd0;
  --muted: #717f97;
  --accent: #00d9ff;
  --accent-2: #3b82f6;
  --ok: #2ee6a6;
  --warn: #fbbf24;
  --bad: #fb7185;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 2px 4px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background:
    radial-gradient(1100px 600px at 70% -200px, rgba(0,217,255,.10), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2 { letter-spacing: -.3px; }

/* ───────── Mise en page ───────── */
.app { display: grid; grid-template-columns: 268px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--sidebar), #0a0f1c);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  padding: 26px 18px;
  position: sticky; top: 0; height: 100vh;
}
/* Logo teinté à la couleur d'accent (comme le `colorize` du kiosque), via un
   masque sur la silhouette du PNG. */
.logo {
  display: inline-block;
  aspect-ratio: 365 / 278;
  background-color: var(--accent);
  -webkit-mask: url(/static/hexceos.png) center / contain no-repeat;
          mask: url(/static/hexceos.png) center / contain no-repeat;
}
.brand { display: flex; align-items: center; gap: 13px; padding: 4px 10px 26px; }
.brand .logo { height: 36px; filter: drop-shadow(0 0 10px rgba(0,217,255,.35)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; letter-spacing: 2px; font-size: 17px; }
.brand-tag { color: var(--muted); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.navlink {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 14px; border-radius: 12px;
  color: var(--text-dim); text-decoration: none; font-size: 15px; font-weight: 500;
  transition: background .15s, color .15s; position: relative;
}
.navlink .ico {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center; font-size: 15px;
  background: rgba(255,255,255,.04); color: var(--muted); transition: .15s;
}
.navlink:hover { background: rgba(255,255,255,.04); color: var(--text); }
.navlink.active { background: linear-gradient(90deg, rgba(0,217,255,.16), rgba(0,217,255,.04)); color: #fff; }
.navlink.active .ico { background: var(--accent); color: #04161c; }

.sidebar-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--border-soft); }
.user { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding: 4px; }
.avatar {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 17px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #04161c;
}
.user-id { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.user-name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: var(--muted); font-size: 12px; }

.main { min-width: 0; }
.content { padding: 40px 48px 72px; max-width: 1640px; margin: 0 auto; width: 100%; }

/* ───────── En-têtes ───────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 30px; }
.page-head h1 { margin: 0; font-size: 30px; font-weight: 750; }
.sub, .page-head .sub { color: var(--muted); font-size: 15px; margin-top: 6px; }
.empty { color: var(--muted); padding: 56px 0; text-align: center; font-size: 16px; }
.back { color: var(--text-dim); text-decoration: none; font-size: 14px; display: inline-block; margin-bottom: 20px; font-weight: 500; }
.back:hover { color: var(--accent); }

/* ───────── Statistiques ───────── */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 18px; margin-bottom: 36px; }
.stats-3 { grid-template-columns: repeat(3, 1fr); max-width: 760px; }
.stats-3 .stat-val { font-size: 30px; white-space: nowrap; }
.stat {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 22px 24px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow);
}
.stat-val { font-size: 38px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.stat-val.ok { color: var(--ok); }
.stat-val.warn { color: var(--warn); }
.stat-val.bad { color: var(--bad); }
.stat-val.muted { color: var(--muted); }
.stat-lbl { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .8px; font-weight: 600; }

/* ───────── Cartes environnement ───────── */
.env-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 20px; }
.env-card {
  display: block; text-decoration: none; color: inherit;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); transition: border-color .15s, transform .15s, box-shadow .15s;
}
.env-card:hover { border-color: rgba(0,217,255,.5); transform: translateY(-3px); box-shadow: 0 14px 40px rgba(0,0,0,.4); }
.env-head { display: flex; align-items: center; gap: 15px; }
.env-avatar {
  width: 50px; height: 50px; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
  background: linear-gradient(135deg, rgba(0,217,255,.22), rgba(59,130,246,.16));
  color: var(--accent); border: 1px solid var(--border);
}
.env-title { flex: 1; min-width: 0; }
.env-title h2 { margin: 0; font-size: 19px; font-weight: 700; }
.env-sub { color: var(--muted); font-size: 13.5px; }
.env-ratio { font-size: 15px; font-weight: 700; color: var(--text-dim); white-space: nowrap; }
.env-ratio.good { color: var(--ok); }

.bar { height: 8px; border-radius: 6px; background: rgba(255,255,255,.06); overflow: hidden; margin: 20px 0 16px; }
.bar-fill { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }

.env-pills, .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { font-size: 12.5px; padding: 5px 11px; border-radius: 8px; font-weight: 600; }
.pill.ok { color: var(--ok); background: rgba(46,230,166,.13); }
.pill.warn { color: var(--warn); background: rgba(251,191,36,.13); }
.pill.bad { color: var(--bad); background: rgba(251,113,133,.13); }
.pill.muted { color: var(--text-dim); background: rgba(255,255,255,.06); }

/* ───────── Liste de stations (lignes horizontales) ───────── */
.station-list { display: flex; flex-direction: column; gap: 12px; }
.station-row {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border-soft); border-left: 3px solid var(--muted);
  border-radius: 14px; padding: 18px 22px; box-shadow: var(--shadow);
  transition: border-color .15s, transform .12s;
}
.station-row:hover { border-color: var(--border); border-left-color: var(--accent); transform: translateX(2px); }
.station-row.health-online { border-left-color: var(--ok); }
.station-row.health-stale { border-left-color: var(--warn); }
.station-row.health-offline, .station-row.health-rejected { border-left-color: var(--bad); }
.station-row.health-pending { border-left-color: var(--muted); }
.srow-id { display: flex; flex-direction: column; gap: 3px; flex: 1 1 220px; min-width: 0; }
.srow-id .st-name { font-size: 16.5px; }
.srow-metrics { display: flex; gap: 30px; }
.metric { display: flex; flex-direction: column; gap: 2px; min-width: 64px; }
.metric b { font-size: 14.5px; font-weight: 700; white-space: nowrap; }
.metric span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.srow-actions { display: flex; gap: 8px; align-items: center; }
.srow-actions .approve { display: flex; gap: 8px; }
.srow-actions select { max-width: 180px; }

@media (max-width: 760px) {
  .srow-metrics { gap: 18px; order: 3; flex-basis: 100%; }
  .srow-actions { flex-basis: 100%; }
}

/* ───────── Groupes par entité ───────── */
.entity { margin-bottom: 36px; }
.entity-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; }
.entity-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.count { color: var(--muted); font-size: 13px; padding: 3px 11px; border: 1px solid var(--border); border-radius: 20px; }
.count.good { color: var(--ok); border-color: rgba(46,230,166,.4); }

/* ───────── Cartes station ───────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
  border-left: 4px solid var(--muted);
}
.card:hover { border-color: var(--border); border-left-color: var(--accent); transform: translateY(-2px); }
.card.health-online { border-left-color: var(--ok); }
.card.health-stale { border-left-color: var(--warn); }
.card.health-offline, .card.health-rejected { border-left-color: var(--bad); }
.card.health-pending { border-left-color: var(--muted); }
.card-top { display: flex; align-items: center; gap: 11px; }
.st-name { color: var(--text); text-decoration: none; font-weight: 700; font-size: 16.5px; flex: 1; }
.st-name:hover { color: var(--accent); }
.st-id { color: var(--muted); font-size: 12.5px; font-family: ui-monospace, "SF Mono", Menlo, monospace; margin: 7px 0 14px; }
.st-meta { display: flex; gap: 18px; flex-wrap: wrap; color: var(--text-dim); font-size: 13.5px; }
.reports-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.reports-link:hover { text-decoration: underline; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot-online { background: var(--ok); box-shadow: 0 0 0 4px rgba(46,230,166,.16); }
.dot-stale { background: var(--warn); box-shadow: 0 0 0 4px rgba(251,191,36,.16); }
.dot-offline, .dot-rejected { background: var(--bad); box-shadow: 0 0 0 4px rgba(251,113,133,.16); }
.dot-pending { background: var(--muted); }

.badge { font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 8px; white-space: nowrap; }
.badge.online { color: var(--ok); background: rgba(46,230,166,.14); }
.badge.stale { color: var(--warn); background: rgba(251,191,36,.14); }
.badge.offline, .badge.rejected { color: var(--bad); background: rgba(251,113,133,.14); }
.badge.pending { color: var(--text-dim); background: rgba(255,255,255,.07); }

/* ───────── Actions & formulaires ───────── */
.actions { align-items: center; margin-top: 18px; }
.approve { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.card .actions { flex-direction: column; align-items: stretch; }
.card .approve input { flex: 1 1 100%; min-width: 0; }
.card .actions .btn, .card .actions .btn-ghost { width: 100%; }

input, select {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size: 15px; outline: none; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0,217,255,.14); }
input::placeholder { color: var(--muted); }

.btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #03121a;
  border: none; font-weight: 700; font-family: inherit;
  padding: 12px 20px; border-radius: 10px; cursor: pointer; font-size: 14.5px;
  transition: filter .15s, transform .05s; box-shadow: 0 6px 18px rgba(0,217,255,.18);
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.block, .btn-ghost.block { width: 100%; }
.btn-ghost {
  background: rgba(255,255,255,.03); color: var(--text-dim); border: 1px solid var(--border);
  padding: 11px 18px; border-radius: 10px; cursor: pointer; font-size: 14.5px; font-family: inherit;
  text-decoration: none; display: inline-block; transition: .15s; font-weight: 500;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); background: rgba(255,255,255,.06); }
.btn-ghost.danger:hover { color: var(--bad); border-color: rgba(251,113,133,.5); }

/* ───────── Détail station ───────── */
.detail { background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 30px; box-shadow: var(--shadow); }
.detail-head { display: flex; align-items: center; gap: 14px; }
.detail-head h1 { margin: 0; font-size: 24px; flex: 1; font-weight: 700; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1px; margin: 28px 0; background: var(--border-soft); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; }
.kv { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; background: var(--panel); }
.kv span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .7px; font-weight: 600; }
.kv b { font-weight: 600; word-break: break-all; font-size: 15px; }
h2 { font-size: 17px; font-weight: 700; margin: 32px 0 16px; }
.engines { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 14px; font-size: 13.5px; color: var(--text-dim); }
.muted { color: var(--muted); }

/* ───────── Tables & panneaux ───────── */
.panel { background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.panel.nopad { padding: 0; overflow: hidden; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .7px; padding: 16px 22px; border-bottom: 1px solid var(--border); font-weight: 700; }
.tbl td { padding: 17px 22px; border-bottom: 1px solid var(--border-soft); font-size: 15px; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover td { background: rgba(255,255,255,.025); }
.tbl .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13.5px; color: var(--text-dim); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.rowlink { color: var(--text); text-decoration: none; font-weight: 700; }
.rowlink:hover { color: var(--accent); }

.form { display: flex; flex-direction: column; gap: 18px; max-width: 560px; }
.form.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 24px; max-width: 820px; }
.form.grid2 button { grid-column: 1 / -1; justify-self: start; }
.form label { display: flex; flex-direction: column; gap: 9px; font-size: 13.5px; color: var(--text-dim); font-weight: 600; }
.hint { color: var(--muted); font-size: 13.5px; margin-top: 20px; }
.error { color: var(--bad); font-size: 14px; background: rgba(251,113,133,.1); border: 1px solid rgba(251,113,133,.25); padding: 12px 16px; border-radius: 10px; }
.notice { color: var(--ok); font-size: 14px; background: rgba(46,230,166,.1); border: 1px solid rgba(46,230,166,.25); padding: 12px 16px; border-radius: 10px; }
.raw {
  background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 22px; overflow: auto; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13.5px; line-height: 1.7; color: var(--text-dim); max-height: 580px;
}
.device-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 24px; }
.device-main { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.device-lbl { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.device-id { font-size: 15px; font-weight: 700; color: var(--accent); }
.device-desc { color: var(--text-dim); font-size: 13.5px; }
.device-parts { display: flex; gap: 8px; flex-wrap: wrap; }
.report-table td { vertical-align: top; }
.report-table .filecol { max-width: 360px; word-break: break-all; white-space: normal; }
.cell-detail { color: var(--muted); font-size: 11.5px; margin-top: 5px; word-break: break-word; max-width: 200px; }
.raw-details { margin-top: 26px; }
.raw-details summary { cursor: pointer; color: var(--muted); font-size: 13.5px; padding: 6px 0; user-select: none; }
.raw-details summary:hover { color: var(--accent); }
.raw-details[open] summary { margin-bottom: 12px; }

/* ───────── Modales ───────── */
dialog.modal {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  color: var(--text);
  border-radius: 18px; padding: 0;
  width: 560px; max-width: 92vw;
  box-shadow: 0 24px 70px rgba(0,0,0,.55);
}
dialog.modal::backdrop { background: rgba(4,8,15,.66); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: modal-in .16s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px; border-bottom: 1px solid var(--border-soft); }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.modal-x { background: transparent; border: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 4px; border-radius: 8px; }
.modal-x:hover { color: var(--text); background: rgba(255,255,255,.05); }
.modal-body { display: flex; flex-direction: column; gap: 18px; padding: 26px; }
.modal-body label { display: flex; flex-direction: column; gap: 9px; font-size: 13.5px; color: var(--text-dim); font-weight: 600; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 26px; border-top: 1px solid var(--border-soft); }

/* ───────── Connexion ───────── */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: radial-gradient(900px 600px at 50% -80px, rgba(0,217,255,.14), transparent 70%), var(--bg);
}
.login {
  width: 400px; display: flex; flex-direction: column; gap: 18px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border); border-radius: 20px; padding: 42px 38px; box-shadow: var(--shadow);
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 16px; justify-content: center; margin: 6px 0 10px; }
.login-brand .logo { height: 96px; filter: drop-shadow(0 0 18px rgba(0,217,255,.45)); }
.login-brand .brand-name { font-weight: 800; letter-spacing: 3px; font-size: 24px; }
.login h1 { font-size: 21px; text-align: center; margin: 8px 0 0; font-weight: 700; }
.login-sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 0 0 8px; }
.login label { display: flex; flex-direction: column; gap: 9px; font-size: 13.5px; color: var(--text-dim); font-weight: 600; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin: 6px 0 0; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-foot { margin: 0 0 0 auto; border: none; padding: 0; display: flex; gap: 12px; align-items: center; }
  .nav { flex-direction: row; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 28px 20px 60px; }
}
