:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #162033;
    --muted: #64748b;
    --primary: #155eef;
    --primary-dark: #0f43ad;
    --border: #d8e1ee;
    --success-bg: #e8f7ef;
    --success: #16794c;
    --warning-bg: #fff4e5;
    --warning: #9a5b00;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
.topbar {
    background: linear-gradient(120deg, #102a56, #155eef);
    color: white;
    padding: 24px;
}
.topbar-inner {
    width: min(100%, 1400px);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
}
.topbar-title { min-width: 280px; }
.topbar h1 { margin: 0 0 8px; font-size: 28px; line-height: 1.15; }
.topbar p { margin: 0; color: #dbeafe; max-width: 660px; }
.topbar-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    flex: 0 0 auto;
}
.topbar-user { display: flex; justify-content: flex-end; }
.topbar-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.topbar-nav a {
    color: white;
    border: 1px solid rgba(255,255,255,.45);
    padding: 9px 13px;
    border-radius: 999px;
    white-space: nowrap;
}
.container {
    max-width: 1180px;
    margin: 28px auto;
    padding: 0 24px 48px;
}
.card, .kpi {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}
.card { padding: 24px; margin-bottom: 22px; }
.card h2 { margin-top: 0; }
.intro p, .hint, small { color: var(--muted); }
.scenario-tabs { display: flex; flex-wrap: wrap; gap: 10px; }
.tab {
    display: inline-block;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: white;
}
.tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.grid.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
label { display: block; font-weight: 700; }
input[type="text"], input[type="number"] {
    width: 100%;
    margin-top: 8px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
}
button.primary {
    margin-top: 22px;
    background: var(--primary);
    color: white;
    border: 0;
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}
button.primary:hover { background: var(--primary-dark); }
.table-wrap { overflow-x: auto; }
table.data-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 760px;
}
.data-table th, .data-table td {
    border-bottom: 1px solid var(--border);
    text-align: left;
    padding: 12px 10px;
    vertical-align: middle;
}
.data-table th {
    background: #f8fafc;
    color: #334155;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.data-table.compact th, .data-table.compact td { padding: 9px 10px; }
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.kpi { padding: 20px; }
.kpi span { display: block; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.kpi strong { display: block; font-size: 30px; line-height: 1; margin-bottom: 10px; }
.primary-kpi { border-color: #93c5fd; background: #eff6ff; }
.notice {
    padding: 14px 16px;
    border-radius: 12px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    margin-bottom: 16px;
}
.notice.warning { background: var(--warning-bg); border-color: #f7d28b; color: var(--warning); }
.notice.success { background: var(--success-bg); border-color: #a8e3c2; color: var(--success); }
@media (max-width: 860px) {
    .topbar-inner { flex-direction: column; align-items: flex-start; }
    .topbar-right { align-items: flex-start; width: 100%; }
    .topbar-user, .topbar-nav { justify-content: flex-start; }
    .grid.two, .kpi-grid { grid-template-columns: 1fr; }
}

.survival-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin: 18px 0 22px;
}
.survival-kpi { background: #f8fafc; }
.survival-kpi strong { font-size: 26px; }
@media (max-width: 1100px) {
    .survival-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
    .survival-grid { grid-template-columns: 1fr; }
}

.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}
.actions, .table-actions, .form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.table-actions a, .button {
    display: inline-block;
    padding: 8px 11px;
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: 999px;
    font-weight: 700;
    background: #fff;
}
.button.secondary {
    color: var(--muted);
    border-color: var(--border);
}
input[readonly] {
    background: #f8fafc;
    color: var(--muted);
}
@media (max-width: 860px) {
    .section-header { flex-direction: column; }
}

.topbar-nav a.active {
    background: rgba(255,255,255,.18);
    border-color: rgba(255,255,255,.8);
}
.user-badge {
    display: inline-flex;
    align-items: center;
    color: #dbeafe;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(15, 23, 42, .18);
    font-size: 14px;
}
input[type="password"], select {
    width: 100%;
    margin-top: 8px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    background: #fff;
}
.auth-container {
    display: flex;
    justify-content: center;
}
.auth-card {
    width: min(100%, 520px);
}
.full-width { width: 100%; }
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 28px;
}
.checkbox-label input { width: auto; margin: 0; }
.user-form button.primary { margin-top: 0; }
code {
    background: #f1f5f9;
    padding: 2px 5px;
    border-radius: 5px;
}

input[data-rate-a][readonly] {
    background: #eef6ff;
    color: #0f43ad;
    font-weight: 700;
}

/* Actions historique : icônes compactes horizontales */
.data-table th:last-child,
.data-table td.table-actions {
    width: 95px !important;
    min-width: 95px !important;
    max-width: 95px !important;
    text-align: center !important;
    vertical-align: middle !important;
}

td.table-actions {
    padding: 8px 6px !important;
}

.actions-inline {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    white-space: nowrap !important;
}

.actions-inline form {
    display: inline-flex !important;
    margin: 0 !important;
    padding: 0 !important;
}

.actions-inline a,
.actions-inline button,
.actions-inline .icon-action {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;

    padding: 0 !important;
    margin: 0 !important;

    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;

    font-size: 15px !important;
    line-height: 1 !important;
    text-decoration: none !important;
    cursor: pointer !important;
}

.actions-inline button {
    appearance: none !important;
    -webkit-appearance: none !important;
}

.actions-inline a:hover,
.actions-inline button:hover {
    background: transparent !important;
    box-shadow: none !important;
    transform: scale(1.15);
}

.actions-inline .view-icon {
    color: #2563eb !important;
}

.actions-inline .edit-icon {
    color: #ca8a04 !important;
}

.actions-inline .delete-icon {
    color: #dc2626 !important;
}
/* Corriger le décalage des lignes horizontales dans la colonne Actions */
.data-table {
    border-collapse: collapse !important;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid #d6e1f0 !important;
    vertical-align: middle !important;
}

.data-table td.table-actions {
    display: table-cell !important;
    padding: 10px 8px !important;
    border-bottom: 1px solid #d6e1f0 !important;
    vertical-align: middle !important;
    text-align: center !important;
}

/* Le conteneur des icônes ne doit pas créer sa propre ligne */
.actions-inline {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;
    white-space: nowrap !important;
    border: none !important;
    border-bottom: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Supprimer toute bordure sur les icônes et le formulaire */
.actions-inline form,
.actions-inline a,
.actions-inline button,
.actions-inline .icon-action {
    border: none !important;
    border-bottom: none !important;
    outline: none !important;
    background: transparent !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.actions-inline form {
    display: inline-flex !important;
}

.actions-inline a,
.actions-inline button {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 15px !important;
    line-height: 1 !important;
    text-decoration: none !important;
    cursor: pointer !important;
}