/* ========================================
   Nam Thanh Gold - Design System v2
   Premium Gold Purchase System
   ======================================== */

:root {
  --gold-400: #fbbf24;
  --gold-500: #f59e0b;
  --gold-600: #d97706;
  --gold-700: #b45309;

  --dark-600: #475569;
  --dark-800: #1e293b;
  --dark-900: #0f172a;

  --success: #10b981;
  --danger: #ef4444;
  --info: #3b82f6;

  --bg-primary: #0c0f1a;
  --bg-input: rgba(15, 23, 42, 0.9);
  --border-color: rgba(148, 163, 184, 0.12);
  --border-color-hover: rgba(251, 191, 36, 0.3);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --gradient-gold: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
  --gradient-gold-soft: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.05) 100%);
  --gradient-card: linear-gradient(145deg, rgba(17, 24, 39, 0.9) 0%, rgba(15, 23, 42, 0.7) 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);

  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 4px 20px rgba(245, 158, 11, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 50%;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-family);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(245, 158, 11, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(217, 119, 6, 0.04) 0%, transparent 50%);
  pointer-events: none; z-index: 0;
}

/* ========== Header ========== */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(12, 15, 26, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

.header-inner {
  max-width: 1600px; margin: 0 auto;
  padding: 12px 24px;
  display: flex; align-items: center;
  justify-content: space-between; gap: 24px;
}

.logo { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.logo-icon { font-size: 2rem; animation: float 3s ease-in-out infinite; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.logo-text h1 {
  font-size: 1.25rem; font-weight: 800;
  background: var(--gradient-gold);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; letter-spacing: -0.02em; line-height: 1.2;
}

.logo-text p {
  font-size: 0.7rem; color: var(--text-muted);
  letter-spacing: 0.1em; text-transform: uppercase; font-weight: 500;
}

.nav {
  display: flex; gap: 4px;
  background: rgba(15, 23, 42, 0.6);
  padding: 4px; border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.nav-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border: none; background: transparent;
  color: var(--text-secondary); font-family: var(--font-family);
  font-size: 0.8125rem; font-weight: 500;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: all var(--transition-fast); white-space: nowrap;
}

.nav-btn:hover { color: var(--text-primary); background: rgba(148,163,184,0.08); }
.nav-btn.active { background: var(--gradient-gold); color: var(--dark-900); box-shadow: var(--shadow-gold); }
.nav-btn.active svg { stroke: var(--dark-900); }

.header-time {
  font-size: 0.8125rem; color: var(--text-muted);
  font-weight: 500; font-variant-numeric: tabular-nums; flex-shrink: 0;
}

/* ========== Main ========== */
.main-content {
  position: relative; z-index: 1;
  max-width: 1600px; margin: 0 auto; padding: 24px;
}

.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

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

/* ========== Card ========== */
.card {
  background: var(--gradient-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
  overflow: hidden;
  transition: border-color var(--transition-base);
}
.card:hover { border-color: var(--border-color-hover); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border-color);
  gap: 8px; flex-wrap: wrap;
}
.card-header h2 {
  font-size: 1rem; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 20px; }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 8px;
  border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 700;
  background: var(--gradient-gold); color: var(--dark-900);
}
.badge-info {
  background: rgba(59,130,246,0.15); color: var(--info);
  border-radius: var(--radius-sm); padding: 4px 8px; font-weight: 500;
}

/* ========== Form ========== */
.form-group { margin-bottom: 12px; }
.form-group label {
  display: block; font-size: 0.75rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.05em;
}

.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); color: var(--text-primary);
  font-family: var(--font-family); font-size: 0.875rem;
  transition: all var(--transition-fast); outline: none;
}
.form-control:focus { border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(245,158,11,0.1); }
.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 40px; cursor: pointer;
}
select.form-control option { background: var(--dark-800); color: var(--text-primary); }

.form-full { grid-column: 1 / -1; }

/* ========== Searchable Select Combobox ========== */
.search-select {
  position: relative;
}

.search-select .form-control {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.search-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: var(--dark-800);
  border: 1px solid var(--border-color-hover);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 150;
  display: none;
  scrollbar-width: thin;
  scrollbar-color: var(--dark-600) transparent;
}

