:root {
    --primary: #053D5B;
    --secondary: #4691A8;
    --accent: #B5866D;
    --bg: #F5F5F5;
    --white: #ffffff;
    --border: #E0E0E0;
    --danger: #D6001C;
    --success: #2E7D5E;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--primary);
}

/* LOGIN */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.login-logo { height: 80px; margin-bottom: 32px; }

.login-box {
    background: var(--white);
    padding: 40px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.login-box h1 {
    color: var(--primary);
    font-size: 20px;
    margin-bottom: 24px;
    text-align: center;
}

.login-box label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
}

.login-box input[type="text"],
.login-box input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    margin-bottom: 16px;
    transition: border-color 0.2s;
}

.login-box input:focus {
    outline: none;
    border-color: var(--secondary);
}

.login-box input[type="submit"] {
    width: 100%;
    padding: 12px;
    border: none;
    background: var(--primary);
    color: var(--white);
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.login-box input[type="submit"]:hover { background: var(--secondary); }

.error-message { color: var(--danger); text-align: center; margin-top: 12px; font-size: 14px; }

/* LAYOUT DASHBOARD */
#wrapper {
    display: flex;
    min-height: 100vh;
}

#sidebar {
    width: 260px;
    background: var(--primary);
    color: var(--white);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#sidebar header {
    text-align: center;
    margin-bottom: 24px;
}

#sidebar header img {
    max-width: 140px;
    margin-bottom: 12px;
}

#sidebar h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--white);
}

#sidebar button {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--white);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

#sidebar button:hover,
#sidebar button.active { background: var(--secondary); }

/* MAIN */
#main {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
}

#main h2 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 22px;
}

#main label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: var(--primary);
}

#main input[type="text"],
#main select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    transition: border-color 0.2s;
}

#main input[type="text"]:focus,
#main select:focus {
    outline: none;
    border-color: var(--secondary);
}

#main input[type="submit"] {
    padding: 10px 24px;
    border: none;
    background: var(--primary);
    color: var(--white);
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

#main input[type="submit"]:hover { background: var(--secondary); }

/* TABLE */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

table th {
    background: var(--primary);
    color: var(--white);
    padding: 12px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
}

table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

table tr:hover { background: rgba(70, 145, 168, 0.05); }

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

/* BUTTONS IN TABLE */
button.modifier {
    padding: 6px 14px;
    border: 1px solid var(--secondary);
    background: transparent;
    color: var(--secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

button.modifier:hover {
    background: var(--secondary);
    color: var(--white);
}

td[contenteditable="true"] {
    background: rgba(70, 145, 168, 0.1);
    border: 2px solid var(--secondary);
    border-radius: 4px;
    padding: 8px;
}

/* STATISTIQUES */
.stats-hint { color: var(--secondary); font-size: 13px; margin-bottom: 24px; }

#main h3.stats-subtitle {
    color: var(--primary);
    font-size: 16px;
    margin: 32px 0 12px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.kpi-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.kpi-value { font-size: 32px; font-weight: 700; color: var(--secondary); }
.kpi-label { font-size: 13px; color: var(--primary); font-weight: 600; }

.chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 160px;
    padding: 12px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.chart-bar {
    flex: 1;
    min-height: 2px;
    background: var(--secondary);
    border-radius: 4px 4px 0 0;
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: background 0.2s;
}

.chart-bar:hover { background: var(--accent); }

.chart-label {
    position: absolute;
    bottom: -20px;
    font-size: 11px;
    color: var(--primary);
}

@media (max-width: 768px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .chart-label { display: none; }
}

/* SECTIONS TOGGLE */
main { display: none; }
main.active { display: block; }

/* RESPONSIVE */
@media (max-width: 768px) {
    #wrapper { flex-direction: column; }
    #sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 12px; }
    #sidebar header { width: 100%; margin-bottom: 8px; }
    #sidebar button { width: auto; flex: 1; min-width: 120px; font-size: 12px; padding: 8px; }
    #main { padding: 20px; }
}
