:root {
  --bg:        #0a0d14;
  --panel:     #12161f;
  --panel-2:   #171c27;
  --border:    #232937;
  --border-2:  #2d3648;
  --text:      #e8ecf3;
  --muted:     #6b7488;
  --green:     #22c55e;
  --green-dim: #0f3d24;
  --red:       #ef4444;
  --red-dim:   #3d1418;
  --amber:     #f59e0b;
  --blue:      #3b82f6;
  --accent:    #38bdf8;
  --radius:    14px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #33405a; }

/* ============ HEADER ============ */
.topbar {
  height: 58px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px;
  position: relative; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  display: grid; place-items: center; font-size: 18px;
  box-shadow: 0 0 18px rgba(56,189,248,.3);
}
.brand h1 { font-size: 15px; font-weight: 700; letter-spacing: .3px; }
.brand p  { font-size: 10px; color: var(--muted); letter-spacing: .6px; text-transform: uppercase; }

.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a {
  font-size: 13px; color: var(--muted); padding: 7px 13px;
  border-radius: 8px; font-weight: 600; transition: .15s;
}
.nav a:hover { color: var(--text); background: var(--panel-2); }
.nav a.on { color: var(--accent); background: rgba(56,189,248,.1); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.userchip {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 6px 8px 6px 12px; border-radius: 20px; font-size: 12px;
}
.userchip .who { font-weight: 600; }
.userchip .role {
  font-size: 9px; text-transform: uppercase; letter-spacing: .6px;
  padding: 2px 7px; border-radius: 10px;
  background: rgba(56,189,248,.14); color: var(--accent);
}
.userchip .role.viewer { background: rgba(107,116,136,.18); color: var(--muted); }
.logout {
  color: var(--muted); font-size: 16px; padding: 3px 6px;
  border-radius: 6px; transition: .15s;
}
.logout:hover { color: var(--red); background: var(--red-dim); }
.clock { text-align: right; }
.clock .t { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.clock .d { font-size: 10px; color: var(--muted); }

/* ============ CARTES ============ */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 13px;
  display: flex; align-items: center; gap: 7px;
}

/* ============ FORMULAIRES ============ */
label.fld { display: block; margin-bottom: 12px; }
label.fld span {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: .7px; color: var(--muted); margin-bottom: 6px;
}
input[type=text], input[type=password], select {
  width: 100%; padding: 11px 13px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); font-size: 14px;
  font-family: inherit; outline: none; transition: .15s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56,189,248,.12); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 18px; border: none; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #04121e; font-weight: 700; font-size: 14px;
  cursor: pointer; transition: .15s; font-family: inherit;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn.ghost { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { border-color: var(--border); background: #1e2534; }
.btn.danger { background: var(--red-dim); border: 1px solid rgba(239,68,68,.35); color: #fca5a5; }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.sm { padding: 6px 12px; font-size: 12px; border-radius: 7px; }

.flash { padding: 11px 14px; border-radius: 9px; font-size: 13px; margin-bottom: 12px; }
.flash.ok    { background: var(--green-dim); color: #86efac; border: 1px solid rgba(34,197,94,.3); }
.flash.error { background: var(--red-dim); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }

/* ============ TABLEAUX ============ */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-size: 10px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--muted); font-weight: 700;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--panel-2); }
code.k {
  font-family: 'Consolas', monospace; font-size: 11px;
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 6px; color: var(--amber);
  user-select: all; word-break: break-all;
}
.pill {
  font-size: 10px; text-transform: uppercase; letter-spacing: .6px;
  padding: 3px 9px; border-radius: 11px; font-weight: 700;
}
.pill.admin  { background: rgba(56,189,248,.14); color: var(--accent); }
.pill.viewer { background: rgba(107,116,136,.18); color: var(--muted); }

@keyframes pulse {
  0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
  50%     { opacity: .5; box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

/* ================= RESPONSIVE ================= */

/* Les tableaux longs (cles API) defilent dans leur carte, jamais la page */
.card { min-width: 0; }
table { min-width: 0; }
.tablewrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

@media (max-width: 1024px) {
  .brand p { display: none; }
  .brand h1 { font-size: 14px; }
}

@media (max-width: 860px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .nav a { padding: 7px 10px; font-size: 12.5px; }
  .clock .d { display: none; }
  .clock .t { font-size: 14px; }
}

@media (max-width: 680px) {
  .topbar { gap: 9px; padding: 0 11px; }
  .brand h1 { display: none; }
  .nav { margin-left: 0; }
  .userchip { padding: 5px 7px 5px 10px; gap: 7px; }
  .userchip .role { display: none; }
  .clock { display: none; }
  code.k { font-size: 10px; }
}

@media (max-width: 480px) {
  .userchip .who { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .btn { padding: 10px 14px; font-size: 13px; }
}