.search-select-dropdown.show {
  display: block;
  animation: dropdownIn 0.15s ease;
}

.search-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 100ms ease;
  border-bottom: 1px solid rgba(148, 163, 184, 0.04);
}

.search-select-option:last-child {
  border-bottom: none;
}

.search-select-option:hover,
.search-select-option.highlighted {
  background: rgba(245, 158, 11, 0.08);
}

.search-select-option.selected {
  background: rgba(245, 158, 11, 0.12);
  border-left: 3px solid var(--gold-500);
}

.search-option-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.search-option-name mark {
  background: rgba(245, 158, 11, 0.3);
  color: var(--gold-400);
  padding: 0 2px;
  border-radius: 2px;
}

.search-option-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 12px;
  flex-shrink: 0;
}

.search-select-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* ========== PURCHASE LAYOUT ========== */
.purchase-layout {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 20px;
  align-items: start;
}

.purchase-left, .purchase-right {
  display: flex; flex-direction: column; gap: 20px;
}

/* Seller form */
.seller-form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}

/* ========== ADD ITEM SECTION (Improved) ========== */
.add-item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.add-item-row .form-group {
  margin-bottom: 0;
}

.price-readonly {
  padding: 10px 14px;
  background: rgba(15,23,42,0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-height: 42px;
  display: flex;
  align-items: center;
}

.total-highlight {
  color: var(--gold-400) !important;
  font-weight: 700 !important;
  font-size: 0.9375rem !important;
}

/* The ADD button - big, prominent, eye-catching */
.btn-add-item {
  min-width: 48px;
  height: 42px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.btn-add-item::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.1);
  opacity: 0;
  transition: opacity 0.2s;
}

.btn-add-item:hover::after { opacity: 1; }

.btn-add-item:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn-add-item:active {
  transform: scale(0.95);
}

.btn-add-text {
  font-weight: 700; font-size: 0.8125rem; letter-spacing: 0.02em;
}

.label-spacer {
  visibility: hidden;
}

.add-btn-group {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 20px; border: none;
  border-radius: var(--radius-md); font-family: var(--font-family);
  font-size: 0.875rem; font-weight: 600; cursor: pointer;
  transition: all var(--transition-fast); white-space: nowrap;
}

.btn-primary {
  background: var(--gradient-gold); color: var(--dark-900);
  box-shadow: var(--shadow-gold);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 25px rgba(245,158,11,0.25); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-success {
  background: var(--gradient-success); color: white;
  box-shadow: 0 4px 15px rgba(16,185,129,0.2);
}
.btn-success:hover { transform: translateY(-1px); }

.btn-secondary {
  background: rgba(148,163,184,0.1); color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover { background: rgba(148,163,184,0.15); color: var(--text-primary); }

.btn-danger {
  background: rgba(239,68,68,0.15); color: var(--danger);
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }

.btn-submit {
  width: 100%; padding: 14px; font-size: 1rem; font-weight: 700;
  margin-top: 12px;
}

.btn-icon {
  width: 32px; height: 32px; padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
}

/* ========== QR Scanner ========== */
.qr-scanner-area {
  margin-bottom: 16px; padding: 16px;
  background: rgba(15,23,42,0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

#qr-reader { width: 100% !important; border-radius: var(--radius-md); overflow: hidden; margin-bottom: 12px; }
#qr-reader video { border-radius: var(--radius-md); }

#qr-reader__dashboard { background: transparent !important; }
#qr-reader__dashboard_section { background: transparent !important; }
#qr-reader__dashboard_section_csr button,
#qr-reader__dashboard_section_fsr button {
  background: var(--gradient-gold) !important; color: var(--dark-900) !important;
  border: none !important; border-radius: var(--radius-sm) !important;
  padding: 8px 16px !important; font-family: var(--font-family) !important;
  font-weight: 600 !important; cursor: pointer !important;
}
#qr-reader__dashboard_section_csr select, #qr-reader select {
  background: var(--bg-input) !important; color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important; border-radius: var(--radius-sm) !important;
  padding: 6px 10px !important; font-family: var(--font-family) !important;
}
#qr-reader__status_span { color: var(--text-secondary) !important; }
#qr-reader__header_message { display: none !important; }
#qr-reader img[alt="Info icon"] { display: none !important; }

.qr-manual-input { margin-top: 12px; }
.qr-manual-input label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 6px; display: block; }
.input-row { display: flex; gap: 8px; }
.input-row .form-control { flex: 1; }
.btn-close-scanner { width: 100%; margin-top: 12px; }

/* ========== CART ITEMS (Improved Table-like Design) ========== */
.cart-items {
  max-height: 350px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--dark-600) transparent;
}

