:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

/* Navbar */
.navbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.nav-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 70px;
}

.logo {
  color: var(--primary);
  font-size: 1.6rem;
  font-weight: 800;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo::before {
  content: "⚡";
  font-size: 1.4rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: all 0.2s;
}

.nav-links a:hover {
  background: #eff6ff;
  color: var(--primary);
}

.nav-user {
  color: var(--text-light);
  font-size: 0.9rem;
  padding: 0 8px;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: #fff;
  border-radius: 9px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 5px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  background: #f1f5f9;
  color: var(--text);
  border: none;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
}

.btn:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-block {
  display: flex;
  width: 100%;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
  color: #fff;
  padding: 80px 0;
  margin-bottom: 40px;
}

.hero-content {
  max-width: 600px;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 20px;
  line-height: 1.2;
}

.hero p {
  font-size: 1.25rem;
  opacity: 0.9;
  margin-bottom: 30px;
}

.hero-btns {
  display: flex;
  gap: 15px;
}

.hero .btn {
  padding: 14px 28px;
  font-size: 1.05rem;
}

.hero .btn:first-child {
  background: #fff;
  color: var(--primary);
}

.hero .btn:first-child:hover {
  background: #f8fafc;
}

/* Features */
.features {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 50px;
}

.feature-card {
  background: var(--card-bg);
  padding: 30px 20px;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 15px;
}

.feature-card h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.feature-card p {
  color: var(--text-light);
  font-size: 0.9rem;
}

/* Page Title */
.page-title {
  margin-bottom: 30px;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}

/* Product Grid */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 60px;
}

.product-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: all 0.3s;
}

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

.product-card a {
  text-decoration: none;
  color: inherit;
  display: block;
}

.product-image {
  height: 220px;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.product-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.3s;
}

.product-card:hover .product-image img {
  transform: scale(1.05);
}

.product-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--danger);
  color: #fff;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.no-image {
  color: var(--text-light);
  font-size: 0.9rem;
}

.product-info {
  padding: 20px;
}

.product-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
  line-height: 1.4;
  min-height: 50px;
}

.product-desc {
  color: var(--text-light);
  font-size: 0.85rem;
  margin-bottom: 15px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.product-price {
  color: var(--danger);
  font-size: 1.4rem;
  font-weight: 700;
}

.product-stock {
  color: var(--text-light);
  font-size: 0.85rem;
}

/* Product Detail */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 50px;
  background: var(--card-bg);
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 40px;
}

.product-detail-image {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border-radius: var(--radius);
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.product-detail-image img {
  max-width: 90%;
  max-height: 380px;
  object-fit: contain;
}

.product-detail-info h1 {
  font-size: 2rem;
  margin-bottom: 15px;
}

.product-detail-info .product-price {
  font-size: 2.2rem;
  margin-bottom: 20px;
}

.product-detail-info .product-stock {
  font-size: 1rem;
  margin-bottom: 20px;
  padding: 10px 15px;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.product-description {
  margin: 25px 0;
  color: var(--text-light);
  line-height: 1.8;
  font-size: 1rem;
  white-space: pre-line;
}

.add-cart-form {
  display: flex;
  align-items: flex-end;
  gap: 15px;
  margin-top: 30px;
}

.add-cart-form .form-group {
  width: 120px;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--card-bg);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.checkbox-group input {
  width: auto;
}

/* Auth Card */
.auth-card {
  max-width: 420px;
  margin: 60px auto;
  background: var(--card-bg);
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.auth-card h1 {
  text-align: center;
  margin-bottom: 25px;
  font-size: 1.8rem;
}

.alert {
  padding: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.hint {
  text-align: center;
  margin-top: 20px;
  color: var(--text-light);
  font-size: 0.9rem;
}

/* Tables */
.data-table {
  width: 100%;
  background: var(--card-bg);
  border-collapse: separate;
  border-spacing: 0;
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.data-table th,
.data-table td {
  padding: 16px;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Cart */
.cart-item,
.order-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cart-thumb,
.order-thumb,
.admin-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
}

.admin-preview {
  max-width: 200px;
  max-height: 150px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
}

.inline-form {
  display: inline-flex;
}

.qty-input {
  width: 70px;
  padding: 8px;
  text-align: center;
}

.cart-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 30px;
  padding: 25px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.total {
  font-size: 1.3rem;
  color: var(--danger);
  font-weight: 700;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-light);
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.empty-state a {
  color: var(--primary);
  font-weight: 600;
}

/* Checkout */
.checkout-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.checkout-cart,
.checkout-form {
  background: var(--card-bg);
  padding: 30px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.checkout-cart h2,
.checkout-form h2 {
  margin-bottom: 20px;
  font-size: 1.3rem;
}

/* Orders */
.order-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  overflow: hidden;
}

.order-header,
.order-footer {
  padding: 18px 24px;
  background: #f8fafc;
}

.order-header {
  display: flex;
  gap: 25px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--text-light);
  align-items: center;
}

.order-items {
  padding: 20px 24px;
}

.order-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.order-status {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.status-shipped {
  background: #dbeafe;
  color: #1e40af;
}

.status-completed {
  background: #d1fae5;
  color: #065f46;
}

.status-cancelled {
  background: #fee2e2;
  color: #991b1b;
}

/* Admin */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--card-bg);
  padding: 30px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  text-align: center;
}

.stat-card h3 {
  color: var(--text-light);
  font-size: 1rem;
  margin-bottom: 12px;
}

.stat-number {
  font-size: 2.8rem;
  color: var(--primary);
  font-weight: 800;
  margin-bottom: 15px;
}

.admin-form {
  max-width: 700px;
  background: var(--card-bg);
  padding: 35px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.order-actions {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 12px;
}

.text-muted {
  color: var(--text-light);
}

/* Footer */
.footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 40px 0;
  margin-top: auto;
  text-align: center;
  color: var(--text-light);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 25px;
  margin-bottom: 15px;
}

.footer-links a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.footer-links a:hover {
  color: var(--primary);
}

/* Mobile */
@media (max-width: 768px) {
  .hero {
    padding: 50px 0;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero-btns {
    flex-direction: column;
  }

  .features {
    grid-template-columns: repeat(2, 1fr);
  }

  .product-detail,
  .checkout-layout {
    grid-template-columns: 1fr;
  }

  .admin-stats {
    grid-template-columns: 1fr;
  }

  .nav-content {
    flex-direction: column;
    height: auto;
    padding: 15px 20px;
    gap: 12px;
  }

  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
  }

  .cart-summary {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }
}

/* Sortable table headers */
.sort-link {
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.sort-link:hover {
  color: var(--primary);
  background: #eff6ff;
}

/* Product category/model tags */
.product-tags {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.product-tag {
  display: inline-block;
  padding: 3px 10px;
  background: #eff6ff;
  color: var(--primary);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.product-tag.tag-model {
  background: #f0fdf4;
  color: #15803d;
}

.access-form { max-width: 560px; }
.policy-content { max-width: 850px; }
.policy-content h2, .account-panels h2 { margin: 1em 0 .5em; }
.policy-content p, .account-panels section > p { margin-bottom: .8em; }
.account-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 1rem; align-items: start; }
.account-panels .admin-form { width: 100%; margin: 0; }
.form-consent, .form-message { margin: .8rem 0; }
.form-consent input { margin-right: .4rem; }
.nav-inline { display: inline; margin: 0; }
.nav-action { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; }
.out-of-stock { font-weight: 600; color: #991b1b; }
.support-message { white-space: pre-wrap; overflow-wrap: anywhere; }
