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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f0f0f;
  color: #e0e0e0;
  min-height: 100vh;
}

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

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid #2a2a2a;
  margin-bottom: 24px;
}

header h1 {
  font-size: 1.5rem;
  color: #fff;
}

.hidden { display: none !important; }

/* Accounts Bar */
.accounts-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 20px;
  font-size: 0.8rem;
}

.account-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
}

.account-remove {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 2px;
  line-height: 1;
}

.account-remove:hover { color: #dc2626; }

.account-tag {
  font-size: 0.7rem;
  color: #60a5fa;
  background: #2563eb22;
  padding: 1px 6px;
  border-radius: 4px;
}

/* Login */
.login-card {
  text-align: center;
  padding: 60px 40px;
  background: #1a1a1a;
  border-radius: 12px;
  border: 1px solid #2a2a2a;
  max-width: 400px;
  margin: 80px auto;
}

.login-card h2 {
  margin-bottom: 12px;
  color: #fff;
}

.login-card p {
  margin-bottom: 24px;
  color: #888;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #1a1a1a;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.15s;
}

.btn:hover { background: #252525; border-color: #444; }

.btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.btn-primary:hover { background: #1d4ed8; }

.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

.btn-success { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }

/* Form */
.select, .input {
  padding: 10px 14px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #1a1a1a;
  color: #e0e0e0;
  font-size: 0.875rem;
}

.select:focus, .input:focus {
  outline: none;
  border-color: #2563eb;
}

/* Controls */
.controls {
  margin-bottom: 24px;
}

.search-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Results */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.results-actions {
  display: flex;
  gap: 8px;
}

.badge {
  background: #2563eb;
  color: #fff;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  margin-left: 8px;
}

/* Email List */
.email-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.email-card {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.email-card:hover { border-color: #444; }

.email-card.selected {
  border-color: #2563eb;
  background: #1a1a2e;
}

.email-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
  cursor: pointer;
}

.email-info {
  flex: 1;
  min-width: 0;
}

.email-subject {
  font-weight: 500;
  color: #fff;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-meta {
  font-size: 0.8rem;
  color: #888;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.email-tracking {
  font-size: 0.75rem;
  color: #666;
  margin-top: 4px;
  font-family: monospace;
}

.carrier-tag {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.carrier-Amazon { background: #f59e0b22; color: #f59e0b; }
.carrier-FedEx { background: #8b5cf622; color: #8b5cf6; }
.carrier-UPS { background: #78350f44; color: #d4a55a; }
.carrier-OnTrac { background: #06b6d422; color: #06b6d4; }
.carrier-Walmart { background: #2563eb22; color: #60a5fa; }
.carrier-Best\ Buy, .carrier-BestBuy { background: #facc1522; color: #facc15; }
.carrier-Target { background: #dc262622; color: #f87171; }
.carrier-Costco { background: #dc262622; color: #f87171; }
.carrier-eBay { background: #16a34a22; color: #4ade80; }
.carrier-null { background: #33333366; color: #888; }

.status-tag {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-Delivered { background: #16a34a22; color: #4ade80; }
.status-Shipped { background: #2563eb22; color: #60a5fa; }
.status-Unknown { background: #33333366; color: #888; }

/* Match Results */
#match-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.match-card {
  background: #1a1a1a;
  border: 1px solid #16a34a44;
  border-radius: 10px;
  padding: 14px 18px;
}

.match-card .match-tracking {
  font-family: monospace;
  color: #4ade80;
  font-size: 0.85rem;
}

.match-card .match-item {
  color: #fff;
  font-weight: 500;
  margin-top: 4px;
}

.match-card .match-detail {
  color: #888;
  font-size: 0.8rem;
  margin-top: 2px;
}

.match-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.no-matches {
  text-align: center;
  padding: 40px;
  color: #888;
}

/* Loading */
#loading {
  text-align: center;
  padding: 60px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #333;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Status Bar */
#status-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #16a34a;
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.875rem;
  z-index: 100;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* Auto Sync */
.auto-sync-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  margin-bottom: 20px;
}

.auto-sync-desc {
  color: #888;
  font-size: 0.85rem;
}

.divider {
  border: none;
  border-top: 1px solid #2a2a2a;
  margin: 20px 0;
}

#sync-results {
  margin-bottom: 20px;
}

.sync-success {
  background: #16a34a11;
  border: 1px solid #16a34a44;
  border-radius: 10px;
  padding: 16px 20px;
}

.sync-success h3 {
  color: #4ade80;
  margin-bottom: 8px;
}

.sync-matches {
  margin-top: 10px;
}

.sync-match-item {
  padding: 4px 0;
  font-size: 0.85rem;
  color: #ccc;
}

.sync-match-item code {
  background: #333;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.sync-empty {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 16px 20px;
  color: #aaa;
}

.sync-hint {
  color: #666;
  font-size: 0.8rem;
  margin-top: 6px;
}

/* Responsive */
@media (max-width: 640px) {
  .search-row { flex-direction: column; }
  .search-row > * { width: 100%; }
  .results-header { flex-direction: column; align-items: flex-start; }
}
