@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #EE0033;
  --primary-hover: #D6002E;
  --primary-subtle: #FFF1F2;
  --primary-glow: rgba(238, 0, 51, 0.15);
  
  --bg-body: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-surface-elevated: #FFFFFF;
  --bg-subtle: #F1F5F9;
  
  --text-main: #0F172A;
  --text-body: #334155;
  --text-muted: #64748B;
  --text-inverse: #FFFFFF;
  
  --border: #E2E8F0;
  --border-focus: #EE0033;
  
  --success: #10B981;
  --success-subtle: #ECFDF5;
  --warning: #F59E0B;
  --warning-subtle: #FFFBEB;
  --danger: #EF4444;
  --danger-subtle: #FEF2F2;
  --info: #3B82F6;
  --info-subtle: #EFF6FF;
  --purple: #8B5CF6;
  --purple-subtle: #F5F3FF;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-body: #0B0F19;
  --bg-surface: #131B2E;
  --bg-surface-elevated: #1E293B;
  --bg-subtle: #192338;
  
  --text-main: #F8FAFC;
  --text-body: #CBD5E1;
  --text-muted: #94A3B8;
  
  --border: #23304B;
  --primary-subtle: rgba(238, 0, 51, 0.15);
  --success-subtle: rgba(16, 185, 129, 0.15);
  --warning-subtle: rgba(245, 158, 11, 0.15);
  --danger-subtle: rgba(239, 68, 68, 0.15);
  --info-subtle: rgba(59, 130, 246, 0.15);
  --purple-subtle: rgba(139, 92, 246, 0.15);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* App Container */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  transition: var(--transition);
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary) 0%, #B90025 100%);
  color: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-info h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.brand-info span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-menu {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 12px 12px 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-body);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--primary-subtle);
  color: var(--primary);
  font-weight: 600;
  border-color: rgba(238, 0, 51, 0.2);
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-icon {
  font-size: 18px;
  display: flex;
  align-items: center;
}

.nav-count {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 600;
}

.nav-item.active .nav-count {
  background: var(--primary);
  color: white;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
}

.theme-toggle-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-body);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top Navbar */
.top-navbar {
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(12px);
}

.search-box {
  position: relative;
  width: 360px;
}

.search-box input {
  width: 100%;
  padding: 9px 16px 9px 38px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-main);
  font-size: 13.5px;
  outline: none;
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px var(--primary-glow);
}

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

.btn-secondary:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

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

/* Content Container */
.content-area {
  padding: 32px;
  flex: 1;
}

.tab-content {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Page Header */
.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title h1 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.page-title p {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: rgba(238, 0, 51, 0.3);
}

.kpi-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-accent, var(--primary));
}

.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.kpi-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: var(--icon-bg, var(--primary-subtle));
  color: var(--icon-color, var(--primary));
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.kpi-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

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

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

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

.card-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Chart Canvas container */
.chart-container {
  width: 100%;
  height: 280px;
  position: relative;
}

/* Table Controls */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-select, .filter-input {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}

.filter-select:focus, .filter-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Data Table Component */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

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

.data-table thead th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  user-select: none;
  cursor: pointer;
}

.data-table thead th:hover {
  color: var(--text-main);
}

.data-table thead th.sortable::after {
  content: " ↕";
  opacity: 0.4;
}

.data-table thead th.sort-asc::after {
  content: " ▲";
  opacity: 1;
  color: var(--primary);
}

.data-table thead th.sort-desc::after {
  content: " ▼";
  opacity: 1;
  color: var(--primary);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background: var(--bg-subtle);
}

.data-table td {
  padding: 12px 16px;
  color: var(--text-body);
  vertical-align: middle;
}

.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.data-table td.center {
  text-align: center;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
}

.badge-success {
  background: var(--success-subtle);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-subtle);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-subtle);
  color: var(--danger);
}

.badge-info {
  background: var(--info-subtle);
  color: var(--info);
}

