/* TEKA na Bwania — thème (au-dessus de Bootstrap 5.2 local) */
:root {
  --tk-navy: #1d2b53;
  --tk-navy-2: #26386b;
  --tk-primary: #2f5bea;
  --tk-primary-600: #2449c4;
  --tk-accent: #f59e0b;
  --tk-success: #12a150;
  --tk-danger: #dc3545;
  --tk-bg: #f3f5fa;
  --tk-card: #ffffff;
  --tk-border: #e4e8f1;
  --tk-muted: #6b7489;
  --tk-radius: 14px;
  --bs-primary: #2f5bea;
  --bs-primary-rgb: 47, 91, 234;
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-bg: var(--tk-bg);
  --bs-link-color: #2f5bea;
  --bs-link-hover-color: #2449c4;
}
body { background: var(--tk-bg); color: #1f2433; -webkit-tap-highlight-color: transparent; }
.btn-primary { --bs-btn-bg: var(--tk-primary); --bs-btn-border-color: var(--tk-primary); --bs-btn-hover-bg: var(--tk-primary-600); --bs-btn-hover-border-color: var(--tk-primary-600); --bs-btn-active-bg: #1f3fae; --bs-btn-disabled-bg: #8ea6f3; --bs-btn-disabled-border-color: #8ea6f3; }
.btn-outline-primary { --bs-btn-color: var(--tk-primary); --bs-btn-border-color: var(--tk-primary); --bs-btn-hover-bg: var(--tk-primary); --bs-btn-hover-border-color: var(--tk-primary); --bs-btn-active-bg: var(--tk-primary); --bs-btn-active-border-color: var(--tk-primary); }
.btn-success { --bs-btn-bg: var(--tk-success); --bs-btn-border-color: var(--tk-success); }
.text-primary { color: var(--tk-primary) !important; }
.form-control:focus, .form-select:focus { border-color: #9bb3f6; box-shadow: 0 0 0 .2rem rgba(47,91,234,.15); }
.card { border: 1px solid var(--tk-border); border-radius: var(--tk-radius); box-shadow: 0 1px 2px rgba(20,30,60,.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--tk-border); font-weight: 600; }
.table > :not(caption) > * > * { padding: .6rem .7rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--tk-muted); font-weight: 600; background: #f8f9fc; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.btn-icon { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.35rem; border: 0; }
.fw-semibold { font-weight: 600 !important; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { background: var(--tk-navy); color: #cdd6f1; width: 250px; flex-shrink: 0; display: flex; flex-direction: column; }
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  .sidebar.offcanvas-lg { visibility: visible; transform: none; background-color: var(--tk-navy) !important; }
}
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { --bs-offcanvas-width: 270px; background: var(--tk-navy); }
}
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--tk-accent), #f97316); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 1.2rem; flex-shrink: 0; }
.brand-name { color: #fff; font-weight: 700; font-size: .95rem; }
.brand-sub { font-size: .72rem; opacity: .7; letter-spacing: .04em; }
.sidebar-nav { padding: .6rem .5rem; flex: 1; }
.sidebar a { display: flex; align-items: center; gap: .75rem; color: #cdd6f1; text-decoration: none; padding: .62rem .8rem; border-radius: 10px; font-size: .93rem; margin-bottom: 2px; }
.sidebar a i { font-size: 1.1rem; width: 1.2rem; text-align: center; }
.sidebar a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar a.active { background: var(--tk-primary); color: #fff; box-shadow: 0 4px 12px rgba(47,91,234,.35); }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .5; padding: .9rem .8rem .3rem; }
.sidebar-foot { padding: .5rem; border-top: 1px solid rgba(255,255,255,.08); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--tk-border); display: flex; align-items: center; gap: .5rem; padding: .55rem 1rem; min-height: 58px; }
.topbar-title { font-size: 1.1rem; font-weight: 700; margin: 0; }
.content { padding: 1.1rem; flex: 1; }
@media (min-width: 992px) { .content { padding: 1.5rem 1.75rem; } }
.net-status { color: #b42318; background: #fee4e2; border-radius: 999px; padding: .2rem .6rem; font-size: .8rem; font-weight: 600; }

/* ---------- KPI */
.kpi { background: var(--tk-card); border: 1px solid var(--tk-border); border-radius: var(--tk-radius); padding: 1rem; display: flex; gap: .85rem; align-items: center; height: 100%; }
.kpi-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0; }
.kpi-label { font-size: .8rem; color: var(--tk-muted); font-weight: 500; }
.kpi-value { font-size: 1.35rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; word-break: break-word; }
.kpi-sub { font-size: .76rem; color: var(--tk-muted); }
.kpi-primary .kpi-icon { background: #e7edff; color: var(--tk-primary); }
.kpi-success .kpi-icon { background: #dcfae6; color: var(--tk-success); }
.kpi-danger .kpi-icon { background: #fee4e2; color: #d92d20; }
.kpi-warning .kpi-icon { background: #fef0c7; color: #b54708; }
.kpi-dark .kpi-icon { background: var(--tk-navy); color: #fff; }
.kpi-dark { background: linear-gradient(135deg, var(--tk-navy), var(--tk-navy-2)); color: #fff; border: 0; }
.kpi-dark .kpi-label, .kpi-dark .kpi-sub { color: #c5cff0; }
.kpi-dark .kpi-icon { background: rgba(255,255,255,.12); }

.period-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; background: var(--tk-card); border: 1px solid var(--tk-border); border-radius: var(--tk-radius); padding: .6rem .75rem; margin-bottom: 1rem; }
.section-title { font-size: 1rem; font-weight: 700; margin: 0; }
.empty { text-align: center; color: var(--tk-muted); padding: 2rem 1rem; }
.empty i { font-size: 2rem; display: block; margin-bottom: .4rem; opacity: .5; }

/* ---------- Barres (graphique) */
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.chart-bars .col-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.chart-bars .bar { width: 100%; max-width: 38px; background: var(--tk-primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.chart-bars .bar.today { background: var(--tk-accent); }
.chart-bars .lbl { font-size: .7rem; color: var(--tk-muted); margin-top: 4px; white-space: nowrap; }
.chart-bars .val { font-size: .66rem; color: #475067; margin-bottom: 3px; white-space: nowrap; }
.rank { width: 26px; height: 26px; border-radius: 8px; background: #eef2ff; color: var(--tk-primary); font-weight: 700; font-size: .8rem; display: inline-grid; place-items: center; }
.rank-1 { background: #fef0c7; color: #b54708; }
.progress-thin { height: 6px; background: #eef1f7; border-radius: 99px; overflow: hidden; }
.progress-thin > div { height: 100%; background: var(--tk-primary); border-radius: 99px; }

/* ---------- Caisse (point de vente) */
.pos { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.pos > section { min-width: 0; }
.main, .content { max-width: 100%; }
@media (min-width: 992px) { .pos { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; } }
@media (min-width: 1400px) { .pos { grid-template-columns: minmax(0, 1fr) 440px; } }
.pos-search { position: sticky; top: 58px; z-index: 5; background: var(--tk-bg); padding-bottom: .6rem; }
.pos-search .form-control { height: 56px; font-size: 1.1rem; border-radius: 14px; padding-left: 3rem; border: 2px solid var(--tk-border); }
.pos-search .form-control:focus { border-color: var(--tk-primary); }
.pos-search .bi-search { position: absolute; left: 1.05rem; top: 17px; font-size: 1.2rem; color: var(--tk-muted); }
.cat-chips { display: flex; gap: .4rem; overflow-x: auto; padding: .5rem 0 .1rem; scrollbar-width: none; }
.cat-chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--tk-border); background: #fff; border-radius: 999px; padding: .3rem .8rem; font-size: .83rem; white-space: nowrap; color: #394056; }
.chip.active { background: var(--tk-navy); color: #fff; border-color: var(--tk-navy); }
.art-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .6rem; }
.art { text-align: left; background: #fff; border: 1px solid var(--tk-border); border-radius: 12px; padding: .75rem .8rem; display: flex; flex-direction: column; gap: .25rem; min-height: 92px; transition: transform .06s, border-color .1s, box-shadow .1s; position: relative; }
.art:hover { border-color: #9bb3f6; box-shadow: 0 4px 14px rgba(47,91,234,.12); }
.art:active { transform: scale(.97); }
.art.kb { border-color: var(--tk-primary); box-shadow: 0 0 0 3px rgba(47,91,234,.2); }
.art-name { font-weight: 600; font-size: .92rem; line-height: 1.25; color: #1f2433; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.art-price { margin-top: auto; font-weight: 800; color: var(--tk-primary); font-variant-numeric: tabular-nums; }
.art-meta { font-size: .72rem; color: var(--tk-muted); }
.art .stock-badge { position: absolute; top: .45rem; right: .5rem; font-size: .68rem; }
.art.out { opacity: .6; }
.art .in-cart { position: absolute; top: -7px; left: -7px; background: var(--tk-accent); color: #fff; font-size: .72rem; font-weight: 700; border-radius: 999px; min-width: 22px; height: 22px; display: grid; place-items: center; padding: 0 5px; }

.cart-panel { background: #fff; }
@media (min-width: 992px) {
  .cart-panel.offcanvas-lg { background-color: #fff !important; position: sticky; top: 74px; border: 1px solid var(--tk-border); border-radius: var(--tk-radius); max-height: calc(100vh - 90px); display: flex; flex-direction: column; overflow: hidden; }
}
@media (max-width: 991.98px) {
  .cart-panel.offcanvas-lg { --bs-offcanvas-height: 92vh; border-radius: 18px 18px 0 0; }
}
.cart-head { padding: .85rem 1rem; border-bottom: 1px solid var(--tk-border); display: flex; align-items: center; gap: .5rem; }
.cart-body { flex: 1; overflow-y: auto; padding: .5rem 1rem; min-height: 120px; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; padding: .6rem 0; border-bottom: 1px dashed var(--tk-border); }
.cart-line:last-child { border-bottom: 0; }
.cart-line .nm { font-weight: 600; font-size: .92rem; }
.cart-line .pu { font-size: .78rem; color: var(--tk-muted); }
.cart-line .lt { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.qty-ctl { display: inline-flex; align-items: center; border: 1px solid var(--tk-border); border-radius: 10px; overflow: hidden; }
.qty-ctl button { border: 0; background: #f4f6fb; width: 34px; height: 34px; font-size: 1.1rem; line-height: 1; }
.qty-ctl input { width: 58px; border: 0; text-align: center; font-weight: 700; height: 34px; -moz-appearance: textfield; }
.qty-ctl input::-webkit-outer-spin-button, .qty-ctl input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cart-foot { border-top: 1px solid var(--tk-border); padding: .85rem 1rem 1rem; background: #fafbfe; }
.total-big { font-size: 2rem; font-weight: 800; color: var(--tk-navy); font-variant-numeric: tabular-nums; line-height: 1.1; }
.btn-sell { height: 58px; font-size: 1.15rem; font-weight: 700; border-radius: 14px; }
.change-box { border-radius: 10px; padding: .5rem .75rem; font-weight: 600; font-size: .92rem; }
.pos-mobile-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; background: var(--tk-navy); color: #fff; padding: .6rem .9rem calc(.6rem + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: .75rem; box-shadow: 0 -6px 20px rgba(0,0,0,.15); }
.pos-mobile-bar .t { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
body.pos-page .content { padding-bottom: 90px; }
@media (min-width: 992px) { body.pos-page .content { padding-bottom: 1.5rem; } }

.toast-container { z-index: 1090; }

/* ---------- Connexion */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(1200px 600px at 10% -10%, #33489a 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #f59e0b33 0%, transparent 60%), var(--tk-navy); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 22px; padding: 1.75rem 1.5rem; box-shadow: 0 25px 60px rgba(0,0,0,.3); }
.auth-card .brand-mark { width: 52px; height: 52px; font-size: 1.6rem; border-radius: 15px; margin: 0 auto .6rem; }
.pin-input { letter-spacing: .9em; text-align: center; font-size: 1.6rem; font-weight: 800; height: 58px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.keypad button { height: 54px; border-radius: 12px; border: 1px solid var(--tk-border); background: #f7f8fc; font-size: 1.3rem; font-weight: 700; }
.keypad button:active { background: #e7edff; }

/* ---------- Rapport imprimable */
.report-sheet { background: #fff; border: 1px solid var(--tk-border); border-radius: var(--tk-radius); padding: 1.5rem; }
.report-head { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 3px solid var(--tk-navy); padding-bottom: .8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.report-head h2 { font-size: 1.35rem; font-weight: 800; margin: 0; color: var(--tk-navy); }
.report-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.report-kpis > div { border: 1px solid var(--tk-border); border-radius: 10px; padding: .6rem .75rem; }
.report-kpis .l { font-size: .74rem; color: var(--tk-muted); text-transform: uppercase; letter-spacing: .03em; }
.report-kpis .v { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.report-kpis .caisse { background: var(--tk-navy); color: #fff; border-color: var(--tk-navy); }
.report-kpis .caisse .l { color: #c5cff0; }
.report-sheet h3 { font-size: 1rem; font-weight: 700; margin: 1.25rem 0 .5rem; color: var(--tk-navy); }
.report-sheet .table { font-size: .86rem; }
.caisse-calc td { padding: .35rem .5rem !important; }
.caisse-calc .tot td { font-weight: 800; border-top: 2px solid var(--tk-navy); font-size: 1.05rem; }
.signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 2.5rem; font-size: .85rem; }
.signatures div { border-top: 1px solid #999; padding-top: .3rem; text-align: center; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; }
  .sidebar, .topbar, .d-print-none, .alert, .pos-mobile-bar { display: none !important; }
  .main, .content { padding: 0 !important; }
  .app-shell { display: block; }
  .report-sheet { border: 0; padding: 0; border-radius: 0; }
  .report-kpis .caisse { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { text-decoration: none; color: inherit; }
  tr { page-break-inside: avoid; }
}
