* { box-sizing: border-box; }

:root {
  color-scheme: light;
  --header-offset: 96px;
  --content-max: 1320px;
  --sidebar-cart-height: 0px;
  --primary-color: #2563eb;
  --primary-dark: #1e40af;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.4;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 16px;
}

main.container {
  padding-top: 0;
  padding-bottom: 12px;
}

.auth-center {
  min-height: calc(100vh - var(--header-offset) - 48px);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Auth pages (login) should occupy full height */
.auth-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-body .auth-center {
  flex: 1;
  min-height: 0;
}

.auth-box {
  width: 100%;
  max-width: 560px;
}

.admin-content {
  width: 100%;
  max-width: 1280px;
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  margin-top: 12px;
  /* Use two-column grid so the sidebar aligns reliably with the content */
} 

.sidebar-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 220px;
}

.sidebar-fixed {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: fixed;
  left: max(16px, calc((100vw - var(--content-max)) / 2 + 16px));
  width: 220px;
  max-height: calc(100vh - var(--header-offset) - 36px);
  z-index: 2;
}

.sidebar {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 0;
  height: fit-content;
  background: #ffffff;
  max-height: none;
  overflow: visible;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  z-index: 1;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar-column {
    width: 100%;
  }

  .sidebar-fixed {
    position: static;
    top: auto;
    left: auto;
    width: auto;
    max-height: none;
  }

  .sidebar {
    position: static;
    width: auto;
    max-height: none;
    overflow: visible;
  }
}

.sidebar-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #111827;
  margin: 0;
  scrollbar-gutter: stable both-edges;
  overflow-y: hidden;
}

.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  text-decoration: none;
  color: inherit;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
  display: block;
  font-size: 0.9rem;
  line-height: 1.25;
}

.sidebar-link:hover {
  background: #f3f4f6;
  border-color: var(--primary-color);
  color: var(--primary-color);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.12);
}

.sidebar-link.is-active {
  border: 2px solid var(--primary-color);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(59, 130, 246, 0.12));
  color: var(--primary-color);
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.15);
}

.sidebar-scroll {
  margin-top: 8px;
  max-height: calc(100vh - var(--header-offset) - var(--sidebar-cart-height) - 68px);
  min-height: 200px;
  overflow: auto;
  margin-right: 0;
  scrollbar-gutter: stable both-edges;
  overscroll-behavior: contain;
}

@media (max-width: 980px) {
  .sidebar-scroll {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

.content {
  min-width: 0;
  margin-top: 12px;
}

.cart-page {
  min-height: calc(100vh - var(--header-offset) - 48px);
}

.cart-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.cart-page-header h1 {
  margin: 0;
}

.content h1 {
  margin: 0 0 16px 0;
  font-size: 1.8rem;
  line-height: 1.2;
}

.content h2 {
  margin: 18px 0 12px 0;
  font-size: 1.3rem;
}

.header {
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 20;
  background: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.brand-icon {
  display: none;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0;
  text-decoration: none;
  color: #0f172a;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.4px;
  white-space: nowrap;
}

.brand-name {
  position: relative;
  padding-right: 0;
}

.brand-name::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(37,99,235,0.5), rgba(17,24,39,0.5));
}


.header-row {
  /* Use a 3-column grid so the header search lines up with the main content (sidebar column + content column) */
  display: grid;
  grid-template-columns: 220px 1fr auto;
  align-items: center;
  gap: 12px;
}

/* On smaller screens revert to the original flex-based header to maintain layout behavior */
@media (max-width: 980px) {
  .header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
  }

  .header-search {
    margin-left: 0 !important;
    justify-content: center !important;
  }
}

.header-search {
  display: flex;
  gap: 0;
  align-items: center;
  flex: 1 1 320px;
  justify-content: center;
  max-width: 480px;
}

/* Align header search start with the page content on wide screens (accounting for sidebar) */
@media (min-width: 980px) {
  .header-search {
    /* Account for container padding within the content column */
    margin-left: 0px;
    justify-content: flex-start;
    /* Allow the search to grow but clamp to a reasonable maximum */
    max-width: min(520px, calc(var(--content-max) - 220px - 64px));
  }
}

.header-search .input {
  width: 100%;
  height: 40px;
  font-size: 1.05rem;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 8px 0 0 8px;
  border: 1px solid #d1d5db;
  border-right: none;
}

