/* =====================================================================
   DGIFN — Système de Gestion des Courriers
   Design system v4 — aligné sur l'identité DGFIN HUB
   ===================================================================== */

:root {
    --forest-deep: #0d2818;
    --forest: #1c7c43;
    --forest-hover: #166536;
    --forest-wash: #e8f5ec;
    --amber: #d97706;
    --amber-wash: #fef3c7;
    --blue: #2563eb;
    --blue-wash: #dbeafe;
    --red: #dc2626;
    --red-wash: #fee2e2;
    --purple: #7c3aed;
    --purple-wash: #ede9fe;

    --bg-app: #f6f7f6;
    --white: #ffffff;
    --ink: #16181c;
    --ink-soft: #5b6169;
    --ink-faint: #9aa0a6;
    --line: #e6e8eb;

    --sidebar-width: 258px;
    --header-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-xs: 0 1px 2px rgba(16, 24, 20, 0.05);
    --shadow-sm: 0 2px 10px rgba(16, 24, 20, 0.06);
    --shadow-md: 0 12px 32px rgba(16, 24, 20, 0.14);

    --font-display: 'Fraunces', 'Georgia', serif;
    --font-body: 'Public Sans', 'Segoe UI', -apple-system, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Public+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-body);
    background: var(--bg-app);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--font-display); }
.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* =====================================================================
   LOGIN
   ===================================================================== */
.login-body { background: var(--forest-deep); min-height: 100vh; }

.login-split { display: flex; min-height: 100vh; }

