@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
    --bg:            #12151a;
    --bg-panel:      #1a1e26;
    --bg-panel-2:    #20242e;
    --border:        #2a3040;
    --text:          #e7e9ee;
    --text-muted:    #8b93a7;
    --accent:        #f0b429;   /* ambre - actions, focus */
    --accent-dim:    #7a5f1d;
    --risque-faible: #34d399;
    --risque-moyen:  #f0b429;
    --risque-eleve:  #f8717a;
    --danger:        #f8717a;
    --danger-bg:     #2a1518;
    --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

code, .mono, .badge-code, th.mono-th {
    font-family: 'IBM Plex Mono', monospace;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout général ---------- */

.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
}

.sidebar .brand {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    padding: 0 24px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.sidebar .brand span {
    display: block;
    color: var(--text-muted);
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.04em;
    margin-top: 4px;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 24px;
    color: var(--text-muted);
    font-size: 14px;
    border-left: 3px solid transparent;
}

.sidebar nav a:hover {
    color: var(--text);
    text-decoration: none;
    background: var(--bg-panel-2);
}

.sidebar nav a.active {
    color: var(--text);
    border-left-color: var(--accent);
    background: var(--bg-panel-2);
}

.sidebar .who {
    margin-top: auto;
    padding: 16px 24px 0;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar .who strong { color: var(--text); display: block; font-size: 13px; }

main {
    padding: 32px 40px;
    max-width: 1100px;
}

h1 {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 6px;
}

.subtitle { color: var(--text-muted); margin: 0 0 28px; font-size: 14px; }

/* ---------- Panels & cartes ---------- */

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
}

.panel h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.stat-card .num {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 26px;
    font-weight: 600;
}

.stat-card .label {
    color: var(--text-muted);
    font-size: 12.5px;
    margin-top: 2px;
}

/* ---------- Badges de risque (le "badge de clearance") ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 3px;
    border: 1px solid transparent;
}

.badge-faible { color: var(--risque-faible); background: rgba(52,211,153,0.1); border-color: rgba(52,211,153,0.3); }
.badge-moyen  { color: var(--risque-moyen);  background: rgba(240,180,41,0.1); border-color: rgba(240,180,41,0.3); }
.badge-eleve  { color: var(--risque-eleve);  background: rgba(248,113,122,0.1); border-color: rgba(248,113,122,0.3); }

.badge-admin {
    color: var(--accent);
    background: rgba(240,180,41,0.12);
    border: 1px solid rgba(240,180,41,0.35);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 3px;
    text-transform: uppercase;
}

.badge-actif   { color: var(--risque-faible); }
.badge-inactif { color: var(--text-muted); }

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-panel-2); }

/* ---------- Formulaires ---------- */

label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

input[type=text], input[type=password], input[type=email], input[type=number], select, textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 12px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 16px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(240,180,41,0.15);
}

button, .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: #1a1406;
    border: none;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
}
button:hover, .btn:hover { background: #ffc94a; text-decoration: none; }

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-panel-2); border-color: var(--text-muted); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(248,113,122,0.4);
}
.btn-danger:hover { background: var(--danger-bg); }

/* ---------- Matrice de permissions ---------- */

.perm-module {
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.perm-module-head {
    background: var(--bg-panel-2);
    padding: 8px 14px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.perm-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
}
.perm-row .perm-name { font-family: 'IBM Plex Mono', monospace; font-size: 13px; flex: 1; }
.perm-row .perm-desc { color: var(--text-muted); font-size: 12.5px; flex: 2; }

/* ---------- Alertes / flash ---------- */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert-success { background: rgba(52,211,153,0.1); border-color: rgba(52,211,153,0.3); color: var(--risque-faible); }
.alert-error   { background: var(--danger-bg); border-color: rgba(248,113,122,0.3); color: var(--danger); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    padding: 4px 8px 4px 10px;
    border-radius: 20px;
    margin: 2px 4px 2px 0;
}
.chip button {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 0; font-size: 14px; line-height: 1;
}
.chip button:hover { color: var(--danger); }

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-box {
    width: 360px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 32px;
}
.login-box .brand {
    font-family: 'IBM Plex Mono', monospace;
    color: var(--accent);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 14px;
    margin-bottom: 24px;
}

.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
