/* ============================================
   VARIABLES & RESET
   ============================================ */
:root {
    --bg:        #f5f4f0;
    --surface:   #ffffff;
    --border:    #e2e0d8;
    --text:      #1a1a18;
    --muted:     #6b6a65;
    --primary:   #3d6b4f;
    --primary-h: #2e5440;
    --danger:    #c0392b;
    --warning:   #e67e22;
    --success:   #27ae60;
    --info:      #2980b9;
    --radius:    10px;
    --shadow:    0 1px 4px rgba(0,0,0,.08);
}

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

body {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* ============================================
   LOGIN
   ============================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-box h1 { font-size: 1.6rem; margin-bottom: .25rem; }
.login-sub { color: var(--muted); margin-bottom: 1.5rem; font-size: .9rem; }

/* ============================================
   LAYOUT
   ============================================ */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-logo {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 1rem;
}

.sidebar-logo span { opacity: .5; font-weight: 400; font-size: .8rem; display: block; }

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

.nav-section {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    padding: .75rem 1.25rem .25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem 1.25rem;
    color: var(--text);
    text-decoration: none;
    font-size: .9rem;
    border-radius: 0;
    transition: background .15s;
}

.nav-link:hover { background: var(--bg); }
.nav-link.active { background: var(--bg); color: var(--primary); font-weight: 500; }
.nav-link .icon { width: 18px; text-align: center; opacity: .7; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    font-size: .8rem;
    color: var(--muted);
}

.sidebar-footer a { color: var(--muted); text-decoration: none; }
.sidebar-footer a:hover { color: var(--danger); }

/* Main */
.main { margin-left: 220px; flex: 1; min-height: 100vh; }

.page-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.page-header h1 { font-size: 1.25rem; font-weight: 600; }
.page-content { padding: 2rem; }

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.stat-label { font-size: .8rem; color: var(--muted); margin-bottom: .25rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-sub   { font-size: .75rem; color: var(--muted); margin-top: .25rem; }

.stat-card.green  { border-left: 3px solid var(--success); }
.stat-card.orange { border-left: 3px solid var(--warning); }
.stat-card.blue   { border-left: 3px solid var(--info); }
.stat-card.red    { border-left: 3px solid var(--danger); }

/* ============================================
   TABLES
   ============================================ */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

thead th {
    text-align: left;
    padding: .6rem 1rem;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

/* ============================================
   FORMS
   ============================================ */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; }

input[type=text], input[type=number], input[type=date],
input[type=password], input[type=email],
select, textarea {
    width: 100%;
    padding: .55rem .8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .9rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: .88rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary  { background: var(--primary);  color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-h); }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-outline  { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm       { padding: .3rem .7rem; font-size: .8rem; }
.btn-full     { width: 100%; justify-content: center; }

/* ============================================
   BADGES & PILLS
   ============================================ */
.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 500;
}

.badge-green  { background: #d4edda; color: #155724; }
.badge-orange { background: #fff3cd; color: #856404; }
.badge-red    { background: #f8d7da; color: #721c24; }
.badge-blue   { background: #d1ecf1; color: #0c5460; }
.badge-gray   { background: #e2e3e5; color: #383d41; }

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: .75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: .9rem;
}

.alert-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
}

.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .75rem; justify-content: flex-end; }

.btn-close { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--muted); padding: .25rem; }

/* ============================================
   UTILITAIRES
   ============================================ */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.font-bold    { font-weight: 600; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* ============================================
   RESPONSIVE MOBILE
   ============================================ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .page-content { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }

    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px; height: 40px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 6px;
        cursor: pointer;
        font-size: 1.2rem;
    }
}

@media (min-width: 769px) {
    .menu-toggle { display: none; }
}