.header-search .btn {
  height: 40px;
  width: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 8px 8px 0;
  margin-left: 0;
  border: 1px solid var(--primary-color);
  background: var(--primary-color);
  color: #ffffff;
}

.header-search .btn.btn-secondary {
  background: var(--primary-color);
  color: #ffffff;
  border-left: none;
}

.header-search .btn:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.header-search .btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.header-search .input:focus,
.header-search .btn:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}


.header-actions {
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.nav-user {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-user-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.nav-logout {
  margin: 0;
}

.nav-note {
  font-size: 0.9rem;
  color: #6b7280;
  text-align: right;
}

.nav-greeting a {
  color: inherit;
}

.nav-greeting {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.3;
}

.nav-cart {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 40px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid #0f172a;
  background: #0f172a;
  color: #f8fafc;
  text-decoration: none;
  line-height: 1.1;
}

.nav-cart-text {
  font-weight: 700;
  font-size: 0.97rem;
}

.nav-cart svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.nav-cart:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.cart-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  margin: 0 0 12px;
}

.cart-summary-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cart-summary-label {
  font-weight: 600;
  color: #4b5563;
}

.cart-summary-value {
  font-size: 1.55rem;
  font-weight: 800;
  color: #0f172a;
}

.cart-summary-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-with-icon svg {
  width: 20px;
  height: 20px;
}

.cart-clear-btn {
  background: #ffffff;
  border-color: #e0e7ff;
  color: #111827;
}

.cart-clear-btn svg {
  color: #b91c1c;
}

.cart-clear-btn:hover {
  background: #e0e7ff;
}

.cart-stock-note {
  margin: 4px 0;
  display: inline-block;
}

.cart-availability {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  font-weight: 700;
  font-size: 0.9rem;
}

.table.cart-table {
  width: fit-content(100%);
  table-layout: auto;
}

.cart-col-product { width: auto; }
.cart-col-qty { width: 180px; }
.cart-col-sum { width: 90px; }
.cart-col-action { width: 70px; }

.cart-table th,
.cart-table td {
  padding-left: 4px;
  padding-right: 4px;
}

.cart-table-card {
  overflow-x: auto;
}

.cart-td-product,
.cart-td-qty,
.cart-td-sum,
.cart-td-action {
  vertical-align: middle;
}

.cart-td-qty {
  white-space: nowrap;
}

.cart-qty-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cart-td-sum {
  white-space: nowrap;
  text-align: right;
  font-weight: 700;
}

.cart-td-action {
  white-space: nowrap;
  text-align: right;
}

.cart-product {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: start;
}

.cart-product-thumb img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  cursor: pointer;
}

.cart-product-info {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.cart-product-name {
  display: inline-block;
  color: inherit;
  text-decoration: none;
  word-break: break-word;
  max-width: 100%;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.3;
}

.cart-product-price {
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn.cart-remove-btn {
  width: 40px;
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ef4444;
  border: 1px solid #ef4444;
  color: #ffffff;
}

.cart-remove-btn:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.sidebar-user,
.sidebar-cart {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
  background: #ffffff;
  margin-bottom: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.sidebar-cart {
  background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.08);
}

.sidebar-cart-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.sidebar-cart-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0;
  font-weight: 600;
  color: #0f172a;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 12px 0 0;
  border-top: 2px solid #e5e7eb;
}

.sidebar-cart-explainer {
  margin-top: 10px;
  font-size: 0.85rem;
  line-height: 1.35;
}


.sidebar-cart-btn {
  width: 100%;
  padding: 6px 12px;
  height: auto;
  min-height: 32px;
  font-size: 0.85rem;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  border: 1px solid var(--primary-dark);
  color: #fff;
}

.sidebar-user-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
  color: #111827;
}

.sidebar-user-name {
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
  text-align: center;
}

.sidebar-user-cart-label {
  margin: 4px 0 2px;
  text-align: left;
  font-weight: 500;
  color: #4b5563;
}

.sidebar-user-separator {
  border-bottom: 1px solid #e5e7eb;
  margin: 8px 0;
}

.sidebar-user-name a {
  color: inherit;
  text-decoration: none;
}

.sidebar-user-name a:hover {
  text-decoration: underline;
}

.sidebar-user-cart {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
  color: #111827;
  align-items: flex-start;
  text-align: left;
}

.sidebar-user-logout {
  width: 100%;
  padding: 8px 10px;
  margin-top: 4px;
  background: #e5e7eb;
  border-color: #d1d5db;
  color: #111827;
  font-weight: 600;
  box-shadow: none;
}

