:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --secondary: #0EA5E9;
  --success: #10B981;
  --success-light: #D1FAE5;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --info: #6366F1;
  --dark: #1E293B;
  --gray-100: #F8FAFC;
  --gray-200: #F1F5F9;
  --gray-300: #E2E8F0;
  --gray-400: #CBD5E1;
  --gray-500: #94A3B8;
  --gray-600: #64748B;
  --gray-700: #475569;
  --gray-800: #334155;
  --gray-900: #1E293B;
  --white: #FFFFFF;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --sidebar-w: 240px;
  --header-h: 60px;
  --transition: .18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }

/* ---- LAYOUT ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  color: var(--gray-400);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--gray-700); border-radius: 2px; }
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--gray-800);
  color: var(--white);
  font-size: 1.2rem;
  font-weight: 700;
}
.sidebar-logo span { color: var(--primary); }
.sidebar-nav { padding: 10px 0; flex: 1; }
.nav-group { margin-bottom: 4px; }
.nav-group-title {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-600);
  padding: 12px 20px 4px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--gray-400);
  border-radius: 0;
  transition: all var(--transition);
  font-size: .9rem;
  position: relative;
}
.nav-link:hover { background: var(--gray-800); color: var(--white); }
.nav-link.active {
  background: var(--primary);
  color: var(--white);
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--gray-700);
}
.page-content { padding: 24px; flex: 1; }
.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---- CARDS ---- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-300);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body { padding: 20px; }

/* ---- STAT CARDS ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-300);
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-label { font-size: .8rem; color: var(--gray-500); margin-bottom: 2px; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--gray-900); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-hover); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #059669; color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #DC2626; color: var(--white); }
.btn-warning { background: var(--warning); color: var(--white); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-pos {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius);
}

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .85rem; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
.form-label.required::after { content: '*'; color: var(--danger); margin-left: 3px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--gray-900);
  font-size: .9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-control:disabled { background: var(--gray-100); cursor: not-allowed; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap: 16px; }
.form-hint { font-size: .78rem; color: var(--gray-500); margin-top: 4px; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: 4px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); flex: 1; }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.checkbox-wrap { display: flex; align-items: center; gap: 8px; }
.checkbox-wrap input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-300);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--gray-200); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-100); }

/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: .74rem;
  font-weight: 600;
}
.badge-green { background: var(--success-light); color: #065F46; }
.badge-red { background: var(--danger-light); color: #991B1B; }
.badge-yellow { background: var(--warning-light); color: #92400E; }
.badge-blue { background: var(--primary-light); color: #3730A3; }
.badge-gray { background: var(--gray-200); color: var(--gray-600); }

/* ---- ALERTS ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: .9rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-light); color: #065F46; border-left: 4px solid var(--success); }
.alert-error { background: var(--danger-light); color: #991B1B; border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: #92400E; border-left: 4px solid var(--warning); }
.alert-info { background: var(--primary-light); color: #3730A3; border-left: 4px solid var(--primary); }

/* ---- PAGINATION ---- */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 16px; }
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
  transition: all var(--transition);
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); color: var(--white); border-color: var(--primary); }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--gray-500); padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-900); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px 20px; border-top: 1px solid var(--gray-200); display: flex; gap: 10px; justify-content: flex-end; }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }

