:root {
  --bg: #EFF4F8;
  --surface: #ffffff;
  --surface-alt: #EFF4F8;
  --sidebar: #0B132B;
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active: #D97706;
  --text: #0B132B;
  --text-muted: #3A506B;
  --border: rgba(11, 19, 43, 0.08);
  --border-strong: rgba(11, 19, 43, 0.14);
  --primary: #1C2541;
  --primary-hover: #0B132B;
  --accent: #5BC0DE;
  --gold: #d97706;
  --gold-bright: #D97706;
  --gold-soft: #F4D6B0;
  --emerald: #5BC0DE;
  --emerald-bg: rgba(91, 192, 222, 0.16);
  --danger: #D97706;
  --danger-bg: #F4D6B0;
  --amber: #d97706;
  --amber-bg: #F4D6B0;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(11, 19, 43, 0.04), 0 10px 28px -6px rgba(11, 19, 43, 0.055);
  --shadow-hover: 0 4px 12px rgba(11, 19, 43, 0.07), 0 16px 34px -8px rgba(11, 19, 43, 0.09);
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'IBM Plex Sans Arabic', 'Readex Pro', 'Segoe UI', Tahoma, Arial, sans-serif;
  background:
    radial-gradient(circle at 85% 0%, rgba(91, 192, 222, 0.06), transparent 42%),
    radial-gradient(circle at 12% 4%, rgba(217, 119, 6, 0.055), transparent 36%),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, .kpi-value, .hl-value {
  font-family: 'Readex Pro', 'IBM Plex Sans Arabic', sans-serif;
}

/* Smooth Top Filter Loading Progress Hairline */
.filter-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 3000;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg, #1C2541 0%, #5BC0DE 45%, #D97706 85%, #5BC0DE 100%);
  background-size: 200% 100%;
  transform: scaleX(0);
  transform-origin: right center;
  transition: opacity 0.22s ease, transform 0.38s var(--ease-spring);
}

.filter-progress-bar.active {
  opacity: 1;
  transform: scaleX(0.78);
  animation: progressShimmer 1.1s linear infinite;
}

.filter-progress-bar.done {
  opacity: 0;
  transform: scaleX(1);
}

@keyframes progressShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: 0% 0; }
}

.hidden { display: none !important; }
.print-only { display: none; }

/* Layout */
.app-shell {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: linear-gradient(180deg, #0B132B 0%, #1C2541 58%, #1C2541 100%);
  color: #EFF4F8;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #ffffff;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 2px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 6px 18px rgba(11, 19, 43, 0.28);
}

.brand-logo img,
.auth-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.app-brand-cell {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  vertical-align: middle;
}

.app-logo-img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  background: #fff;
  border: 1px solid #EFF4F8;
  box-shadow: 0 1px 3px rgba(11, 19, 43, 0.08);
  flex-shrink: 0;
}

.app-logo-sm {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  object-fit: cover;
  background: #fff;
  border: 1px solid rgba(11, 19, 43, 0.1);
  flex-shrink: 0;
}

.promo-channel-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.brand-text h1 {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}

.brand-text span {
  font-size: 12px;
  color: #3A506B;
}