.sidebar-user-news {
  width: 100%;
  margin-top: 6px;
  background: #e5e7eb;
  border-color: #d1d5db;
  color: #111827;
  font-weight: 600;
  box-shadow: none;
}

.admin-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
}

@media (max-width: 720px) {
  .admin-hero {
    grid-template-columns: 1fr;
  }
}

.admin-hero h1 {
  margin: 4px 0 6px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-size: 0.78rem;
  color: #6b7280;
  margin: 0 0 4px;
}

.admin-hero__status {
  display: grid;
  gap: 8px;
  min-width: 220px;
}

.admin-content {
  padding-bottom: 16px;
}

.brand--stack {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
}

.admin-subtitle {
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.15;
  white-space: nowrap;
}

.admin-content h1 {
  margin: 6px 0 18px;
}

.alert {
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid transparent;
  font-weight: 600;
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.35);
  color: #15803d;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #b91c1c;
}

.admin-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0;
}

.pill-link {
  text-decoration: none;
  color: #0f172a;
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pill-link:hover {
  border-color: #0f172a;
  box-shadow: 0 6px 20px rgba(0,0,0,0.05);
}

.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.04);
}

.stat-card__label {
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 6px;
}

.stat-card__value {
  font-size: 1.6rem;
  font-weight: 800;
  color: #0f172a;
}

.stat-card__hint {
  color: #6b7280;
  font-size: 0.9rem;
  margin-top: 4px;
}

.admin-section {
  margin-top: 22px;
  display: grid;
  gap: 10px;
}

.admin-section {
  scroll-margin-top: calc(var(--header-offset) + 16px);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 10px;
  border-bottom: 1px solid #e5e7eb;
}

.section-head .muted {
  max-width: 72ch;
}

.section-head h2 {
  margin: 4px 0 6px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.admin-content .form-grid {
  grid-template-columns: 1fr;
}

.admin-content .form-actions {
  justify-content: flex-start;
}

.form-stack {
  display: grid;
  gap: 10px;
}

.form-field {
  display: grid;
  gap: 6px;
  font-weight: 650;
  color: #111827;
}

.form-field .input {
  width: 100%;
  font-weight: 500;
}

.field-hint {
  font-size: 0.9rem;
  color: #6b7280;
}

.form-checkbox {
  align-items: center;
  grid-auto-flow: column;
  justify-content: start;
  gap: 8px;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-section .card {
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
}

.inline-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid transparent;
}

.badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.35);
}

.badge-muted {
  background: rgba(107, 114, 128, 0.12);
  color: #374151;
  border-color: rgba(107, 114, 128, 0.25);
}

.badge-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.admin-user-row input[disabled] {
  opacity: 0.75;
}

textarea.input {
  min-height: 120px;
  resize: vertical;
  max-height: 320px;
}

.table-responsive {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
}

.admin-content .table {
  margin: 0;
}

.admin-content .table thead th {
  background: #f9fafb;
  font-weight: 750;
  font-size: 0.9rem;
  color: #111827;
}

.admin-content .table td {
  vertical-align: top;
}

.table-compact td,
.table-compact th {
  padding: 10px 12px;
}

.sidebar-user-news:hover {
  background: #dfe3ea;
  border-color: #cfd6e1;
  color: #0f172a;
}

.sidebar-user-logout:hover {
  background: #dfe3ea;
  border-color: #cfd6e1;
  color: #0f172a;
}

.sidebar-user-action {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  color: #2563eb;
  font-weight: 600;
  text-decoration: none;
}

.sidebar-user-action:hover {
  text-decoration: underline;
}

.nav a + a {
  margin-left: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

.news-block h1 {
  margin-top: 0;
}

.news-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.news-card__title {
  font-weight: 700;
  font-size: 1.05rem;
  color: #0f172a;
}

.news-card__body {
  color: #374151;
  line-height: 1.5;
}

.card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  width: 100%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: box-shadow 120ms ease, border-color 120ms ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  border-color: #d1d5db;
}

.card.is-unavailable {
  background: rgba(239, 68, 68, 0.06);
  border-color: rgba(239, 68, 68, 0.25);
}

.product-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  border-radius: 8px;
  border: none;
  background: transparent;
  padding: 0;
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.product-img:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.product-img--detail {
  max-height: 220px;
  margin: 8px 0 12px;
  padding: 0;
}