.cart-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: rgba(15,23,42,0.3);
  animation: slideIn 0.2s ease;
  transition: all var(--transition-fast);
}

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

.cart-item:hover {
  border-color: var(--border-color-hover);
  background: rgba(245, 158, 11, 0.03);
}

.cart-item-info { min-width: 0; }

.cart-item-name {
  font-weight: 700; color: var(--text-primary); font-size: 0.875rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.cart-item-meta {
  font-size: 0.75rem; color: var(--text-muted); margin-top: 3px;
  display: flex; gap: 8px; align-items: center;
}

.cart-item-qty-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 1px 8px; border-radius: 4px;
  background: rgba(245, 158, 11, 0.12);
  color: var(--gold-400); font-weight: 600; font-size: 0.7rem;
}

.cart-item-total {
  font-weight: 800; font-size: 1rem; color: var(--gold-400);
  font-variant-numeric: tabular-nums; text-align: right;
  white-space: nowrap;
}

.cart-item-delete {
  opacity: 0.4; transition: all var(--transition-fast);
}
.cart-item:hover .cart-item-delete { opacity: 1; }
.cart-item-delete:hover { transform: scale(1.15); }

/* Cart total */
.cart-total-section {
  padding: 18px 20px; margin-top: 16px;
  background: var(--gradient-gold-soft);
  border: 1px solid rgba(251,191,36,0.25);
  border-radius: var(--radius-md);
}

.cart-total-row {
  display: flex; justify-content: space-between; align-items: center;
}

.cart-total-row span:first-child {
  font-size: 0.9rem; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em;
}

.cart-grand-total {
  font-size: 1.75rem; font-weight: 900;
  background: var(--gradient-gold);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; font-variant-numeric: tabular-nums;
}

/* ========== Today's Purchases ========== */
.today-card {
  margin-top: 4px;
}

.today-list {
  max-height: 500px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--dark-600) transparent;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 10px;
}

.today-item {
  padding: 14px; margin-bottom: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  cursor: pointer; transition: all var(--transition-fast);
}

.today-item:hover {
  border-color: var(--border-color-hover);
  background: rgba(255,255,255,0.02);
}

.today-item-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px;
}

.today-item-seller { font-weight: 600; font-size: 0.875rem; color: var(--text-primary); }
.today-item-total { font-weight: 700; color: var(--gold-400); font-variant-numeric: tabular-nums; }
.today-item-meta { font-size: 0.75rem; color: var(--text-muted); }

.today-item-items { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.today-item-tag {
  padding: 2px 8px;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.15);
  border-radius: 4px; font-size: 0.7rem;
  color: var(--gold-400); font-weight: 500;
}

/* ========== Empty State ========== */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 40px; color: var(--text-muted); text-align: center;
}
.empty-state p { margin-top: 8px; font-size: 0.8125rem; }

/* ========== Statistics ========== */
.stats-layout { display: flex; flex-direction: column; gap: 20px; }

.stats-filter-body {
  display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
}

.stats-filter-separator {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); padding-bottom: 4px;
  flex-shrink: 0;
}

.stats-filter-buttons {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding-bottom: 4px;
}

.stats-filter-buttons .btn.active {
  background: var(--gradient-gold); color: var(--dark-900);
  border-color: transparent; box-shadow: var(--shadow-gold);
}

.summary-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }

.summary-card {
  display: flex; align-items: center; gap: 20px;
  padding: 24px; border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  transition: all var(--transition-base);
}

.summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.summary-total {
  background: linear-gradient(145deg, rgba(16,185,129,0.08) 0%, rgba(16,185,129,0.02) 100%);
  border-color: rgba(16,185,129,0.15);
}

.summary-icon {
  flex-shrink: 0; width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
}
.summary-total .summary-icon { background: rgba(16,185,129,0.12); color: var(--success); }

