/* ==============================================================================
   bPOS Executive Dashboard - Modern Soft-Minimal UI
   Executive Indigo / Cobalt & Emerald Palette with Sticky Navbar & Smooth Scroll
   ============================================================================== */

:root {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subcard: #f8fafc;
  --bg-subcard-hover: #f1f5f9;

  --border-card: #e2e8f0;
  --border-subtle: #f1f5f9;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  /* Executive Brand Colors: Indigo & Cobalt */
  --accent-brand-bg: #eef2ff;
  --accent-brand-border: #c7d2fe;
  --accent-brand-text: #4338ca;
  --accent-brand-solid: #4f46e5;
  --accent-brand-glow: rgba(79, 70, 229, 0.15);

  /* Performance Accents */
  --accent-emerald: #059669;
  --accent-emerald-bg: #ecfdf5;
  --accent-emerald-border: #a7f3d0;

  --accent-amber: #d97706;
  --accent-amber-bg: #fffbeb;
  --accent-amber-border: #fde68a;

  --accent-blue: #2563eb;
  --accent-cyan: #0284c7;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-pill: 999px;
  --radius-card: 22px;
  --radius-subcard: 14px;
  --radius-btn: 10px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-card: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -1px rgba(15, 23, 42, 0.02);
  --shadow-sticky: 0 12px 30px -4px rgba(15, 23, 42, 0.08), 0 4px 10px -2px rgba(15, 23, 42, 0.03);
}

/* Enable Global Smooth Scrolling with Header Offset */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 110px;
}

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

html, body {
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-page);
  background-image: 
    radial-gradient(circle at 50% -60px, rgba(79, 70, 229, 0.09), rgba(248, 250, 252, 0) 550px),
    radial-gradient(circle at 10% 120px, rgba(14, 165, 233, 0.06), rgba(248, 250, 252, 0) 450px);
  background-repeat: no-repeat;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Page Outer Container */
.page-container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem 1.5rem 4rem;
  overflow-x: hidden;
}

/* 1. STICKY Header Container (Eliminates scroll overlap & peeking text) */
.sticky-header-container {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-page);
  padding-top: 12px;
  padding-bottom: 8px;
  margin-bottom: 1.25rem;
}

.pill-navbar {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius-card);
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sticky);
  margin-bottom: 0;
  transition: all 0.25s ease;
}

.pill-nav-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.nav-pill {
  padding: 6px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #475569;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-pill:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--text-main);
  transform: translateY(-1px);
}

.nav-pill.active {
  background: var(--accent-brand-bg);
  border-color: var(--accent-brand-border);
  color: var(--accent-brand-text);
  font-weight: 600;
  box-shadow: 0 1px 3px var(--accent-brand-glow);
}

/* 2. Main Hero Header Card */
.hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 2rem 2.25rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 280px;
  height: 100%;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.04), rgba(14, 165, 233, 0.04));
  pointer-events: none;
}

.hero-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-brand-solid);
  margin-bottom: 0.35rem;
}

.hero-title {
  font-size: 2.1rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.hero-subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-pill-brand {
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--accent-brand-border);
  background: var(--accent-brand-bg);
  color: var(--accent-brand-text);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-pill-brand:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
  color: #3730a3;
  transform: translateY(-1px);
}

.status-dot-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.5);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
  100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

/* 3. Scope & Timeframe Ribbon */
.scope-ribbon-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 1rem 1.75rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.scope-select-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.scope-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* Custom Modern Dropdown Container */
.custom-select-container {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.scope-prefix-icon {
  position: absolute;
  left: 14px;
  color: var(--accent-brand-solid);
  pointer-events: none;
  z-index: 2;
  transition: transform 0.2s ease;
}

.scope-chevron-icon {
  position: absolute;
  right: 14px;
  color: var(--accent-brand-solid);
  pointer-events: none;
  z-index: 2;
  transition: transform 0.2s ease;
}

.scope-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  padding: 8px 38px 8px 36px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
}

.scope-select:hover {
  border-color: #c7d2fe;
  background-color: #fbfbfe;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.08);
  transform: translateY(-1px);
}

.custom-select-container:hover .scope-chevron-icon {
  transform: translateY(1px);
}

.scope-select:focus {
  border-color: var(--accent-brand-solid);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px var(--accent-brand-glow), 0 4px 14px rgba(79, 70, 229, 0.08);
}

.scope-select option {
  font-weight: 500;
  padding: 8px;
  background: #ffffff;
  color: #0f172a;
}

