/* ==========================================================================
   InsightDeck Design System Stylesheet
   Polished, presentation-ready, persuasive business intelligence theme.
   Teal-driven palette (#0D9488), Purple accents (#9333EA), Pink callouts (#EC4899).
   Desktop-first architecture with dedicated mobile navigation (<= 768px).
   ========================================================================== */

/* ---------------------------------------------------------------------------
   1. Design Tokens & Variables
   --------------------------------------------------------------------------- */
:root {
  /* InsightDeck Core Colors */
  --color-primary:         #0D9488; /* Teal: Core actions, highlights, active nav */
  --color-primary-hover:   #0F766E;
  --color-primary-active:  #115E59;
  --color-primary-light:   #CCFBF1;
  --color-primary-subtle:  rgba(13, 148, 136, 0.12);

  --color-secondary:       #9333EA; /* Purple: Accents, premium, insight callouts */
  --color-secondary-hover: #7E22CE;
  --color-secondary-light: #F3E8FF;
  --color-secondary-subtle:rgba(147, 51, 234, 0.12);

  --color-tertiary:        #EC4899; /* Pink: Trend indicators, alert badges */
  --color-tertiary-hover:  #DB2777;
  --color-tertiary-light:  #FCE7F3;
  --color-tertiary-subtle: rgba(236, 72, 153, 0.12);

  /* InsightDeck Canvas & Surfaces */
  --color-bg:              #F8FAFC; /* Global page background (Slate 50) */
  --color-surface:         #FFFFFF; /* Cards, panels, tables */
  --color-surface-hover:   #F1F5F9;
  --color-surface-elevated:#FFFFFF;
  --color-border:          #E2E8F0; /* Slate 200 */
  --color-border-subtle:   #F1F5F9;

  /* Typography / Text Colors */
  --color-text-main:       #0F172A; /* Slate 900 */
  --color-text-muted:      #64748B; /* Slate 500 */
  --color-text-subtle:     #94A3B8; /* Slate 400 */
  --color-text-inverse:    #FFFFFF;

  /* Semantic Feedback */
  --color-success:         #10B981;
  --color-success-bg:      #ECFDF5;
  --color-success-border:  #A7F3D0;
  --color-warning:         #F59E0B;
  --color-warning-bg:      #FFFBEB;
  --color-warning-border:  #FDE68A;
  --color-error:           #EF4444;
  --color-error-bg:        #FEF2F2;
  --color-error-border:    #FECACA;
  --color-info:            #3B82F6;
  --color-info-bg:         #EFF6FF;
  --color-info-border:     #BFDBFE;

  /* Backward Compatibility Aliases */
  --ps-primary:            var(--color-primary);
  --ps-primary-hover:      var(--color-primary-hover);
  --ps-primary-pressed:    var(--color-primary-active);
  --ps-canvas-dark:        var(--color-bg);
  --ps-surface-dark:       var(--color-surface);
  --ps-surface-dark-elevated: var(--color-surface-elevated);
  --ps-hairline-dark:      var(--color-border);
  --ps-on-dark:            var(--color-text-main);
  --ps-body-dark:          var(--color-text-main);
  --ps-mute-dark:          var(--color-text-muted);
  --ps-success:            var(--color-success);
  --ps-warning:            var(--color-warning);
  --ps-error:              var(--color-error);

  /* Typography Stack */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Elevation Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.06);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------------------------------------------------------------------------
   Dark Theme Variant (Persisted via data-theme="dark")
   --------------------------------------------------------------------------- */
