:root {
  /* Palette inspirée de VS Code Dark+ — familière, forte densité d'information lisible */
  --bg: #1e1e1e;
  --panel: #252526;
  --border: #3c3c3c;
  --text: #cccccc;
  --muted: #969696;
  --ok: #89d185;
  --warn: #e2c08d;
  --soon: #d19a66;
  --expired: #f14c4c;
  --link: #3794ff;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(55, 148, 255, 0.15);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}

h1 { margin: 0 0 1rem; font-size: 1.5rem; }

/* --- Structure : sidebar façon explorateur + panneau principal --- */

.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 1rem 1.1rem;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border);
}

.brand-mark { color: var(--link); margin-right: 0.4rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.5rem 0; }

.sidebar-nav a {
  display: block;
  padding: 0.5rem 1.1rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  border-left: 2px solid transparent;
}

.sidebar-nav a:hover { background: var(--sidebar-hover); color: var(--text); }
.sidebar-nav a.active {
  background: var(--sidebar-active);
  color: var(--text);
  border-left-color: var(--link);
  font-weight: 600;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 0.75rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-footer .current-user { color: var(--muted); font-size: 0.75rem; }

.sidebar-footer form button {
  width: 100%;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
}

.sidebar-footer form button:hover { color: var(--text); border-color: var(--muted); }

.app-main-wrap { flex: 1; min-width: 0; overflow-x: auto; }
.app-main { padding: 2rem; max-width: 1100px; }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-nav { display: flex; overflow-x: auto; padding: 0.25rem; }
  .sidebar-nav a { border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; }
  .sidebar-nav a.active { border-left-color: transparent; border-bottom-color: var(--link); }
}

h2 { font-size: 1.1rem; margin: 2rem 0 0.75rem; border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 0.5rem; color: var(--muted); }

.subtitle { color: var(--muted); margin-bottom: 1.5rem; }
.subtitle a { color: var(--link); }

.errors {
  background: #2a1414;
  border: 1px solid var(--expired);
  color: #ffb3ab;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }

table { border-collapse: collapse; width: 100%; min-width: 640px; }

th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }

tbody tr:hover { background: var(--panel); }

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.ok { background: rgba(137,209,133,0.18); color: var(--ok); }
.badge.warn { background: rgba(226,192,141,0.18); color: var(--warn); }
.badge.soon { background: rgba(209,154,102,0.18); color: var(--soon); }
.badge.expired { background: rgba(241,76,76,0.18); color: var(--expired); }
.badge.unknown { background: rgba(150,150,150,0.15); color: var(--muted); }

.autorenew-on { color: var(--ok); }
.autorenew-off { color: var(--muted); }

.cost-override { color: var(--warn); }
.cost-override::after { content: " *"; }

.empty { color: var(--muted); font-style: italic; padding: 1rem; }

.project-block { margin-bottom: 1.25rem; }
.project-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; cursor: pointer; }
.project-title::marker { color: var(--muted); }
.project-block[open] > .project-title { margin-bottom: 0.75rem; }
.project-count { color: var(--muted); font-weight: 400; font-size: 0.85rem; }

footer { margin-top: 2.5rem; color: var(--muted); font-size: 0.8rem; }

select, input[type="text"], input[type="number"], input[type="password"] {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

.form-row input[type="text"], .form-row input[type="password"], .form-row input[type="number"], .form-row select {
  width: 100%;
}

.btn {
  display: inline-block;
  background: var(--link);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger { background: var(--expired); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }

.form-row { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.3rem; max-width: 420px; }
.form-row label { font-size: 0.8rem; color: var(--muted); }

.notice {
  border: 1px solid var(--link);
  background: rgba(55,148,255,0.12);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}

.compliance-note {
  border: 1px solid var(--warn);
  background: rgba(226,192,141,0.12);
  color: #ffd98f;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin: 1rem 0;
  font-size: 0.85rem;
}

.alert-row.critical { background: rgba(241,76,76,0.1); }
.alert-row.warning { background: rgba(226,192,141,0.1); }

.chat { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.5rem; max-width: 720px; }

.chat-msg {
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  max-width: 90%;
}

.chat-msg.user { align-self: flex-end; background: rgba(55,148,255,0.18); }
.chat-msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); }

.pending-action {
  border: 1px solid var(--soon);
  background: rgba(209,154,102,0.12);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  max-width: 720px;
}

.pending-action pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
  font-size: 0.8rem;
  overflow-x: auto;
}

.success-banner {
  border: 1px solid var(--ok);
  background: rgba(137,209,133,0.12);
  color: #b7f0c5;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}