.badge-purple {
  background: var(--purple-subtle);
  color: var(--purple);
}

.badge-gray {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.badge-new {
  background: linear-gradient(135deg, #FF1744 0%, #D50000 100%);
  color: #FFFFFF !important;
  font-weight: 800;
  font-size: 9.5px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 4px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(229, 9, 20, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin-left: 6px;
  animation: badgeNewPulse 2.2s infinite ease-in-out;
}

@keyframes badgeNewPulse {
  0% { transform: scale(1); box-shadow: 0 2px 6px rgba(229, 9, 20, 0.35); }
  50% { transform: scale(1.06); box-shadow: 0 3px 10px rgba(229, 9, 20, 0.55); }
  100% { transform: scale(1); box-shadow: 0 2px 6px rgba(229, 9, 20, 0.35); }
}

/* Product Avatar in Table */
.prod-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.prod-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  object-fit: cover;
  flex-shrink: 0;
}

.prod-thumb-placeholder {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.prod-info-name {
  font-weight: 600;
  color: var(--text-main);
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prod-info-cat {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Pagination */
.pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  flex-wrap: wrap;
  gap: 12px;
}

.page-info {
  font-size: 13px;
  color: var(--text-muted);
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-btn {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-body);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.page-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 600;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Modal styles */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 20px;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95);
  transition: transform 0.2s ease;
  overflow: hidden;
}

.modal-backdrop.open .modal-box {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.modal-close-btn:hover {
  background: var(--bg-subtle);
  color: var(--danger);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-subtle);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.6;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .top-navbar {
    padding: 0 16px;
  }
  .content-area {
    padding: 16px;
  }
  .search-box {
    width: 200px;
  }
}

/* Button Variants */
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  background: #DC2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover {
  background: #059669;
}

.btn-outline-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-outline-danger:hover {
  background: var(--danger-subtle);
}

.action-btns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Form Styles */
.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 600px) {
  .form-row, .form-row-3 {
    grid-template-columns: 1fr;
  }
}

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

.form-label .req {
  color: var(--primary);
  margin-left: 2px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-textarea {
  resize: vertical;
  min-height: 70px;
}

.form-help {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease-out;
}

.toast.toast-success {
  border-left-color: var(--success);
}

.toast.toast-danger {
  border-left-color: var(--danger);
}

.toast.toast-warning {
  border-left-color: var(--warning);
}

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-main);
}

.toast-desc {
  font-size: 12px;
  color: var(--text-muted);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Period Switcher (Month / Quarter / Year) */
.period-switcher {
  display: inline-flex;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  border: 1px solid var(--border);
  gap: 2px;
}

.period-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.period-btn:hover {
  color: var(--text-main);
}

.period-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

/* Profit Badges */
.badge-profit-high {
  background: #ECFDF5;
  color: #059669;
  font-weight: 700;
}

.badge-profit-mid {
  background: #EFF6FF;
  color: #2563EB;
  font-weight: 700;
}

.badge-profit-low {
  background: #FFFBEB;
  color: #D97706;
  font-weight: 700;
}

.badge-profit-neg {
  background: #FEF2F2;
  color: #DC2626;
  font-weight: 700;
}

[data-theme="dark"] .badge-profit-high {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
}

[data-theme="dark"] .badge-profit-mid {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
}

[data-theme="dark"] .badge-profit-low {
  background: rgba(245, 158, 11, 0.15);
  color: #FBBF24;
}

[data-theme="dark"] .badge-profit-neg {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
}

/* Financial Stat Callout */
.finance-callout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

.finance-callout-item {
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.finance-callout-item[onclick]:hover {
  opacity: 0.82;
  transform: translateY(-2px);
}


.finance-callout-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.finance-callout-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   THERMAL RECEIPT & BILL STYLING (Khổ K80 / 80mm POS Bill)
   ========================================================= */
.receipt-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0 16px;
}

.receipt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
  width: 100%;
  max-width: 440px;
}

