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

body {
  font-family: "Segoe UI", Arial, sans-serif;
  color: #1f2933;
  background: #f3f4f6;
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: min(1100px, 92%);
  margin: 0 auto;
}

.site-header {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.nav {
  display: flex;
  gap: 18px;
  font-size: 14px;
  color: #4b5563;
}

.nav a:hover {
  color: #111827;
}

.avatar-link {
  display: inline-flex;
  align-items: center;
}

.avatar-link.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #9ca3af;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.avatar.has-image img {
  display: block;
}

.avatar.has-image span {
  display: none;
}

.primary-btn {
  background: #111827;
  color: #ffffff;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.2);
}

.products {
  padding: 60px 0;
}

.products-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.products-title {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.products-head-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.list-mode-switch {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
}

.mode-btn {
  border: none;
  background: #ffffff;
  color: #4b5563;
  font-size: 13px;
  padding: 8px 12px;
  cursor: pointer;
}

.mode-btn + .mode-btn {
  border-left: 1px solid #e5e7eb;
}

.mode-btn.active {
  background: #111827;
  color: #ffffff;
}

.audit-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #4b5563;
}

.audit-search input {
  width: 190px;
  max-width: 40vw;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}

.audit-search input::placeholder {
  color: #9ca3af;
}

.title-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #4b5563;
  user-select: none;
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #d1d5db;
  transition: 0.2s;
  border-radius: 999px;
}

.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: #ffffff;
  transition: 0.2s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background: #111827;
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

.ip-role-selector {
  display: inline-flex;
}

.category-selector {
  display: inline-flex;
}

.category-trigger {
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  font-size: 14px;
  border-radius: 10px;
  padding: 8px 34px 8px 12px;
  cursor: pointer;
  min-width: 110px;
  text-align: left;
  position: relative;
}

.category-trigger[aria-expanded="true"] {
  border-color: #111827;
}

.ip-role-trigger {
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  font-size: 14px;
  border-radius: 10px;
  padding: 8px 34px 8px 12px;
  cursor: pointer;
  min-width: 130px;
  text-align: left;
  position: relative;
}

.ip-role-trigger[aria-expanded="true"] {
  border-color: #111827;
}

.ip-role-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.ip-role-modal.show {
  display: flex;
}

.category-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.category-modal.show {
  display: flex;
}

.category-dialog {
  width: min(420px, 92vw);
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  padding: 14px;
  display: grid;
  gap: 10px;
  max-height: 78vh;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.category-title {
  font-size: 16px;
  color: #111827;
  font-weight: 600;
}

.category-close {
  border: none;
  background: #f3f4f6;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  color: #111827;
}

.category-options {
  max-height: 58vh;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  display: grid;
  gap: 6px;
}

.ip-role-dialog {
  width: min(480px, 92vw);
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  padding: 14px;
  display: grid;
  gap: 10px;
  max-height: 78vh;
}

.ip-role-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ip-role-title {
  font-size: 16px;
  color: #111827;
  font-weight: 600;
}

.ip-role-close {
  border: none;
  background: #f3f4f6;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  color: #111827;
}

.ip-role-options {
  max-height: 58vh;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  display: grid;
  gap: 6px;
}

.ip-role-group-label {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 4px;
  padding: 2px 2px 0;
}

.ip-group {
  display: grid;
  gap: 4px;
}

.ip-role-option {
  border: none;
  background: #f9fafb;
  color: #111827;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.ip-role-option:hover {
  background: #eef2ff;
}

.ip-role-ip-option {
  font-weight: 600;
  position: relative;
  padding-left: 28px;
}

.ip-role-ip-option::before {
  content: "▶";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #6b7280;
  transition: transform 0.2s ease;
}

.ip-role-ip-option.open::before {
  transform: translateY(-50%) rotate(90deg);
}

.ip-role-children {
  display: grid;
  gap: 4px;
  padding-left: 12px;
}

.ip-role-role-option {
  font-size: 13px;
}

.ip-role-option.active {
  background: #111827;
  color: #ffffff;
}

.ip-role-option:focus-visible,
.ip-role-trigger:focus-visible,
.category-trigger:focus-visible,
.category-close:focus-visible,
.ip-role-close:focus-visible,
.mode-btn:focus-visible,
.pagination-btn:focus-visible,
.audit-search input:focus-visible {
  outline: 2px solid #111827;
  outline-offset: 2px;
}

.products-head h1 {
  font-size: 28px;
}

.empty-state {
  text-align: center;
  color: #6b7280;
  background: #ffffff;
  border-radius: 12px;
  padding: 40px 16px;
  border: 1px dashed #e5e7eb;
}

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

@media (min-width: 900px) {
  .product-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

.product-pagination {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-btn {
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}

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

.pagination-text {
  font-size: 13px;
  color: #4b5563;
}

.product-card {
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  display: grid;
  cursor: pointer;
}

.product-card:focus-visible {
  outline: 2px solid #111827;
  outline-offset: 4px;
}

.product-card img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #e5e7eb;
}

.product-body {
  background: #ffffff;
  padding: 14px 16px 18px;
  display: grid;
  gap: 6px;
}

.product-title {
  font-weight: 600;
  font-size: 16px;
}

.product-grid.hide-product-title .product-title {
  display: none;
}

.product-price {
  font-weight: 700;
  font-size: 20px;
  color: #111827;
}

.product-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.product-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.product-mini-btn {
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1.2;
}

.product-mini-btn.primary {
  border-color: #111827;
  background: #111827;
  color: #ffffff;
}

.product-mini-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.product-desc {
  color: #4b5563;
  font-size: 14px;
}

.product-category {
  color: #6b7280;
  font-size: 13px;
  flex: 1;
}

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

.product-iprole {
  font-size: 12px;
  color: #1f2937;
  background: #eef2ff;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.site-footer {
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 20px 0;
  margin-top: 20px;
  position: relative;
  z-index: 2;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  color: #4b5563;
  font-size: 14px;
}

.footer-admin {
  display: flex;
  align-items: center;
  gap: 16px;
}

#adminShortcut {
  cursor: pointer;
  user-select: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #111827;
  display: inline-block;
}

.global-toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  background: rgba(17, 24, 39, 0.9);
  color: #ffffff;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2000;
}

.global-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.global-toast.error {
  background: rgba(185, 28, 28, 0.92);
}

@media (max-width: 640px) {
  .hero-text h1 {
    font-size: 30px;
  }

  .nav {
    gap: 12px;
  }
}
