/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    min-height: 100vh;
}
a { color: #818cf8; text-decoration: none; }
a:hover { color: #a5b4fc; }

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

/* Sidebar */
.sidebar {
    width: 220px;
    background: #1e293b;
    border-right: 1px solid #334155;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .2s;
}
.sidebar-brand {
    padding: 1.2rem 1rem;
    font-size: 1.3rem;
    font-weight: 700;
    color: #6366f1;
    border-bottom: 1px solid #334155;
}
.sidebar-nav { flex: 1; padding: .5rem 0; overflow-y: auto; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .65rem 1rem;
    color: #94a3b8;
    font-size: .9rem;
    transition: all .15s;
}
.sidebar-nav a:hover { background: #334155; color: #e2e8f0; }
.sidebar-nav a.active { background: #6366f1; color: #fff; }
.sidebar-user {
    padding: .8rem 1rem;
    border-top: 1px solid #334155;
    font-size: .8rem;
    color: #64748b;
}
.sidebar-user a { color: #f87171; }

/* Main */
.main { flex: 1; margin-left: 220px; padding: 1.5rem 2rem; min-width: 0; }

/* Mobile menu */
.menu-toggle {
    display: none;
    position: fixed;
    top: .8rem; left: .8rem;
    z-index: 200;
    background: #6366f1;
    border: none;
    color: #fff;
    width: 40px; height: 40px;
    border-radius: 8px;
    font-size: 1.3rem;
    cursor: pointer;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
}

/* === CARDS === */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.2rem;
    color: #f1f5f9;
}
.card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 1.2rem;
}
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.kpi-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
}
.kpi-card .kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #f1f5f9;
}
.kpi-card .kpi-label {
    font-size: .8rem;
    color: #94a3b8;
    margin-top: .3rem;
}
.kpi-card.accent { border-color: #6366f1; }
.kpi-card.green .kpi-value { color: #4ade80; }
.kpi-card.red .kpi-value { color: #f87171; }
.kpi-card.amber .kpi-value { color: #fbbf24; }
.kpi-card.teal .kpi-value { color: #2dd4bf; }
.kpi-card.blue .kpi-value { color: #60a5fa; }

/* === SECTION GRID === */
.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.section-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 1.2rem;
}
.section-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: .8rem;
    color: #f1f5f9;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    padding: .4rem 0;
    border-bottom: 1px solid #1e293b;
    font-size: .9rem;
}
.stat-row:last-child { border-bottom: none; }
.stat-label { color: #94a3b8; }
.stat-value { font-weight: 600; }

/* === FILTERS === */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin-bottom: 1.2rem;
    align-items: center;
}
.filters select, .filters input[type="text"], .filters input[type="date"] {
    background: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: .45rem .7rem;
    border-radius: 6px;
    font-size: .85rem;
}
.filters select:focus, .filters input:focus {
    outline: none;
    border-color: #6366f1;
}

/* === TABLE === */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
th {
    text-align: left;
    padding: .6rem .8rem;
    background: #1e293b;
    color: #94a3b8;
    font-weight: 600;
    border-bottom: 1px solid #334155;
    white-space: nowrap;
}
td {
    padding: .55rem .8rem;
    border-bottom: 1px solid #1e293b;
    color: #cbd5e1;
}
tr:hover td { background: #1e293b; }

/* === BADGES === */
.badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 9999px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-green { background: #065f46; color: #6ee7b7; }
.badge-red { background: #7f1d1d; color: #fca5a5; }
.badge-amber { background: #78350f; color: #fcd34d; }
.badge-blue { background: #1e3a5f; color: #93c5fd; }
.badge-gray { background: #374151; color: #9ca3af; }
.badge-indigo { background: #312e81; color: #a5b4fc; }

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: 6px;
    font-size: .85rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all .15s;
}
.btn-primary { background: #6366f1; color: #fff; }
.btn-primary:hover { background: #4f46e5; }
.btn-sm { padding: .3rem .6rem; font-size: .78rem; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: #94a3b8; border: 1px solid #334155; }
.btn-ghost:hover { background: #334155; color: #e2e8f0; }
.btn-green { background: #059669; color: #fff; }
.btn-green:hover { background: #047857; }
.btn-amber { background: #d97706; color: #fff; }
.btn-amber:hover { background: #b45309; }

/* === FORMS === */
.form-group { margin-bottom: .8rem; }
.form-group label {
    display: block;
    font-size: .8rem;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: .3rem;
}
.form-control {
    width: 100%;
    padding: .5rem .7rem;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: .9rem;
}
.form-control:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99,102,241,.2);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-inline {
    display: flex;
    gap: .5rem;
    align-items: end;
    flex-wrap: wrap;
}
.form-inline .form-group { margin-bottom: 0; }

/* === FLASH === */
.flash {
    padding: .6rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: .85rem;
}
.flash-success { background: #065f46; color: #6ee7b7; border: 1px solid #059669; }
.flash-error { background: #7f1d1d; color: #fca5a5; border: 1px solid #dc2626; }

/* === PIPELINE FUNNEL === */
.funnel {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.funnel-step {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 1rem 1.5rem;
    text-align: center;
    flex: 1;
    min-width: 140px;
}
.funnel-step .funnel-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f1f5f9;
}
.funnel-step .funnel-label {
    font-size: .8rem;
    color: #94a3b8;
}
.funnel-arrow {
    color: #475569;
    font-size: 1.2rem;
}
.funnel-rate {
    font-size: .7rem;
    color: #6366f1;
    font-weight: 600;
}

/* === FICHE === */
.fiche-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.fiche-title { font-size: 1.3rem; font-weight: 700; color: #f1f5f9; }
.fiche-meta { font-size: .85rem; color: #94a3b8; }
.fiche-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}
.info-list dt { font-size: .8rem; color: #64748b; margin-top: .6rem; }
.info-list dd { font-size: .95rem; color: #e2e8f0; }

/* === PAGINATION === */
.pagination {
    display: flex;
    gap: .3rem;
    margin-top: 1rem;
    justify-content: center;
}
.pagination a, .pagination span {
    padding: .3rem .7rem;
    border-radius: 4px;
    font-size: .85rem;
}
.pagination a { background: #1e293b; color: #94a3b8; }
.pagination a:hover { background: #334155; }
.pagination .current { background: #6366f1; color: #fff; }

/* === NOTES === */
.note-item {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: .8rem;
    margin-bottom: .6rem;
}
.note-meta { font-size: .75rem; color: #64748b; margin-bottom: .3rem; }
.note-text { font-size: .9rem; color: #cbd5e1; }

/* === LOGIN === */
.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}
.login-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 380px;
}
.login-card h1 {
    text-align: center;
    color: #6366f1;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

/* === SETTINGS === */
.settings-section {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 1.2rem;
    margin-bottom: 1rem;
}
.settings-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: .8rem;
    color: #f1f5f9;
}
.webhook-url {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: .5rem .8rem;
    font-family: monospace;
    font-size: .8rem;
    color: #94a3b8;
    word-break: break-all;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .menu-toggle { display: flex; align-items: center; justify-content: center; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main { margin-left: 0; padding: 1rem; padding-top: 3.5rem; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .funnel { flex-direction: column; }
    .funnel-arrow { transform: rotate(90deg); }
    .fiche-grid { grid-template-columns: 1fr; }
}