.login-panel-brand {
    flex: 1.1;
    background:
        radial-gradient(ellipse 120% 60% at 10% 100%, rgba(28,124,67,0.35) 0%, transparent 55%),
        radial-gradient(ellipse 90% 50% at 100% 0%, rgba(28,124,67,0.18) 0%, transparent 50%),
        linear-gradient(165deg, #0f2f1c 0%, #0a1f14 100%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px 56px;
    color: var(--white);
    position: relative;
    overflow: hidden;
}

.login-logo-row { display: flex; align-items: center; gap: 14px; z-index: 2; position: relative; }
.brand-decor { position: absolute; bottom: 0; right: 0; width: 62%; height: auto; pointer-events: none; z-index: 1; }
.login-logo { width: 50px; height: auto; }
.login-logo-text strong { display: block; font-family: var(--font-display); font-size: 15.5px; font-weight: 600; line-height: 1.25; }
.login-logo-text span { display: block; font-size: 10px; color: rgba(255,255,255,0.55); text-transform: uppercase; letter-spacing: 0.8px; margin-top: 2px; }

.brand-stripe { display: flex; height: 3px; width: 84px; border-radius: 3px; overflow: hidden; margin-top: 14px; }
.stripe { flex: 1; }
.stripe-green { background: #1c7c43; }
.stripe-yellow { background: #d9a012; }
.stripe-red { background: #c0392b; }

.brand-content { z-index: 2; max-width: 460px; }
.brand-content h1 {
    font-family: var(--font-display);
    font-size: 38px;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 18px;
    letter-spacing: -0.3px;
}
.login-tagline { font-size: 14.5px; color: rgba(255,255,255,0.68); line-height: 1.7; max-width: 420px; }

.brand-stats { display: flex; gap: 36px; z-index: 2; padding-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,0.12); margin-bottom: 18px; }
.brand-stat strong { display: block; font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.brand-stat span { display: block; font-size: 10px; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 0.6px; margin-top: 4px; }

.login-footer-note { font-size: 11.5px; color: rgba(255,255,255,0.42); z-index: 2; }

.login-panel-form {
    flex: 1;
    background: var(--bg-app);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.login-form-wrap { width: 100%; max-width: 380px; }

.login-eyebrow { font-size: 11px; font-weight: 700; color: var(--forest); text-transform: uppercase; letter-spacing: 1.2px; margin-bottom: 10px; }
.login-form-wrap h2 { font-family: var(--font-display); font-size: 28px; color: var(--ink); margin-bottom: 8px; font-weight: 600; }
.login-desc { color: var(--ink-soft); font-size: 13.8px; margin-bottom: 30px; }

.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 7px;
}
.input-icon-wrap { position: relative; }
.input-icon-wrap .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); pointer-events: none; }
.input-icon-wrap input { padding-left: 38px !important; }
.input-icon-wrap .toggle-visibility {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--ink-faint); display: flex; padding: 2px;
}
.input-icon-wrap .toggle-visibility:hover { color: var(--ink-soft); }

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 13.8px;
    font-family: var(--font-body);
    transition: border-color 0.15s, box-shadow 0.15s;
    background: var(--white);
    color: var(--ink);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--forest);
    box-shadow: 0 0 0 3px var(--forest-wash);
}
.form-hint { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.delai-readonly {
    display: flex; align-items: center;
    padding: 11px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 13.8px;
    font-weight: 600;
    background: var(--bg-app);
    color: var(--ink-soft);
}
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 13.6px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-primary { background: var(--forest-deep); color: var(--white); }
.btn-primary:hover { background: #061a10; }
.btn-secondary { background: var(--white); color: var(--ink-soft); border: 1.5px solid var(--line); }
.btn-secondary:hover { background: var(--bg-app); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #b91c1c; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 15px; font-size: 12.6px; }

.login-footer { display: flex; align-items: center; gap: 8px; margin-top: 26px; font-size: 12px; color: var(--ink-faint); }
.login-footer .icon { color: var(--forest); }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.2px; margin-bottom: 18px; border-left: 3px solid transparent; }
.alert-danger { background: var(--red-wash); color: var(--red); border-left-color: var(--red); }
.alert-success { background: var(--forest-wash); color: var(--forest-hover); border-left-color: var(--forest); }
.alert-warning { background: var(--amber-wash); color: #92600a; border-left-color: var(--amber); }

/* =====================================================================
   LAYOUT APPLICATIF
   ===================================================================== */
.app-layout { display: flex; min-height: 100vh; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(16,24,20,0.5); z-index: 90; }
.sidebar-overlay.open { display: block; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--line);
    color: var(--ink);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.2s ease;
}

.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 19px 20px; border-bottom: 1px solid var(--line); }
.sidebar-brand img { width: 32px; border-radius: 7px; }
.sidebar-brand-text { line-height: 1.2; }
.sidebar-brand-text strong { display: block; font-family: var(--font-display); font-size: 15px; color: var(--ink); font-weight: 600; }
.sidebar-brand-text span { font-size: 10px; color: var(--ink-faint); }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.sidebar-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: var(--ink-faint);
    padding: 16px 12px 6px;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.4px;
    font-weight: 500;
    color: var(--ink-soft);
    margin-bottom: 2px;
    transition: all 0.15s;
}
.sidebar-nav a:hover { background: var(--bg-app); color: var(--ink); }
.sidebar-nav a.active { background: var(--forest); color: var(--white); font-weight: 600; }
.sidebar-nav a .nav-icon { display: flex; opacity: 0.9; }
.sidebar-nav a .nav-badge {
    margin-left: auto;
    background: var(--red);
    color: var(--white);
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
}
.sidebar-nav a.active .nav-badge { background: rgba(255,255,255,0.25); }

.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.sidebar-user-avatar {
    width: 32px; height: 32px; background: var(--forest-wash); color: var(--forest);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.sidebar-user-info { line-height: 1.3; flex: 1; overflow: hidden; }
.sidebar-user-info strong { display: block; font-size: 12.6px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info span { font-size: 10.8px; color: var(--ink-faint); }
.sidebar-footer a.logout-btn { color: var(--ink-faint); display: flex; flex-shrink: 0; }
.sidebar-footer a.logout-btn:hover { color: var(--red); }

.main-content { margin-left: var(--sidebar-width); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 20px;
}
.topbar-left { display: flex; align-items: center; gap: 16px; flex: 1; }
.mobile-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    background: var(--white); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
    color: var(--ink-soft);
    flex-shrink: 0;
}
.topbar-search {
    display: flex; align-items: center; gap: 9px;
    background: var(--bg-app); border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 8px 13px; max-width: 320px; flex: 1;
    color: var(--ink-faint);
}
.topbar-search input { border: none; background: none; outline: none; font-size: 13px; width: 100%; color: var(--ink); font-family: var(--font-body); }
.topbar h1 { font-family: var(--font-display); font-size: 19px; color: var(--ink); font-weight: 600; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.icon-btn {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: var(--white); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
    color: var(--ink-soft); position: relative; flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-app); }
.icon-btn .badge-count {
    position: absolute; top: -5px; right: -5px;
    background: var(--red); color: var(--white);
    font-size: 9.5px; font-weight: 700;
    width: 16px; height: 16px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--white);
}
.date-badge {
    display: flex; align-items: center; gap: 7px;
    padding: 8px 14px;
    background: var(--ink); color: var(--white);
    border-radius: 20px;
    font-size: 12px; font-weight: 600;
    font-family: var(--font-mono);
    white-space: nowrap;
}

