* {
  box-sizing: border-box;
}

:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --line: #d5deea;
  --text: #101828;
  --muted: #667085;
  --primary: #2f9f44;
  --primary-dark: #237d35;
  --accent: #ef8b10;
  --danger: #dc2626;
  --soft: #f8fafc;
  --header-h: 84px;
}

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

.hidden {
  display: none !important;
}

.site-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 24px 14px 32px;
  margin-top: 18px;
}

.site-footer-text {
  max-width: 900px;
  text-align: center;
  color: #8a94a8;
  font-size: 11px;
  line-height: 1.7;
}

.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 120;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

.toast.success {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.toast.error {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #991b1b;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-panel {
  width: min(1080px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.09);
}

.auth-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.hk-logo {
  width: 76px;
  height: 76px;
  border-radius: 999px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  padding: 4px;
}

.auth-head h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.auth-head p {
  margin: 4px 0 0 0;
  color: var(--muted);
}

.auth-lang-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.auth-lang-row select,
.lang-select,
input,
select,
textarea {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.auth-tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
}

.auth-tab.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.auth-form {
  display: grid;
  gap: 9px;
}

.auth-form label {
  font-size: 13px;
  color: #334155;
  display: block;
  margin-bottom: 4px;
}

.section-title {
  margin-top: 8px;
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.field-hint {
  margin: -2px 0 6px;
  font-size: 12px;
  color: #667085;
}

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

.auth-form .two-col > div,
.product-form .two-col > div {
  display: flex;
  flex-direction: column;
}

.auth-form input,
.auth-form select,
.auth-form textarea,
.product-form input,
.product-form select,
.product-form textarea {
  width: 100%;
  min-height: 40px;
}

.auth-form textarea,
.product-form textarea {
  min-height: 90px;
}

.notice-box {
  margin-bottom: 12px;
  border-radius: 10px;
  padding: 9px 11px;
  border: 1px solid;
}

.notice-box.success {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.notice-box.error {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #991b1b;
}

.w-full {
  width: 100%;
}

.bot-trap {
  position: absolute;
  left: -99999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.btn {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: #334155;
  padding: 9px 13px;
  font-weight: 700;
  cursor: pointer;
}

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

.btn.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn.dark {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
}

.btn.ghost {
  background: var(--soft);
}

.btn.danger {
  border-color: #fca5a5;
  color: #b91c1c;
  background: #fff5f5;
}

.b2b-app {
  min-height: 100vh;
}

.hk-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1.2fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 10px 16px;
}

.hk-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hk-brand .hk-logo {
  width: 58px;
  height: 58px;
}

.hk-brand-text strong {
  display: block;
  font-size: 20px;
  line-height: 1.2;
}

.hk-brand-text span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.hk-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.menu-toggle {
  display: none;
}

.nav-link {
  border: none;
  background: none;
  color: #344054;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 9px;
  border-bottom: 2px solid transparent;
}

.nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.hk-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.hk-main {
  padding: 14px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.catalog-top {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto auto;
  gap: 9px;
  margin-bottom: 12px;
}

.search-input {
  width: 100%;
  border-radius: 999px;
}

.mobile-only-inline {
  display: none;
}

.catalog-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 300px;
  gap: 12px;
  align-items: start;
}

.filters-panel,
.order-sidebar,
.admin-card,
.account-card {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 12px;
}

.filters-panel h3,
.order-sidebar h3,
.admin-card h3 {
  margin: 0 0 10px 0;
}

.filters-panel label,
.order-sidebar label {
  display: block;
  margin: 9px 0 6px 0;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.filters-panel select,
.order-sidebar textarea {
  width: 100%;
  margin-bottom: 8px;
}

.stock-filter-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.stock-filter-buttons .btn {
  font-size: 12px;
  padding: 8px 6px;
}

.stock-filter-buttons .btn.active {
  border-color: #15803d;
  color: #166534;
  background: #f0fdf4;
}

.products-wrap {
  min-width: 0;
}

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

.products-head h2 {
  margin: 0;
}

.products-head span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.p-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.p-img-wrap {
  position: relative;
  height: 170px;
  background: #f1f5f9;
  border-bottom: 1px solid #e5e7eb;
}

.p-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ref-chip {
  position: absolute;
  left: 8px;
  top: 8px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 8px;
  border: 1px solid #d1d5db;
  padding: 3px 7px;
  font-weight: 700;
  font-size: 12px;
}

.p-body {
  padding: 10px;
  display: grid;
  gap: 7px;
}

.p-brand {
  color: #64748b;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.p-body h4 {
  margin: 0;
  min-height: 48px;
  font-size: 18px;
  line-height: 1.25;
}

.p-local {
  color: #5b6779;
  min-height: 18px;
}

.p-line {
  font-size: 12px;
  color: #475569;
}

.p-line span {
  font-weight: 700;
}

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

.p-price-label {
  color: #64748b;
  font-size: 12px;
}

.p-price-value {
  color: #111827;
  font-size: 14px;
  font-weight: 700;
}

.stock-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
}

.stock-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.stock-badge.in {
  color: #166534;
}

.stock-badge.in .stock-dot {
  background: #16a34a;
}

.stock-badge.out {
  color: #b91c1c;
}

.stock-badge.out .stock-dot {
  background: #ef4444;
}

.qty-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border-radius: 999px;
  background: #35a83e;
  padding: 4px;
  width: 100%;
  max-width: 190px;
  min-width: 0;
  overflow: hidden;
}

.qty-box.compact {
  max-width: 150px;
}

.qty-box button {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #334155;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

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

.qty-box span {
  color: #fff;
  flex: 1;
  font-size: 26px;
  font-weight: 800;
  min-width: 0;
  text-align: center;
}

.summary-grid {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 12px;
  padding: 8px 9px;
  margin-bottom: 10px;
}

.summary-grid > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.summary-grid strong {
  font-size: 20px;
}

.shipping-box {
  border: 1px solid #dbe6f3;
  border-radius: 12px;
  background: #f8fbff;
  padding: 8px 9px;
  margin-bottom: 10px;
}

.shipping-box h4 {
  margin: 0 0 6px 0;
}

.shipping-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 13px;
}

.shipping-row strong {
  font-size: 14px;
}

.shipping-rule-text,
.shipping-note-text {
  margin: 6px 0 0;
  font-size: 12px;
  color: #64748b;
  line-height: 1.5;
}

.cart-list {
  display: grid;
  gap: 8px;
}

.company-box {
  margin-top: 10px;
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
  display: grid;
  gap: 3px;
  font-size: 12px;
  color: #475569;
}

.company-box strong {
  color: #0f172a;
}

.company-box a {
  color: #2563eb;
  text-decoration: none;
}

.cart-item {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px;
  background: #fff;
}

.cart-item .line1 {
  display: grid;
  gap: 3px;
  margin-bottom: 6px;
}

.cart-item .line1 strong {
  font-size: 13px;
}

.cart-item .line1 small {
  color: #64748b;
  font-size: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.table th,
.table td {
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 10px;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

.table th {
  background: #eef3f8;
  font-weight: 800;
}

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

.account-item {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.account-item span {
  color: #64748b;
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.account-item strong {
  font-size: 15px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
}

.admin-left,
.admin-right {
  min-width: 0;
}

.customer-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  margin-bottom: 8px;
  overflow: hidden;
}

.customer-card summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 9px;
}

.customer-card summary::-webkit-details-marker {
  display: none;
}

.customer-card summary small {
  display: block;
  color: #64748b;
  margin-top: 2px;
}

.customer-details {
  padding: 0 9px 9px;
  border-top: 1px solid #eef2f7;
}

.customer-details p {
  margin: 7px 0;
  font-size: 13px;
  color: #334155;
}

.status-pill {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.pending {
  background: #fff7ed;
  color: #9a3412;
}

.status-pill.approved,
.status-pill.in_stock {
  background: #f0fdf4;
  color: #166534;
}

.status-pill.rejected,
.status-pill.out_of_stock {
  background: #fef2f2;
  color: #991b1b;
}

.status-pill.suspended {
  background: #f8fafc;
  color: #475569;
}

.mini-link {
  color: #1d4ed8;
  text-decoration: none;
  font-size: 12px;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.product-form {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.product-form label {
  display: block;
  margin-bottom: 4px;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.product-form textarea {
  width: 100%;
  resize: vertical;
}

.inline-row {
  margin-top: 6px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-row input[type="text"],
.inline-row input[type="file"] {
  flex: 1;
  min-width: 0;
}

.image-preview {
  margin-top: 8px;
  width: 100%;
  max-width: 180px;
  max-height: 160px;
  object-fit: contain;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.admin-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 220px;
  gap: 8px;
  margin-bottom: 8px;
}

.admin-products {
  display: grid;
  gap: 8px;
}

.admin-product-row {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.admin-product-main {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.admin-product-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-product-name {
  font-weight: 700;
}

.admin-product-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 12px;
  color: #475569;
  font-size: 12px;
}

.pagination {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.page-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.page-dot {
  color: #64748b;
  font-size: 13px;
}

.backup-box {
  margin-top: 12px;
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
}

.empty {
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  padding: 12px;
  color: #64748b;
}

.app-footer {
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

@media (max-width: 1280px) {
  .catalog-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .order-sidebar {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  .hk-header {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand actions"
      "menu menu"
      "nav nav";
  }

  .hk-brand {
    grid-area: brand;
  }

  .hk-actions {
    grid-area: actions;
    justify-self: end;
  }

  .menu-toggle {
    display: inline-flex;
    grid-area: menu;
    width: fit-content;
  }

  .hk-nav {
    grid-area: nav;
    display: none;
    border-top: 1px solid #eef2f7;
    padding-top: 8px;
  }

  .hk-nav.open {
    display: flex;
  }

  .catalog-top {
    grid-template-columns: 1fr 1fr;
  }

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

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

@media (max-width: 680px) {
  .auth-panel {
    padding: 14px;
  }

  .auth-head h1 {
    font-size: 23px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .catalog-top {
    grid-template-columns: 1fr 1fr;
  }

  .catalog-layout {
    grid-template-columns: 1fr;
  }

  .filters-panel {
    display: none;
  }

  .filters-panel.mobile-visible {
    display: block;
  }

  .mobile-only-inline {
    display: inline-flex;
  }

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

  .p-img-wrap {
    height: 126px;
  }

  .p-body h4 {
    font-size: 15px;
    min-height: 38px;
  }

  .p-price-value {
    font-size: 13px;
  }

  .qty-box {
    max-width: 100%;
    width: 100%;
    gap: 5px;
  }

  .qty-box button {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
    font-size: 20px;
  }

  .qty-box span {
    font-size: 18px;
  }

  .account-grid {
    grid-template-columns: 1fr;
  }

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

  .site-footer {
    padding: 20px 10px 28px;
  }

  .site-footer-text {
    font-size: 10px;
  }
}