/* ---- POS LAYOUT ---- */
.pos-wrap {
  display: grid;
  gap: 0;
  overflow: hidden;
  margin: 0;
}
.pos-left {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--gray-300);
  overflow: hidden;
  background: var(--gray-100);
}
.pos-right {
  display: flex;
  flex-direction: column;
  background: var(--white);
  overflow: hidden;
}
.pos-search {
  padding: 12px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-300);
}
.pos-categories {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  background: var(--white);
  border-bottom: 1px solid var(--gray-300);
}
.pos-categories::-webkit-scrollbar { height: 3px; }
.cat-btn {
  padding: 5px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--gray-300);
  background: var(--white);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 500;
  white-space: nowrap;
  transition: all var(--transition);
  color: var(--gray-700);
}
.cat-btn.active, .cat-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}
.pos-products {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(130px,1fr));
  gap: 10px;
  align-content: start;
}
.product-tile {
  background: var(--white);
  border-radius: var(--radius);
  border: 1.5px solid var(--gray-300);
  padding: 12px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
}
.product-tile:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.product-tile.out-of-stock { opacity: .5; cursor: not-allowed; }
.product-tile img { width: 60px; height: 60px; object-fit: cover; border-radius: var(--radius-sm); margin: 0 auto; }
.product-tile-img-placeholder {
  width: 60px; height: 60px;
  background: var(--gray-200);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
  color: var(--gray-400);
}
.product-tile-name { font-size: .82rem; font-weight: 500; line-height: 1.3; color: var(--gray-800); }
.product-tile-price { font-size: .95rem; font-weight: 700; color: var(--primary); }
.product-tile-stock { font-size: .72rem; color: var(--gray-500); }

/* ---- CART ---- */
.cart-header { padding: 14px 16px; border-bottom: 1px solid var(--gray-200); }
.cart-customer {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-200);
}
.cart-items { flex: 1; overflow-y: auto; }
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  align-items: center;
}
.cart-item-name { font-size: .88rem; font-weight: 500; }
.cart-item-price { font-size: .8rem; color: var(--gray-500); }
.cart-item-controls { display: flex; align-items: center; gap: 6px; }
.qty-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--gray-300);
  background: var(--white);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  transition: all var(--transition);
}
.qty-btn:hover { border-color: var(--primary); color: var(--primary); }
.qty-input {
  width: 44px;
  text-align: center;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 4px;
  font-size: .88rem;
}
.cart-item-total { font-size: .9rem; font-weight: 600; min-width: 70px; text-align: right; }
.cart-remove { color: var(--danger); background: none; border: none; cursor: pointer; padding: 4px; }

.cart-totals {
  border-top: 1px solid var(--gray-200);
  padding: 12px 14px;
  background: var(--gray-100);
}
.cart-totals-row {
  display: flex;
  justify-content: space-between;
  font-size: .88rem;
  padding: 3px 0;
  color: var(--gray-600);
}
.cart-totals-row.grand-total {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gray-900);
  padding-top: 10px;
  border-top: 1.5px solid var(--gray-300);
  margin-top: 6px;
}
.cart-payment { padding: 12px 14px; }
.payment-methods { display: flex; gap: 6px; margin-bottom: 10px; }
.pm-btn {
  flex: 1;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-300);
  background: var(--white);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 500;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.pm-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.pm-btn svg { width: 18px; height: 18px; }

/* ---- LOGIN ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
  padding: 16px;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -.02em;
}
.login-logo p { color: var(--gray-500); font-size: .9rem; margin-top: 4px; }

.pin-grid {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 10px;
  margin: 16px 0;
}
.pin-btn {
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 1.5px solid var(--gray-300);
  background: var(--gray-100);
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.pin-btn:hover { background: var(--primary); color: var(--white); border-color: var(--primary); }
.pin-display {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 12px;
}
.pin-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--gray-400);
  transition: all var(--transition);
}
.pin-dot.filled { background: var(--primary); border-color: var(--primary); }
.login-tabs { display: flex; margin-bottom: 24px; border-bottom: 1px solid var(--gray-300); }
.login-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: .9rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.login-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- INSTALL WIZARD ---- */
.install-wrap {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--gray-900) 0%, var(--primary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.install-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.install-steps {
  display: flex;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-300);
}
.install-step {
  flex: 1;
  padding: 14px;
  text-align: center;
  font-size: .8rem;
  font-weight: 500;
  color: var(--gray-500);
  position: relative;
}
.install-step.active { color: var(--primary); font-weight: 600; }
.install-step.done { color: var(--success); }
.install-step::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
}
.install-step.active::after { background: var(--primary); }
.install-step.done::after { background: var(--success); }
.install-body { padding: 32px; }
.install-footer {
  padding: 20px 32px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
}

