@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;600;700&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bleu: #1E3A8A;
  --bleu-vif: #2F5AD1;
  --bleu-light: #EAF0FD;
  --bleu-dark: #14265C;
  --ambre: #B7791F;
  --ambre-light: #FBF2E1;
  --rouge: #C0392B;
  --rouge-light: #FDF0EE;
  --vert: #1E7A4C;
  --vert-light: #E7F5EC;
  --gris: #2D3748;
  --gris-clair: #EEF1F6;
  --gris-mid: #718096;
  --surface: #F6F7FB;
  --border: rgba(30,58,138,0.12);
  --text: #1A202C;
  --text-muted: #718096;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20,38,92,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

html, body { height: 100%; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ===== SHELL ===== */
.dash-root { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  min-width: 240px;
  background: #0B1739;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow: hidden;
  z-index: 20;
}

.sidebar::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(to bottom, #2F5AD1 33.3%, #B7791F 33.3% 66.6%, #C0392B 66.6%);
  z-index: 2;
}

.sidebar-logo { padding: 20px 20px 16px 24px; border-bottom: 1px solid rgba(255,255,255,0.08); }

.org-badge { display: flex; align-items: center; gap: 10px; }

.org-icon {
  width: 36px; height: 36px;
  background: rgba(47,90,209,0.22);
  border: 1px solid rgba(47,90,209,0.45);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #8AA6F5;
}

.org-name { font-family: 'Playfair Display', serif; color: #FAFAFA; font-size: 13px; font-weight: 600; line-height: 1.3; }
.org-type { color: rgba(255,255,255,0.45); font-size: 10px; letter-spacing: 0.5px; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-section {
  padding: 8px 16px 4px 24px; font-size: 9px; letter-spacing: 1.2px; text-transform: uppercase;
  color: rgba(255,255,255,0.3); font-weight: 500; margin-top: 8px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px 8px 24px; color: rgba(255,255,255,0.6);
  cursor: pointer; border-left: 3px solid transparent; transition: all .15s;
  font-size: 13px; font-weight: 400; text-decoration: none;
}
.nav-item:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.05); }
.nav-item.active { color: #FAFAFA; background: rgba(47,90,209,0.35); border-left-color: #B7791F; font-weight: 500; }
.nav-item.disabled { cursor: default; opacity: .55; }
.nav-item.disabled:hover { background: none; color: rgba(255,255,255,0.6); }
.nav-item i { font-size: 16px; width: 16px; text-align: center; }

.nav-badge { margin-left: auto; background: var(--rouge); color: #fff; border-radius: 10px; padding: 1px 6px; font-size: 10px; font-weight: 600; }
.nav-badge.soon { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.55); font-weight: 500; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(183,121,31,0.3); border: 1.5px solid rgba(183,121,31,0.55);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #E8B85A; flex-shrink: 0;
}
.user-name { color: rgba(255,255,255,0.85); font-size: 12px; font-weight: 500; }
.user-role { color: rgba(255,255,255,0.4); font-size: 10px; }
.logout-link {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: rgba(255,255,255,0.55); cursor: pointer; text-decoration: none;
  border: 0.5px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.04);
}
.logout-link:hover { color: #fff; background: rgba(192,57,43,0.35); border-color: rgba(192,57,43,0.5); }

/* ===== MAIN ===== */
.main { flex: 1; display: flex; flex-direction: column; margin-left: 240px; min-height: 100vh; }

.topbar {
  background: #fff; border-bottom: 0.5px solid var(--border);
  padding: 10px 24px; min-height: 56px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap; row-gap: 8px;
}
.topbar-title { font-family: 'Playfair Display', serif; font-size: 16px; font-weight: 600; color: var(--bleu-dark); flex: 1; }
.topbar-subtitle { font-size: 11px; color: var(--text-muted); font-weight: 400; display: block; font-family: 'Inter', sans-serif; margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.btn-icon {
  width: 34px; height: 34px; border-radius: 8px; border: 0.5px solid var(--border);
  background: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted); font-size: 16px; position: relative; text-decoration: none;
}
.btn-icon:hover { background: var(--gris-clair); color: var(--bleu-vif); }
.notif-dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; background: var(--rouge); border-radius: 50%; border: 1.5px solid #fff; }

.btn-primary, button, .button {
  display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; height: 34px;
  border-radius: 8px; background: var(--bleu-vif); color: #fff; border: none;
  font-size: 12px; font-weight: 500; cursor: pointer; font-family: 'Inter', sans-serif; text-decoration: none;
}
.btn-primary:hover, button:hover, .button:hover { background: var(--bleu-dark); }

.search-bar {
  display: flex; align-items: center; gap: 8px; background: var(--gris-clair);
  border: 0.5px solid var(--border); border-radius: 8px; padding: 0 12px; height: 34px; width: 200px;
}
.search-bar input { border: none; background: transparent; font-size: 12px; font-family: 'Inter', sans-serif; color: var(--text); outline: none; width: 100%; }
.search-bar i { color: var(--text-muted); font-size: 14px; }

.content { flex: 1; padding: 20px 24px 40px; }

/* ===== ALERT ===== */
.alert-banner {
  background: var(--rouge-light); border: 0.5px solid rgba(192,57,43,0.2); border-radius: 8px;
  padding: 10px 14px; display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: 12px; color: #7b1e15;
}
.alert-banner.ok { background: var(--vert-light); border-color: rgba(30,122,76,0.2); color: #114a2c; }
.alert-banner i { font-size: 16px; color: var(--rouge); }
.alert-banner.ok i { color: var(--vert); }
.alert-banner strong { font-weight: 600; }
.alert-banner a { text-decoration: underline; cursor: pointer; }

/* ===== STAT CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stats-grid-3 { grid-template-columns: repeat(3, 1fr); }

.stat-card { background: #fff; border: 0.5px solid var(--border); border-radius: var(--radius); padding: 16px; position: relative; overflow: hidden; }
.stat-card::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 3px; }
.stat-card.bleu::after { background: var(--bleu-vif); }
.stat-card.ambre::after { background: var(--ambre); }
.stat-card.rouge::after { background: var(--rouge); }
.stat-card.vert::after { background: var(--vert); }
.stat-card.gris::after { background: var(--gris-mid); }

.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-value { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 500; color: var(--text); line-height: 1; margin-bottom: 6px; }
.stat-delta { font-size: 11px; display: flex; align-items: center; gap: 3px; color: var(--text-muted); }
.stat-delta.up { color: var(--vert); }
.stat-delta.down { color: var(--rouge); }
.stat-delta.warn { color: var(--ambre); }

.stat-icon { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.stat-icon.bleu { background: var(--bleu-light); color: var(--bleu-vif); }
.stat-icon.ambre { background: var(--ambre-light); color: var(--ambre); }
.stat-icon.rouge { background: var(--rouge-light); color: var(--rouge); }
.stat-icon.vert { background: var(--vert-light); color: var(--vert); }
.stat-icon.gris { background: var(--gris-clair); color: var(--gris-mid); }

/* ===== CHART / TABLE CARDS ===== */
.charts-row { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 20px; }
.bottom-row { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 20px; }

.chart-card, .panel, .card { background: #fff; border: 0.5px solid var(--border); border-radius: var(--radius); padding: 20px; }
.chart-header, .panel-title { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.chart-title, .panel-title h2 { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.chart-subtitle, .panel-title span { font-size: 11px; color: var(--text-muted); font-weight: 400; }

.chart-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

.table-card { background: #fff; border: 0.5px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-head { padding: 16px 20px 12px; border-bottom: 0.5px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.table-title { font-size: 13px; font-weight: 600; color: var(--text); }

.btn-sm { padding: 4px 10px; border-radius: 6px; font-size: 11px; border: 0.5px solid var(--border); background: #fff; cursor: pointer; color: var(--text-muted); font-family: 'Inter', sans-serif; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; height: auto; }
.btn-sm:hover { background: var(--gris-clair); }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
table th { padding: 8px 16px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); background: var(--surface); border-bottom: 0.5px solid var(--border); }
table td { padding: 10px 16px; font-size: 12px; border-bottom: 0.5px solid rgba(30,58,138,0.06); vertical-align: middle; }
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: var(--bleu-light); }
table td small { color: var(--text-muted); display: block; font-size: 11px; margin-top: 2px; }
table td b { font-weight: 600; }
table td a { color: var(--bleu-vif); text-decoration: none; font-weight: 500; }
table td a:hover { text-decoration: underline; }
.row-active td { background: var(--bleu-light); }
.mono { font-family: 'JetBrains Mono', monospace; }

/* ===== BADGES ===== */
.status-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 10px; font-weight: 500; }
.status-badge.production, .status-badge.ok { background: var(--vert-light); color: #114a2c; }
.status-badge.staging, .status-badge.warning { background: var(--ambre-light); color: #7a5c00; }
.status-badge.development, .status-badge.test { background: var(--bleu-light); color: #1e3a8a; }
.status-badge.down, .status-badge.error { background: var(--rouge-light); color: #7b1e15; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 20px; background: var(--gris-clair); color: var(--gris-mid); font-weight: 500; }

/* ===== MINI STATS ===== */
.mini-stats { display: flex; flex-direction: column; gap: 12px; }
.mini-stats-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.mini-card { background: #fff; border: 0.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.mini-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.mini-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.mini-value { font-size: 16px; font-weight: 600; font-family: 'JetBrains Mono', monospace; }
.mini-bar { height: 3px; background: var(--gris-clair); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.mini-bar-fill { height: 100%; border-radius: 2px; }

.donut-labels { width: 100%; margin-top: 12px; }
.donut-item { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; border-bottom: 0.5px solid var(--border); font-size: 11px; }
.donut-item:last-child { border-bottom: none; }
.donut-item-name { display: flex; align-items: center; gap: 6px; color: var(--text); }
.donut-item-val { font-weight: 500; color: var(--text); }

/* ===== TABS ===== */
.tabs { display: flex; background: #fff; border: 0.5px solid var(--border); border-radius: 8px; padding: 3px; gap: 2px; }
.tab { padding: 5px 14px; border-radius: 6px; font-size: 12px; cursor: pointer; color: var(--text-muted); font-weight: 400; text-decoration: none; }
.tab.active { background: var(--bleu-vif); color: #fff; font-weight: 500; }

/* ===== FORMS ===== */
label { display: block; color: var(--text-muted); font-size: 12px; font-weight: 500; margin: 12px 0 5px; }
input, select, textarea {
  width: 100%; display: block; padding: 10px 12px; border-radius: 8px;
  border: 0.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--bleu-vif); background: #fff; }
textarea { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
form .button, form button { margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
.hint { font-size: 11px; color: var(--text-muted); display: block; margin-top: 10px; }
.error { color: var(--rouge) !important; font-size: 12px; background: var(--rouge-light); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; display: block; }
.inline-form select { width: auto; min-width: 220px; margin: 0; height: 34px; padding: 0 12px; }

/* ===== AUTH ===== */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at top, #16255e 0%, #0B1739 55%, #08102a 100%);
  padding: 20px;
}
.auth-card { background: #fff; border-radius: 16px; padding: 36px 34px; width: min(400px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,0.35); }
.auth-card .org-icon { width: 44px; height: 44px; font-size: 20px; background: var(--bleu-light); border-color: var(--border); color: var(--bleu-vif); margin-bottom: 14px; }
.auth-card h1 { font-family: 'Playfair Display', serif; font-size: 21px; font-weight: 600; color: var(--bleu-dark); }
.auth-card p.lede { color: var(--text-muted); margin: 6px 0 22px; font-size: 12.5px; }
.auth-card button { width: 100%; justify-content: center; margin-top: 18px; height: 40px; font-size: 13px; }

/* ===== SIDEBAR TOGGLE (mobile) ===== */
.sidebar-toggle { display: none; }
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(11,23,57,0.5);
  opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 15;
}
body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1080px) {
  .charts-row, .bottom-row { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 30;
    box-shadow: 0 0 40px rgba(0,0,0,0.25);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .stats-grid, .stats-grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .content { padding: 14px 14px 30px; }
  .topbar { padding: 8px 14px; gap: 8px; }
  .topbar-title { font-size: 14px; }
  .search-bar { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stats-grid-3 { grid-template-columns: 1fr; }
  .stat-value { font-size: 21px; }
  .form-grid { grid-template-columns: 1fr; }
  .chart-card, .panel, .card { padding: 14px; }
  .table-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  table th, table td { padding: 8px 10px; }
  .auth-card { padding: 28px 22px; }
  .inline-form select { min-width: 0; width: 100%; }
}
@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
}