.timeframe-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.timeframe-btn {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.timeframe-btn:hover {
  color: var(--text-main);
  border-color: #cbd5e1;
}

.timeframe-btn.active {
  background: var(--accent-brand-bg);
  border-color: var(--accent-brand-border);
  color: var(--accent-brand-text);
  box-shadow: 0 1px 3px var(--accent-brand-glow);
}

.refresh-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.refresh-btn:hover {
  color: var(--text-main);
  border-color: #cbd5e1;
  transform: rotate(45deg);
}

/* 4. Main Section Card */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 1.75rem 2rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.5rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.section-subtitle {
  font-size: 0.84rem;
  color: var(--text-muted);
}

/* 4 Sub-Cards Grid (Responsive Fit) */
.metric-subgrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 1.25rem;
}

@media (max-width: 1100px) {
  .metric-subgrid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 580px) {
  .metric-subgrid {
    grid-template-columns: 1fr;
  }
}

.metric-subcard {
  background: #ffffff;
  border: 1px solid #eef2f6;
  border-radius: 20px;
  padding: 1.4rem 1.25rem 1.25rem;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.03);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.metric-subcard:hover {
  border-color: #cbd5e1;
  box-shadow: 0 10px 25px -4px rgba(15, 23, 42, 0.06);
  transform: translateY(-2px);
}

/* Circular pastel watermark in bottom-right (Matched to main Indigo/Cobalt color) */
.metric-subcard::after {
  content: '';
  position: absolute;
  bottom: -30px;
  right: -30px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  pointer-events: none;
  z-index: 1;
}

/* Featured gradient card (Card 2 - Matched to main soft Indigo/Violet theme) */
.metric-subcard.featured-gradient {
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 45%, #e0e7ff 100%);
  border: 1px solid #c7d2fe;
  box-shadow: 0 4px 20px -2px rgba(99, 102, 241, 0.14);
}

.metric-subcard.featured-gradient::after {
  background: rgba(99, 102, 241, 0.22);
}

.metric-subcard-label {
  font-size: 0.84rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: #475569;
  margin-bottom: 0.75rem;
  z-index: 2;
  position: relative;
}

.metric-subcard-value {
  font-size: clamp(1.35rem, 1.7vw, 1.75rem);
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 0.4rem;
  z-index: 2;
  position: relative;
  white-space: nowrap;
}

.metric-subcard-footer {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 2;
  position: relative;
  font-weight: 500;
  white-space: nowrap;
}

.section-footer-note {
  font-size: 0.82rem;
  color: #94a3b8;
  margin-top: 0.25rem;
}

/* 5. Charts 2-Column Grid */
.charts-2col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

#chartSalesTrend,
#chartBranchComp,
#chartCategories {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

@media (max-width: 950px) {
  .charts-2col {
    grid-template-columns: 1fr;
  }
}

/* 6. Modern Data Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.modern-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.86rem;
}

.modern-table th {
  padding: 12px 16px;
  color: #64748b;
  font-weight: 700;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid #e2e8f0;
  background: transparent;
}

.modern-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  font-weight: 500;
}

.modern-table tr:last-child td {
  border-bottom: none;
}

.modern-table tr:hover td {
  background: #f8fafc;
}

.branch-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.branch-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.pill-green {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent-emerald-bg);
  color: var(--accent-emerald);
  border: 1px solid var(--accent-emerald-border);
}

.pill-amber {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent-amber-bg);
  color: var(--accent-amber);
  border: 1px solid var(--accent-amber-border);
}

.progress-bar-bg {
  width: 100%;
  max-width: 90px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-brand-solid);
}

/* Category & Payment Pills */
.pill-row {
  display: flex;
  gap: 10px;
  margin-top: 1rem;
}

.pill-box {
  flex: 1;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-subcard);
  padding: 12px;
  text-align: center;
}

.pill-box-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
}

.pill-box-val {
  font-size: 1rem;
  font-weight: 800;
  color: #0f172a;
  margin-top: 2px;
}

/* Footer */
.modern-footer {
  text-align: center;
  padding: 2rem 0;
  font-size: 0.8rem;
  color: #94a3b8;
}

/* ==============================================================================
   7. Mobile & Responsive Design System (< 1024px, < 768px, < 480px)
   ============================================================================== */

