:root {
  --bg: #f5f8fd;
  --surface: #ffffff;
  --ink: #14213d;
  --muted: #62708a;
  --line: #d8e2f0;
  --brand: #073f9e;
  --brand-deep: #022a78;
  --brand-soft: #e8f1ff;
  --accent: #f6bf16;
  --accent-deep: #e88a00;
  --danger: #b42318;
  --shadow: 0 12px 30px rgba(7, 63, 158, .09);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.brand img {
  display: block;
  width: min(220px, 42vw);
  max-height: 72px;
  object-fit: contain;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-menu {
  position: relative;
}

.user-menu summary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
}

.user-menu summary::-webkit-details-marker {
  display: none;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  background: var(--brand);
}

.user-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 20;
  width: min(320px, calc(100vw - 32px));
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.user-panel span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

nav a,
.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
  font-weight: 700;
  cursor: pointer;
}

nav a {
  color: var(--ink);
  background: transparent;
}

.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 18px;
}

.section-nav a {
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--brand);
  background: var(--brand-soft);
  font-weight: 700;
}

.section-nav a.active {
  color: #14213d;
  background: var(--accent);
}

button.accent,
.button.accent,
.accent {
  color: #14213d;
  background: var(--accent);
}

.secondary {
  color: var(--brand);
  background: var(--brand-soft);
}

.danger {
  background: var(--danger);
}

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

.shell {
  flex: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 56px;
}

.landing-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 20%, #ffffff 0, #f5f8fd 42%, #e8f1ff 100%);
}

.landing-card {
  display: grid;
  justify-items: center;
  gap: 28px;
  width: min(520px, 100%);
}

.landing-card img {
  display: block;
  width: min(440px, 90vw);
  height: auto;
}

.landing-card .button {
  min-width: min(280px, 100%);
  min-height: 48px;
  font-size: 17px;
}

.notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #073f9e;
  background: #e8f1ff;
}

.notice.error {
  color: #842029;
  background: #f8d7da;
}

.auth-card,
.panel {
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card {
  max-width: 460px;
  margin: 8vh auto;
}

h1,
h2 {
  margin-top: 0;
}

.muted,
.eyebrow {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.password-field:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(7, 63, 158, .14);
}

.password-field input {
  min-height: 42px;
  border: 0;
  border-radius: 8px 0 0 8px;
  box-shadow: none;
}

.password-toggle {
  width: 44px;
  min-height: 42px;
  padding: 0;
  border-radius: 0 8px 8px 0;
  color: var(--brand);
  background: transparent;
}

.password-toggle:hover,
.password-toggle:focus {
  color: var(--brand-deep);
  background: var(--brand-soft);
}

.password-toggle svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-toggle .eye-closed,
.password-toggle.is-visible .eye-open {
  display: none;
}

.password-toggle.is-visible .eye-closed {
  display: block;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: clamp(22px, 4vw, 38px);
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep) 72%, #101b36);
  box-shadow: inset 0 -4px 0 rgba(246, 191, 22, .85);
}

.hero p {
  max-width: 620px;
}

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

.category-sidebar {
  position: sticky;
  top: 102px;
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.home-link,
.category-group summary,
.category-group a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 10px;
  border-radius: 8px;
}

.home-link,
.category-group summary {
  font-weight: 800;
}

.category-group summary {
  cursor: pointer;
  color: var(--brand);
  background: var(--brand-soft);
}

.category-group div {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  padding-left: 10px;
}

.category-group a {
  color: var(--muted);
}

.category-sidebar .selected,
.category-group a.selected {
  color: #14213d;
  background: var(--accent);
  font-weight: 800;
}

.catalog-content {
  min-width: 0;
}

.search-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.filters a {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.filters .selected {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.filters.small a {
  font-size: 14px;
}

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

.product-card {
  display: grid;
  gap: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.product-card > a {
  display: block;
}

.product-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e8edf1;
}

.product-card > div,
.product-card form {
  margin: 0 16px;
}

.product-card form {
  margin-bottom: 16px;
}

.inline-form,
.purchase-row,
.quantity-form {
  display: flex;
  align-items: end;
  gap: 10px;
}

.inline-form input,
.purchase-row input,
.quantity-form input {
  max-width: 100px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: auto;
}

.compact-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.compact-action input {
  width: 80px;
}

.product-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 14px;
  align-items: end;
}

.price-tier-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 14px;
  align-items: end;
}