.summary-info { display: flex; flex-direction: column; }

.summary-label {
  font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}

.summary-value {
  font-size: 1.5rem; font-weight: 800; color: var(--text-primary);
  font-variant-numeric: tabular-nums; margin-top: 4px;
}

.summary-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* Charts */
.charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.chart-body { position: relative; height: 300px; }
.chart-body-wide { height: 250px; }
.chart-body canvas { width: 100% !important; height: 100% !important; }

/* Data Table */
.table-responsive { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }

.data-table thead th {
  padding: 12px 16px; text-align: left;
  font-size: 0.7rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border-color); white-space: nowrap;
}

.data-table tbody td {
  padding: 10px 16px; font-size: 0.8125rem;
  border-bottom: 1px solid rgba(148,163,184,0.06); white-space: nowrap;
}

.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* Price table */
.price-input {
  width: 160px; padding: 8px 14px;
  background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font-family); font-size: 0.8125rem;
  font-variant-numeric: tabular-nums; text-align: right;
  transition: all var(--transition-fast); outline: none;
}
.price-input:focus { border-color: var(--gold-500); box-shadow: 0 0 0 2px rgba(245,158,11,0.1); }

.price-layout { display: flex; flex-direction: column; gap: 20px; }

/* ========== Toast ========== */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 1000;
  display: flex; flex-direction: column-reverse; gap: 8px;
}

.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  background: var(--dark-800); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  min-width: 300px; max-width: 450px;
}
.toast.toast-out { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100px); } }

.toast-icon { flex-shrink: 0; width: 24px; height: 24px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--info); }
.toast-message { flex: 1; font-size: 0.8125rem; color: var(--text-primary); }

/* ========== Modal ========== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-box {
  background: var(--dark-800); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%; max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease;
}
.modal-wide { max-width: 600px; }

@keyframes modalIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }

.modal-body { padding: 20px; color: var(--text-secondary); max-height: 60vh; overflow-y: auto; }

.modal-footer {
  padding: 12px 20px; border-top: 1px solid var(--border-color);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* Detail modal */
.detail-section { margin-bottom: 16px; }
.detail-section-title {
  font-size: 0.75rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border-color);
}
.detail-row {
  display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.8125rem;
}
.detail-row .detail-label { color: var(--text-muted); }
.detail-row .detail-value { color: var(--text-primary); font-weight: 500; }

.detail-items-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.detail-items-table th {
  padding: 6px 8px; text-align: left; font-size: 0.7rem;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}
.detail-items-table td {
  padding: 6px 8px; font-size: 0.8125rem;
  border-bottom: 1px solid rgba(148,163,184,0.06);
}
.detail-total-row {
  display: flex; justify-content: space-between;
  padding: 12px 0; margin-top: 8px;
  border-top: 2px solid var(--border-color);
  font-weight: 700; font-size: 1rem;
}
.detail-total-value { color: var(--gold-400); }

