:root {
    --primary: #1f8a8c;
    --primary-dark: #17696b;
    --primary-light: #e6f5f5;
    --secondary: #16324a;
    --secondary-light: #1e435f;
    --bg: #f2f6f7;
    --card-bg: #ffffff;
    --text: #22303f;
    --text-light: #6b7c8c;
    --border: #e5eaed;
    --danger: #e0554f;
    --warning: #e5a83a;
    --success: #2e9e5b;
    --info: #3a8fd6;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 10px rgba(22,50,74,0.06);
    --shadow-lg: 0 12px 32px rgba(22,50,74,0.14);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Layout ---------- */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--secondary), #102030);
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px 20px 16px;
}
.sidebar-logo img { height: 48px; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    margin:  12px 10px;
    background: rgba(255,255,255,0.06);
    border-radius: var(--radius-sm);
  
}
.avatar {
    width: 70px; height: 70px; border-radius: 50%;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 22px; flex-shrink: 0;
    object-fit: cover;
}
.avatar-photo { background: none; }
.sidebar-user-name { font-size: 13px; font-weight: 600; }
.sidebar-user-roles { font-size: 11px; color: rgba(255,255,255,0.55); text-align: center;
    width: 100%; }

.sidebar nav { flex: 1; padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; }

.nav-icon { width: 19px; height: 19px; flex-shrink: 0; display: inline-flex; }
.nav-label { flex: 1; }

a.nav-link, button.nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: rgba(255,255,255,0.8);
    font-size: 13.5px;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}
a.nav-link:hover, button.nav-group-toggle:hover { background: rgba(255,255,255,0.08); color: #fff; }
a.nav-link.active { background: var(--primary); color: #fff; font-weight: 600; }
a.nav-link-top { margin-bottom: 2px; }

.nav-group { margin-bottom: 2px; }
.nav-group .nav-chevron { width: 14px; height: 14px; transition: transform 0.2s; opacity: 0.6; }
.nav-group.open .nav-chevron { transform: rotate(90deg); }
.nav-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    padding-left: 14px;
    border-left: 2px solid rgba(255,255,255,0.08);
    margin-left: 22px;
}
.nav-group.open .nav-group-items { max-height: 400px; }
.nav-group-items a.nav-link { padding: 8px 10px; font-size: 13px; }
.nav-group-items .nav-icon { width: 16px; height: 16px; }

.nav-link-logout {
    margin: 10px 12px 16px;
    color: rgba(255,255,255,0.55);
    border-top: 1px solid rgba(255,255,255,0.08);
    border-radius: 0;
    padding-top: 16px !important;
}
.nav-link-logout:hover { color: #fff; background: none; }

.btn-menu-mobile { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--secondary); }

.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: #fff;
    padding: 18px 28px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 21px; margin: 0; color: var(--secondary); font-weight: 700; }

.content { padding: 26px 28px; flex: 1; }

/* ---------- Cards ---------- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 20px;
}
.card h2, .card h3 { margin-top: 0; color: var(--secondary); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary);
}
.stat-card.danger::before { background: var(--danger); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.success::before { background: var(--success); }
.stat-card .label { font-size: 12px; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.stat-card .value { font-size: 25px; font-weight: 800; color: var(--secondary); margin-top: 8px; }

/* ---------- Forms ---------- */
label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 13px; color: var(--secondary); }
input, select, textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }

.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.checkbox-pill {
    display: flex; align-items: center; gap: 8px;
    border: 1.5px solid var(--border); border-radius: 30px;
    padding: 8px 16px; cursor: pointer; font-size: 13px; font-weight: 600;
    color: var(--text-light); transition: all 0.15s;
}
.checkbox-pill input { width: auto; margin: 0; }
.checkbox-pill:has(input:checked) { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(0.98); }
.btn-secondary { background: #eef2f4; color: var(--text); }
.btn-secondary:hover { background: #e2e8ec; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #c8433d; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #f8fafb; color: var(--text-light); text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.5px; font-weight: 700; }
tr:hover td { background: #fafcfd; }

.tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.tag-success { background: #e4f6ec; color: var(--success); }
.tag-danger { background: #fce9e8; color: var(--danger); }
.tag-warning { background: #fdf2e0; color: #b9791f; }
.tag-info { background: #e7f2fc; color: var(--info); }
.tag-gray { background: #eef1f3; color: var(--text-light); }

/* ---------- Alerts ---------- */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #e4f6ec; color: #1c6b40; border: 1px solid #bfe6cf; }
.alert-error { background: #fce9e8; color: #a02626; border: 1px solid #f3c2c2; }
.alert-info { background: #e7f2fc; color: #1a5185; border: 1px solid #c1defa; }
.alert-warning { background: #fdf2e0; color: #8a5b0f; border: 1px solid #f3ddac; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.search-box { display: flex; gap: 8px; flex-wrap: wrap; }
.search-box input, .search-box select { margin-bottom: 0; min-width: 200px; }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--secondary), var(--primary)); }
.login-box { background: #fff; padding: 40px; border-radius: 16px; width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); }
.login-box img { display: block; margin: 0 auto 20px; height: 60px; }
.login-box h1 { text-align: center; color: var(--secondary); font-size: 20px; margin-bottom: 24px; }

/* POS */
.pos-layout { display: flex; flex-direction: column; gap: 24px; max-width: 900px; margin: 0 auto; }
.pos-products { max-height: 55vh; overflow-y: auto; scrollbar-width: thin; }
.pos-product-item { display: flex; justify-content: space-between; align-items: center; padding: 13px 14px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: var(--radius-sm); transition: background 0.15s, transform 0.1s; }
.pos-product-item:hover { background: var(--primary-light); transform: translateX(2px); }
.pos-product-item .nom-produit { font-weight: 600; color: var(--secondary); }
.pos-product-item .infos-produit { color: var(--text-light); font-size: 11.5px; margin-top: 2px; }
.pos-product-item .prix-produit { font-weight: 700; color: var(--primary-dark); font-size: 14.5px; white-space: nowrap; }
.pos-cart {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0;
    position: sticky;
    top: 16px;
    overflow: hidden;
}
.pos-cart-header {
    background: linear-gradient(135deg, var(--secondary), var(--primary-dark));
    color: #fff;
    padding: 18px 22px;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}
.pos-cart-body { padding: 20px 22px; }
.pos-cart table td, .pos-cart table th { padding: 8px 6px; font-size: 12.5px; }
.pos-cart table th { color: var(--text-light); font-size: 10.5px; }
.pos-total-box {
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin: 14px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.pos-total { font-size: 22px; font-weight: 800; color: var(--secondary); text-align: right; margin: 0; }
.pos-sous-total { font-size: 12.5px; color: var(--text-light); }

.badge-count { background: var(--danger); color: #fff; border-radius: 20px; font-size: 10px; font-weight: 700; padding: 2px 7px; margin-left: auto; }

/* ---------- Charts (SVG natifs, sans dépendance) ---------- */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { width: 100%; height: auto; stroke: none; }
.chart-bar { fill: var(--primary); }
.chart-bar:hover { fill: var(--primary-dark); }
.chart-axis { stroke: var(--border); stroke-width: 1; fill: none; }
.chart-label { fill: var(--text-light); font-size: 10px; font-family: inherit; stroke: none; }
.chart-value { fill: var(--secondary); font-size: 10px; font-weight: 700; font-family: inherit; stroke: none; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 12px; }
.chart-legend-item { display: flex; align-items: center; gap: 6px; }
.chart-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

.btn i, h3 i, .toolbar i { font-size: 14px; }
.card h3 i { margin-right: 6px; }

@media print {
    .no-print { display: none !important; }
    .content { padding: 0; }
    .sidebar { display: none; }
}

@media (max-width: 900px) {
    .app-layout { flex-direction: column; }
    .sidebar { position: fixed; left: -280px; z-index: 100; width: 260px; transition: left 0.2s; }
    .sidebar.open { left: 0; }
    .btn-menu-mobile { display: block; }
    .pos-layout { grid-template-columns: 1fr; }
    .main-content { width: 100%; }
}

/* ---------- Alertes (accordéon dépliable) ---------- */
.alert-accordion {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}
.alert-accordion summary {
    list-style: none;
    cursor: pointer;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-weight: 700;
    color: var(--secondary);
    font-size: 15px;
    user-select: none;
}
.alert-accordion summary::-webkit-details-marker { display: none; }
.alert-accordion summary .left { display: flex; align-items: center; gap: 12px; }
.alert-accordion summary .right { display: flex; align-items: center; gap: 10px; }
.alert-accordion summary .chevron { width: 14px; height: 14px; color: var(--text-light); transition: transform 0.2s ease; flex-shrink: 0; }
.alert-accordion[open] summary .chevron { transform: rotate(180deg); }
.alert-accordion[open] summary { border-bottom: 1px solid var(--border); }
.alert-accordion .accordion-body { padding: 4px 22px 20px; }
.alert-accordion .accordion-body table { margin-top: 10px; }

.alert-icon-badge {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.alert-icon-badge svg { width: 18px; height: 18px; }
.alert-icon-badge.danger { background: #fce9e8; color: var(--danger); }
.alert-icon-badge.warning { background: #fdf2e0; color: #b9791f; }
.alert-icon-badge.info { background: #e7f2fc; color: var(--info); }
.alert-icon-badge.neutral { background: #eef1f3; color: var(--text-light); }

.alert-count-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 11px;
    border-radius: 20px;
    background: #eef1f3;
    color: var(--text-light);
}
.alert-count-badge.has-items.danger { background: #fce9e8; color: var(--danger); }
.alert-count-badge.has-items.warning { background: #fdf2e0; color: #b9791f; }
.alert-count-badge.has-items.info { background: #e7f2fc; color: var(--info); }

.empty-state {
    text-align: center;
    padding: 34px 10px;
    color: var(--text-light);
}
.empty-state svg { width: 30px; height: 30px; display: block; margin: 0 auto 10px; opacity: 0.4; }

/* ---------- Alertes v2 : résumé + accordéon modernisé ---------- */
.alert-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.alert-summary-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.alert-summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.alert-summary-icon {
    width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 19px; flex-shrink: 0;
}
.alert-summary-icon.danger { background: #fce9e8; color: var(--danger); }
.alert-summary-icon.warning { background: #fdf2e0; color: #b9791f; }
.alert-summary-icon.info { background: #e7f2fc; color: var(--info); }
.alert-summary-icon.neutral { background: #eef1f3; color: var(--text-light); }
.alert-summary-value { font-size: 22px; font-weight: 800; color: var(--secondary); line-height: 1.1; }
.alert-summary-label { font-size: 12.5px; color: var(--text-light); font-weight: 600; margin-top: 2px; }

.alert-accordion-title { display: block; font-weight: 700; color: var(--secondary); font-size: 15px; }
.alert-accordion-sub { display: block; font-weight: 500; font-size: 11.5px; color: var(--text-light); margin-top: 1px; }

.empty-state i { font-size: 30px; display: block; margin: 0 auto 10px; opacity: 0.4; }
.dev-credit {
    position: fixed;
    bottom: 12px;
    left: 16px;
    font-size: 12px;
    color: #6b7280;
    opacity: .85;
    z-index: 10;
}
.dev-credit strong { font-weight: 600; }

/* Sur mobile, on centre pour éviter le chevauchement */
@media (max-width: 576px) {
    .dev-credit {
        left: 0;
        right: 0;
        text-align: center;
        font-size: 11px;
    }
}