/* ---- RECEIPT ---- */
.receipt { max-width: 320px; margin: 0 auto; font-family: 'Courier New', monospace; font-size: 12px; }
.receipt-header { text-align: center; border-bottom: 1px dashed #000; padding-bottom: 8px; margin-bottom: 8px; }
.receipt-items { width: 100%; }
.receipt-items td { padding: 2px 0; }
.receipt-footer { text-align: center; border-top: 1px dashed #000; padding-top: 8px; margin-top: 8px; }
@media print {
  .no-print { display: none !important; }
  body { background: white; }
  .receipt { font-size: 11px; }
}

/* ---- TOAST ---- */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--gray-900);
  color: var(--white);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: .88rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
  max-width: 320px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }
@keyframes toastIn {
  from { transform: translateX(60px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- AVATAR ---- */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  background: var(--primary-light);
  color: var(--primary);
  flex-shrink: 0;
}

/* ---- DROPDOWN ---- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-300);
  min-width: 180px;
  z-index: 500;
  display: none;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  color: var(--gray-700);
  font-size: .88rem;
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--gray-100); color: var(--gray-900); }
.dropdown-item svg { width: 16px; height: 16px; }
.dropdown-divider { border: none; border-top: 1px solid var(--gray-200); margin: 4px 0; }

/* ---- TABS ---- */
.tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }
.tab-link {
  padding: 10px 18px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: all var(--transition);
}
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- CHART ---- */
.chart-container { position: relative; height: 250px; }

/* ---- LOADER ---- */
.loader {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--gray-300);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-500);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; color: var(--gray-400); }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }

/* ---- SEARCH BAR ---- */
.search-bar { position: relative; }
.search-bar input { padding-left: 36px; }
.search-bar svg {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--gray-400);
  pointer-events: none;
}