[data-theme="dark"] {
  --color-bg:              #0B1120; /* Slate 950 Deep Canvas */
  --color-surface:         #151F32; /* Slate 900 Surface Card */
  --color-surface-hover:   #1E293B; /* Slate 800 */
  --color-surface-elevated:#1E293B;
  --color-border:          #24324D;
  --color-border-subtle:   #1A253C;

  --color-text-main:       #F8FAFC;
  --color-text-muted:      #94A3B8;
  --color-text-subtle:     #64748B;
  --color-text-inverse:    #0F172A;

  --color-primary:         #14B8A6; /* Vibrant Teal */
  --color-primary-hover:   #2DD4BF;
  --color-primary-light:   #134E4A;
  --color-primary-subtle:  rgba(20, 184, 166, 0.18);

  --color-secondary:       #A855F7;
  --color-secondary-hover: #C084FC;
  --color-secondary-light: #581C87;
  --color-secondary-subtle:rgba(168, 85, 247, 0.18);

  --color-tertiary:        #F472B6;
  --color-tertiary-hover:  #F687B3;
  --color-tertiary-light:  #831843;
  --color-tertiary-subtle: rgba(244, 114, 182, 0.18);

  --color-success-bg:      rgba(16, 185, 129, 0.15);
  --color-success-border:  rgba(16, 185, 129, 0.3);
  --color-warning-bg:      rgba(245, 158, 11, 0.15);
  --color-warning-border:  rgba(245, 158, 11, 0.3);
  --color-error-bg:        rgba(239, 68, 68, 0.15);
  --color-error-border:    rgba(239, 68, 68, 0.3);
  --color-info-bg:         rgba(59, 130, 246, 0.15);
  --color-info-border:     rgba(59, 130, 246, 0.3);

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

/* ---------------------------------------------------------------------------
   2. Reset & Global Layout
   --------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-family);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  min-height: 100vh;
  background-color: var(--color-bg);
  color: var(--color-text-main);
  line-height: 1.5;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ---------------------------------------------------------------------------
   3. Typography
   --------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-text-main);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

p {
  color: var(--color-text-main);
}

.text-muted {
  color: var(--color-text-muted) !important;
}

.text-center {
  text-align: center;
}

.mt-sm {
  margin-top: 6px;
}

.cell-strong {
  font-weight: 600;
  color: var(--color-text-main);
}

/* ---------------------------------------------------------------------------
   4. Header & Navigation (InsightDeck Deck Bar)
   --------------------------------------------------------------------------- */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

[data-theme="dark"] header {
  background-color: rgba(21, 31, 50, 0.88);
  border-bottom-color: var(--color-border);
}

.navbar {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-text-main);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  transition: opacity var(--transition-fast);
}

.nav-brand:hover {
  opacity: 0.9;
}

.brand-icon-badge {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary), #065F46);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.35);
}

.brand-system-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background-color: var(--color-primary-subtle);
  color: var(--color-primary);
  border: 1px solid rgba(13, 148, 136, 0.2);
  margin-left: 4px;
}

/* Desktop Nav Links */
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-link:hover {
  color: var(--color-text-main);
  background-color: var(--color-surface-hover);
}

.nav-link.active {
  color: var(--color-primary);
  background-color: var(--color-primary-subtle);
  font-weight: 600;
}

/* Nav Actions (Tools, Language, Theme, Presentation, User) */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background-color: transparent;
  color: var(--color-text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.nav-tool-btn:hover {
  color: var(--color-text-main);
  background-color: var(--color-surface-hover);
  border-color: var(--color-border);
}

.nav-tool-btn.active {
  color: var(--color-primary);
  background-color: var(--color-primary-subtle);
  border-color: rgba(13, 148, 136, 0.3);
}

/* Unified Single-Click Language Toggle Switch */
.lang-toggle-switch {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  border-radius: var(--radius-full);
}

.lang-toggle-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  background-color: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 2px;
  width: 60px;
  height: 28px;
  box-sizing: border-box;
  transition: all var(--transition-fast);
}

.lang-toggle-switch:hover .lang-toggle-track {
  border-color: var(--color-primary);
}

.lang-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 22px;
  background-color: var(--color-surface);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition-fast);
  z-index: 1;
}

[data-theme="dark"] .lang-toggle-thumb {
  background-color: var(--color-border);
}

.lang-toggle-thumb.lang-en {
  transform: translateX(28px);
}

.lang-label {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  z-index: 2;
  transition: color var(--transition-fast);
  line-height: 22px;
}

.lang-label.active {
  color: var(--color-primary);
  font-weight: 700;
}

/* Account & Logout Buttons */
.nav-btn-account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-main);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.nav-btn-account:hover {
  background-color: var(--color-surface-hover);
  border-color: var(--color-primary);
}

.nav-btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background-color: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav-btn-logout:hover {
  color: var(--color-error);
  border-color: var(--color-error-border);
  background-color: var(--color-error-bg);
}

.nav-btn-login {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background-color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-md);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-fast);
  box-shadow: 0 1px 2px rgba(13, 148, 136, 0.2);
}

.nav-btn-login:hover {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}



body.presentation-mode .container {
  max-width: 100% !important;
  padding: 20px 32px !important;
}

body.presentation-mode {
  background-color: var(--color-surface);
}

.presentation-exit-btn {
  display: none;
}

