/* =====================================================================
   F&B Analytics — feuille de style
   ===================================================================== */
/* Police Inter auto-hébergée (latin) — chargée en local, sans dépendance réseau */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/inter-400.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/inter-500.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/inter-600.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/inter-700.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 800; font-display: swap; src: url(../fonts/inter-800.woff2) format('woff2'); }

:root {
    /* Thème plat & épuré (façon Olshop) : blanc, cartes sans arrondi ni couleur, traits fins */
    --bg:        #f5f6f9;
    --surface:   #ffffff;
    --surface-2: #f4f5f8;   /* fonds de barres / hover */
    --border:    #ebecf0;   /* traits fins */
    --text:      #1f2330;
    --text-dim:  #8b8f9c;
    --primary:   #4a3fd0;
    --primary-2: #5b50e0;
    --accent:    #6a8bf0;
    --green:     #1faf6f;
    --red:       #e0524f;
    --gold:      #d9a200;
    --navy:      #1f2330;   /* foncé pour l'élément de menu actif */
    --radius:    0px;        /* cartes à coins carrés */
    --shadow:    0 1px 2px rgba(20,20,50,.03);
}

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

/* Réserve en permanence l'espace de la barre de défilement : évite le décalage
   de la mise en page (et de la barre latérale) quand la scrollbar apparaît. */
html { scrollbar-gutter: stable; overflow-y: scroll; }

body {
    font-family: 'Inter', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    letter-spacing: -.01em;
}

.app { display: flex; min-height: calc(100vh - 56px); }

