@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
    --teal-50:  #f0fafa;
    --teal-100: #d8f0f0;
    --teal-200: #a8dcdc;
    --teal-500: #0d7377;
    --teal-600: #0a5e62;
    --teal-700: #084a4d;

    --gray-25:  #fcfcfd;
    --gray-50:  #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #0f172a;

    --green:    #10b981;
    --green-bg: #d1fae5;
    --orange:   #f59e0b;
    --orange-bg:#fef3c7;
    --red:      #ef4444;
    --red-bg:   #fee2e2;
    --blue:     #3b82f6;
    --blue-bg:  #dbeafe;
    --purple:   #8b5cf6;
    --purple-bg:#ede9fe;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.03);
    --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.05), 0 2px 4px -2px rgba(16, 24, 40, 0.03);
    --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.03);
    --shadow-xl: 0 20px 24px -4px rgba(16, 24, 40, 0.08), 0 8px 8px -4px rgba(16, 24, 40, 0.03);

    --r-xs: 6px;
    --r-sm: 8px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 20px;
    --r-2xl: 24px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --sidebar-w: 248px;
    --header-h: 72px;
}

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

html, body { height: 100%; }

body {
    font-family: var(--font);
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ───────── Layout ───────── */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ───────── Sidebar ───────── */
.sidebar {
    background: linear-gradient(180deg, #052b2d 0%, #0a1a1c 100%);
    color: white;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    /* Scroll vertical si trop d'items ; pas de scroll horizontal */
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}
/* Webkit scrollbar custom (Chrome/Edge/Safari) */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }

/* La sidebar-footer doit rester en bas de la pile, même quand le contenu scroll */
.sidebar-footer { margin-top: auto; }
.sidebar::before {
    content: '';
    position: absolute;
    width: 320px; height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(13,115,119,0.35) 0%, transparent 70%);
    filter: blur(60px);
    top: -120px; right: -100px;
    pointer-events: none;
    animation: sidebarFloat 18s ease-in-out infinite;
}
@keyframes sidebarFloat {
    0%, 100% { transform: translate(0,0); }
    50% { transform: translate(-20px, 30px); }
}
.sidebar > * { position: relative; z-index: 1; }

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 12px 28px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 24px;
}

.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, #14b8a6 0%, var(--teal-500) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 900;
    font-size: 18px;
    letter-spacing: -0.03em;
    box-shadow: 0 4px 16px rgba(13, 115, 119, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
    overflow: hidden;
}
.brand-logo:has(> img) {
    background: transparent;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
    padding: 0;
}
.brand-logo > img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: var(--r-md);
}

.brand-text {
    flex: 1;
    overflow: hidden;
}
.brand-text .brand-name {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: white;
}
.brand-text .brand-sub {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 1px;
}

.nav-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.4);
    padding: 16px 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    color: rgba(255,255,255,0.65);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: white;
}

.nav-item.active {
    background: rgba(13, 115, 119, 0.18);
    color: var(--teal-200);
}
.nav-item.active .nav-icon { color: var(--teal-200); }

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: rgba(255,255,255,0.5);
}

.nav-item.active .nav-icon { color: var(--teal-200); }

.sidebar-footer {
    margin-top: auto;
    padding: 16px 12px 4px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer .user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
}
.user-logout {
    background: transparent;
    border: none;
    color: rgba(255,255,255,.45);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all .15s;
    display: grid; place-items: center;
}
.user-logout:hover { color: white; background: rgba(255,255,255,.08); }
.user-logout svg { width: 16px; height: 16px; }
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d7377, #14b8a6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: white; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.5); }