.page-body { padding: 26px 28px 46px; flex: 1; max-width: 1440px; }
.page-subtitle { color: var(--ink-faint); font-size: 13px; margin-top: 3px; }
.page-heading-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; flex-wrap: wrap; gap: 14px; }
.page-heading-row h1 { font-size: 23px; font-weight: 600; color: var(--ink); }
.page-heading-row .actions { display: flex; gap: 10px; }

/* =====================================================================
   KPI CARDS — icône circulaire, empilement vertical
   ===================================================================== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: box-shadow 0.15s, transform 0.15s;
}
.kpi-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.kpi-icon { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi-green .kpi-icon { background: var(--forest-wash); color: var(--forest); }
.kpi-yellow .kpi-icon { background: var(--amber-wash); color: var(--amber); }
.kpi-red .kpi-icon { background: var(--red-wash); color: var(--red); }
.kpi-blue .kpi-icon { background: var(--blue-wash); color: var(--blue); }

.kpi-value { font-family: var(--font-display); font-size: 25px; font-weight: 600; color: var(--ink); line-height: 1.1; }
.kpi-label { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

/* =====================================================================
   PANELS / TABLES
   ===================================================================== */
.panel { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-xs); border: 1px solid var(--line); margin-bottom: 18px; overflow: hidden; }
.panel-header { padding: 17px 21px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-header h3 { font-family: var(--font-display); font-size: 15px; color: var(--ink); font-weight: 600; display: flex; align-items: center; gap: 9px; }
.panel-body { padding: 21px; }

.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; }
table.data-table th {
    text-align: left; font-size: 10.8px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700;
    color: var(--ink-faint); padding: 12px 21px; background: var(--bg-app); border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.data-table td { padding: 13px 21px; border-bottom: 1px solid var(--bg-app); font-size: 13.3px; vertical-align: middle; }
table.data-table tr:hover td { background: var(--bg-app); }
table.data-table tr:last-child td { border-bottom: none; }

.ref-mono {
    font-family: var(--font-mono); font-weight: 600; color: var(--forest);
    font-size: 11.8px; letter-spacing: 0.2px;
    border: 1px solid var(--line); border-radius: 5px;
    padding: 3px 8px; background: var(--forest-wash);
    white-space: nowrap;
}
.ref-stamp {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: var(--font-mono); font-weight: 600; letter-spacing: 0.6px;
    color: var(--forest);
    padding: 8px 16px;
    border: 1.5px solid var(--forest);
    border-radius: 20px;
    background: var(--forest-wash);
}

.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-gray { background: var(--bg-app); color: var(--ink-soft); }
.badge-gray-dark { background: var(--line); color: var(--ink); }
.badge-blue { background: var(--blue-wash); color: var(--blue); }
.badge-yellow { background: var(--amber-wash); color: #92600a; }
.badge-orange { background: #fcefe1; color: #b25b06; }
.badge-red { background: var(--red-wash); color: var(--red); }
.badge-green { background: var(--forest-wash); color: var(--forest-hover); }
.badge-green-dark { background: #cfe4d4; color: var(--forest-deep); }
.badge-purple { background: var(--purple-wash); color: var(--purple); }
.badge-retard { background: var(--red); color: var(--white); }

.type-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.type-dot { width: 7px; height: 7px; border-radius: 50%; }
.type-entrant .type-dot { background: var(--blue); }
.type-sortant .type-dot { background: var(--forest); }
.type-interne .type-dot { background: var(--amber); }
.type-cabinet .type-dot { background: var(--red); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--ink-faint); }
.empty-state .icon { color: var(--forest); opacity: 0.6; margin-bottom: 10px; }

.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 15px 21px; background: var(--bg-app); border-bottom: 1px solid var(--line); }
.filters-bar select, .filters-bar input[type="text"], .filters-bar input[type="date"] {
    padding: 8px 12px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); font-size: 12.8px; background: var(--white); font-family: var(--font-body);
}
.filters-bar .search-input { flex: 1; min-width: 200px; }

.pagination { display: flex; justify-content: center; gap: 6px; padding: 18px; }
.pagination a, .pagination span { padding: 7px 13px; border-radius: var(--radius-sm); font-size: 12.6px; border: 1px solid var(--line); color: var(--ink-soft); }
.pagination a:hover { background: var(--bg-app); }
.pagination .active { background: var(--forest); color: var(--white); border-color: var(--forest); }

.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before { content: ''; position: absolute; left: -24px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--forest); border: 2px solid var(--white); box-shadow: 0 0 0 2px var(--forest); }
.timeline-date { font-size: 11px; color: var(--ink-faint); margin-bottom: 3px; }
.timeline-text { font-size: 13.1px; color: var(--ink); }
.timeline-text strong { color: var(--forest); }