.thermal-receipt {
  width: 100%;
  max-width: 360px;
  background: #FFFFFF !important;
  color: #0F172A !important;
  padding: 24px 20px 28px;
  border-radius: 6px;
  box-shadow: 0 14px 34px -4px rgba(0, 0, 0, 0.22), 0 4px 12px -2px rgba(0, 0, 0, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  box-sizing: border-box;
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.receipt-sep-double {
  font-family: monospace, Courier, monospace;
  font-size: 13px;
  letter-spacing: -0.5px;
  text-align: center;
  margin: 6px 0;
  color: #0F172A !important;
  user-select: none;
  overflow: hidden;
  white-space: nowrap;
  font-weight: 700;
}

.receipt-sep-dash {
  font-family: monospace, Courier, monospace;
  font-size: 14px;
  letter-spacing: 0.5px;
  text-align: center;
  margin: 6px 0;
  color: #0F172A !important;
  user-select: none;
  overflow: hidden;
  white-space: nowrap;
}

.receipt-store-title {
  font-size: 18.5px;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.5px;
  color: #000000 !important;
  margin-top: 2px;
  margin-bottom: 4px;
}

.receipt-store-sub {
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  color: #1E293B !important;
  line-height: 1.45;
}

.receipt-order-id {
  font-size: 13.5px;
  font-weight: 700;
  color: #000000 !important;
  margin-top: 4px;
}

.receipt-order-cust {
  font-size: 14px;
  font-weight: 800;
  color: #000000 !important;
  margin-top: 3px;
}

.receipt-table-header {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: 13px;
  color: #000000 !important;
  padding: 2px 0;
}

.receipt-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}

.receipt-item-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.receipt-item-name {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  color: #000000 !important;
  line-height: 1.35;
}

.receipt-item-qty {
  width: 32px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 800;
  color: #000000 !important;
}

.receipt-item-price {
  width: 85px;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.receipt-price-old {
  font-size: 11.5px;
  color: #94A3B8 !important;
  text-decoration: line-through;
  font-weight: 600;
}

.receipt-price-val {
  font-size: 13.5px;
  font-weight: 800;
  color: #000000 !important;
}

.receipt-summary {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 2px 0;
}

.receipt-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  font-weight: 600;
  color: #000000 !important;
}

.receipt-summary-grand {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16.5px;
  font-weight: 900;
  color: #000000 !important;
  padding: 2px 0;
}

.receipt-note {
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  color: #000000 !important;
  margin-top: 10px;
  line-height: 1.45;
}

.receipt-thank {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: #000000 !important;
  margin-top: 4px;
}

.receipt-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 12px;
}

.receipt-qr-title {
  font-size: 13.5px;
  font-weight: 900;
  color: #000000 !important;
  letter-spacing: 0.5px;
  text-align: center;
  margin-bottom: 8px;
}

.receipt-qr-img {
  width: 200px;
  height: 200px;
  display: block;
  margin: 0 auto 10px;
  border-radius: 4px;
  background: #FFF;
}

.receipt-bank-info {
  font-size: 13px;
  font-weight: 700;
  color: #000000 !important;
  text-align: center;
  line-height: 1.45;
}

.receipt-paid-box {
  background: #ECFDF5 !important;
  border: 1.5px dashed #059669;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  margin-top: 12px;
}

.receipt-paid-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #059669;
  font-size: 14.5px;
  font-weight: 900;
  letter-spacing: 0.5px;
}

/* -------------------------------------------------------------
 * PURCHASE ORDER THERMAL RECEIPT (K80 Black & White Text Info)
 * ------------------------------------------------------------- */
.po-thermal-receipt {
  width: 100%;
  max-width: 360px;
  background: #FFFFFF !important;
  color: #000000 !important;
  padding: 22px 18px 24px;
  border-radius: 4px;
  border: 1px solid #CBD5E1;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  font-family: "Courier New", Courier, "Lucida Console", Monaco, monospace;
  font-size: 12.5px;
  line-height: 1.4;
  box-sizing: border-box;
  margin: 0 auto;
  position: relative;
}