.connection-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.conn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3A506B;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.live { background: #5BC0DE; box-shadow: 0 0 0 3px rgba(91, 192, 222, 0.22); }
.status-dot.demo { background: #D97706; box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.22); }
.status-dot.error { background: #D97706; box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.22); }

.conn-meta {
  font-size: 11.5px;
  color: #3A506B;
  word-break: break-word;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  width: 100%;
  border: none;
  background: transparent;
  color: #F4D6B0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 14px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: right;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(217, 119, 6, 0.18), rgba(91, 192, 222, 0.14));
  color: #fff;
  border-right: 3px solid var(--sidebar-active);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.nav-ico { font-size: 16px; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.security-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(91, 192, 222, 0.1);
  border: 1px solid rgba(91, 192, 222, 0.22);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
}

.security-badge strong {
  display: block;
  color: #5BC0DE;
  font-size: 12px;
}

.security-badge small {
  color: #3A506B;
  font-size: 11px;
}

/* Main Content */
.main-content {
  padding: 22px 26px 40px;
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
}

/* Banners */
.notice-banner {
  background: linear-gradient(90deg, #F4D6B0, #F4D6B0);
  border: 1px solid #F4D6B0;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.notice-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.notice-ico { font-size: 22px; }
.notice-content strong { display: block; color: #D97706; font-size: 14px; }
.notice-content p { color: #D97706; font-size: 12.5px; }
.notice-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.error-banner {
  background: var(--danger-bg);
  border: 1px solid #F4D6B0;
  color: #D97706;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  font-weight: 600;
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.topbar-title h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

.topbar-title p {
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Buttons */
button {
  font-family: inherit;
}

.btn-primary, .btn-secondary, .btn-ghost, .btn-outline-light {
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  padding: 9px 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.65; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-alt); border-color: #F4D6B0; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: #EFF4F8; color: var(--text); }

.btn-outline-light {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
}
.btn-outline-light:hover { background: rgba(255, 255, 255, 0.16); }

.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }

.spinning {
  display: inline-block;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Filter Bar */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filter-row-top,
.filter-row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-row-top {
  padding-bottom: 10px;
  border-bottom: 1px solid #EFF4F8;
}

.day-mode-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.day-mode-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.mode-pill {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-pill:hover {
  border-color: var(--accent);
  color: var(--text);
}

.mode-pill.active {
  background: linear-gradient(135deg, #1C2541, #5BC0DE);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(91, 192, 222, 0.22);
}

.window-preview-badge {
  font-size: 12px;
  font-weight: 700;
  color: #1C2541;
  background: rgba(91, 192, 222, 0.16);
  border: 1px solid rgba(91, 192, 222, 0.35);
  padding: 6px 12px;
  border-radius: 9px;
}

.active-filter-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(91, 192, 222, 0.16);
  border: 1px solid rgba(91, 192, 222, 0.35);
  color: #1C2541;
  font-size: 13px;
  font-weight: 700;
}

.warehouse-coverage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 14px;
  border-radius: 10px;
  background: #F4D6B0;
  border: 1px solid #F4D6B0;
  color: #D97706;
  font-size: 12.5px;
  font-weight: 700;
}

.sync-controls-row {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #EFF4F8;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5BC0DE, #5BC0DE);
  transition: width 0.35s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.mini-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.cust-type-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
}
.cust-type-pill.reg { background: rgba(91, 192, 222, 0.16); color: #1C2541; }
.cust-type-pill.walk { background: #EFF4F8; color: #3A506B; }
.cust-type-pill.cat-delivery_app { background: rgba(91, 192, 222, 0.16); color: #1C2541; }
.cust-type-pill.cat-company_app { background: rgba(91, 192, 222, 0.16); color: #1C2541; }
.cust-type-pill.cat-direct { background: rgba(91, 192, 222, 0.16); color: #1C2541; }
.cust-type-pill.cat-employees { background: #F4D6B0; color: #D97706; }
.cust-type-pill.cat-special { background: #F4D6B0; color: #D97706; }
.cust-type-pill.cat-other { background: #EFF4F8; color: #3A506B; }

/* Payment Count + Smaller Value side-by-side */
.pay-metric {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.pay-count {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text);
}

.pay-amount {
  font-size: 11.5px;
  font-weight: 600;
  color: #3A506B;
  background: #EFF4F8;
  padding: 1px 7px;
  border-radius: 6px;
}

.pay-metric.pay-zero .pay-count {
  color: #3A506B;
  font-weight: 600;
}

.pay-metric.pay-zero .pay-amount {
  color: #3A506B;
  background: transparent;
  padding: 0;
}

.data-table tfoot .pay-amount {
  background: #EFF4F8;
  color: #0B132B;
  font-weight: 700;
}

/* Sub-tabs inside Sold Products */
.subtabs-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.subtab-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow);
}

.subtab-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.subtab-btn.active {
  background: linear-gradient(135deg, #0B132B, #1C2541);
  color: #fff;
  border-color: transparent;
}

.prod-subpanel {
  display: none;
}

.prod-subpanel.active {
  display: block;
}

@media print {
  .prod-subpanel {
    display: block !important;
    margin-bottom: 14px;
  }
}

@media (max-width: 1100px) {
  .mini-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
  .mini-kpi-grid { grid-template-columns: 1fr; }
}

.presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover { border-color: var(--accent); color: var(--text); }
.preset-btn.active {
  background: #0B132B;
  color: #fff;
  border-color: #0B132B;
}

.filter-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.field-inline input,
.field-inline select,
.search-input {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.field-inline input:focus,
.field-inline select:focus,
.search-input:focus {
  outline: 2px solid rgba(91, 192, 222, 0.25);
  border-color: var(--accent);
}

/* Visual Brand & Delivery Apps Quick-Filter Dock */
.brand-dock-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(11, 19, 43, 0.06);
  overflow-x: auto;
  scrollbar-width: thin;
}

.brand-dock-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.brand-dock {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: nowrap;
  padding: 2px 0 4px;
}

.brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.2s var(--ease-spring), border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.brand-chip:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 5px 14px rgba(28, 37, 65, 0.11);
}

.brand-chip:active {
  transform: scale(0.96);
}

.brand-chip.active {
  background: linear-gradient(135deg, #0B132B 0%, #1C2541 100%);
  color: #ffffff;
  border-color: #D97706;
  box-shadow: 0 6px 18px rgba(28, 37, 65, 0.24), 0 0 0 2px rgba(217, 119, 6, 0.28);
  animation: chipPop 0.3s var(--ease-spring);
}

.brand-chip img {
  width: 21px;
  height: 21px;
  border-radius: 6px;
  object-fit: cover;
  background: #ffffff;
  border: 1px solid rgba(11, 19, 43, 0.1);
  flex-shrink: 0;
}

.brand-chip-share {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: #EFF4F8;
  color: #3A506B;
}

.brand-chip.active .brand-chip-share {
  background: rgba(217, 119, 6, 0.24);
  color: #F4D6B0;
}

.brand-chip-stack {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
}

.brand-chip-stack img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  margin-right: -5px;
  border: 1.5px solid #ffffff;
  box-shadow: 0 1px 3px rgba(11, 19, 43, 0.15);
}

.brand-chip-stack img:first-child { margin-right: 0; }

@keyframes chipPop {
  0% { transform: scale(0.93); }
  55% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* Tab Panels & Smooth Filter Transitions */
.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  animation: panelFadeSlide 0.28s var(--ease-spring);
}

.prod-subpanel.active,
.adm-subpanel.active {
  animation: panelFadeSlide 0.24s var(--ease-spring);
}

@keyframes panelFadeSlide {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.main-content.is-filtering .tab-panel.active {
  opacity: 0.62;
  transform: translateY(2px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.main-content.filter-settled .kpi-card {
  animation: kpiReveal 0.36s var(--ease-spring) both;
}
.main-content.filter-settled .kpi-card:nth-child(2) { animation-delay: 0.03s; }
.main-content.filter-settled .kpi-card:nth-child(3) { animation-delay: 0.06s; }
.main-content.filter-settled .kpi-card:nth-child(4) { animation-delay: 0.09s; }
.main-content.filter-settled .kpi-card:nth-child(5) { animation-delay: 0.12s; }

@keyframes kpiReveal {
  from {
    opacity: 0.75;
    transform: translateY(6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.kpi-value.kpi-flash {
  animation: kpiValueGlow 0.55s var(--ease-spring);
}

@keyframes kpiValueGlow {
  0% { opacity: 0.45; transform: translateY(3px); }
  100% { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: transform 0.22s var(--ease-spring), box-shadow 0.22s ease, border-color 0.22s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(91, 192, 222, 0.22);
}

.kpi-card.kpi-primary {
  background: linear-gradient(135deg, #0B132B 0%, #1C2541 55%, #1C2541 100%);
  color: #fff;
  border-color: rgba(217, 119, 6, 0.35);
  box-shadow: 0 12px 28px -6px rgba(28, 37, 65, 0.34);
}

.kpi-card.kpi-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #D97706, #5BC0DE, #5BC0DE);
}

.kpi-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-card.kpi-primary .kpi-head { color: #F4D6B0; }

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.kpi-card.kpi-primary .kpi-sub { color: #F4D6B0; }

.kpi-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #EFF4F8;
  color: #3A506B;
  white-space: nowrap;
}

.kpi-badge.up { background: var(--emerald-bg); color: var(--emerald); }
.kpi-badge.down { background: var(--danger-bg); color: var(--danger); }
.kpi-card.kpi-primary .kpi-badge.up { background: rgba(91, 192, 222, 0.2); color: #5BC0DE; }
.kpi-card.kpi-primary .kpi-badge.down { background: rgba(217, 119, 6, 0.2); color: #F4D6B0; }

/* Highlights */
.highlights-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.highlight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 17px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s ease;
}

.highlight-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.hl-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}

.hl-emerald { background: rgba(91, 192, 222, 0.16); }
.hl-sky { background: rgba(91, 192, 222, 0.16); }
.hl-amber { background: #F4D6B0; }

.hl-label { display: block; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.hl-value { display: block; font-size: 15px; font-weight: 700; color: var(--text); }
.hl-sub { display: block; font-size: 12px; color: var(--text-muted); }

/* Cards & Charts */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.22s ease;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-header h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.card-header p {
  font-size: 12.5px;
  color: var(--text-muted);
}

.card-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.charts-grid-main {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.charts-grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.chart-wrap {
  position: relative;
  height: 300px;
  width: 100%;
}

.chart-wrap.chart-tall { height: 320px; }
.chart-wrap.chart-donut { height: 220px; }

.mini-legend {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--surface-alt);
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  background: #EFF4F8;
  color: #3A506B;
  font-weight: 700;
  text-align: right;
  padding: 11px 12px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid #EFF4F8;
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #EFF4F8;
}

.data-table tfoot td {
  background: #EFF4F8;
  font-weight: 800;
  border-top: 2px solid #F4D6B0;
  padding: 12px;
}

.num-cell { font-weight: 700; white-space: nowrap; }

.share-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 125px;
}

.share-bar {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: #EFF4F8;
  overflow: hidden;
}

.share-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5BC0DE, #5BC0DE);
}

.state-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(91, 192, 222, 0.16);
  color: #1C2541;
}
.state-pill.done { background: rgba(91, 192, 222, 0.16); color: #1C2541; }
.state-pill.invoiced { background: rgba(91, 192, 222, 0.16); color: #1C2541; }

/* Reports Center */
.export-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.export-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.export-ico { font-size: 28px; }
.export-card h3 { font-size: 16px; font-weight: 800; }
.export-card p { font-size: 13px; color: var(--text-muted); flex: 1; }

.csv-buttons-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.archive-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
}

.files-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}

.file-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 13px;
}

.file-name {
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
  direction: ltr;
  text-align: left;
}

.file-meta {
  font-size: 11.5px;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 26px 12px;
  font-size: 13.5px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 19, 43, 0.58);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 18px;
}

.modal-card {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 540px;
  box-shadow: 0 24px 60px rgba(11, 19, 43, 0.25);
  overflow: hidden;
}

.modal-header {
  padding: 18px 22px;
  background: #0B132B;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.modal-header h3 { font-size: 17px; font-weight: 800; }
.modal-header p { font-size: 12.5px; color: #F4D6B0; margin-top: 2px; }
.modal-close {
  background: transparent;
  border: none;
  color: #F4D6B0;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: #fff; }

.modal-body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field span {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.form-field input {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid #F4D6B0;
  border-radius: 10px;
}

.form-field input:focus {
  outline: 2px solid rgba(91, 192, 222, 0.25);
  border-color: var(--accent);
}

.form-field small {
  font-size: 11.5px;
  color: var(--text-muted);
}

.modal-status {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
}

.modal-status.ok { background: var(--emerald-bg); color: #1C2541; border: 1px solid rgba(91, 192, 222, 0.35); }
.modal-status.err { background: var(--danger-bg); color: #D97706; border: 1px solid #F4D6B0; }

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Classification Quality Audit Panel */
.audit-summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}

.audit-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
}

.audit-pill.ok {
  background: rgba(91, 192, 222, 0.16);
  border-color: rgba(91, 192, 222, 0.35);
  color: #1C2541;
}

.audit-pill.warn {
  background: #F4D6B0;
  border-color: #F4D6B0;
  color: #D97706;
}

.audit-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.audit-subtab {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.audit-subtab:hover {
  border-color: #3A506B;
  color: var(--text);
}

.audit-subtab.active {
  background: #0B132B;
  border-color: #0B132B;
  color: #fff;
}

.audit-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.audit-meta-note {
  margin-right: auto;
  font-size: 12px;
  color: var(--text-muted);
}

.audit-table-wrap {
  max-height: 440px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.audit-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: #EFF4F8;
  color: #3A506B;
}
.audit-badge.cash { background: rgba(91, 192, 222, 0.16); color: #1C2541; }
.audit-badge.card { background: rgba(91, 192, 222, 0.16); color: #1C2541; }
.audit-badge.credit { background: rgba(91, 192, 222, 0.16); color: #1C2541; }
.audit-badge.warn { background: #F4D6B0; color: #D97706; }

.audit-id-chip {
  display: inline-block;
  margin: 2px 3px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #EFF4F8;
  border: 1px solid #EFF4F8;
  font-size: 12px;
  color: #3A506B;
}

/* Promotions Executive Analytics Badges */
.promo-status-dot {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  margin-right: 6px;
}
.promo-status-dot.active { background: rgba(91, 192, 222, 0.16); color: #1C2541; border: 1px solid rgba(91, 192, 222, 0.35); }
.promo-status-dot.archived { background: #EFF4F8; color: #3A506B; border: 1px solid #F4D6B0; }

.promo-channel-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(91, 192, 222, 0.16);
  color: #1C2541;
  white-space: nowrap;
}
.promo-rule-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
}
.promo-rule-box strong { color: #0B132B; }
.promo-rule-box small { color: #3A506B; }
.promo-targets-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 260px;
}
.promo-target-chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  background: #EFF4F8;
  border: 1px solid #EFF4F8;
  font-size: 11.5px;
  color: #3A506B;
}

/* Auth Overlay, Sidebar User Card & Admin RBAC UI */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: linear-gradient(135deg, #0B132B 0%, #1C2541 50%, #1C2541 100%);
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 28px 70px rgba(11, 19, 43, 0.42);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.auth-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #ffffff;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 2px;
  border: 1.5px solid #EFF4F8;
  box-shadow: 0 4px 12px rgba(11, 19, 43, 0.1);
}

.auth-brand h2 { font-size: 17px; font-weight: 800; color: #0B132B; }
.auth-brand p { font-size: 12.5px; color: #3A506B; margin-top: 2px; }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-submit-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  justify-content: center;
}

.auth-foot-note {
  text-align: center;
  font-size: 12px;
  color: #3A506B;
}

.totp-banner {
  background: rgba(91, 192, 222, 0.16);
  border: 1px solid rgba(91, 192, 222, 0.35);
  border-radius: 12px;
  padding: 12px 14px;
  color: #1C2541;
  font-size: 13px;
}
.totp-banner p { margin-top: 4px; font-size: 12px; color: #5BC0DE; }

.user-profile-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-prof-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #5BC0DE, #5BC0DE);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.user-prof-info { min-width: 0; }
.user-prof-info strong { display: block; color: #fff; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-prof-info small { display: block; color: #3A506B; font-size: 11.5px; }
.user-prof-meta { font-size: 11.5px; color: #F4D6B0; background: rgba(11, 19, 43, 0.35); padding: 4px 8px; border-radius: 8px; }

.adm-subpanel { display: none; }
.adm-subpanel.active { display: block; }

.modal-card-lg { max-width: 720px; }
.ua-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-grid-branches {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #EFF4F8;
}
.check-grid-branches label, .perms-check-grid label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.check-grid-branches label:hover, .perms-check-grid label:hover { background: #EFF4F8; }

.perms-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #EFF4F8;
}

.perms-override-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.perm-override-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  background: #fff;
  border: 1px solid #EFF4F8;
  border-radius: 8px;
  padding: 5px 8px;
}
.perm-override-row select {
  font-family: inherit;
  font-size: 11.5px;
  padding: 2px 6px;
  border: 1px solid #F4D6B0;
  border-radius: 6px;
}

.roles-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.role-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.role-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.role-card-head h4 { font-size: 15px; font-weight: 800; color: var(--text); }
.role-card-desc { font-size: 12.5px; color: var(--text-muted); }
.role-perms-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.role-perm-chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(91, 192, 222, 0.16); color: #1C2541; }
.role-perm-chip.off { background: #F4D6B0; color: #D97706; }

@media (max-width: 720px) {
  .ua-grid-2, .check-grid-branches, .perms-check-grid, .perms-override-grid, .roles-grid { grid-template-columns: 1fr; }
}

/* Responsive */
@media (max-width: 1220px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .charts-grid-main, .charts-grid-two, .archive-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .kpi-grid, .highlights-grid, .export-cards-grid { grid-template-columns: 1fr; }
}

/* ============================================================================
   Executive A4 Print / PDF Report Stylesheet
   ============================================================================ */
@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }

  body {
    background: #fff !important;
    color: #0B132B !important;
    font-size: 11px;
  }

  .no-print { display: none !important; }
  .print-only { display: block !important; }

  .app-shell { display: block !important; }
  .main-content { padding: 0 !important; max-width: 100% !important; }

  .print-header {
    border-bottom: 3px solid #0B132B;
    padding-bottom: 10px;
    margin-bottom: 14px;
  }

  .print-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
  }

  .print-header h1 { font-size: 18px; font-weight: 800; color: #0B132B; }
  .print-header p { font-size: 11px; color: #3A506B; }
  .print-meta { font-size: 10.5px; text-align: left; color: #3A506B; }

  /* Show all key analytical sections in the PDF report */
  .tab-panel.print-section {
    display: block !important;
    margin-bottom: 16px;
  }

  .kpi-grid {
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 8px !important;
  }

  .kpi-card {
    box-shadow: none !important;
    border: 1px solid #F4D6B0 !important;
    padding: 10px !important;
    break-inside: avoid;
  }

  .kpi-card.kpi-primary {
    background: #0B132B !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .kpi-value { font-size: 15px !important; }

  .highlights-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
  }

  .charts-grid-main, .charts-grid-two {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #F4D6B0 !important;
    padding: 12px !important;
    break-inside: avoid;
    margin-bottom: 10px;
  }

  .chart-wrap { height: 210px !important; }

  .data-table th {
    background: #0B132B !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    padding: 6px 8px !important;
    font-size: 10.5px !important;
  }

  .data-table td {
    padding: 6px 8px !important;
    font-size: 10.5px !important;
  }

  .print-footer {
    display: flex !important;
    justify-content: space-between;
    border-top: 1px solid #F4D6B0;
    padding-top: 8px;
    margin-top: 14px;
    font-size: 10px;
    color: #3A506B;
  }
}