.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 14px; }
.detail-title h2 { font-family: var(--font-display); font-size: 22px; margin-bottom: 10px; font-weight: 600; color: var(--ink); }
.detail-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; }
.info-item label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; color: var(--ink-faint); margin-bottom: 4px; }
.info-item div { font-size: 13.6px; color: var(--ink); font-weight: 500; }

.alert-list-item { display: flex; gap: 12px; padding: 13px 21px; border-bottom: 1px solid var(--bg-app); }
.alert-list-item:last-child { border-bottom: none; }
.alert-list-item.unread { background: var(--forest-wash); }
.alert-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.alert-icon.retard { background: var(--red-wash); color: var(--red); }
.alert-icon.nouveau { background: var(--blue-wash); color: var(--blue); }
.alert-icon.cabinet { background: var(--amber-wash); color: var(--amber); }
.alert-text { font-size: 13.1px; color: var(--ink); }
.alert-time { font-size: 11px; color: var(--ink-faint); margin-top: 2px; }

/* =====================================================================
   GRILLE D'ACCÈS RAPIDE (modules) — cartes icône + titre + sous-titre
   ===================================================================== */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.module-card {
    display: flex; flex-direction: column; gap: 12px;
    padding: 18px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: all 0.15s;
}
.module-card:hover { border-color: var(--forest); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.module-card-icon { width: 38px; height: 38px; border-radius: 9px; background: var(--forest-wash); color: var(--forest); display: flex; align-items: center; justify-content: center; }
.module-card-title { font-size: 13.6px; font-weight: 700; color: var(--ink); }
.module-card-desc { font-size: 12px; color: var(--ink-faint); line-height: 1.5; }

/* =====================================================================
   SÉLECTEUR DE TYPE DE COURRIER
   ===================================================================== */
.type-selector { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.type-card {
    position: relative;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    text-align: center;
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 14px 16px;
    cursor: pointer;
    background: var(--white);
    transition: all 0.15s;
}
.type-card input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.type-card .type-card-icon {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-app); color: var(--ink-faint);
    transition: all 0.15s;
}
.type-card .type-card-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); line-height: 1.3; }
.type-card .type-card-check {
    position: absolute; top: 10px; right: 10px;
    width: 16px; height: 16px; border-radius: 50%;
    border: 1.5px solid var(--line);
    background: var(--white);
    transition: all 0.15s;
}
.type-card:hover { border-color: var(--forest); box-shadow: var(--shadow-xs); }
.type-card:has(input:checked) { border-color: var(--forest); background: var(--forest-wash); box-shadow: 0 0 0 3px rgba(28,124,67,0.10); }
.type-card:has(input:checked) .type-card-icon { background: var(--forest); color: var(--white); }
.type-card:has(input:checked) .type-card-label { color: var(--forest); }
.type-card:has(input:checked) .type-card-check { border-color: var(--forest); background: var(--forest); }
.type-card:has(input:checked) .type-card-check::after {
    content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    color: var(--white); font-size: 10px; font-weight: 700;
}
.type-card:has(input:focus-visible) { outline: 2px solid var(--forest); outline-offset: 2px; }

/* =====================================================================
   RESPONSIVE — TABLETTE (≤ 1024px) & MOBILE (≤ 600px)
   ===================================================================== */