body.presentation-mode .presentation-exit-btn {
  display: flex;
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background-color: var(--color-surface);
  color: var(--color-text-main);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

body.presentation-mode .presentation-exit-btn:hover {
  background-color: var(--color-surface-hover);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ---------------------------------------------------------------------------
   6. Main Container & Cards
   --------------------------------------------------------------------------- */
.container {
  flex: 1;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.card-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text-main);
  letter-spacing: -0.015em;
  margin: 0;
}

/* ---------------------------------------------------------------------------
   7. InsightDeck Business Intelligence KPI Grid
   Data clarity and visual storytelling
   --------------------------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(13, 148, 136, 0.3);
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--color-border);
}

.stat-card.stat-primary::before {
  background: linear-gradient(90deg, var(--color-primary), #14B8A6);
}

.stat-card.stat-secondary::before {
  background: linear-gradient(90deg, var(--color-secondary), #A855F7);
}

.stat-card.stat-tertiary::before {
  background: linear-gradient(90deg, var(--color-tertiary), #F472B6);
}

.stat-card.stat-info::before {
  background: linear-gradient(90deg, var(--color-info), #60A5FA);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.stat-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-surface-hover);
  color: var(--color-text-muted);
}

.stat-card.stat-primary .stat-icon {
  background-color: var(--color-primary-subtle);
  color: var(--color-primary);
}

.stat-card.stat-secondary .stat-icon {
  background-color: var(--color-secondary-subtle);
  color: var(--color-secondary);
}

.stat-card.stat-tertiary .stat-icon {
  background-color: var(--color-tertiary-subtle);
  color: var(--color-tertiary);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-text-main);
  letter-spacing: -0.02em;
}

.stat-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background-color: var(--color-surface-hover);
  color: var(--color-text-muted);
}

.stat-badge.badge-trend-up {
  background-color: var(--color-primary-subtle);
  color: var(--color-primary);
}

.stat-badge.badge-trend-highlight {
  background-color: var(--color-tertiary-subtle);
  color: var(--color-tertiary);
}

/* Visual Progress Bar (BI Visual Gauge) */
.quota-meter-wrapper {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
}

.quota-meter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
}

.quota-meter-track {
  width: 100%;
  height: 10px;
  background-color: var(--color-surface-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.quota-meter-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.quota-meter-fill.meter-warning {
  background: linear-gradient(90deg, #F59E0B, #EF4444);
}

/* ---------------------------------------------------------------------------
   8. Tables (Presentation-ready, clean BI data styling)
   --------------------------------------------------------------------------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

thead th {
  background-color: var(--color-bg);
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background-color var(--transition-fast);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background-color: var(--color-surface-hover);
}

tbody td {
  padding: 14px 16px;
  vertical-align: middle;
  color: var(--color-text-main);
}

/* ---------------------------------------------------------------------------
   9. Toolbar, Search & Column Visibility
   --------------------------------------------------------------------------- */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-form-unified {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 420px;
}

.search-input-unified {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background-color: var(--color-surface);
  color: var(--color-text-main);
  font-size: 13px;
  outline: none;
  transition: all var(--transition-fast);
}

.search-input-unified:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.search-btn-unified {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.search-btn-unified:hover {
  color: var(--color-primary);
}

.search-btn-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 40px;
  border-radius: var(--radius-md);
}

/* Column Toggle Dropdown */
.column-toggle-wrapper {
  position: relative;
}

.column-toggle-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 200px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px;
}

.column-toggle-dropdown.show {
  display: block;
  animation: fadeInDown 0.15s ease-out;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.column-toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--color-text-main);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.column-toggle-item:hover {
  background-color: var(--color-surface-hover);
}

.column-toggle-item input[type="checkbox"] {
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* ---------------------------------------------------------------------------
   10. Badges (Color-coded analytical states)
   --------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  line-height: 1.4;
  white-space: nowrap;
}

.badge-muted {
  background-color: var(--color-surface-hover);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.badge-success {
  background-color: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
}

.badge-warning {
  background-color: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning-border);
}

.badge-error {
  background-color: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid var(--color-error-border);
}

.badge-admin {
  background-color: var(--color-secondary-subtle);
  color: var(--color-secondary);
  border: 1px solid rgba(147, 51, 234, 0.25);
}

.badge-primary {
  background-color: var(--color-primary-subtle);
  color: var(--color-primary);
  border: 1px solid rgba(13, 148, 136, 0.25);
}

/* ---------------------------------------------------------------------------
   11. Buttons
   --------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background-color: var(--color-primary);
  color: #FFFFFF;
  border-color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(13, 148, 136, 0.3);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.4);
}

.btn-secondary {
  background-color: var(--color-surface);
  color: var(--color-text-main);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background-color: var(--color-surface-hover);
  border-color: var(--color-text-muted);
}

.btn-danger {
  background-color: var(--color-error-bg);
  color: var(--color-error);
  border-color: var(--color-error-border);
}

.btn-danger:hover {
  background-color: var(--color-error);
  color: #FFFFFF;
  border-color: var(--color-error);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------------------------------------------------------------------------
   12. Alerts & Notifications
   --------------------------------------------------------------------------- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
}

.alert-success {
  background-color: var(--color-success-bg);
  color: #065F46;
  border-color: var(--color-success-border);
}

[data-theme="dark"] .alert-success {
  color: #34D399;
}

.alert-warning {
  background-color: var(--color-warning-bg);
  color: #92400E;
  border-color: var(--color-warning-border);
}

[data-theme="dark"] .alert-warning {
  color: #FBBF24;
}

.alert-error {
  background-color: var(--color-error-bg);
  color: #991B1B;
  border-color: var(--color-error-border);
}

[data-theme="dark"] .alert-error {
  color: #F87171;
}

/* ---------------------------------------------------------------------------
   13. Form Elements
   --------------------------------------------------------------------------- */
.form-page-container {
  max-width: 520px;
  margin: 32px auto;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-main);
  margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="search"] {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  font-size: 14px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-main);
  outline: none;
  transition: all var(--transition-fast);
}