/* ---- LABEL DESIGNER ---- */
.label-preview {
  border: 2px dashed var(--gray-400);
  border-radius: var(--radius);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  position: relative;
  overflow: hidden;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
  .pos-wrap { grid-template-columns: 1fr 340px; }
}
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 199;
  }
  .sidebar-overlay.show { display: block; }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .pos-wrap {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    height: auto;
    margin: -16px;
  }
  .pos-left { height: 60vh; }
  .pos-right { min-height: 40vh; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .form-row { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .login-card { padding: 28px 20px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .pos-products { grid-template-columns: repeat(auto-fill,minmax(100px,1fr)); gap: 8px; }
}

/* ─── POS search-item dropdown ─── */
.search-item{padding:8px 12px;cursor:pointer;border-bottom:1px solid var(--gray-100);font-size:.88rem;transition:.1s}
.search-item:hover{background:var(--gray-50)}
#customer-results{background:#fff;border:1px solid var(--gray-200);border-radius:8px;box-shadow:0 4px 12px rgba(0,0,0,.1);margin-top:4px;max-height:200px;overflow-y:auto}
.held-item{padding:12px;border-bottom:1px solid var(--gray-100);cursor:pointer;display:flex;justify-content:space-between;align-items:center}
.held-item:hover{background:var(--gray-50)}

/* ─── Modal improvements ─── */
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.5);display:none;align-items:center;justify-content:center;z-index:500}
.modal-overlay.active{display:flex}
.modal{background:#fff;border-radius:12px;max-width:90vw;max-height:85vh;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 20px 60px rgba(0,0,0,.25)}
.modal-header{padding:16px 20px;border-bottom:1px solid var(--gray-200);display:flex;align-items:center;justify-content:space-between;flex-shrink:0}
.modal-header h3{font-weight:700;font-size:1rem}
.modal-body{padding:16px 20px;overflow-y:auto;flex:1}
.modal-footer{padding:12px 20px;border-top:1px solid var(--gray-200);display:flex;justify-content:flex-end;gap:8px;flex-shrink:0}
.modal-close{background:none;border:none;cursor:pointer;color:var(--gray-500);font-size:1.1rem;padding:4px 8px}

/* ─── Alerts in pos ─── */
.alert-success{background:#D1FAE5;color:#065F46;border-color:#10B981}
.alert-error{background:#FEE2E2;color:#991B1B;border-color:#EF4444}
.alert-info{background:#EEF2FF;color:#3730A3;border-color:#4F46E5}
.alert-warning{background:#FEF3C7;color:#92400E;border-color:#F59E0B}

/* ─── Toast ─── */
.toast-container{position:fixed;bottom:20px;right:20px;z-index:9999;display:flex;flex-direction:column;gap:8px}
.toast{padding:10px 18px;border-radius:10px;font-size:.88rem;font-weight:500;box-shadow:0 4px 16px rgba(0,0,0,.15);max-width:280px;word-break:break-word;animation:slideIn .2s ease}
@keyframes slideIn{from{transform:translateX(60px);opacity:0}to{transform:translateX(0);opacity:1}}
.toast.success{background:#10B981;color:#fff}
.toast.error{background:#EF4444;color:#fff}
.toast.info{background:#4F46E5;color:#fff}
.toast.warning{background:#F59E0B;color:#fff}

/* ═══════════════════════════════════════════
   RESPONSIVE / MOBILE
   ═══════════════════════════════════════════ */

/* Admin layout mobile */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: -260px; top: 0; bottom: 0; z-index: 400;
    transition: left .25s; box-shadow: 4px 0 20px rgba(0,0,0,.15);
    width: 260px;
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 399;
  }
  .sidebar-overlay.show { display: block; }
  .main-content { padding: 12px; }
  .menu-toggle { display: flex !important; }
  .page-header { padding: 10px 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 1.1rem; }
  .card-header { padding: 10px 14px; font-size: .9rem; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 500px; }
  .form-row { grid-template-columns: 1fr !important; }
  .btn { padding: 8px 14px; font-size: .85rem; }
  .tabs { overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .page-header h1 { font-size: .95rem; }
}

/* ═══════════════════════════════════════════
   DARK THEME
   ═══════════════════════════════════════════ */
[data-theme="dark"] {
  --white: #1E293B;
  --gray-50:  #0F172A;
  --gray-100: #1E293B;
  --gray-200: #334155;
  --gray-300: #475569;
  --gray-400: #64748B;
  --gray-500: #94A3B8;
  --gray-600: #CBD5E1;
  --gray-700: #E2E8F0;
  --gray-800: #F1F5F9;
  --gray-900: #F8FAFC;
  color-scheme: dark;
}
[data-theme="dark"] body        { background: #0F172A; color: #E2E8F0; }
[data-theme="dark"] .sidebar    { background: #020617; }
[data-theme="dark"] .header     { background: #1E293B; border-color: #334155; }
[data-theme="dark"] .card       { background: #1E293B; border-color: #334155; }
[data-theme="dark"] .card-header{ background: #1E293B; border-color: #334155; }
[data-theme="dark"] .form-control{ background: #0F172A; border-color: #475569; color: #E2E8F0; }
[data-theme="dark"] .form-control:focus{ background: #1E293B; border-color: var(--primary); }
[data-theme="dark"] table thead  { background: #0F172A; }
[data-theme="dark"] table tr:hover{ background: #0F172A; }
[data-theme="dark"] .dropdown-menu{ background: #1E293B; border-color: #334155; }
[data-theme="dark"] .dropdown-item:hover{ background: #334155; }
[data-theme="dark"] .nav-link   { color: #94A3B8; }
[data-theme="dark"] .nav-link:hover,[data-theme="dark"] .nav-link.active{ background: rgba(99,102,241,.15); color: #A5B4FC; }
[data-theme="dark"] .stat-card  { background: #1E293B; border-color: #334155; }
[data-theme="dark"] .badge      { opacity: .9; }
[data-theme="dark"] .main-content{ background: #0F172A; }
[data-theme="dark"] input[type="date"]{ color-scheme: dark; }
