:root{
  /* Premium Afreetech palette (Primary provided by client: #0F1368) */
  --navy:#0F1368;
  --navy-2:#1820A8;
  --accent:#C8A24A;
  --teal:#2BA6B3;
  --green:#2FAD66;
  --yellow:#E0B84C;
  --surface:#F6F7FB;

  --card:#FFFFFF;
  --text:#0b1220;
  --muted:#5d6b7b;

  --radius:16px;
  --shadow: 0 10px 30px rgba(15,19,104,.10);
  --shadow-sm: 0 6px 18px rgba(15,19,104,.08);
  --ring: 0 0 0 .22rem rgba(15,19,104,.18);
}

html, body { background: var(--surface); color: var(--text); }
body { font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; overflow-x: hidden; }

/* Safer default typography that feels app-like */
h1,h2,h3,h4,h5{ letter-spacing: -.02em; }

a { color: var(--navy-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.bg-surface{ background: var(--surface) !important; }

.container, .container-fluid { padding-left: 14px; padding-right: 14px; }
@media (min-width: 992px) { .container { max-width: 1024px; } }

.skip-link{
  position:absolute; left:-999px; top:10px;
  background: #fff; color: var(--navy);
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid rgba(15,32,53,.12);
  box-shadow: var(--shadow-sm);
  z-index: 9999;
}
.skip-link:focus{ left: 14px; outline: none; box-shadow: var(--ring); }

.app-navbar{
  background: var(--navy) !important;
  box-shadow: 0 10px 30px rgba(15,19,104,.22);
  transition: background .5s ease, box-shadow .5s ease;
  position: relative;
}
.app-navbar .navbar-brand{ font-weight: 950; }

/* ── Offline state: navbar desaturates to slate ── */
body.is-offline .app-navbar{
  background: #4a5568 !important;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
}

/* Icon button: premium, compact header actions */
.icon-btn{
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color: #fff;
}
.icon-btn:hover{ background: rgba(255,255,255,.12); color: #fff; }
.icon-btn:focus-visible{ outline: none; box-shadow: 0 0 0 .22rem rgba(255,255,255,.20); }
.icon-btn i{ font-size: 20px; line-height: 1; }
.icon-btn.dropdown-toggle::after{ display:none; }

.avatar{
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(86,171,176,.22);
  border: 1px solid rgba(86,171,176,.28);
  font-weight: 950;
  font-size: 13px;
}
.navbar .navbar-brand{
  font-weight: 900;
  letter-spacing: -.01em;
}
.brand-dot{
  width: 10px; height: 10px; border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(200,162,74,.22);
}

.app-main{ padding-top: 16px !important; padding-bottom: 18px !important; }

/* Give mobile room for the bottom nav */
@media (max-width: 991.98px){
  .app-main{ padding-bottom: calc(92px + env(safe-area-inset-bottom)) !important; }
}

.page-title{ font-weight: 900; letter-spacing: -.02em; margin: 0; }
.page-subtitle{ color: var(--muted); margin-top: 2px; }

.card, .app-card{
  background: var(--card);
  border: 1px solid rgba(15,32,53,.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header{
  background: transparent;
  border-bottom: 0;
  padding: 14px 14px 0 14px;
}
.card-body{ padding: 14px; }

.kpi{
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(15,32,53,.08);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

/* KPI tiles inspired by mobile dashboards */
.kpi-tile{
  border-radius: 18px;
  padding: 14px;
  color: #fff;
  border: 1px solid rgba(15,32,53,.08);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-tile .kpi-icon{
  width: 38px; height: 38px; border-radius: 14px;
  display:flex; align-items:center; justify-content:center;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.20);
}
.kpi-tile .kpi-label{ color: rgba(255,255,255,.78); font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin-top: 10px; }
.kpi-tile .kpi-value{ font-size: 28px; font-weight: 950; letter-spacing: -.02em; line-height: 1.0; margin-top: 2px; }
.kpi-tile--blue{ background: linear-gradient(135deg, #1971ff, #22b8ff); }
.kpi-tile--purple{ background: linear-gradient(135deg, #6f42c1, #748ffc); }
.kpi-tile--teal{ background: linear-gradient(135deg, #12b886, #56ABB0); }
.kpi-tile--orange{ background: linear-gradient(135deg, #C8A24A, #f59f00); }
.kpi .kpi-label{ color: var(--muted); font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .kpi-value{ font-size: 28px; font-weight: 950; letter-spacing: -.02em; line-height: 1.0; margin-top: 4px; }
.kpi .kpi-help{ color: var(--muted); font-size: 12px; margin-top: 6px; }

.btn{ border-radius: 12px; font-weight: 800; padding: .58rem .9rem; }
.btn-sm{ padding: .42rem .7rem; border-radius: 12px; font-weight: 800; }
.btn-primary{ background: var(--accent); border-color: var(--accent); }
.btn-primary:hover{ filter: brightness(.96); }
.btn-outline-primary{
  border-color: rgba(200,162,74,.45);
  color: var(--accent);
}
.btn-outline-primary:hover{
  background: rgba(200,162,74,.12);
  border-color: rgba(200,162,74,.55);
  color: var(--accent);
}
.btn-outline-light{ border-color: rgba(255,255,255,.38) !important; }
.btn:focus-visible{ box-shadow: var(--ring); outline: none; }

.form-control, .form-select{
  border-radius: 12px;
  border-color: rgba(15,32,53,.12);
  padding: .62rem .78rem;
}
.form-control:focus, .form-select:focus{
  border-color: rgba(15,19,104,.35);
  box-shadow: var(--ring);
}
label.form-label{ font-weight: 800; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.table-wrap{ overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table{ min-width: 560px; }

/* Responsive chart containers */
.chart-wrap{ height: 200px; }
@media (min-width: 576px){ .chart-wrap{ height: 240px; } }
@media (min-width: 992px){ .chart-wrap{ height: 280px; } }
.table{ margin-bottom: 0; }
.table thead th{
  font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
  border-top: 0;
}
.table td, .table th{ padding: .75rem .6rem; vertical-align: middle; }

.chip{
  display:inline-flex; align-items:center; gap: 8px;
  padding: 6px 10px; border-radius: 999px;
  font-weight: 900; font-size: 12px;
  border: 1px solid rgba(15,32,53,.10);
}
.chip .dot{ width: 8px; height: 8px; border-radius: 50%; }
.chip-assigned{ background: rgba(95,182,88,.12); }
.chip-assigned .dot{ background: var(--green); }
.chip-sold{ background: rgba(236,202,81,.18); }
.chip-sold .dot{ background: var(--yellow); }
.chip-lost{ background: rgba(208,86,54,.12); }
.chip-lost .dot{ background: var(--accent); }
.chip-planned{ background: rgba(86,171,176,.12); }
.chip-planned .dot{ background: var(--teal); }

/* Status pill (scan/search results) */
.status-pill{
  display:inline-flex; align-items:center; gap:8px;
  padding: 6px 10px; border-radius: 999px;
  font-weight: 900; font-size: 12px;
  border: 1px solid rgba(15,32,53,.10);
}
.status-pill::before{ content:''; width:8px; height:8px; border-radius:50%; background: rgba(15,32,53,.35); }
.status-in-stock{ background: rgba(18,184,134,.12); }
.status-in-stock::before{ background: #12b886; }
.status-assigned{ background: rgba(86,171,176,.12); }
.status-assigned::before{ background: var(--teal); }
.status-sold{ background: rgba(236,202,81,.18); }
.status-sold::before{ background: var(--yellow); }
.status-lost{ background: rgba(208,86,54,.12); }
.status-lost::before{ background: var(--accent); }
.status-pending{ background: rgba(255,193,7,.18); }
.status-pending::before{ background: #f0ad00; }
.status-self{ background: rgba(13,110,253,.12); }
.status-self::before{ background: #0d6efd; }
.status-neutral{ background: rgba(15,32,53,.08); }
.status-neutral::before{ background: rgba(15,32,53,.45); }

.overdue-badge{
  display:inline-flex; align-items:center;
  padding: 4px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 900;
  background: rgba(236,202,81,.22);
  /* border: 1px solid rgba(236,202,81,.35); */
}

/* Insight card inspired by the warehouse analytics screens */
.insight-card{
  border-radius: 22px;
  padding: 18px;
  color: #fff;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.18);
  background: radial-gradient(1200px 480px at 10% 10%, rgba(255,255,255,.24), transparent 60%),
              linear-gradient(135deg, #8a4dff, #ff4d6d, #f59f00);
}
.insight-card .tag{
  display:inline-flex; gap:8px; align-items:center;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(0,0,0,.20);
  border: 1px solid rgba(255,255,255,.18);
  font-weight: 900; font-size: 12px;
}
.insight-card .title{ font-weight: 950; font-size: 22px; line-height: 1.15; margin-top: 12px; }
.insight-card .subtitle{ color: rgba(255,255,255,.82); margin-top: 8px; }

/* Bottom navigation */
.bottom-nav{
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  height: 66px;
  padding: 10px 12px;
  display:flex;
  justify-content: space-between;
  gap: 8px;
  border-radius: 22px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(15,32,53,.12);
  box-shadow: 0 14px 40px rgba(15,32,53,.18);
  z-index: 10000;
}
.bottom-nav__item{
  flex:1;
  min-width: 0;
  display:flex;
  flex-direction: column;
  align-items:center;
  justify-content:center;
  gap: 4px;
  color: var(--muted);
  font-weight: 900;
  font-size: 11px;
  border-radius: 16px;
}
.bottom-nav__item i{ font-size: 18px; line-height: 1; }
.bottom-nav__item.is-active{
  color: var(--navy);
  background: rgba(86,171,176,.14);
  border: 1px solid rgba(86,171,176,.22);
}
.bottom-nav__item:focus-visible{ outline:none; box-shadow: var(--ring); }

/* Scan screen frame */
.scan-frame{
  position: relative;
  height: 220px;
  border-radius: 22px;
  background: radial-gradient(900px 260px at 20% 0%, rgba(34,184,255,.18), transparent 55%),
              radial-gradient(900px 260px at 80% 100%, rgba(208,86,54,.14), transparent 55%),
              rgba(15,32,53,.02);
  border: 1px dashed rgba(15,32,53,.20);
  overflow: hidden;
}

.scan-video{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: contrast(1.06) saturate(1.02);
}
.scan-frame__target{
  position:absolute;
  left: 16px; right: 16px; top: 34px; bottom: 46px;
  border-radius: 22px;
  border: 2px solid rgba(15,32,53,.22);
}
.scan-frame__target:before{
  content:'';
  position:absolute;
  left: 12%; right: 12%; top: 50%;
  height: 2px;
  background: rgba(86,171,176,.55);
  box-shadow: 0 0 0 6px rgba(86,171,176,.12);
}
.scan-frame__hint{
  position:absolute;
  left: 0; right: 0; bottom: 14px;
  text-align:center;
  font-weight: 900;
  color: var(--muted);
  font-size: 12px;
}

.row-overdue{
  background: rgba(236,202,81,.22) !important;
  border-left: 4px solid var(--yellow);
}

.sale-details summary{ list-style:none; cursor:pointer; }
.sale-details summary::-webkit-details-marker{ display:none; }
.sale-details[open] summary{ background: rgba(86,171,176,.10); }

.mini-meta{ color: var(--muted); font-size: 12px; }
.section-title{ font-weight: 900; letter-spacing: -.01em; margin-bottom: 8px; }

@media (max-width: 576px){
  .table-wrap table{ min-width: 520px; }
}

/* Header action buttons (nice on mobile): keep a single row, allow horizontal scroll */
.action-grid{ display:flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 575.98px){
  .action-grid{ flex-wrap: nowrap; overflow-x:auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .action-grid .btn{ white-space: nowrap; }
}

/* Recent sales mobile cards */
.sale-card{
  border-radius: 18px;
  border: 1px solid rgba(15,32,53,.08);
  box-shadow: var(--shadow-sm);
  padding: 12px;
  background: #fff;
}
.sale-card__top{ display:flex; align-items:flex-start; justify-content:space-between; gap: 10px; }
.sale-card__device{ font-weight: 950; letter-spacing: -.01em; }
.sale-card__meta{ color: var(--muted); font-size: 12px; }
.sale-card__amount{ font-weight: 950; }
.sale-card__actions{ display:flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* Leaderboard list */
.leaderboard{ list-style: none; padding-left: 0; margin: 0; display:flex; flex-direction: column; gap: 8px; }
.leaderboard__item{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(15,32,53,.08);
  background: rgba(255,255,255,.65);
}
.leaderboard__rank{
  width: 28px; height: 28px;
  border-radius: 12px;
  display:flex; align-items:center; justify-content:center;
  background: rgba(86,171,176,.16);
  border: 1px solid rgba(86,171,176,.22);
  font-weight: 950;
}

/* Offcanvas + modal refinements */
.offcanvas{
  border-top-right-radius: 22px;
  border-bottom-right-radius: 22px;
  border-right: 1px solid rgba(15,32,53,.10);
}
.offcanvas-header{
  border-bottom: 1px solid rgba(15,32,53,.06);
}
.app-navlink{
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 900;
  color: var(--text);
}
.app-navlink:hover{ background: rgba(86,171,176,.12); text-decoration:none; }
.app-modal{ border-radius: 22px; border: 1px solid rgba(15,32,53,.10); box-shadow: var(--shadow); }

/* Backwards compatibility */
.overdue{ background: rgba(236,202,81,.22) !important; border-left: 4px solid var(--yellow); }

/* ===== Premium horizontal pill strip (no wrap + scroll) ===== */
.pill-strip-container {
  position: relative;
}

.pill-strip {
  display: flex;
  flex-wrap: nowrap !important; /* critical */
  gap: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0.25rem 0.35rem;
  scrollbar-width: none; /* Firefox */
  white-space: nowrap;   /* prevents line breaks */
}

.pill-strip::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

/* each pill should never shrink or wrap */
.pill-strip .pill {
  flex: 0 0 auto;         /* critical: prevents shrinking/wrapping */
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.42rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(220, 53, 69, 0.25); /* default-ish, overridden below */
  background: transparent;
  color: var(--bs-primary);
  border-color: rgba(13, 110, 253, 0.35);
}

/* active state */
.pill-strip .pill--active {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
  color: #fff;
}

/* count badge inside a pill */
.pill-strip .pill .pill-count {
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.7;
  letter-spacing: 0;
}
.pill-strip .pill--active .pill-count {
  opacity: 0.85;
}

/* danger (Lost) */
.pill-strip .pill--danger {
  color: var(--bs-danger);
  border-color: rgba(220, 53, 69, 0.35);
}
.pill-strip .pill--danger.pill--active {
  background: var(--bs-danger);
  border-color: var(--bs-danger);
  color: #fff;
}

/* subtle fades to hint scroll */
.pill-strip-container::after,
.pill-strip-container::before {
  content: "";
  position: absolute;
  top: 0;
  width: 28px;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.pill-strip-container::after {
  right: 0;
  background: linear-gradient(to right, rgba(255,255,255,0), var(--bs-body-bg));
}

.pill-strip-container::before {
  left: 0;
  background: linear-gradient(to left, rgba(255,255,255,0), var(--bs-body-bg));
}

/* Overdue pill — matches row highlight color */

.pill--overdue {
  border-color: #ff9800;
  color: #ff9800;
}

.pill--overdue.pill--active {
  background-color: #ff9800;
  border-color: #ff9800;
  color: #fff;
}

/* Top navbar should always be above sticky table headers */
.navbar,
.top-nav,
.app-navbar {
  position: sticky; /* or fixed */
  top: 0;
  z-index: 1050;    /* Bootstrap navbar/modal-friendly */
}

/* Bottom nav (if you have one) */
.bottom-nav,
.app-bottom-nav,
.mobile-nav {
  position: fixed;
  bottom: 0;
  z-index: 1050;
}

.navbar.fixed-top,
.navbar.fixed-bottom { z-index: 1050; }