.form-group input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

/* Panel Form (e.g. Add user inline) */
.panel-form {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
}

.panel-form-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-main);
  margin-bottom: 16px;
}

/* ---------------------------------------------------------------------------
   14. Public QR Scanner (InsightDeck Sun-readable & Viewfinder)
   --------------------------------------------------------------------------- */
.scan-container {
  max-width: 580px;
  margin: 16px auto;
}

.video-box {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 420px;
  border-radius: var(--radius-lg);
  background-color: #0F172A;
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--color-border);
  position: relative;
  overflow: hidden;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scanner-reticle {
  width: 72%;
  height: 72%;
  position: relative;
}

.reticle-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--color-primary);
  border-style: solid;
}

.reticle-corner.top-left {
  top: 0; left: 0;
  border-width: 3px 0 0 3px;
  border-top-left-radius: 6px;
}

.reticle-corner.top-right {
  top: 0; right: 0;
  border-width: 3px 3px 0 0;
  border-top-right-radius: 6px;
}

.reticle-corner.bottom-left {
  bottom: 0; left: 0;
  border-width: 0 0 3px 3px;
  border-bottom-left-radius: 6px;
}

.reticle-corner.bottom-right {
  bottom: 0; right: 0;
  border-width: 0 3px 3px 0;
  border-bottom-right-radius: 6px;
}

.scanner-laser {
  position: absolute;
  left: 5%;
  right: 5%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-primary), #2DD4BF, transparent);
  box-shadow: 0 0 10px var(--color-primary);
  animation: scanLaser 2.2s ease-in-out infinite alternate;
}

@keyframes scanLaser {
  0% { top: 6%; }
  100% { top: 92%; }
}

.btn-torch {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background-color: rgba(15, 23, 42, 0.7);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all var(--transition-fast);
}

.btn-torch.active {
  background-color: #F59E0B;
  color: #FFFFFF;
}

.scan-result-card {
  padding: 24px;
  border-radius: var(--radius-lg);
  text-align: center;
  animation: popIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.scan-result-success {
  background-color: var(--color-success-bg);
  border: 2px solid var(--color-success-border);
  color: #065F46;
}

[data-theme="dark"] .scan-result-success {
  color: #34D399;
}

.scan-result-error {
  background-color: var(--color-error-bg);
  border: 2px solid var(--color-error-border);
  color: #991B1B;
}

[data-theme="dark"] .scan-result-error {
  color: #F87171;
}

.scan-member-name {
  font-size: 28px;
  font-weight: 800;
  margin: 12px 0;
  letter-spacing: -0.02em;
}

/* ---------------------------------------------------------------------------
   15. Wallet Buttons (Apple & Google Wallet)
   --------------------------------------------------------------------------- */
.wallet-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 360px;
  margin: 24px auto 0;
}

.wallet-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 52px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.wallet-btn:hover {
  transform: translateY(-1px);
}

.wallet-btn:active {
  transform: translateY(1px);
}