/* ========== Responsive ========== */
@media (max-width: 1024px) {
  .purchase-layout { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .add-item-row {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .add-btn-group {
    grid-column: 1 / -1;
  }
  .btn-add-item { width: 100%; height: 48px; }
  .label-spacer { display: none; }
}

@media (max-width: 768px) {
  .header-inner { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .logo-icon { font-size: 1.5rem; }
  .logo-text h1 { font-size: 1.1rem; }
  .logo-text p { font-size: 0.6rem; }
  .logo { gap: 8px; }

  /* Nav: full width tabs */
  .nav {
    order: 3; width: 100%; overflow-x: auto; scrollbar-width: none;
    justify-content: stretch;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-btn { flex: 1; justify-content: center; padding: 10px 8px; font-size: 0.75rem; }

  .header-time { display: none; }
  .main-content { padding: 10px; }
  .card-header { padding: 12px 14px; }
  .card-body { padding: 14px; }

  /* Seller form: single column */
  .seller-form-grid { grid-template-columns: 1fr; gap: 8px; }

  /* Add item: full stacked */
  .add-item-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .add-item-row .form-group:first-child { grid-column: auto; }
  .add-btn-group { width: 100%; grid-column: auto; }
  .btn-add-item { width: 100%; height: 48px; font-size: 0.9375rem; }
  .label-spacer { display: none; }

  /* Cart */
  .cart-grand-total { font-size: 1.25rem; }
  .cart-item { padding: 12px; gap: 10px; }
  .cart-item-total { font-size: 0.875rem; }

  /* Form */
  .form-group { margin-bottom: 8px; }
  .form-control { padding: 12px 14px; font-size: 1rem; }
  select.form-control { font-size: 1rem; }

  /* Stats date filter: stack vertically */
  .stats-filter-body {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .stats-filter-body .form-group {
    min-width: unset !important;
    flex: unset !important;
  }
  .stats-filter-separator {
    transform: rotate(90deg);
    align-self: center;
    margin: -4px 0;
  }
  .stats-filter-buttons {
    justify-content: center;
    padding-bottom: 0;
    gap: 6px;
  }
  .stats-filter-buttons .btn {
    flex: 1;
    text-align: center;
    min-width: 0;
  }

  /* Stats */
  .summary-value { font-size: 1.25rem; }
  .chart-body { height: 220px; }
  .chart-body-wide { height: 180px; }

  /* Price table: hide STT, make inputs wider */
  .price-table th:first-child,
  .price-table td:first-child { display: none; }
  .price-input { width: 100%; min-width: 100px; }

  /* Toast */
  .toast-container { left: 10px; right: 10px; bottom: 10px; }
  .toast { min-width: auto; max-width: none; padding: 12px 14px; }

  /* Modal */
  .modal-box { width: 95%; }
  .modal-wide { max-width: 95%; }

  /* Tables on mobile */
  .data-table thead th { padding: 8px 10px; font-size: 0.65rem; }
  .data-table tbody td { padding: 8px 10px; font-size: 0.75rem; }
}

@media (max-width: 480px) {
  .nav-btn span { display: none; }
  .nav-btn { padding: 10px 16px; }
  .nav-btn svg { width: 22px; height: 22px; }

  .card-header h2 { font-size: 0.875rem; }

  /* Stats filter: keep vertical, tighten spacing */
  .stats-filter-buttons .btn {
    padding: 10px 8px;
    font-size: 0.75rem;
  }

  .price-input { width: 100%; }

  /* Today items */
  .today-item-header { flex-direction: column; align-items: flex-start; gap: 2px; }
  .today-item-total { font-size: 0.8125rem; }

  /* Stats tables: tighter padding */
  .data-table thead th { padding: 6px 8px; font-size: 0.6rem; }
  .data-table tbody td { padding: 6px 8px; font-size: 0.7rem; }

  /* Summary card */
  .summary-card { padding: 16px; gap: 14px; }
  .summary-icon { width: 44px; height: 44px; }
  .summary-icon svg { width: 24px; height: 24px; }

  /* Delete all button */
  .card-header .btn-sm { padding: 6px 8px; font-size: 0.7rem; }
  .card-header .btn-sm svg { width: 12px; height: 12px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--dark-600); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

::selection { background: rgba(245,158,11,0.3); color: var(--text-primary); }

.price-saved { animation: priceSaved 0.6s ease; }
@keyframes priceSaved { 0% { background: rgba(16,185,129,0.2); } 100% { background: transparent; } }

/* ========== User Menu ========== */
.user-menu {
  position: relative;
  flex-shrink: 0;
}

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-primary);
  font-family: var(--font-family);
}

.user-menu-btn:hover {
  border-color: var(--border-color-hover);
  background: rgba(245, 158, 11, 0.05);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--gradient-gold);
  color: var(--dark-900);
  font-weight: 800;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.user-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.user-role-badge.manager {
  background: rgba(245, 158, 11, 0.15);
  color: var(--gold-400);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.user-role-badge.employee {
  background: rgba(59, 130, 246, 0.12);
  color: var(--info);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
}

.status-badge.active {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.inactive {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* User Dropdown */
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--dark-800);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  display: none;
  animation: dropdownIn 0.15s ease;
  overflow: hidden;
}

.user-dropdown.show {
  display: block;
}

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

.user-dropdown-header {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-dropdown-header strong {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.user-dropdown-header small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border-color);
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.user-dropdown-item:hover {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-primary);
}

.user-dropdown-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* Mobile user menu */
@media (max-width: 768px) {
  .user-name { display: none; }
  .user-role-badge { display: none; }
  .user-menu-btn { padding: 4px; border-radius: var(--radius-full); }
  .user-dropdown { right: -10px; width: 220px; }
}

@media (max-width: 480px) {
  .user-dropdown { right: -10px; }
}

/* ========== TRANSACTION TYPE BADGES ========== */
.tx-type-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tx-type-badge.sale {
  background: rgba(245, 158, 11, 0.15);
  color: var(--gold-400);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.tx-type-badge.import {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* ========== STOCK BADGES ========== */
.stock-badge {
  display: inline-block;
  padding: 2px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
}
.stock-badge.in-stock {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}
.stock-badge.out-stock {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}
.stock-ok {
  color: var(--success) !important;
  font-weight: 600;
}
.stock-empty {
  color: var(--danger) !important;
  font-weight: 600;
}

/* ========== SEARCH OPTION STOCK ========== */
.search-option-stock {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-right: 6px;
}
.search-option-stock.in-stock {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}
.search-option-stock.out-stock {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

/* ========== STATS LAYOUT ========== */
.stats-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ========== SUMMARY GRID ========== */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.summary-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.summary-card {
  background: var(--dark-800);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: all var(--transition-fast);
}
.summary-card:hover {
  border-color: var(--border-color-hover);
  transform: translateY(-2px);
}

.summary-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.summary-import .summary-icon {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
}
.summary-sale .summary-icon {
  background: rgba(245, 158, 11, 0.12);
  color: var(--gold-400);
}
.summary-profit .summary-icon {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}

.summary-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.summary-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.summary-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}
.summary-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ========== CHARTS GRID ========== */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.chart-body {
  height: 280px;
  position: relative;
}
.chart-body-wide {
  height: 220px;
}

/* ========== STATS FILTER ========== */
.stats-filter-card {
  border: 1px solid var(--border-color);
}
.stats-filter-body {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}
.stats-filter-separator {
  color: var(--text-muted);
  padding-bottom: 8px;
}
.stats-filter-buttons {
  display: flex;
  gap: 8px;
  padding-bottom: 4px;
}

/* ========== DATA TABLE ========== */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 16px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(148, 163, 184, 0.04);
}
.data-table tbody tr:hover {
  background: rgba(148, 163, 184, 0.03);
}
.data-table tfoot td {
  border-top: 2px solid var(--border-color);
  color: var(--text-primary);
  padding: 14px 16px;
  font-size: 0.875rem;
}

.table-responsive {
  overflow-x: auto;
}

/* ========== PRICE TABLE ========== */
.price-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.price-input {
  width: 100%;
  max-width: 180px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.8125rem;
  transition: border-color var(--transition-fast);
}
.price-input:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}
.price-saved {
  animation: priceSaveFlash 0.6s ease;
}
@keyframes priceSaveFlash {
  0%, 100% { background: transparent; }
  50% { background: rgba(16, 185, 129, 0.08); }
}

/* ========== STATUS BADGES ========== */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
}
.status-badge.active {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}
.status-badge.inactive {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

/* ========== MOBILE RESPONSIVE ========== */
@media (max-width: 1024px) {
  .summary-grid-3 { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .stats-filter-body { flex-direction: column; align-items: stretch; }
  .stats-filter-separator { display: none; }
  .stats-filter-buttons { justify-content: center; }
  .add-item-row { grid-template-columns: 1fr 1fr !important; }
}

/* ========== IMPORT HEADER ACTIONS ========== */
.import-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.import-header-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ========== BRAND BADGES ========== */
.brand-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.brand-badge-mini {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
  margin-right: 4px;
  vertical-align: middle;
}

/* ========== SYNC CONTROLS ========== */
.sync-controls {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 10px;
}
.sync-controls-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.sync-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sync-label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}
.sync-status {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 2px 8px;
  background: rgba(148, 163, 184, 0.1);
  border-radius: 4px;
}
.sync-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.sync-btn {
  border: none;
  color: #fff;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sync-btn:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .sync-controls-inner { flex-direction: column; align-items: stretch; }
  .sync-buttons { justify-content: center; }
}