* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; }
body { background: linear-gradient(135deg, #1f2937, #111827); min-height: 100vh; color: #e5e7eb; }

:root {
  --primary: #22c55e; --secondary: #f97316; --success: #22c55e; --error: #ef4444; --neutral: #4b5563;
  --white: rgba(255, 255, 255, 0.9); --shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
  --border: 1px solid rgba(255, 255, 255, 0.1); --radius: 0.5rem; --spacing-sm: 0.75rem;
  --spacing-md: 1.25rem; --spacing-lg: 2rem; --font-size-sm: 0.875rem; --font-size-md: 1rem;
}

.container { max-width: 1200px; margin: 0 auto; padding: var(--spacing-md); }
.card { background: rgba(31, 41, 55, 0.9); backdrop-filter: blur(10px); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--spacing-lg); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.space-x-2 > * + * { margin-left: var(--spacing-sm); }
.space-y-4 > * + * { margin-top: var(--spacing-md); }
.bg-primary { background-color: var(--primary); }
.bg-secondary { background-color: var(--secondary); }
.bg-success { background-color: var(--success); }
.bg-error { background-color: var(--error); }
.bg-neutral { background-color: var(--neutral); }
.text-white { color: #ffffff; }
.text-dark { color: #e5e7eb; }
.text-secondary { color: #9ca3af; }
.text-lg { font-size: 1.25rem; }
.font-bold { font-weight: 700; }
.p-2 { padding: var(--spacing-sm); }
.p-4 { padding: var(--spacing-md); }
.p-6 { padding: var(--spacing-lg); }
.px-4 { padding-left: var(--spacing-md); padding-right: var(--spacing-md); }
.py-2 { padding-top: var(--spacing-sm); padding-bottom: var(--spacing-sm); }
.mb-4 { margin-bottom: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-md); }
.w-full { width: 100%; }
.w-1-3 { width: 33.333%; }
.h-screen { height: 100vh; }
.border { border: var(--border); }
.rounded { border-radius: var(--radius); }
.shadow-lg { box-shadow: var(--shadow); }
.hidden { display: none !important; }
.absolute { position: absolute; }
.relative { position: relative; }
.fixed { position: fixed; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.bg-black-50 { background-color: rgba(0, 0, 0, 0.7); }

input, select, button { font-family: 'Poppins', sans-serif; font-size: var(--font-size-md); }
input[type="text"], input[type="number"], input[type="date"], input[type="month"], input[type="password"], select {
  border: var(--border); padding: var(--spacing-sm); border-radius: var(--radius); width: 100%;
  background: rgba(75, 85, 99, 0.8); color: #e5e7eb; transition: all 0.3s ease;
}
input::placeholder, select::placeholder { color: #9ca3af; }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.3); }

button {
  font-size: var(--font-size-md); font-weight: 700; padding: var(--spacing-sm) var(--spacing-md);
  border: none; border-radius: var(--radius); cursor: pointer; color: #ffffff;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
button:hover:not(:disabled) { transform: scale(1.05); box-shadow: 0 2px 8px rgba(255, 255, 255, 0.2); }
button:disabled { opacity: 0.6; cursor: not-allowed; }
button.bg-neutral { color: #ffffff; }

table { width: 100%; border-collapse: collapse; background: rgba(31, 41, 55, 0.9); border-radius: var(--radius); overflow: hidden; }
th, td { border: var(--border); padding: var(--spacing-sm); text-align: left; color: #e5e7eb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.table-container { max-height: 500px; overflow-y: auto; border-radius: var(--radius); }
thead th { position: sticky; top: 0; background: var(--primary); color: #ffffff; z-index: 10; }
.float-right { float: right; }

.autocomplete-item { padding: var(--spacing-sm); cursor: pointer; color: #e5e7eb; background: rgba(31, 41, 55, 0.9); transition: background 0.2s ease; }
.autocomplete-item:hover { background: rgba(20, 184, 166, 0.2); }

.status-in-stock { background: #065f46; color: #d1fae5; border-radius: var(--radius); padding: 0.25rem 0.5rem; }
.status-low-stock { background: #854d0e; color: #fef9c3; border-radius: var(--radius); padding: 0.25rem 0.5rem; }
.status-out-of-stock { background: #991b1b; color: #fee2e2; border-radius: var(--radius); padding: 0.25rem 0.5rem; }

#inventoryTable tr.selected { background: rgba(20, 184, 166, 0.2); }
.modal { z-index: 1000; animation: fadeIn 0.7s ease; }

.alert {
  font-weight: 700; padding: var(--spacing-md); border-radius: var(--radius); color: #ffffff; box-shadow: var(--shadow);
  position: fixed; top: var(--spacing-md); right: var(--spacing-md); z-index: 1000;
}

.header {
  background: rgba(31, 41, 55, 0.9); backdrop-filter: blur(10px); padding: var(--spacing-md); box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 15;
}

.nav-menu {
  position: fixed; top: 0; left: -100%; width: 95%; max-width: 300px; height: 100%;
  background: rgba(31, 41, 55, 0.9); backdrop-filter: blur(10px); padding: var(--spacing-lg); box-shadow: var(--shadow);
  transition: left 0.3s ease; z-index: 20;
}
.nav-menu.active { left: 0; }
.nav-menu ul { list-style: none; }
.nav-menu li { margin: var(--spacing-md) 0; }
.nav-menu a {
  display: flex; align-items: center; font-weight: 600; color: #e5e7eb; text-decoration: none;
  padding: var(--spacing-sm); border-radius: var(--radius); transition: background 0.2s ease;
}
.nav-menu a:hover { background: rgba(20, 184, 166, 0.2); }
.nav-menu i { margin-right: var(--spacing-sm); color: #e5e7eb; }
.hamburger { font-size: 1.5rem; cursor: pointer; color: #e5e7eb; }

#salesBreakdown { width: 100%; overflow-x: auto; position: relative; }
#salesBreakdown p { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--spacing-sm); width: 100%; padding: var(--spacing-sm); }
#salesBreakdown .subtotal { display: flex; align-items: center; gap: var(--spacing-sm); }
#salesBreakdown .item-details { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#salesBreakdown .remove-item { padding: var(--spacing-sm); background-color: transparent; color: var(--error); border-radius: var(--radius); cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; }
#salesBreakdown .remove-item:hover { transform: scale(1.05); box-shadow: 0 2px 8px rgba(255, 255, 255, 0.2); }
#salesBreakdown .grand-total { margin-top: var(--spacing-md); border-top: var(--border); padding-top: var(--spacing-sm); }

.date-range-container, .report-date-control { display: flex; gap: var(--spacing-sm); align-items: center; }
.date-range-container.hidden, .report-date-control.hidden { display: none; }

/* Sales Breakdown Close Button */
.breakdown-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--spacing-md); }
.close-breakdown {
  background: transparent; color: var(--error); border: none; border-radius: var(--radius);
  padding: var(--spacing-sm); cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-size: 1.1rem; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
}
.close-breakdown:hover { transform: scale(1.1); box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3); }

/* Pagination */
.pagination { display: flex; justify-content: center; align-items: center; margin-top: var(--spacing-md); gap: var(--spacing-sm); flex-wrap: wrap; }
.pagination button { padding: 0.5rem 0.75rem; border: var(--border); background: rgba(31, 41, 55, 0.9); color: #e5e7eb; border-radius: var(--radius); cursor: pointer; transition: all 0.2s ease; min-width: 40px; }
.pagination button:hover:not(:disabled) { background: var(--primary); transform: scale(1.05); }
.pagination button.active { background: var(--primary); color: white; }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.page-info { color: #9ca3af; margin: 0 var(--spacing-sm); }
.table-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--spacing-sm); color: #9ca3af; flex-wrap: wrap; gap: var(--spacing-sm); }
.row-count { background: rgba(31, 41, 55, 0.9); padding: 0.25rem 0.5rem; border-radius: var(--radius); border: var(--border); }
.search-controls { display: flex; gap: var(--spacing-sm); align-items: center; flex-wrap: wrap; margin-bottom: var(--spacing-md); }
.search-input { flex: 1; min-width: 200px; }
.filter-select { min-width: 150px; }

/* Dashboard Styles */
.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.metrics-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.quick-actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.metric-card { background: rgba(31, 41, 55, 0.9); border-radius: var(--radius); padding: var(--spacing-md); border: var(--border); }
.metric-card.green { background: linear-gradient(135deg, #064e3b, #047857); }
.metric-card.blue { background: linear-gradient(135deg, #1e3a8a, #1d4ed8); }
.metric-card.orange { background: linear-gradient(135deg, #7c2d12, #c2410c); }
.metric-card.red { background: linear-gradient(135deg, #7f1d1d, #b91c1c); }

/* Enhanced Dashboard Header */
.dashboard-header {
  background: linear-gradient(135deg, #1e3a8a, #3730a3);
  border-radius: var(--radius);
  padding: var(--spacing-lg);
  border: var(--border);
  margin-bottom: 1.5rem;
}

/* Top Selling Items Styles */
.top-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}
.top-item:hover { background-color: rgba(255, 255, 255, 0.05); }
.top-item-rank {
  background: var(--primary);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
}
.top-item-name {
  flex: 1;
  margin: 0 0.75rem;
  font-size: 0.875rem;
}
.top-item-qty {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Enhanced Quick Action & Stock Alert Buttons */
.quick-actions-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.quick-action-btn, .stock-alert-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 1rem 1.25rem;
  border: var(--border);
  border-radius: var(--radius);
  background: rgba(31, 41, 55, 0.9);
  color: #e5e7eb;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  min-height: 70px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  width: 100%;
}
.quick-action-btn { border-left: 4px solid var(--primary); }
.stock-alert-btn { border-left: 4px solid var(--error); }
.quick-action-btn:hover, .stock-alert-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  background: rgba(55, 65, 81, 0.9);
  border-color: var(--secondary);
}
.quick-action-btn:focus, .stock-alert-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3);
}
.quick-action-btn:active, .stock-alert-btn:active {
  transform: translateY(0);
  transition: transform 0.1s ease;
}
.btn-content { display: flex; align-items: center; width: 100%; }
.btn-icon { font-size: 1.5rem; margin-right: 0.75rem; width: 40px; text-align: center; }
.btn-text { flex: 1; }
.btn-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 0.25rem; color: #ffffff; }
.btn-subtitle { font-size: 0.8rem; color: #9ca3af; font-weight: 400; }
.btn-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--error);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.alert-item { padding: 0.75rem; border-radius: var(--radius); display: flex; justify-content: between; align-items: center; margin-bottom: 0.5rem; }
.alert-item.out-of-stock { background-color: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); }
.alert-item.low-stock { background-color: rgba(249, 115, 22, 0.1); border: 1px solid rgba(249, 115, 22, 0.3); }
.recent-sale-item { padding: 0.75rem; border: var(--border); border-radius: var(--radius); display: flex; justify-content: between; align-items: center; margin-bottom: 0.5rem; }

@media (min-width: 768px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
  .metrics-grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

/* Login Styles */
.login-container {
  max-width: 450px; width: 100%; background: rgba(31, 41, 55, 0.9); backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 16px; padding: 40px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); animation: fadeIn 0.8s ease-out;
}
.logo-container { text-align: center; margin-bottom: 30px; position: relative; }
.logo-circle {
  width: 120px; height: 120px; background: linear-gradient(135deg, #22c55e, #0d9e4a); border-radius: 50%;
  margin: 0 auto 20px; display: flex; justify-content: center; align-items: center;
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.3); animation: pulse 3s infinite;
}
@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 8px 20px rgba(34, 197, 94, 0.3); }
  50% { transform: scale(1.03); box-shadow: 0 10px 30px rgba(34, 197, 94, 0.4); }
  100% { transform: scale(1); box-shadow: 0 8px 20px rgba(34, 197, 94, 0.3); }
}
.logo-icon { font-size: 50px; color: white; transform: rotate(-15deg); }
.logo-text {
  font-size: 36px; font-weight: 700; background: linear-gradient(to right, #22c55e, #f97316);
  -webkit-background-clip: text; background-clip: text; color: transparent; margin-top: 15px;
  letter-spacing: 1px; position: relative;
}
.logo-text::after {
  content: ""; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
  width: 80px; height: 4px; background: linear-gradient(to right, #22c55e, #f97316); border-radius: 2px;
}
.welcome-text {
  text-align: center; font-size: 26px; font-weight: 600; margin-bottom: 30px; color: #f0f0f0;
  background: rgba(255, 255, 255, 0.05); padding: 12px 20px; border-radius: 50px; letter-spacing: 1px;
}
.form-group { margin-bottom: 25px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; color: #a0aec0; }
.form-group input {
  width: 100%; padding: 14px 18px; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 10px;
  background: rgba(75, 85, 99, 0.8); color: #e5e7eb; transition: all 0.3s ease;
}
.form-group input:focus { outline: none; border-color: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3); }
.form-group input::placeholder { color: #9ca3af; }
.login-button {
  width: 100%; padding: 15px; background: linear-gradient(to right, #22c55e, #16a34a); border: none;
  border-radius: 10px; color: white; font-weight: 600; cursor: pointer; transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(34, 197, 94, 0.3); position: relative; overflow: hidden;
}
.login-button::before {
  content: ""; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent); transition: 0.5s;
}
.login-button:hover::before { left: 100%; }
.login-button:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4); }
.login-button:active { transform: translateY(0); }
.error-message {
  color: #ef4444; padding: 10px; background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px; display: none; font-weight: 500;
}
.error-message.show { display: block; animation: shake 0.5s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.login-button:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
.login-button[data-loading="true"] { position: relative; color: transparent; }
.login-button[data-loading="true"]::after {
  content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  border: 2px solid transparent; border-top: 2px solid #ffffff; border-radius: 50%; width: 20px; height: 20px;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}
.footer-text { text-align: center; margin-top: 25px; color: #9ca3af; }

/* Enhanced Dashboard Header - Narrower Layout */
.dashboard-header {
  background: linear-gradient(135deg, #1e3a8a, #3730a3);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  border: var(--border);
  margin-bottom: 1.5rem;
}
.dashboard-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.store-info { display: flex; flex-direction: column; }
.store-name { font-size: 1.5rem; font-weight: 700; color: white; margin-bottom: 0.25rem; }
.welcome-message { font-size: 0.9rem; color: #e5e7eb; font-weight: 400; }
.time-info { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.current-datetime { font-size: 0.9rem; color: white; font-weight: 500; margin-bottom: 0.25rem; }
.sync-info { display: flex; flex-direction: column; align-items: flex-end; }
.sync-label { font-size: 0.8rem; color: #9ca3af; }
.sync-time { font-size: 0.9rem; color: #22c55e; font-weight: 600; }

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .container { padding: var(--spacing-sm); max-width: 100%; }
  .w-1-3 { width: 100%; }
  .flex { flex-direction: column; }
  .space-x-2 > * + * { margin-left: 0; margin-top: var(--spacing-sm); }
  button { padding: 0.5rem 0.75rem; }
  .card { padding: var(--spacing-sm); max-height: 80vh; overflow-y: auto; width: 100%; max-width: 100vw; }
  .table-container { overflow-x: auto; white-space: nowrap; }
  th, td { padding: 0.5rem; max-width: 100px; }
  input, select { padding: 0.5rem; width: 100%; }
  .sales-section { max-height: 80vh; overflow-y: auto; width: 100%; }
  .sales-form-container { max-height: 50vh; overflow-y: auto; width: 100%; max-width: 100%; }
  .modal { width: 100vw; margin: 0; }
  .modal > div { width: 100vw; max-width: 100vw; max-height: 85vh; overflow-y: auto; padding: var(--spacing-sm); margin: 0; box-sizing: border-box; }
  .alert { padding: 0.5rem; }
  .date-range-container { flex-direction: column; }
  .pagination { gap: 0.25rem; }
  .pagination button { padding: 0.25rem 0.5rem; min-width: 32px; }
  .table-info { flex-direction: column; align-items: flex-start; }
  .search-controls { flex-direction: column; align-items: stretch; }
  .search-input, .filter-select { min-width: 100%; }
  .breakdown-header { flex-wrap: wrap; }
  .close-breakdown { margin-left: auto; }
  .metrics-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .quick-actions-grid { grid-template-columns: 1fr; }
  
  .dashboard-header { padding: var(--spacing-md); }
  .dashboard-header-content { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .time-info { align-items: flex-start; text-align: left; }
  .store-name { font-size: 1.25rem; }
  .current-datetime { font-size: 0.85rem; }
  
  .quick-actions-container { grid-template-columns: 1fr; gap: 0.75rem; }
  .quick-action-btn, .stock-alert-btn { padding: 0.875rem 1rem; min-height: 60px; }
  .btn-icon { font-size: 1.25rem; margin-right: 0.5rem; width: 35px; }
  .btn-title { font-size: 0.9rem; }
  .btn-subtitle { font-size: 0.75rem; }
  
  .top-item { padding: 0.375rem; }
  .top-item-name { font-size: 0.8rem; margin: 0 0.5rem; }
}

@media (max-width: 480px) {
  .login-container { padding: 30px 20px; }
  .logo-circle { width: 100px; height: 100px; }
  .logo-icon { font-size: 40px; }
  .logo-text { font-size: 28px; }
  .welcome-text { font-size: 22px; }
  
  .quick-actions-container { gap: 0.5rem; }
  .quick-action-btn, .stock-alert-btn { padding: 0.75rem; min-height: 55px; }
  
  .dashboard-header { padding: 0.5rem 0.75rem; }
  .store-name { font-size: 1.1rem; }
  .current-datetime { font-size: 0.8rem; }
}