:root {
  /* Golden Glaze Donuts Color Scheme (Light Theme) */
  --bg: #fff0dd; /* Light cream background (rgb(255, 240, 221)) */
  --card: #ffffff; /* White cards */
  --text: #2c1810; /* Dark brown text */
  --muted: #8b6f47; /* Muted brown */
  --accent: #da9256; /* Golden tan - primary brand color (rgb(218, 146, 86)) */
  --accent-light: #fff0dd; /* Light cream */
  --accent-pink: #df96a7; /* Pink accent (rgb(223, 150, 167)) */
  --accent-purple: #461257; /* Deep purple (rgb(70, 18, 87)) */
  --positive: #2ecc71;
  --negative: #e74c3c;
  --border: #e8d4b8; /* Light tan border */
}

[data-theme="dark"] {
  /* Dark Theme */
  --bg: #0b0f14;
  --card: #121821;
  --text: #e7eef8;
  --muted: #a9b3c1;
  --accent: #da9256; /* Keep golden accent for brand consistency */
  --accent-light: #1a2332;
  --accent-pink: #df96a7;
  --accent-purple: #461257;
  --positive: #2ecc71;
  --negative: #e74c3c;
  --border: #1f2a37;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
}

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

.header-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(218, 146, 86, 0.1);
  border: 1px solid rgba(218, 146, 86, 0.3);
  transition: all 0.2s;
  font-weight: 500;
  font-size: 14px;
  user-select: none;
}

.header-checkbox:hover {
  background: rgba(218, 146, 86, 0.15);
  border-color: rgba(218, 146, 86, 0.5);
}

.header-checkbox input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.header-checkbox input[type="checkbox"]:checked {
  accent-color: var(--accent);
}

.header-checkbox input[type="checkbox"]:checked ~ span {
  color: var(--accent);
  font-weight: 600;
}

.header-checkbox span {
  color: var(--text);
  font-size: 14px;
}

/* Store Cards */
.stores-section {
  margin-bottom: 40px;
}

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

.stores-section-title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stores-section-header h2 {
  margin: 0;
  font-size: 22px;
}

.store-filter-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  color: var(--muted);
  transition: color 0.2s;
}

.store-filter-checkbox:hover {
  color: var(--text);
}

.store-filter-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
  margin: 0;
}

.store-filter-checkbox input[type="checkbox"]:checked ~ span {
  color: var(--text);
  font-weight: 500;
}

.store-filter-checkbox span {
  color: inherit;
}

.carousel-controls {
  display: flex;
  gap: 8px;
}

.carousel-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
  line-height: 1;
}

.carousel-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  transform: scale(1.1);
}

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

.stores-carousel-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}

.stores-carousel {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  padding: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--card);
  align-items: stretch;
}

.stores-carousel::-webkit-scrollbar {
  height: 8px;
}

.stores-carousel::-webkit-scrollbar-track {
  background: var(--card);
  border-radius: 4px;
}

.stores-carousel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.stores-carousel::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.stores-carousel .store-card {
  flex: 0 0 300px;
  min-width: 300px;
  max-width: 300px;
  min-height: 280px;
  height: 280px;
}

.store-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 280px;
  height: 280px;
}

.store-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(218, 146, 86, 0.2);
}

.store-card-selected {
  border-color: var(--accent);
  background: rgba(218, 146, 86, 0.08);
  box-shadow: 0 0 0 2px rgba(218, 146, 86, 0.2);
}

.store-card-selected:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(218, 146, 86, 0.2);
}

.store-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 16px;
}

.store-checkbox-indicator {
  width: 24px;
  height: 24px;
  border: 2px solid var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  color: var(--accent);
  font-weight: bold;
  font-size: 14px;
  flex-shrink: 0;
  transition: all 0.2s;
}

.store-card-selected .store-checkbox-indicator {
  background: var(--accent);
  color: #ffffff;
}

.store-name {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px 0;
  color: var(--text);
}

.store-status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.store-status.active {
  background: rgba(46, 204, 113, 0.2);
  color: var(--positive);
}

.store-status.inactive {
  background: rgba(169, 179, 193, 0.2);
  color: var(--muted);
}

.store-address {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 16px;
  flex: 1 1 auto;
  min-height: 60px;
  max-height: 100px;
  overflow: hidden;
}

.store-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.store-stat {
  text-align: center;
}

.store-stat-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent);
  display: block;
}

.store-stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 4px;
}

/* Charts Section */
.charts-section {
  margin-bottom: 40px;
}

.charts-section h2 {
  margin: 0 0 20px 0;
  font-size: 22px;
}

.chart-controls {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.chart-controls label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
}

.chart-controls select {
  margin-top: 6px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  min-width: 150px;
}


.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
}

.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.chart-card h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.chart-card canvas {
  max-height: 300px;
}

/* Tabs */
.tabs-container {
  margin-top: 32px;
}

.tabs-nav {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--accent-light);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-content {
  display: none;
}

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

/* Leaderboard Table */
.leaderboard-table {
  margin-bottom: 20px;
}