.po-thermal-receipt * {
  color: #000000 !important;
  background: transparent !important;
  border-color: #000000 !important;
  box-sizing: border-box;
}

.po-receipt-sep-double {
  font-family: monospace;
  font-size: 13px;
  letter-spacing: -0.5px;
  text-align: center;
  margin: 5px 0;
  user-select: none;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
}

.po-receipt-sep-dash {
  font-family: monospace;
  font-size: 13.5px;
  letter-spacing: 0.5px;
  text-align: center;
  margin: 5px 0;
  user-select: none;
  overflow: hidden;
  white-space: nowrap;
}

.po-receipt-store-title {
  font-size: 18px;
  font-weight: 900;
  text-align: center;
  margin-top: 2px;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.po-receipt-title {
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.po-receipt-sub {
  font-size: 11.5px;
  text-align: center;
  margin-bottom: 2px;
}

.po-receipt-info-block {
  margin: 6px 0;
  font-size: 12px;
  line-height: 1.45;
}

.po-receipt-info-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.po-receipt-table-header {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: 11.5px;
  padding: 3px 0;
  border-top: 1px dashed #000000;
  border-bottom: 1px dashed #000000;
  margin: 4px 0;
}

.po-receipt-item-row {
  margin: 6px 0;
  line-height: 1.35;
}

.po-receipt-item-title {
  font-weight: 700;
  font-size: 12px;
  word-break: break-word;
}

.po-receipt-item-calc {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  padding-left: 10px;
}

.po-receipt-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 2px 0;
}

.po-receipt-grand-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15.5px;
  font-weight: 900;
  padding: 5px 0;
  border-top: 1px dashed #000000;
  border-bottom: 1px dashed #000000;
  margin: 6px 0;
}

.po-receipt-signatures {
  display: flex;
  justify-content: space-between;
  text-align: center;
  margin-top: 12px;
  font-size: 11px;
}

.po-receipt-sign-col {
  width: 48%;
}

.po-receipt-sign-col strong {
  display: block;
}

.po-receipt-sign-space {
  height: 44px;
}

.po-receipt-footer-text {
  text-align: center;
  font-size: 10.5px;
  margin-top: 10px;
  line-height: 1.35;
}

/* Print CSS */
@media print {
  body * {
    visibility: hidden !important;
  }
  #receipt-print-area,
  #receipt-print-area *,
  #po-receipt-print-area,
  #po-receipt-print-area * {
    visibility: visible !important;
  }
  #receipt-print-area,
  #po-receipt-print-area {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 80mm !important;
    max-width: 80mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #FFFFFF !important;
  }
  .receipt-toolbar, .modal-header, .modal-backdrop, .toast-container {
    display: none !important;
  }
  .thermal-receipt, .po-thermal-receipt {
    box-shadow: none !important;
    border: none !important;
    padding: 4mm 2mm !important;
    width: 100% !important;
    max-width: 80mm !important;
  }
}

/* -------------------------------------------------------------
 * FLOATING INTERACTIVE CHART TOOLTIP
 * ------------------------------------------------------------- */
.chart-floating-tooltip {
  position: fixed;
  display: none;
  opacity: 0;
  pointer-events: none;
  z-index: 99999;
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12px;
  box-shadow: 0 14px 34px -4px rgba(0, 0, 0, 0.22), 0 4px 12px -2px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  min-width: 230px;
  max-width: 290px;
  transition: opacity 0.12s cubic-bezier(0.16, 1, 0.3, 1), transform 0.12s cubic-bezier(0.16, 1, 0.3, 1);
  line-height: 1.45;
  box-sizing: border-box;
}

[data-theme="dark"] .chart-floating-tooltip {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.55);
}

.chart-tt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
}

.chart-tt-title {
  font-weight: 800;
  font-size: 13.5px;
  color: var(--text-main);
}