/* --- Palier tablette : la sidebar passe en tiroir masquable --- */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-md); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .topbar-search { display: none; }

    .login-split { flex-direction: column; min-height: auto; }
    .login-panel-brand { padding: 34px; }
    .login-panel-form { padding: 32px 24px; }
    .brand-content h1 { font-size: 28px; }
    .brand-stats { gap: 22px; flex-wrap: wrap; }

    .page-body { padding: 20px 18px 36px; }
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
    .module-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .info-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

    .topbar { padding: 0 16px; gap: 12px; }
    .date-badge { display: none; }

    .form-row { flex-wrap: wrap; }
    .form-row .form-group { flex: 1 1 100%; min-width: 0; }
}

/* --- Palier mobile : téléphone (Android/iPhone) --- */
@media (max-width: 600px) {
    body { font-size: 13.5px; }

    .login-panel-brand { padding: 26px 22px; }
    .login-panel-form { padding: 26px 18px; }
    .brand-content h1 { font-size: 23px; }
    .brand-content { max-width: 100%; }
    .login-tagline { font-size: 13px; }
    .brand-stats { gap: 16px; padding-bottom: 14px; }
    .brand-stat strong { font-size: 18px; }
    .login-form-wrap { max-width: 100%; }

    .page-body { padding: 16px 12px 30px; }
    .page-heading-row { flex-direction: column; align-items: stretch; }
    .page-heading-row .actions { flex-wrap: wrap; }
    .page-heading-row .actions .btn { flex: 1 1 auto; }

    .topbar { padding: 0 12px; height: 56px; }
    .topbar h1 { font-size: 16px; }
    .topbar-actions { gap: 8px; }
    .icon-btn, .theme-toggle { width: 32px; height: 32px; }

    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi-card { padding: 14px; gap: 10px; }
    .kpi-icon { width: 36px; height: 36px; }
    .kpi-value { font-size: 19px; }

    .module-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .type-selector { grid-template-columns: repeat(2, 1fr); }

    .panel-header { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
    .panel-body { padding: 16px; }
    .filters-bar { padding: 12px 16px; }
    .filters-bar .search-input { min-width: 100%; order: -1; }

    /* Tableaux : on garde le scroll horizontal mais on resserre le texte */
    table.data-table th { padding: 10px 14px; font-size: 10px; }
    table.data-table td { padding: 10px 14px; font-size: 12.6px; }

    .detail-header { flex-direction: column; align-items: stretch; }
    .form-group input, .form-group select, .form-group textarea { font-size: 16px; } /* évite le zoom auto iOS Safari au focus */
}

/* =====================================================================
   MODE SOMBRE
   ===================================================================== */
[data-theme="dark"] {
    --bg-app: #0f1117;
    --white: #1a1d27;
    --ink: #e8eaf0;
    --ink-soft: #9aa3b8;
    --ink-faint: #5a6480;
    --line: #2a2d3a;
    --forest-wash: #0d2818;
    --blue-wash: #0d1a2e;
    --red-wash: #2e0d0d;
    --amber-wash: #2a1f0d;
    --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
    --shadow-sm: 0 2px 10px rgba(0,0,0,.4);
}

[data-theme="dark"] .sidebar { background:#111320; border-color:#2a2d3a; }
[data-theme="dark"] .topbar  { background:#111320; border-color:#2a2d3a; }
[data-theme="dark"] .panel   { background:#1a1d27; border-color:#2a2d3a; }
[data-theme="dark"] .data-table th { background:#111320; color:#5a6480; }
[data-theme="dark"] .data-table tr:hover td { background:#111320; }
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea { background:#111320; color:#e8eaf0; border-color:#2a2d3a; }
[data-theme="dark"] .sidebar-nav a.active { background:var(--forest); color:#fff; }
[data-theme="dark"] .kpi-card { background:#1a1d27; border-color:#2a2d3a; }

/* Bouton mode sombre */
.theme-toggle {
    display:flex; align-items:center; justify-content:center;
    width:36px; height:36px;
    background:var(--white); border:1.5px solid var(--line); border-radius:var(--radius-sm);
    color:var(--ink-soft); cursor:pointer; flex-shrink:0;
}
.theme-toggle:hover { background:var(--bg-app); }