.product-img--row {
  max-width: 180px;
  max-height: 120px;
  margin: 0;
  padding: 0;
  justify-self: center;
}

.row-card {
  display: grid;
  grid-template-columns: 180px 1fr 240px;
  gap: 12px;
  align-items: stretch;
}

.row-card .product-img--row {
  align-self: start;
}

.row-card__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.row-card__title {
  display: block;
  width: 100%;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.product-code-row {
  width: 100%;
  margin-top: 4px;
}

.product-code-label,
.product-code-gap {
  user-select: none;
}

.product-code-value {
  user-select: text;
  display: inline-block;
  white-space: nowrap;
}

.row-card__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.row-card__price-row {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}

.in-cart-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 32px;
  padding: 4px 0.6rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  border-radius: 999px;
  background: #16a34a;
  color: #fff;
  vertical-align: middle; /* center with adjacent price in inline contexts */
  white-space: nowrap;
}

.row-card__price {
  font-weight: 700;
  font-size: 1.2rem;
  color: #111827;
  padding-bottom: 0.3rem;
  vertical-align: middle; /* center with pill in inline contexts */
}

.btn.row-card__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 12px;
  line-height: 1.2;
  font: inherit;
  white-space: nowrap;
}

.input.row-card__qty {
  height: 40px;
  padding: 0 10px;
  font-size: 1rem;
  width: 64px;
  border-radius: 8px;
  text-align: center;
  border-right: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  border: 1px solid #d1d5db;
  background: #ffffff;
}

/* Focus follows header search styling for consistency */
.input.row-card__qty:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.08);
}

.input.row-card__qty:focus-visible {
  box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
}

/* Embedded buttons to the right of the input (stacked vertically) */
.qty-control {
  display: inline-flex;
  align-items: center;
  gap: 0;
  position: relative;
  /* Use a single container border so seams match the site's inputs */
  border: 1px solid #d1d5db;
  border-radius: 8px;
  overflow: hidden;
}

.qty-embedded .js-qty-input {
  border-radius: 8px 0 0 8px;
  border: none;
  padding: 0 10px;
  width: 64px;
  height: 40px;
  background: #ffffff;
  text-align: center;
  position: relative;
  z-index: 1; /* input sits below the buttons so their area covers the seam */
}

.qty-buttons {
  display: flex;
  flex-direction: column;
  height: 40px;
  background: #f8fafc; /* subtle light background to contrast the input */
  position: relative;
  z-index: 2; /* buttons sit above the input so they cover the input outline on the seam */
  border-left: 1px solid #d1d5db; /* visual separator between buttons and input */
  border-radius: 0 8px 8px 0; /* rounded right corner */
  overflow: hidden;
}

/* Separator between + and - */
.qty-button:first-child {
  border-bottom: 1px solid #e5e7eb;
}

.qty-button {
  width: 36px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  color: #111827;
  font-weight: 600;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.qty-button:first-child {
  border-top-right-radius: 0; /* handled by container radius */
}

.qty-button:last-child {
  border-bottom-right-radius: 0; /* handled by container radius */
}

.qty-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.qty-button:hover {
  background: rgba(17,24,39,0.03);
}

.qty-button:focus {
  outline: none; /* remove default focus ring for mouse */
  background: rgba(17,24,39,0.03);
}

.qty-button:focus-visible {
  box-shadow: 0 0 0 3px rgba(59,130,246,0.08);
  background: rgba(17,24,39,0.05);
}

/* Slightly larger numeric inputs for readability */
.input[type="number"] {
  font-size: 1rem;
  line-height: 1.2;
  -moz-appearance: textfield; /* Firefox */
  -webkit-appearance: none; /* Safari/Chrome */
  appearance: textfield;
}

/* Fly-to-cart animation element */
.fly-image {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  /* Default opacity transition available; motion (offset-distance/transform) transitions are set inline in JS for precision */
  transition: opacity 320ms ease-out;
  will-change: offset-distance, transform, opacity;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(17,24,39,0.12);
}

/* Small tweak to make source image visually shrink during animation */
/* Hide native number input spinners (Chrome, Safari, Edge, Opera) */
.input[type="number"]::-webkit-outer-spin-button,
.input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Hide clear & spin on IE/Edge */
.input[type="number"]::-ms-clear,
.input[type="number"]::-ms-expand {
  display: none;
}  

.row-card__btn--details {
  margin-top: 8px;
}

.availability {
  font-size: 0.95rem;
  display: block; /* place availability on its own line */
  margin-left: 0;
  margin-top: 0px;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 28px;
} 

.availability--in {
  color: #16a34a;
  /* color: rgba(34, 197, 94, 0.95); */
}

.availability--out {
  color: rgba(239, 68, 68, 0.95);
}

/* Wrapper removed; spacing is provided by row-card__price and availability */


.muted {
  color: #6b7280;
}

.preserve-spaces {
  white-space: pre-wrap;
}

.product-name {
  text-transform: none;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  height: 36px;
  border: 1px solid #111827;
  background: #111827;
  color: #ffffff;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

/* Allow Add/Update/In-cart buttons to size to their content (auto width) */
button[data-product-id] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto; /* size to content */
  max-width: 100%;
  white-space: nowrap; /* keep label on a single line */
  box-sizing: border-box;
  transition: transform 80ms ease, box-shadow 120ms ease;
}

@media (max-width: 420px) {
  /* Keep auto width on narrow screens as well; buttons will shrink naturally if needed */
  button[data-product-id] {
    width: auto;
  }
}

/* Subtle press feedback on buy buttons */
button[data-product-id]:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
}