.chart-tt-badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-subtle);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.chart-tt-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0 8px;
}

.chart-tt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
  font-size: 12px;
}

.chart-tt-label {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.chart-tt-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.chart-tt-val {
  font-weight: 700;
  color: var(--text-main);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart-hitbox {
  cursor: pointer;
}

.chart-bar {
  cursor: pointer;
  transition: opacity 0.15s ease, filter 0.15s ease;
}

.chart-bar:hover {
  filter: brightness(1.15);
  opacity: 1 !important;
}

/* ============================================================= */
/* AUTHENTICATION & USER PROFILE STYLES                          */
/* ============================================================= */

/* Top Navbar User Profile Pill */
.user-auth-container {
  display: flex;
  align-items: center;
  position: relative;
}

.user-profile-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 4px 10px 4px 6px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.user-profile-pill:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #EE0033 0%, #FF5E7E 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  box-shadow: 0 2px 4px rgba(238, 0, 51, 0.25);
  flex-shrink: 0;
}

.user-meta-info {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.user-meta-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta-role {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.user-dropdown-arrow {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 2px;
}

/* User Dropdown Menu */
.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  min-width: 220px;
  padding: 8px 0;
  display: none;
  z-index: 100;
  animation: slideInDown 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-dropdown-menu.open {
  display: block;
}

.user-dropdown-header {
  padding: 8px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.user-dropdown-email {
  font-size: 11.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text-body);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.user-dropdown-item:hover {
  background: var(--bg-subtle);
  color: var(--primary);
}

.user-dropdown-item.danger:hover {
  background: var(--danger-subtle);
  color: var(--danger);
}

/* Sidebar User Info Card */
.sidebar-user-card {
  margin: 10px 14px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
}

.sidebar-user-card:hover {
  background: var(--bg-surface);
  border-color: var(--primary);
}

/* Auth Modal Styles */
.auth-modal-box {
  max-width: 500px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.auth-brand-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #EE0033 0%, #B90027 100%);
  color: #FFFFFF;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(238, 0, 51, 0.3);
}

.auth-tabs-nav {
  display: flex;
  background: var(--bg-subtle);
  padding: 4px;
  border-bottom: 1px solid var(--border);
}

.auth-tab-btn {
  flex: 1;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.auth-tab-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.auth-modal-body {
  padding: 24px;
}

/* Input Icon Wrapper & Password Reveal */
.input-icon-wrapper {
  position: relative;
  width: 100%;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.form-input.has-icon {
  padding-left: 38px;
}

.form-input.has-pwd-toggle {
  padding-right: 40px;
}

.pwd-toggle-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.pwd-toggle-btn:hover {
  color: var(--text-main);
  background: var(--bg-subtle);
}

.auth-submit-btn {
  width: 100%;
  padding: 12px;
  font-size: 14.5px;
  font-weight: 700;
  border-radius: var(--radius-md);
  margin-top: 10px;
  box-shadow: 0 4px 12px rgba(238, 0, 51, 0.25);
}

/* Quick Demo Login Section */
.auth-demo-section {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.auth-demo-divider {
  text-align: center;
  margin-bottom: 12px;
  position: relative;
}

.auth-demo-divider span {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 0 10px;
}

.auth-demo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.demo-acc-btn {
  padding: 8px 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.demo-acc-btn:hover {
  border-color: var(--primary);
  background: var(--primary-subtle);
  transform: translateY(-1px);
}

.demo-role {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.demo-email {
  font-size: 10px;
  color: var(--text-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Auth Alert Banner */
.auth-alert {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 16px;
  animation: slideInDown 0.2s ease;
}

.auth-alert.info {
  background: var(--info-subtle);
  border: 1px solid #BFDBFE;
  color: #1E40AF;
}

.auth-alert.success {
  background: var(--success-subtle);
  border: 1px solid #A7F3D0;
  color: #065F46;
}

.auth-alert.warning {
  background: var(--warning-subtle);
  border: 1px solid #FDE68A;
  color: #92400E;
}

.auth-alert.danger {
  background: var(--danger-subtle);
  border: 1px solid #FECACA;
  color: #991B1B;
}

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

/* ============================================================= */
/* ROLE-BASED ACCESS CONTROL (RBAC) STYLES                       */
/* ============================================================= */

/* Hide admin-only elements when CTV is logged in */
body.role-ctv .admin-only {
  display: none !important;
}

/* Hide ctv-only elements when Admin is logged in */
body.role-admin .ctv-only {
  display: none !important;
}

/* Order Approval & Status Badges */
.btn-approve-ship {
  background: #10B981;
  color: #FFFFFF;
  border: 1px solid #059669;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-approve-ship:hover:not(:disabled) {
  background: #059669;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.btn-approve-ship:disabled,
.btn-approve-ship[disabled] {
  background: #94A3B8 !important;
  color: #F8FAFC !important;
  border-color: #64748B !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
  opacity: 0.72;
}

.order-source-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  margin-top: 3px;
  line-height: 1.2;
}

.order-source-tag.ctv {
  background: #F3E8FF;
  color: #7E22CE;
  border: 1px solid #E9D5FF;
}

.order-source-tag.web {
  background: #FFF1F2;
  color: #BE123C;
  border: 1px solid #FECDD3;
}

.order-source-tag.system {
  background: #F1F5F9;
  color: #475569;
  border: 1px solid #E2E8F0;
}

.ctv-notice-banner {
  background: linear-gradient(135deg, #FAF5FF 0%, #F3E8FF 100%);
  border: 1px solid #D8B4FE;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ctv-notice-icon {
  font-size: 24px;
}

.ctv-notice-title {
  font-weight: 700;
  color: #6B21A8;
  font-size: 13.5px;
}

.ctv-notice-desc {
  font-size: 12px;
  color: #7E22CE;
}

/* ============================================================= */
/* AUTHENTICATION GATE SCREEN: Khóa cổng Quản trị & CTV           */
/* ============================================================= */
body.not-authenticated {
  overflow: auto;
  background-color: var(--bg-body);
}

body.not-authenticated .app-layout {
  display: none !important;
}

.auth-gate-screen {
  display: none;
  min-height: 100vh;
  width: 100%;
  background: radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.12) 0%, transparent 40%),
              radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.12) 0%, transparent 40%),
              var(--bg-body);
  align-items: center;
  justify-content: center;
  padding: 30px 16px;
  position: relative;
  z-index: 9999;
}

body.not-authenticated .auth-gate-screen {
  display: flex !important;
}

.auth-gate-card {
  width: 100%;
  max-width: 530px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  animation: authFadeUp 0.35s ease-out;
}

@keyframes authFadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-gate-header {
  padding: 28px 24px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, var(--bg-subtle) 0%, var(--bg-surface) 100%);
}

.auth-gate-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.35);
}

.auth-gate-title {
  font-size: 21px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.auth-gate-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.45;
}

.auth-gate-security-notice {
  margin: 14px 0 0;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  color: #1E40AF;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.auth-gate-body {
  padding: 24px;
}

.auth-gate-shop-link {
  margin-top: 20px;
  padding: 14px 16px;
  background: #FDF2F8;
  border: 1px dashed #F472B6;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  color: #9D174D;
  transition: all 0.2s;
}

.auth-gate-shop-link:hover {
  background: #FCE7F3;
  transform: translateY(-1px);
}

/* ============================================================= */
/* STOCK SHORTAGE HIGHLIGHTS & ORDER ITEM MANAGEMENT             */
/* ============================================================= */
.row-stock-shortage {
  background-color: rgba(254, 242, 242, 0.45) !important;
  border-left: 4px solid #EF4444 !important;
}

.row-stock-shortage:hover {
  background-color: rgba(254, 226, 226, 0.6) !important;
}

.badge-shortage {
  background: #FEE2E2;
  color: #B91C1C;
  border: 1px solid #FCA5A5;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  animation: pulseShortage 2s infinite ease-in-out;
}

@keyframes pulseShortage {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); box-shadow: 0 0 8px rgba(239, 68, 68, 0.35); }
  100% { transform: scale(1); }
}

.so-item-row-edit, .po-item-row-edit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  gap: 10px;
  transition: all 0.2s ease;
  flex-wrap: wrap;
}

.so-item-row-edit:hover, .po-item-row-edit:hover {
  border-color: var(--primary-light);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.so-item-row-edit.shortage {
  background: #FFF1F2 !important;
  border: 1px solid #FDA4AF !important;
  border-left: 4px solid #E11D48 !important;
}

/* =========================================================
   SUPPLIER DEBT REPORT & PAYABLES STYLING
   ========================================================= */
.debt-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.debt-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.debt-progress-fill {
  height: 100%;
  background: #10B981;
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.debt-progress-fill.warning {
  background: #F59E0B;
}

.debt-progress-fill.danger {
  background: #EF4444;
}

.debt-aging-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.debt-aging-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.debt-aging-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.debt-aging-card.aging-tier-1 {
  border-left: 4px solid #10B981;
}

.debt-aging-card.aging-tier-2 {
  border-left: 4px solid #3B82F6;
}

.debt-aging-card.aging-tier-3 {
  border-left: 4px solid #F59E0B;
}

.debt-aging-card.aging-tier-4 {
  border-left: 4px solid #EF4444;
}

.debt-aging-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.debt-aging-tier-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.debt-aging-amount {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}

.debt-aging-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.supplier-debt-statement-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 18px;
}

/* Discount Configuration & Preset Styles */
.discount-type-segmented {
  display: inline-flex;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border);
  gap: 2px;
}

.discount-type-segmented button {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.discount-type-segmented button.active {
  background: var(--primary);
  color: #FFFFFF;
}

.discount-formula-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: #EFF6FF;
  color: #1D4ED8;
}

[data-theme="dark"] .discount-formula-tag {
  background: #1E3A8A;
  color: #93C5FD;
}

/* Searchable Category Combobox Dropdown */
.cat-combobox-wrap {
  position: relative;
  width: 100%;
}

.cat-combobox-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.cat-combobox-input-wrap .form-input {
  padding-right: 54px;
}

.cat-combobox-actions {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.cat-combobox-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: background 0.15s ease, color 0.15s ease;
  padding: 0;
}

.cat-combobox-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.cat-combobox-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1200;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.14);
  max-height: 220px;
  overflow-y: auto;
  display: none;
  padding: 4px;
}