/* ───────── Main area ───────── */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--header-h);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-title h1 {
    font-size: 22px;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.025em;
    line-height: 1.1;
}
.topbar-title p {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 3px;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.lang-switch, .entity-switch {
    display: inline-flex;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 999px;
    padding: 3px;
}
.ent-btn {
    background: transparent;
    border: none;
    color: var(--gray-500);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 6px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.ent-btn:hover { color: var(--gray-900); }
.ent-btn.active {
    background: var(--teal-500);
    color: white;
    box-shadow: 0 1px 3px rgba(13,115,119,.25);
}
.lang-btn {
    background: transparent;
    border: none;
    color: var(--gray-500);
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 5px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: all .15s;
    min-width: 32px;
}
.lang-btn:hover { color: var(--gray-900); }
.lang-btn.active {
    background: white;
    color: var(--teal-600);
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.content {
    padding: 32px;
    max-width: 1440px;
    width: 100%;
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ───────── Dashboard hero ───────── */
.dash-hero {
    background: linear-gradient(135deg, #052b2d 0%, #084a4d 50%, #0d7377 100%);
    color: white;
    border-radius: 14px;
    padding: 18px 24px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 16px;
}
.dash-hero::before {
    content: '';
    position: absolute;
    width: 200px; height: 200px;
    top: -80px; right: -50px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(20,184,166,0.30) 0%, transparent 70%);
    filter: blur(40px);
    pointer-events: none;
}
.dash-hero > * { position: relative; z-index: 1; }
.dash-hero-eyebrow {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(92, 196, 190, 1);
}
.dash-hero-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.2;
    flex: 1;
}
.dash-hero-title em {
    font-style: normal;
    background: linear-gradient(90deg, #ffffff 0%, #5cc4be 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.dash-hero-sub {
    font-size: 12px;
    color: rgba(255,255,255,0.72);
    line-height: 1.4;
}

/* ───────── Stat cards (modern KPI) ───────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.kpi-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--r-lg);
    padding: 22px;
    transition: all 0.25s cubic-bezier(.4,.4,.2,1);
    position: relative;
    overflow: hidden;
    animation: kpiIn .5s cubic-bezier(.4,.4,.2,1) backwards;
}
.kpi-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 60px; height: 60px;
    background: radial-gradient(circle at top left, rgba(13,115,119,0.06) 0%, transparent 70%);
    pointer-events: none;
}
.kpi-grid .kpi-card:nth-child(1) { animation-delay: .02s; }
.kpi-grid .kpi-card:nth-child(2) { animation-delay: .06s; }
.kpi-grid .kpi-card:nth-child(3) { animation-delay: .10s; }
.kpi-grid .kpi-card:nth-child(4) { animation-delay: .14s; }
.kpi-grid .kpi-card:nth-child(5) { animation-delay: .18s; }
.kpi-grid .kpi-card:nth-child(6) { animation-delay: .22s; }
.kpi-grid .kpi-card:nth-child(7) { animation-delay: .26s; }
.kpi-grid .kpi-card:nth-child(8) { animation-delay: .30s; }
@keyframes kpiIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--teal-200);
}

.kpi-card.clickable {
    cursor: pointer;
    user-select: none;
}
.kpi-card.clickable:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
    border-color: var(--teal-500);
}
.kpi-card.clickable:active {
    transform: translateY(-1px);
}
.kpi-arrow {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gray-50);
    color: var(--gray-400);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s cubic-bezier(.4,.4,.2,1);
}
.kpi-arrow svg { width: 14px; height: 14px; }
.kpi-card.clickable:hover .kpi-arrow {
    background: var(--teal-500);
    color: white;
    transform: translateX(2px);
}

.kpi-card .kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.kpi-card .kpi-icon svg { width: 20px; height: 20px; }

.kpi-card.teal .kpi-icon  { background: var(--teal-100); color: var(--teal-600); }
.kpi-card.green .kpi-icon { background: var(--green-bg); color: var(--green); }
.kpi-card.orange .kpi-icon{ background: var(--orange-bg); color: var(--orange); }
.kpi-card.blue .kpi-icon  { background: var(--blue-bg); color: var(--blue); }
.kpi-card.purple .kpi-icon{ background: var(--purple-bg); color: var(--purple); }
.kpi-card.red .kpi-icon   { background: var(--red-bg); color: var(--red); }

.kpi-label {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
    margin-bottom: 4px;
}
.kpi-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.kpi-trend {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ───────── Section headers ───────── */
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-head h2 {
    font-size: 20px;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

.section-head .section-sub {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 2px;
}

/* ───────── Toolbar ───────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.input, .select {
    padding: 9px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--r-sm);
    font-size: 14px;
    font-family: var(--font);
    background: white;
    color: var(--gray-900);
    transition: all 0.15s;
}
.input:focus, .select:focus {
    outline: none;
    border-color: var(--teal-500);
    box-shadow: 0 0 0 3px var(--teal-100);
}
.input.with-icon { padding-left: 38px; }

.input-wrap {
    position: relative;
    display: inline-block;
}
.input-wrap svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--gray-400);
    pointer-events: none;
}

.search { width: 320px; }

.spacer { flex: 1; }

/* ───────── Buttons ───────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    user-select: none;
}
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--teal-100);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--teal-500);
    color: white;
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--teal-600); box-shadow: var(--shadow-sm); }

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border-color: var(--gray-300);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-success {
    background: var(--green);
    color: white;
}
.btn-success:hover { background: #059669; }

.btn-danger {
    background: white;
    color: var(--red);
    border-color: var(--gray-300);
}
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); }

.btn-ghost {
    background: transparent;
    color: var(--gray-700);
}
.btn-ghost:hover { background: var(--gray-100); }

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn svg { width: 16px; height: 16px; }

/* ───────── Compose tabs (email page) ───────── */
.mb-20 { margin-bottom: 20px; }

.compose-tabs, .compose-tabs-lang {
    display: inline-flex;
    background: var(--gray-100);
    border-radius: 8px;
    padding: 3px;
}
.tab-btn {
    background: transparent;
    border: none;
    color: var(--gray-500);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all .15s;
}
.tab-btn:hover { color: var(--gray-900); }
.tab-btn.active {
    background: white;
    color: var(--teal-600);
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.compose-tabs-lang .tab-btn { padding: 5px 12px; font-size: 12px; }

.compose-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.hint-text {
    font-size: 12px;
    color: var(--gray-500);
    font-family: ui-monospace, monospace;
}

#tpl-body {
    width: 100%;
    font-family: ui-monospace, 'SF Mono', Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.55;
    padding: 12px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    resize: vertical;
    transition: all .15s;
}
#tpl-body:focus, #tpl-subject:focus {
    outline: none;
    border-color: var(--teal-500);
    box-shadow: 0 0 0 3px var(--teal-100);
}

.compose-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 6px;
    padding-top: 14px;
    border-top: 1px solid var(--gray-100);
}

.send-summary {
    text-align: center;
    padding: 8px 0;
}
.send-summary .count-big {
    font-size: 48px;
    font-weight: 800;
    color: var(--teal-600);
    line-height: 1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.send-summary .count-label {
    font-size: 14px;
    color: var(--gray-600);
    margin-top: 4px;
    margin-bottom: 18px;
}
.send-summary .lang-split {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}
.send-summary .lang-pill {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 13px;
    color: var(--gray-700);
}
.send-summary .lang-pill strong {
    color: var(--gray-900);
    font-weight: 700;
    margin-right: 4px;
}
.send-summary .note {
    font-size: 13px;
    color: var(--gray-500);
    line-height: 1.5;
    max-width: 420px;
    margin: 0 auto;
}

/* ───────── Cards & Tables ───────── */
.card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.card-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-head h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
}
.card-head .head-sub {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    padding: 12px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

tbody td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

tbody tr {
    transition: background 0.15s, transform 0.15s;
    cursor: pointer;
}
tbody tr:hover {
    background: linear-gradient(90deg, var(--teal-50) 0%, var(--gray-50) 100%);
}
tbody tr:last-child td { border-bottom: none; }

td strong, td .name { color: var(--gray-900); font-weight: 600; }

/* ───────── Badges ───────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
}
.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.8;
}

.badge-pending   { background: var(--orange-bg); color: #92400e; }
.badge-confirmed { background: var(--green-bg); color: #065f46; }
.badge-modified  { background: var(--blue-bg); color: #1e40af; }
.badge-validated { background: var(--green-bg); color: #065f46; }
.badge-client    { background: var(--teal-100); color: var(--teal-700); }
.badge-fournisseur { background: var(--purple-bg); color: #5b21b6; }
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-sap       { background: #fef3c7; color: #92400e; }
.badge-sage      { background: var(--blue-bg); color: #1e40af; }
.badge-codial    { background: var(--red-bg); color: #991b1b; }

/* ───────── Modal ───────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    z-index: 200;
    justify-content: center;
    align-items: flex-start;
    padding: 60px 20px;
    overflow-y: auto;
    animation: overlayIn 0.2s ease;
}
.modal-overlay.active { display: flex; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: white;
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 880px;
    animation: modalIn 0.35s cubic-bezier(.4,.4,.2,1);
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
    padding: 24px 28px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.modal-head h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.025em;
    line-height: 1.15;
}
.modal-head .modal-sub {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 4px;
}

.modal-close {
    background: var(--gray-100);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    cursor: pointer;
    color: var(--gray-500);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}
.modal-close:hover { background: var(--gray-200); color: var(--gray-900); }

.modal-body { padding: 24px 28px; }

.modal-foot {
    padding: 16px 28px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 0 0 var(--r-2xl) var(--r-2xl);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ───────── Detail sections ───────── */
.section {
    margin-bottom: 24px;
}
.section:last-child { margin-bottom: 0; }

.section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
}

.fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.field-label {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 500;
}
.field-value {
    font-size: 14px;
    color: var(--gray-900);
    font-weight: 500;
}
.field-value.empty { color: var(--gray-400); font-weight: 400; }

.field-modified {
    background: linear-gradient(to right, var(--orange-bg), transparent);
    border-left: 3px solid var(--orange);
    padding: 8px 12px;
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.field-modified .original {
    text-decoration: line-through;
    color: var(--gray-500);
    font-size: 12px;
    display: block;
}
.field-modified .new {
    color: #92400e;
    font-weight: 600;
}

.edit-input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--r-sm);
    font-size: 14px;
    font-family: var(--font);
    color: var(--gray-900);
    background: white;
    transition: all 0.15s;
    width: 100%;
}
.edit-input:hover:not([readonly]) { border-color: var(--gray-400); }
.edit-input:focus {
    outline: none;
    border-color: var(--teal-500);
    box-shadow: 0 0 0 3px var(--teal-100);
}
.edit-input[readonly] {
    background: var(--gray-50);
    color: var(--gray-500);
    cursor: not-allowed;
}
.edit-input.invalid {
    border-color: var(--red);
    background: #fef2f2;
    box-shadow: 0 0 0 3px rgba(239,68,68,0.10);
}
.edit-error {
    font-size: 12px;
    color: var(--red);
    margin-top: 4px;
    min-height: 0;
}
.edit-error:empty { display: none; }
select.edit-input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 36px;
}

/* ───────── Form fields (settings) ───────── */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}
.form-group input, .form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--r-sm);
    font-size: 14px;
    font-family: var(--font);
    transition: all 0.15s;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--teal-500);
    box-shadow: 0 0 0 3px var(--teal-100);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ───────── Toast ───────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--gray-900);
    color: white;
    padding: 12px 16px;
    border-radius: var(--r-md);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-xl);
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 280px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 3px solid var(--teal-500);
}
.toast-success { border-left-color: var(--green); }
.toast-error   { border-left-color: var(--red); }
.toast-info    { border-left-color: var(--blue); }