/* Tablet & Smaller Desktops */
@media (max-width: 1024px) {
  .page-container {
    padding: 0.75rem 1.25rem 3.5rem;
  }
  .metric-subgrid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

/* Tablets & Large Mobile (< 768px) */
@media (max-width: 768px) {
  html {
    scroll-padding-top: 130px;
  }

  body {
    background-size: 100% 280px;
  }

  .page-container {
    padding: 0.5rem 0.75rem 3rem;
  }

  /* 1. Sticky Mobile Navbar */
  .sticky-header-container {
    padding-top: 6px;
    padding-bottom: 6px;
    margin-bottom: 0.75rem;
  }

  .pill-navbar {
    padding: 8px 10px;
    border-radius: 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    box-shadow: 0 4px 18px -2px rgba(15, 23, 42, 0.08);
  }

  /* Top Group: Horizontal touch-scrolling chips */
  .pill-nav-group:first-child {
    width: 100%;
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 2px;
  }

  .pill-nav-group:first-child::-webkit-scrollbar {
    display: none;
  }

  .nav-pill {
    padding: 6px 14px;
    font-size: 0.8rem;
    flex-shrink: 0;
  }

  /* Bottom Group: Utility status bar */
  .pill-nav-group:last-child {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f1f5f9;
    padding-top: 6px;
  }

  .pill-nav-group:last-child .nav-pill,
  .pill-nav-group:last-child .btn-pill-brand {
    font-size: 0.78rem;
    padding: 5px 12px;
  }

  /* 2. Hero Card on Mobile */
  .hero-card {
    padding: 1.25rem 1rem;
    border-radius: 18px;
    margin-bottom: 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
  }

  .hero-card::after {
    display: none;
  }

  .hero-tag {
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    margin-bottom: 0.2rem;
  }

  .hero-title {
    font-size: clamp(1.4rem, 6vw, 1.85rem);
    line-height: 1.2;
  }

  .hero-subtitle {
    font-size: 0.84rem;
    margin-top: 0.25rem;
  }

  .hero-actions {
    width: 100%;
  }

  .hero-actions .btn-pill-brand {
    width: 100%;
    justify-content: center;
    padding: 9px 16px;
    font-size: 0.85rem;
  }

  /* 3. Scope & Timeframe Ribbon on Mobile */
  .scope-ribbon-card {
    padding: 1rem 0.85rem;
    border-radius: 18px;
    margin-bottom: 1rem;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .scope-select-wrap {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .scope-label {
    font-size: 0.72rem;
  }

  .custom-select-container {
    width: 100%;
  }

  .scope-select {
    width: 100%;
    font-size: 0.84rem;
    padding: 9px 34px 9px 34px;
    text-overflow: ellipsis;
  }

  .timeframe-group {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr) 34px;
    gap: 4px;
    align-items: center;
  }

  .timeframe-btn {
    padding: 7px 2px;
    font-size: 0.75rem;
    text-align: center;
    justify-content: center;
    width: 100%;
    border-radius: 8px;
  }

  .refresh-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }

  /* 4. Section Card & Headers */
  .section-card {
    padding: 1.25rem 0.85rem;
    border-radius: 18px;
    margin-bottom: 1rem;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 1rem;
  }

  .section-title {
    font-size: 1.15rem;
  }

  .section-subtitle {
    font-size: 0.78rem;
  }

  /* 5. Metrics Subgrid (< 680px single column) */
  .metric-subgrid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 1rem;
  }

  .metric-subcard {
    padding: 1.15rem 1rem 1rem;
    border-radius: 16px;
  }

  .metric-subcard-label {
    font-size: 0.8rem;
    margin-bottom: 0.35rem;
  }

  .metric-subcard-value {
    font-size: clamp(1.3rem, 6vw, 1.65rem);
  }

  .metric-subcard-footer {
    font-size: 0.76rem;
    flex-wrap: wrap;
    gap: 4px;
  }

  .section-footer-note {
    font-size: 0.74rem;
  }

  /* 6. Charts Grid */
  .charts-2col {
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
  }

  .pill-row {
    flex-direction: column;
    gap: 8px;
  }

  .pill-box {
    width: 100%;
    padding: 10px;
  }

  /* 7. Modern Tables Mobile Scrolling */
  .table-wrap {
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
  }

  .modern-table {
    min-width: 500px;
    font-size: 0.82rem;
  }

  .modern-table th {
    padding: 10px 10px;
    font-size: 0.68rem;
  }

  .modern-table td {
    padding: 11px 10px;
  }

  /* 8. Settings Table on Mobile */
  .credentials-table td:first-child {
    width: 130px !important;
    font-size: 0.78rem;
  }
}

/* Small Smart Phones (< 480px) */
@media (max-width: 480px) {
  .page-container {
    padding: 0.35rem 0.5rem 2.5rem;
  }

  .hero-card,
  .scope-ribbon-card,
  .section-card {
    padding: 1rem 0.75rem;
    border-radius: 16px;
  }

  .hero-title {
    font-size: 1.35rem;
  }

  .timeframe-group {
    grid-template-columns: repeat(4, 1fr) 30px;
    gap: 3px;
  }

  .timeframe-btn {
    font-size: 0.7rem;
    padding: 6px 1px;
  }

  .refresh-btn {
    width: 30px;
    height: 30px;
  }

  .metric-subcard {
    padding: 1rem 0.85rem;
  }

  .credentials-table,
  .credentials-table tbody,
  .credentials-table tr,
  .credentials-table td {
    display: block;
    width: 100% !important;
  }

  .credentials-table tr {
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
  }

  .credentials-table td {
    padding: 3px 0 !important;
    border-bottom: none !important;
  }

  .credentials-table td:first-child {
    color: #64748b;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
}