/* ---------- Icônes SVG ---------- */
svg.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.nav-icon { display: inline-flex; }
.kpi-icon { display: inline-flex; color: var(--text-dim); }
.logo-mark { display: inline-flex; color: var(--text); }
.page-title { display: inline-flex; align-items: center; gap: 9px; }
.page-title svg.icon { color: var(--primary); }
.section-title { display: inline-flex; align-items: center; gap: 6px; }
.stat-purple .stat-icon { color: #6a4df0; }
.stat-orange .stat-icon { color: #df8a2c; }
.stat-green  .stat-icon { color: #1faf6f; }
.stat-blue   .stat-icon { color: #3f7ae0; }
.stat-pink   .stat-icon { color: #e0568f; }

/* ---------- Top bar (façon Mews POS) ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding-right: 24px;
}
.topbar-brand {
    display: flex; align-items: center; gap: 10px;
    width: 248px; height: 100%;
    padding: 0 18px;
    border-right: 1px solid var(--border);
    box-sizing: border-box;
}
.logo-mark { font-size: 22px; }
.logo-text { font-weight: 800; font-size: 16px; letter-spacing: -.02em; color: var(--text); }
.logo-chip {
    background: var(--text); color: #fff; font-size: 10px; font-weight: 700;
    letter-spacing: .1em; padding: 2px 6px; border-radius: 5px;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-api { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.topbar-burger { display: none; background: none; border: none; cursor: pointer; color: var(--text); padding: 8px; margin-left: 10px; border-radius: 8px; align-items: center; }
.topbar-burger:hover { background: var(--surface-2); }
.sidebar-backdrop { display: none; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: 248px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 18px 16px;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; padding: 0 6px; }
.brand-logo { font-size: 30px; }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub  { font-size: 11px; color: var(--text-dim); letter-spacing: .04em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: 10px;
    color: var(--text-dim); text-decoration: none; font-size: 14px; font-weight: 500;
    transition: all .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--navy); color: #fff; font-weight: 600; box-shadow: 0 6px 16px rgba(31,29,61,.25); }
.nav-icon { font-size: 16px; }

.sidebar-foot { padding-top: 16px; border-top: 1px solid var(--border); }
.badge { font-size: 11px; padding: 6px 10px; border-radius: 20px; font-weight: 600; }
.badge-demo { background: rgba(255,180,84,.14); color: var(--accent); }
.badge-live { background: rgba(62,207,142,.14); color: var(--green); }

/* ---------- Content ---------- */
.content { flex: 1; min-width: 0; padding: 30px 38px; max-width: 1400px; transition: opacity .12s ease; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 26px; flex-wrap: wrap; gap: 16px; }
.page-title { font-size: 26px; font-weight: 700; }
.page-sub { color: var(--text-dim); font-size: 14px; margin-top: 4px; }

/* ---------- Filtres période ---------- */
.range-filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.range-btn {
    padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text-dim); font-size: 13px; cursor: pointer;
    text-decoration: none; transition: all .15s;
}
.range-btn:hover { border-color: var(--primary); color: var(--text); }
.range-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Section ---------- */
.section { margin-bottom: 34px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.section-title { font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); }
.section-line { flex: 1; height: 1px; background: var(--border); }

/* ---------- Grilles KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.kpi-grid.metrics { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: relative;
    transition: border-color .15s;
}
.kpi-card:hover { border-color: #d8dae2; }
.kpi-card.favorite { border-color: var(--border); }

.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kpi-label { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-dim); font-weight: 500; }
.kpi-icon { font-size: 17px; }

.star {
    background: none; border: none; cursor: pointer; font-size: 17px;
    color: var(--text-dim); opacity: .5; transition: all .15s; line-height: 1;
}
.star:hover { opacity: 1; transform: scale(1.15); }
.star.on { color: var(--gold); opacity: 1; }

.kpi-main { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }

/* breakdown */
.bd-total { font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }
.bd-row { margin-bottom: 11px; }
.bd-row:last-child { margin-bottom: 0; }
.bd-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.bd-head .lbl { color: var(--text); }
.bd-head .val { color: var(--text-dim); }
.bd-bar { height: 7px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bd-fill { height: 100%; background: linear-gradient(90deg, var(--primary-2), var(--primary)); border-radius: 5px; }
.bd-pct { font-size: 11px; color: var(--text-dim); margin-left: 8px; }

/* ranking */
.rank-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.rank-row:last-child { margin-bottom: 0; }
.rank-num { width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--text-dim); flex-shrink: 0; }
.rank-row:nth-child(1) .rank-num { background: rgba(255,209,102,.18); color: var(--gold); }
.rank-body { flex: 1; min-width: 0; }
.rank-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-sub { font-size: 11px; color: var(--text-dim); }
.rank-track { height: 5px; background: var(--surface-2); border-radius: 4px; margin-top: 5px; overflow: hidden; }
.rank-track-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.rank-val { font-size: 13px; font-weight: 600; text-align: right; flex-shrink: 0; }
.rank-qty { font-size: 11px; color: var(--text-dim); }

/* mini chart (timeseries) */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 120px; margin-top: 8px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.chart-bar { width: 100%; max-width: 26px; background: linear-gradient(180deg, #6a8bf0, #4fd2c2); border-radius: 6px 6px 0 0; min-height: 3px; transition: opacity .15s; cursor: default; }
.chart-col:hover .chart-bar { opacity: .8; }
.chart-lbl { font-size: 10px; color: var(--text-dim); white-space: nowrap; }

/* ---------- KPI vide / placeholder ---------- */
.empty-hint { color: var(--text-dim); font-size: 13px; padding: 14px 0; }

/* ---------- Cartes statistiques (hero) ---------- */
.hero-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 8px; }
.hero-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.hero-card .h-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.hero-card .h-value { font-size: 30px; font-weight: 700; margin-top: 8px; }

/* ---------- Réglages ---------- */
.settings-group { margin-bottom: 28px; }
.kpi-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.kpi-list-item { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 14px 16px; }
.kpi-list-item .info { flex: 1; }
.kpi-list-item .ttl { font-size: 14px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.kpi-list-item .dsc { font-size: 12px; color: var(--text-dim); margin-top: 3px; }

/* toggle switch */
.switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 24px; cursor: pointer; transition: .2s; }
.slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: var(--text-dim); border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); background: #fff; }

/* ---------- Boutons / cartes génériques ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }

/* ---------- Bandeau statistique à plat (façon Olshop) ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    background: var(--surface);
    border: 1px solid var(--border);
    margin-bottom: 22px;
}
.stat-card { padding: 20px 22px; border-right: 1px solid var(--border); }
.stat-card:last-child { border-right: none; }
.stat-icon { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 19px; margin-bottom: 13px; }
.stat-value { font-size: 23px; font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.stat-label { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }
/* couleur uniquement sur la petite icône, jamais autour de la carte */
.stat-caption { margin-bottom: 10px; }
.delta { font-size: 12px; margin-top: 8px; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.delta-up   { color: var(--green); }
.delta-down { color: var(--red); }
.delta-flat { color: var(--text-dim); font-weight: 500; }
.delta-sub  { color: var(--text-dim); font-weight: 400; }

.stat-purple .stat-icon { background: #efeaff; }
.stat-orange .stat-icon { background: #fff2e3; }
.stat-green  .stat-icon { background: #e6f6ee; }
.stat-blue   .stat-icon { background: #e7f0ff; }
.stat-pink   .stat-icon { background: #ffe9f2; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: 10px; border: none; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; transition: all .15s; }
.btn-primary { background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); }

.alert { padding: 14px 18px; border-radius: 11px; font-size: 14px; margin-bottom: 18px; }
.alert-ok  { background: rgba(62,207,142,.12); color: var(--green); border: 1px solid rgba(62,207,142,.3); }
.alert-err { background: rgba(255,107,107,.1); color: var(--red); border: 1px solid rgba(255,107,107,.3); }
.alert-info{ background: rgba(108,140,255,.1); color: var(--primary); border: 1px solid rgba(108,140,255,.3); }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Analyse ventes : tableau, filtres, totaux ---------- */
table.data td.num, table.data th.num { text-align: right; }
table.data tbody tr:hover { background: var(--surface-2); }
.data tfoot .totals-row td {
    border-top: 2px solid #dcdce4; border-bottom: none;
    font-weight: 700; color: var(--text); background: var(--surface-2); padding: 14px 12px;
}
.totals-sub { display: block; font-weight: 400; color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.data-sales { width: 100%; table-layout: auto; }
@media (max-width: 640px) {
    .data-sales { table-layout: fixed; }
    .data-sales th, .data-sales td { padding: 9px 6px; font-size: 11.5px; }
    .data-sales td { word-break: break-word; }
    .data-sales th { word-break: normal; overflow-wrap: normal; letter-spacing: 0; font-size: 10px; }
    .data-sales td.col-date { white-space: nowrap; }
    .data-sales .col-time { display: none; }
    .data-sales .chip { padding: 1px 6px; font-size: 10px; white-space: normal; }
    .data-sales th:nth-child(1), .data-sales td:nth-child(1) { width: 19%; }
    .data-sales th:nth-child(2), .data-sales td:nth-child(2) { width: 29%; }
    .data-sales th:nth-child(3), .data-sales td:nth-child(3) { width: 19%; }
    .data-sales th:nth-child(4), .data-sales td:nth-child(4) { width: 18%; }
    .data-sales th:nth-child(5), .data-sales td:nth-child(5) { width: 15%; }
}
.chip { display: inline-block; padding: 2px 9px; border-radius: 20px; background: var(--surface-2); color: var(--text-dim); font-size: 11.5px; white-space: nowrap; }
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filter-field { display: flex; flex-direction: column; }
.filter-field .form-input { min-width: 150px; width: 100%; }
.filter-actions { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.pager { display: flex; align-items: center; gap: 14px; justify-content: center; margin-top: 18px; }
.range-btn.disabled { opacity: .4; pointer-events: none; }

/* ---------- Authentification (login / setup) ---------- */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px; box-shadow: 0 10px 40px rgba(40,30,90,.10); }
.auth-brand { display: flex; align-items: center; gap: 9px; justify-content: center; margin-bottom: 22px; }
.auth-title { font-size: 21px; font-weight: 700; text-align: center; }
.auth-sub { font-size: 13px; color: var(--text-dim); text-align: center; margin: 6px 0 22px; }
.auth-foot { font-size: 12px; color: var(--text-dim); }

/* ---------- Utilisateur dans le bandeau ---------- */
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-link { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; padding: 4px 8px; border-radius: 10px; }
.user-link:hover { background: var(--surface-2); }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.user-meta { line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-dim); }
.topbar-logout { display: inline-flex; color: var(--text-dim); padding: 6px; border-radius: 8px; }
.topbar-logout:hover { background: var(--surface-2); color: var(--red); }

/* ---------- Boutons compacts + modale ---------- */
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,20,50,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--surface); border-radius: 14px; padding: 26px; width: 100%; max-width: 460px; box-shadow: var(--shadow); }

/* ---------- Établissements ---------- */
.est-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.est-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.est-name { font-weight: 600; font-size: 15px; }
.cron-method { margin-bottom: 14px; }
.cron-pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; font-size: 12.5px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre-wrap; word-break: break-all; color: var(--text); margin-top: 6px; }

.kv { display: grid; grid-template-columns: 180px 1fr; gap: 10px 18px; font-size: 14px; }
.kv .k { color: var(--text-dim); }

/* formulaires */
.form-row { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 7px; font-weight: 500; }
.form-input {
    width: 100%; padding: 11px 14px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
    font-size: 14px; font-family: inherit;
}
.form-input:focus { outline: none; border-color: var(--primary); }
.checkbox-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); margin-top: 10px; }
.checkbox-line input { width: 15px; height: 15px; }

.toast { position: fixed; bottom: 24px; right: 24px; background: var(--surface-2); border: 1px solid var(--primary); color: var(--text); padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: all .25s; z-index: 100; }
.toast.show { opacity: 1; transform: translateY(0); }

/* Tablettes & smartphones : barre latérale en tiroir (menu burger). */
@media (max-width: 1024px) {
    .topbar-burger { display: inline-flex; }
    .topbar-brand { width: auto; border-right: none; padding-left: 4px; }
    .sidebar {
        position: fixed; top: 56px; left: 0;
        height: calc(100vh - 56px); width: 252px;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 60;
        box-shadow: 0 12px 40px rgba(20, 20, 50, .18);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open {
        display: block; position: fixed; inset: 56px 0 0 0;
        background: rgba(20, 20, 50, .4); z-index: 55;
    }
    .content { padding: 22px; }
}

/* Smartphones : on allège le bandeau. */
@media (max-width: 560px) {
    .topbar .badge { display: none; }
    .user-meta { display: none; }
    .content { padding: 16px; }
    .page-head { gap: 12px; }
}