/* Small transient badge inserted after buttons when item is added; keeps button text unchanged */
.js-added-indicator {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  color: rgba(34, 197, 94, 0.95);
  font-size: 0.95rem;
  line-height: 1;
}

/* Inline quantity error shown when user enters invalid quantity */
.js-qty-error {
  color: #b91c1c;
  font-size: 0.95rem;
  margin-top: 6px;
}


.btn-secondary {
  background: transparent;
  color: #111827;
  border: 1px solid #d1d5db;
}

.btn-secondary:hover {
  background: rgba(229, 231, 235, 0.5);
  border-color: #c7d2e0;
}

/* Cart-specific secondary button override (must be after .btn-secondary) */
.btn.btn-secondary.cart-clear-btn {
  background: #ffffff;
  border-color: #e0e7ff;
  color: #111827;
}

.btn.btn-secondary.cart-clear-btn:hover {
  background: #ffcccc;
  border-color: #c7d2e0;
}

.btn-admin {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border: 1px solid #1e40af;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.btn-admin:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-admin:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.input {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  color: #111827;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

input.input[type="file"] {
  padding: 8px;
}

input.input[type="file"]::file-selector-button {
  margin-right: 10px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #111827;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 650;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

input.input[type="file"]::file-selector-button:hover {
  background: #e5e7eb;
  border-color: #cbd5e1;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 6px;
  text-align: left;
}

.footer {
  border-top: 1px solid #e5e7eb;
  margin-top: 24px;
  padding-top: 16px;
}

/* Image Modal */
.image-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.image-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(2px);
}

.image-modal-panel {
  position: relative;
  z-index: 10000;
  --modal-max-w: min(1100px, 90vw);
  --modal-max-h: min(720px, 80vh);
  display: inline-flex;
  max-width: var(--modal-max-w);
  max-height: var(--modal-max-h);
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  flex-direction: column;
}

.image-modal-actions {
  display: flex;
  justify-content: flex-end;
  padding: 12px;
}

.image-modal-container {
  position: relative;
  padding: 0 20px 20px 20px;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-modal-img {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(var(--modal-max-w) - 40px);
  max-height: calc(var(--modal-max-h) - 12px - 44px - 20px);
  object-fit: contain;
  background: transparent;
  margin: 0 auto;
  transition: opacity 160ms ease, transform 160ms ease;
}

.image-modal-close {
  position: static;
  width: 44px;
  height: 44px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  color: #111827;
  font-size: 24px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, transform 120ms ease;
  box-shadow: 0 6px 18px rgba(0,0,0,0.16);
}

.image-modal-close:active { transform: scale(0.96); }

.image-modal-close:hover {
  background: #f9fafb;
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
    padding-left: 0;
  }

  .header-row {
    flex-wrap: wrap;
  }

  .sidebar {
    position: static;
    width: auto;
    max-height: none;
    overflow: visible;
  }

  .row-card {
    grid-template-columns: 1fr;
  }

  .row-card__side {
    align-items: flex-start;
  }

  .product-img--row {
    max-width: 100%;
    max-height: 160px;
  }
}

/* workaround for Firefox scrollbar misbehavior */
@supports (-moz-appearance:none) {
  .sidebar-scroll {
    padding: 0 12px;
  }
  .sidebar-title {
    padding: 0 12px;
  }
}