@keyframes toastIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ───────── Export cards (special) ───────── */
.export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.export-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--r-lg);
    padding: 28px;
    position: relative;
    overflow: hidden;
    transition: all .25s cubic-bezier(.4,.4,.2,1);
}
.export-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--teal-500), #14b8a6);
}
.export-card.diff::before { background: linear-gradient(90deg, var(--blue), var(--purple)); }
.export-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--teal-200);
}

.export-card .ec-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--r-md);
    background: var(--teal-100);
    color: var(--teal-600);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.export-card.diff .ec-icon {
    background: var(--blue-bg);
    color: var(--blue);
}
.export-card .ec-icon svg { width: 22px; height: 22px; }

.export-card h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}
.export-card p {
    font-size: 13px;
    color: var(--gray-500);
    line-height: 1.6;
    margin-bottom: 18px;
}

/* ───────── Empty / loading ───────── */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--gray-500);
}
.empty-state h3 {
    font-size: 16px;
    color: var(--gray-700);
    margin-bottom: 4px;
}
.empty-state p { font-size: 13px; }

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--teal-500);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────── Checkbox modern ───────── */
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--teal-500);
    cursor: pointer;
}

.checkbox-cell { width: 40px; }

/* ───────── Responsive ───────── */
@media (max-width: 1024px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: -100%;
        z-index: 100;
        width: var(--sidebar-w);
        transition: left 0.25s;
    }
    .sidebar.open { left: 0; }
    .topbar { padding: 0 20px; }
    .content { padding: 20px; }
    .search { width: 100%; }
    .form-row { grid-template-columns: 1fr; }
}

/* Card pliable (utilisé pour le bloc Composition emails) */
.card.collapsible .card-body { transition: max-height .25s ease, opacity .2s; }
.card.collapsible.collapsed .card-body { display: none; }
/* État replié indiqué par le chevron (pas de texte, pour rester multilingue) */
.card.collapsible:not(.collapsed) #compose-chevron-icon { transform: rotate(180deg); }