.image-slots {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
}

.image-picker {
  display: grid;
  gap: 8px;
}

.image-picker input[type="file"] {
  width: 100%;
  min-height: auto;
  padding: 8px;
  font-size: 14px;
}

.image-preview {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 140px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fbff;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-remove {
  min-height: 36px;
  width: 100%;
}

.detail {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, .9fr);
  gap: 22px;
  align-items: start;
}

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

.gallery img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  background: #e8edf1;
}

.price {
  display: block;
  margin: 18px 0;
  font-size: 30px;
}

.detail h2 {
  margin-top: 18px;
  font-size: 20px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.cart-total {
  margin: 18px 0;
  font-size: 24px;
  font-weight: 800;
  text-align: right;
}

.promo-gifts {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid rgba(246, 191, 22, .55);
  border-radius: 8px;
  background: #fff8df;
}

.promo-gifts h2 {
  margin-bottom: 8px;
}

.promo-gifts p {
  margin: 0;
  font-weight: 700;
}

.print-header {
  display: none;
}

.print-header img {
  width: 220px;
  height: auto;
}

.panel-heading,
.cart-actions,
.order-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading h1 {
  margin-bottom: 0;
}

.cart-actions form {
  flex: 1;
}

.cart-actions .accent {
  width: 100%;
}

.order-actions {
  margin-top: 24px;
  justify-content: flex-start;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.dashboard article {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.dashboard span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.dashboard strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.list-row span {
  display: block;
  color: var(--muted);
}

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

.row-actions form {
  display: inline;
}

.editable-row {
  align-items: flex-start;
}

.inline-edit summary {
  list-style: none;
}

.inline-edit summary::-webkit-details-marker {
  display: none;
}

.row-actions .edit-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  min-width: min(420px, calc(100vw - 48px));
  margin-top: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.row-actions .product-edit-form {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  min-width: min(720px, calc(100vw - 48px));
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.form-actions button,
.form-actions .button {
  flex: 1;
}

.address-options {
  display: grid;
  gap: 10px;
}

.address-option {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

.address-option input[type="radio"] {
  width: 18px;
  min-height: 18px;
  margin-top: 3px;
  padding: 0;
}

.address-option small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 400;
}

.address-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.address-form-grid.is-disabled {
  opacity: .58;
}

.address-form-grid label:last-child {
  grid-column: 1 / -1;
}

.full-field {
  grid-column: 1 / -1;
}

.compact-list {
  margin-top: 18px;
}

.empty-state {
  grid-column: 1 / -1;
}

.error-page {
  max-width: 760px;
  margin: 8vh auto;
}

.error-detail {
  overflow-x: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f8fd;
  color: #842029;
  white-space: pre-wrap;
}

.site-footer {
  padding: 18px 16px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: #fff;
  text-align: center;
  font-size: 14px;
}

@media (max-width: 780px) {
  .topbar,
  .hero,
  .list-row {
    align-items: stretch;
    flex-direction: column;
  }

  nav {
    justify-content: flex-start;
  }

  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .row-actions,
  .row-actions .product-edit-form {
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .product-meta-grid,
  .price-tier-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .image-slots {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .user-panel {
    position: static;
    width: 100%;
    margin-top: 10px;
  }

  .detail,
  .split,
  .dashboard,
  .catalog-layout,
  .search-bar {
    grid-template-columns: 1fr;
  }

  .category-sidebar {
    position: static;
  }

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

  .inline-form,
  .purchase-row,
  .quantity-form,
  .form-actions,
  .panel-heading,
  .cart-actions,
  .order-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form input,
  .purchase-row input,
  .quantity-form input {
    max-width: none;
  }
}

@media (max-width: 520px) {
  .product-meta-grid,
  .price-tier-grid,
  .image-slots,
  .address-form-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  .topbar,
  .site-footer,
  .notice,
  .no-print {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .shell {
    padding: 0;
  }

  .panel {
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .print-header {
    display: block;
    margin-bottom: 18px;
    text-align: center;
  }

  th,
  td {
    padding: 8px;
  }
}