.wallet-btn-apple {
  background-color: #000000;
  color: #FFFFFF;
  border: 1px solid #000000;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.wallet-btn-google {
  background-color: #FFFFFF;
  color: #1F2937;
  border: 1px solid #D1D5DB;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.wallet-btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------------------------------------------------------------------------
   16. Mobile Touch Cards & Dedicated Mobile Nav
   --------------------------------------------------------------------------- */
.mobile-only {
  display: none !important;
}

.desktop-only {
  display: flex !important;
}

/* Hide mobile bottom navigation bar and mobile FAB on desktop by default */
.bottom-nav,
.fab-add {
  display: none !important;
}

@media (max-width: 768px) {
  .mobile-only {
    display: block !important;
  }
  .nav-tool-btn.mobile-only {
    display: inline-flex !important;
  }
  .desktop-only {
    display: none !important;
  }

  /* Ultra-compact 3-column KPI Cards on mobile */
  .stat-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
    margin-top: 12px !important;
    margin-bottom: 14px !important;
  }

  .stat-card {
    padding: 8px 6px !important;
    border-radius: var(--radius-sm) !important;
    text-align: center !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 58px !important;
    gap: 2px !important;
    box-shadow: var(--shadow-xs) !important;
  }

  .stat-card::before {
    height: 2px !important;
  }

  .stat-header {
    justify-content: center !important;
    width: 100% !important;
    margin-bottom: 0 !important;
  }

  .stat-label {
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em !important;
    text-transform: uppercase !important;
    color: var(--color-text-muted) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
  }

  .stat-icon {
    display: none !important;
  }

  .stat-value {
    font-size: 18px !important;
    font-weight: 800 !important;
    line-height: 1.15 !important;
    letter-spacing: -0.02em !important;
  }

  .stat-footer {
    margin-top: 0 !important;
    font-size: 10px !important;
    justify-content: center !important;
    white-space: nowrap !important;
  }

  .stat-footer span:not(.stat-badge) {
    display: none !important;
  }

  .stat-badge {
    font-size: 9px !important;
    padding: 1px 5px !important;
    border-radius: var(--radius-sm) !important;
  }

  /* Full-width strip for secondary KPI (e.g. Apple Quota in members) */
  .stat-card.stat-span-full {
    grid-column: span 3 !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    padding: 6px 12px !important;
    min-height: 36px !important;
  }

  .stat-card.stat-span-full .stat-header {
    width: auto !important;
  }

  .stat-card.stat-span-full .stat-footer span:not(.stat-badge) {
    display: inline !important;
  }

  .container {
    padding: 16px;
    padding-bottom: 96px; /* Room for bottom bar */
  }

  .navbar {
    padding: 0 16px;
    height: 56px;
  }

  /* Mobile Member Card */
  .member-card-mobile {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-xs);
  }

  .member-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
  }

  .member-card-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text-main);
  }

  .member-card-date {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
  }

  .member-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
  }

  .member-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--color-border);
    padding-top: 12px;
  }

  /* Floating Action Button (FAB) */
  .fab-add {
    position: fixed;
    right: 20px;
    bottom: 84px;
    z-index: 45;
    width: 52px;
    height: 52px;
    border-radius: var(--radius-full);
    background-color: var(--color-primary);
    color: #FFFFFF;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(13, 148, 136, 0.4);
    text-decoration: none;
    transition: transform var(--transition-fast);
  }

  .fab-add:active {
    transform: scale(0.92);
  }

  .fab-add svg {
    width: 24px;
    height: 24px;
  }

  /* Native Mobile Bottom Navigation Bar */
  .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    height: 64px;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--color-border);
    display: flex !important;
    align-items: center;
    justify-content: space-around;
    padding: 0 6px;
  }

  [data-theme="dark"] .bottom-nav {
    background-color: rgba(21, 31, 50, 0.95);
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    transition: color var(--transition-fast);
  }

  .bottom-nav-item svg {
    width: 20px;
    height: 20px;
  }

  .bottom-nav-item.active {
    color: var(--color-primary);
    font-weight: 700;
  }

  .bottom-nav-scan-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    position: relative;
    top: -12px;
  }

  .bottom-nav-scan {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary), #065F46);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.4);
    text-decoration: none;
    transition: transform var(--transition-fast);
  }

  .bottom-nav-scan:active {
    transform: scale(0.92);
  }

  .bottom-nav-scan svg {
    width: 26px;
    height: 26px;
  }
}

/* ---------------------------------------------------------------------------
   17. Footer
   --------------------------------------------------------------------------- */
.footer {
  border-top: 1px solid var(--color-border);
  padding: 20px 24px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 12px;
  background-color: var(--color-surface);
}

@media (max-width: 768px) {
  .footer {
    display: none;
  }
}
