:root {
  --primary: #1e88e5;
  --danger: #e53935;
  --bg: #f5f7fb;
  --text: #222;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.site-header {
  background: white;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.logo {
  font-weight: 700;
  font-size: 1.2rem;
}

nav a {
  margin-left: 1rem;
  text-decoration: none;
  color: var(--text);
}

.content {
  padding: 2rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
}

.secondary {
  background: #e8f1ff;
  color: var(--primary);
  border: 1px solid #c6dbff;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  margin-left: 0.6rem;
}

.form-card,
.auth-card {
  max-width: 420px;
  margin: 0 auto;
  background: white;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

label {
  display: block;
  margin-bottom: 1rem;
}

input,
select {
  width: 100%;
  padding: 0.6rem;
  margin-top: 0.4rem;
  border-radius: 6px;
  border: 1px solid #d0d7e2;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 260px);
  gap: 1.5rem;
  justify-content: center;
}

.product-card {
  background: white;
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 3px 8px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: 260px;
}

.product-image img {
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  cursor: zoom-in;
}

.placeholder {
  aspect-ratio: 2 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef2f8;
  border-radius: 8px;
}

.product-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: nowrap;
  width: 100%;
}

.product-card .qty-editor {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
}

.stock-btn,
.cart-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #e3e9f4;
  font-size: 1.1rem;
  cursor: pointer;
}

.link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
}

.action-btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}

.action-btn.edit-btn {
  background: #e8f1ff;
  color: var(--primary);
  border-color: #c6dbff;
}

.action-btn.delete-btn {
  background: #ffe9e9;
  color: var(--danger);
  border-color: #ffc5c5;
}

.stock-pill {
  background: #f2f5fb;
  border: 1px solid #d4dbe6;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-weight: 600;
}

.qty-editor {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.qty-input {
  width: 80px;
  text-align: center;
}

.hidden {
  display: none !important;
}

.bulk-form {
  background: white;
  padding: 1rem;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.bulk-table {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.bulk-row {
  display: grid;
  grid-template-columns: 2fr 2fr 1.3fr 2fr 1.3fr;
  gap: 0.8rem;
  align-items: center;
}

.bulk-header {
  font-weight: 700;
  font-size: 0.9rem;
  color: #6b7280;
}

.bulk-stock {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.bulk-sizes input {
  width: 110px;
}

@media (max-width: 768px) {
  .bulk-row {
    grid-template-columns: 1fr;
  }
}

.action-delete.hidden,
.action-edit.hidden {
  display: none !important;
}

.link.danger {
  color: var(--danger);
}

.inline {
  display: inline;
}

.muted {
  color: #6b7280;
  font-size: 0.9rem;
  margin-left: 0.5rem;
}

.filters form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.tab-bar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  justify-content: center;
}

.tab-btn {
  border: 1px solid #d4dbe6;
  background: #f2f5fb;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.tab-panel {
  display: none;
}

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

.tab-title {
  margin-top: 0;
  margin-bottom: 1rem;
  text-align: center;
}

.subtab-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.tab-label {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin: 0.75rem 0 0.4rem;
  text-align: center;
}

.subtab-btn {
  border: 1px solid #d4dbe6;
  background: #fff;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.subtab-btn.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

.subtab-panel {
  display: none;
}

.subtab-panel.active {
  display: block;
}

.flash {
  margin-bottom: 1rem;
}

.flash-success {
  background: #e8f5e9;
  padding: 0.6rem;
  border-radius: 6px;
}

.flash-error {
  background: #ffebee;
  padding: 0.6rem;
  border-radius: 6px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  padding: 1rem;
  border-radius: 10px;
  text-align: center;
}

.orders .order-card {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.cart-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cart-item {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cart-qty-input {
  width: 64px;
  text-align: center;
}

.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-modal img {
  max-width: 80%;
  max-height: 80%;
  border-radius: 8px;
}

.image-modal.hidden {
  display: none;
}

#modal-close {
  position: absolute;
  top: 20px;
  right: 40px;
  font-size: 2rem;
  color: white;
  cursor: pointer;
}

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  nav a {
    margin-left: 0.5rem;
  }
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.category-item {
  background: white;
  border-radius: 8px;
  padding: 0.8rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.category-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.category-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.invite-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.invite-card {
  background: white;
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.invite-link {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.invite-link input {
  width: 380px;
}

.invite-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.invite-status {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-start;
}

@media (max-width: 768px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.9rem 1rem;
  }

  nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  nav a {
    margin-left: 0;
    background: #f2f5fb;
    border: 1px solid #d4dbe6;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.9rem;
  }

  .content {
    padding: 1.2rem;
  }

  .invite-card {
    flex-direction: column;
    align-items: stretch;
  }

  .invite-link {
    flex-direction: column;
    align-items: stretch;
  }

  .invite-link input {
    width: 100%;
  }

  .invite-meta {
    flex-direction: column;
    gap: 0.35rem;
  }

  .invite-status {
    align-items: flex-start;
  }

  .copy-btn,
  .invite-status .action-btn {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 600px) {
  .tab-bar,
  .subtab-bar {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.3rem;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn,
  .subtab-btn {
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
  }

  .product-card {
    width: auto;
    padding: 0.8rem;
  }

  .product-image img,
  .placeholder {
    height: auto;
  }
}

.status {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
}

.status.used {
  background: #e8f5e9;
  color: #1b5e20;
}

.status.pending {
  background: #fff3e0;
  color: #e65100;
}