.leaderboard-table-content {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.leaderboard-table-content th {
  text-align: left;
  padding: 12px;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
}

.leaderboard-table-content td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.leaderboard-table-content tr:hover {
  background: var(--accent-light);
}

.leaderboard-table-content .positive {
  color: var(--positive);
  font-weight: 600;
}

.leaderboard-table-content .negative {
  color: var(--negative);
  font-weight: 600;
}

/* Sales List */
.sales-list {
  max-height: 600px;
  overflow-y: auto;
}

.sale-list-item {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sale-list-item:last-child {
  border-bottom: none;
}

.sale-list-item-info {
  flex: 1;
}

.sale-list-item-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pagination {
  margin-top: 20px;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-danger {
  background: var(--negative);
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover:not(:disabled) {
  background: #c0392b;
  transform: translateY(-1px);
}

.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Buttons */
button {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

button:hover {
  background: var(--accent-light);
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  border: none;
}

.btn-primary:hover {
  background: #c87d3f;
}

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

a.btn-secondary {
  text-decoration: none;
  display: inline-block;
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
  font-family: inherit;
}

.btn-logout:hover {
  background: var(--negative);
  border-color: var(--negative);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-logout svg {
  width: 18px;
  height: 18px;
}

.btn-theme {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.btn-theme:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-theme svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-theme span {
  white-space: nowrap;
}

.btn-secondary:hover {
  background: var(--accent-light);
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.btn-back:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-back svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-back span {
  white-space: nowrap;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.2s ease-out;
}

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

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

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

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

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  margin-top: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}

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

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.form-message {
  margin-top: 12px;
  padding: 10px;
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
}

.form-message.success {
  background: rgba(46, 204, 113, 0.2);
  color: var(--positive);
  border: 1px solid rgba(46, 204, 113, 0.3);
}

.form-message.error {
  background: rgba(231, 76, 60, 0.2);
  color: var(--negative);
  border: 1px solid rgba(231, 76, 60, 0.3);
}

.form-message.warning {
  background: rgba(243, 156, 18, 0.2);
  color: #f39c12;
  border: 1px solid rgba(243, 156, 18, 0.3);
}

.form-message.info {
  background: rgba(124, 196, 255, 0.2);
  color: var(--accent);
  border: 1px solid rgba(124, 196, 255, 0.3);
}

/* Form Section */
.form-section {
  max-width: 800px;
  margin: 0 auto;
}

.form-section .card {
  padding: 24px;
}

.form-section h2 {
  margin-top: 0;
  margin-bottom: 20px;
}

.form-section h3 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 18px;
}

/* Recent Sales */
.recent-sales {
  max-height: 400px;
  overflow-y: auto;
}

.recent-sales-item {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.recent-sales-item:last-child {
  border-bottom: none;
}

.recent-sales-item-info {
  flex: 1;
}

.recent-sales-item-info strong {
  display: block;
  margin-bottom: 4px;
}

.recent-sales-item-info small {
  color: var(--muted);
  font-size: 12px;
}

.recent-sales-item-amount {
  font-size: 18px;
  font-weight: 600;
  color: var(--positive);
}

.muted {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 20px;
}

/* Store List */
.stores-list {
  max-height: 500px;
  overflow-y: auto;
}

.store-list-item {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.store-list-item:last-child {
  border-bottom: none;
}

.store-list-item-info {
  flex: 1;
}

.store-list-item-info strong {
  display: block;
  margin-bottom: 4px;
  font-size: 16px;
}

.store-list-item-info small {
  color: var(--muted);
  font-size: 13px;
}

.store-list-item-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-edit,
.btn-delete {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.btn-edit:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-delete:hover {
  background: var(--negative);
  border-color: var(--negative);
  color: #ffffff;
}

.btn-edit svg,
.btn-delete svg {
  width: 16px;
  height: 16px;
}

.status-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.active {
  background: rgba(46, 204, 113, 0.2);
  color: var(--positive);
  border: 1px solid rgba(46, 204, 113, 0.3);
}

.status-badge.inactive {
  background: rgba(169, 179, 193, 0.2);
  color: var(--muted);
  border: 1px solid rgba(169, 179, 193, 0.3);
}

/* Login Page */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg);
}

.login-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.login-card h1 {
  margin: 0 0 8px 0;
  font-size: 28px;
  color: var(--text);
  text-align: center;
}

.login-subtitle {
  text-align: center;
  color: var(--muted);
  margin: 0 0 32px 0;
  font-size: 14px;
}

.login-footer {
  margin-top: 24px;
  text-align: center;
}

.btn-block {
  width: 100%;
}

.error-message {
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.3);
  color: #e74c3c;
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}

.link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}

.link:hover {
  text-decoration: underline;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

.status-badge.expired {
  background: rgba(231, 76, 60, 0.2);
  color: var(--negative);
  border: 1px solid rgba(231, 76, 60, 0.3);
}

/* Responsive */
@media (max-width: 900px) {
  .stores-carousel .store-card {
    flex: 0 0 280px;
    min-width: 280px;
    max-width: 280px;
    min-height: 280px;
    height: 280px;
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
}

@media (max-width: 600px) {
  .stores-carousel .store-card {
    flex: 0 0 260px;
    min-width: 260px;
    max-width: 260px;
    min-height: 280px;
    height: 280px;
  }
  .store-stats {
    grid-template-columns: 1fr;
  }
  .carousel-controls {
    display: none; /* Hide on very small screens, use touch scroll */
  }
}