.cat-combobox-dropdown.open {
  display: block;
}

.cat-combobox-header {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 4px 8px 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cat-combobox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 5px;
  font-size: 12.5px;
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.12s ease;
}

.cat-combobox-item:hover,
.cat-combobox-item.active {
  background: var(--bg-subtle);
}

.cat-combobox-item.selected {
  background: rgba(238, 0, 51, 0.08);
  color: var(--primary);
  font-weight: 700;
}

.cat-combobox-item .cat-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.cat-combobox-item.create-new {
  color: #059669;
  font-weight: 700;
  border-top: 1px dashed var(--border);
  margin-top: 3px;
  padding-top: 8px;
}

.cat-combobox-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Inline New Product Panel inside Purchase Order Modal */
.po-new-prod-panel {
  background: #F0FDF4;
  border: 1.5px dashed #10B981;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
}

[data-theme="dark"] .po-new-prod-panel {
  background: rgba(16, 185, 129, 0.1);
  border-color: #059669;
}

.po-new-prod-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 10px;
  margin-top: 6px;
  background: #FEF3C7;
  border: 1px dashed #F59E0B;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #92400E;
}

[data-theme="dark"] .po-new-prod-prompt {
  background: rgba(245, 158, 11, 0.14);
  color: #FCD34D;
  border-color: #D97706;
}







