:root {
  --component-gap: 12px;
  --component-padding: 16px;
  --muted: var(--text-secondary);
}

/* App shell */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg-body);
  color: var(--text-primary);
}

/* Header (AppBar) */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--component-gap);
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand .brand-title {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--primary-dark);
}

/* Topbar title & meta */
.topbar-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Component Button */
.btn-component {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-component:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
  color: var(--primary);
}

/* Primary button matches sidebar primary color */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 6px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 12px rgba(79, 70, 229, 0.3);
  color: white;
}

/* Sidebar component style */
.sidebar-component {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
  border-right: 1px solid var(--border-dark);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar-component .menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px 16px;
  overflow-y: auto;
}

.sidebar-component .menu .item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-muted-dark);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition-fast);
}

.sidebar-component .menu .item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.sidebar-component .menu .item.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 0 15px rgba(79, 70, 229, 0.4);
}

/* Content area */
.app-content {
  flex: 1;
  padding: 32px;
  max-width: 1400px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Card component */
.card-component {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.card-component:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.card-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 24px;
}

.col-12 {
  grid-column: span 12;
}

.col-6 {
  grid-column: span 6;
}

.col-4 {
  grid-column: span 4;
}

.col-3 {
  grid-column: span 3;
}

@media (max-width: 1024px) {
  .col-6 {
    grid-column: span 12;
  }

  .col-4 {
    grid-column: span 12;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .sidebar-component {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 60;
  }

  .sidebar-component.active {
    transform: translateX(0);
  }

  .app-content {
    padding: 14px;
  }
}

/* Sales page two-column layout */
.two-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

/* Scrollable product grid for POS */
.product-grid-scroll {
  display: grid;
  /* Bigger cards: more legible on POS */
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  max-height: 600px;
  overflow-y: auto;
  padding-right: 6px;
}

/* Product card (POS) - larger, clearer */
.product-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  text-align: center;
  transition: var(--transition-fast);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.product-card.selected {
  border-color: var(--primary);
  background: #eef2ff;
  /* Indigo 50 */
  box-shadow: 0 0 0 2px var(--primary);
}

.product-name {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.4;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  overflow: hidden;
}

.product-price {
  background: var(--primary);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 700;
  display: inline-block;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

/* Stat card icon alignment */
.card .card-value {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-icon {
  font-size: 1.5rem;
  color: var(--primary);
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
}

.stat-icon.secondary {
  color: var(--secondary) !important;
  background: var(--secondary-light) !important;
}

/* Colored stat helpers */
.stat-icon.orange {
  color: var(--accent);
  background: #fef3c7;
}

.stat-icon.green {
  color: var(--secondary);
  background: #d1fae5;
}

.stat-value {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.stat-value.orange {
  color: var(--accent);
}

.stat-value.green {
  color: var(--secondary);
}

/* Stats grid layout and larger stat visuals (match dashboard screenshot) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.stats-grid .card {
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.stats-grid .card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.stats-grid .card .card-value {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stats-grid .card .stat-icon {
  width: 56px;
  height: 56px;
  font-size: 24px;
  border-radius: 14px;
}

.stats-grid .card .stat-value {
  font-size: 1.75rem;
  line-height: 1;
  font-weight: 800;
}

.stats-grid .card .card-title {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@media (max-width: 700px) {
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .stats-grid .card .stat-value {
    font-size: 1.4rem;
  }

  .stats-grid .card .stat-icon {
    width: 42px;
    height: 42px;
    font-size: 18px;
  }
}

/* Chart containers: bar + line stacked and aligned */
.css-chart-container {
  display: grid;
  grid-template-rows: auto 200px;
  gap: 24px;
}

.css-bar-chart,
.css-line-chart {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.css-bar-chart {
  min-height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.css-chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.css-chart-bar {
  width: 70%;
  background: var(--primary);
  border-radius: 6px 6px 0 0;
  transition: height 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
}

/* Shine effect on bars */
.css-chart-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
}

.css-chart-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 8px;
  font-weight: 500;
}

.css-chart-value {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 700;
  margin-bottom: 6px;
}

.css-line-chart {
  position: relative;
}

.css-line-chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.css-line-chart .line-point {
  fill: var(--primary);
}

.css-line-chart .line-path {
  stroke: var(--primary);
  stroke-width: 2;
  fill: none;
}

@media (max-width: 700px) {
  .css-chart-container {
    grid-template-rows: auto 120px;
  }

  .css-bar-chart {
    min-height: 120px;
  }
}

/* Small utilities */
.row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.text-muted {
  color: var(--muted);
}

/* Polished forms */
.input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: #fff;
}

/* Make icons crisp and aligned */
.component-icon {
  width: 18px;
  height: 18px;
}

/* Smooth focus outlines for keyboard users */
:focus {
  outline: 3px solid rgba(67, 56, 202, 0.12);
  outline-offset: 2px;
}

/* Avatar initials styling */
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.avatar-initials {
  line-height: 1;
}

.no-profile-icon-header {
  font-size: 1.5rem !important;
  color: #6b7280 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
  background: linear-gradient(135deg, #f3f4f6, #e5e7eb) !important;
  border-radius: 50% !important;
  border: 2px solid #d1d5db !important;
  transition: all 0.3s ease !important;
  z-index: 10 !important;
  position: relative !important;
}

.no-profile-icon-header:hover {
  background: linear-gradient(135deg, #e5e7eb, #d1d5db);
  border-color: #9ca3af;
  color: #4b5563;
  transform: scale(1.05);
}

@media (max-width: 480px) {
  .user-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
  }

  .no-profile-icon-header {
    font-size: 1rem;
  }
}

/* Avatar image fit */
.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

/* Ensure user avatar always shows user icon when no logo */
.user-avatar:not(:has(.user-avatar-img)) {
  background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
  border-radius: 50%;
  border: 2px solid #d1d5db;
}

.user-avatar .fa-user {
  color: #6b7280 !important;
  font-size: 1.5rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  right: 16px;
  top: 16px;
  z-index: 9999;
  display: flex;
}

.stat-icon.secondary {
  color: var(--secondary, #ff7a00);
  background: rgba(255, 122, 0, 0.06);
}

.toast {
  min-width: 240px;
  max-width: 360px;
  background: #111827;
  color: white;
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(17, 24, 39, 0.4);
  opacity: 0;
  transform: translateY(-6px);
  transition: all 0.28s cubic-bezier(.2, .9, .2, 1);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: linear-gradient(90deg, #059669, #10B981);
}

.toast.error {
  background: linear-gradient(90deg, #dc2626, #ef4444);
}

.toast .title {
  font-weight: 700;
  margin-bottom: 4px;
}

.toast .message {
  font-size: 0.95rem;
}

/* Product table + form helpers */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: transparent;
  border-radius: 8px;
}

.product-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg, #fff);
  border-radius: 8px;
  overflow: hidden;
}

.product-table thead {
  background: var(--light, #f7f7fb);
}

.product-table th,
.product-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.product-table th {
  font-size: 0.95rem;
  color: var(--muted, #6B7280);
  font-weight: 600;
}

.product-table tbody tr:last-child td {
  border-bottom: none;
}

.product-title {
  font-weight: 700;
}

.product-sub {
  font-size: 0.88rem;
  color: var(--muted, #6B7280);
}

.form-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.form-group-flex {
  flex: 1;
  min-width: 220px;
}

.mt-2 {
  margin-top: 10px;
}

.icon-left {
  margin-right: 8px;
}

@media (max-width:700px) {

  .product-table th,
  .product-table td {
    padding: 10px 8px;
  }

  .form-group-flex {
    min-width: 100%;
  }
}